Posted on 2005-10-27 10:13:15-07 by lobonz
Hack for blank lines
Well this module is great (thx DJ), nice and easy to get the job done, the trouble I ran into was with trying to export CSV files for MYOB sales items, MYOB delimits its invoices using blank lines so I made the changes below to achieve that, although calling add_line with an empty hashref allowed the import it created a whole bunch of errors in MYOB.
sub add_line { my ($self, $args) = @_; #die "Cannot call add_line without an argument!\n" # unless (defined $args and $args); my $line = ''; if (defined $args and $args){ $line = $self->new_line($args); } push(@{$self->{lines}}, $line); } sub string { my ($self) = @_; die "No lines to write!\n" unless (ref $self->lines() eq 'ARRAY'); my @string = (); #map { push(@string, $_->string()); } @{$self->lines()}; foreach my $ob (@{$self->lines()}){ if ($ob){ push(@string, $ob->string()); }else{ push(@string, $ob); } } return join($self->line_separator(), @string). $self->line_separator(); }
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.