RandomWalk has asked for the wisdom of the Perl Monks concerning the following question:
...sub parse_file { my ($class, $file) = @_; local $/; open my $f, $file or croak $!; my $data = <$f>; return $class->parse($data); } =head2 parse Creates a C<Finance::QIF> object from a string. =cut sub parse { my ($class, $data) = @_; my @lines = split /\n/, $data; my $type = shift @lines; croak "Can only handle bank accounts right now, not type $type" unless $type eq "!Type:Bank";
My question is why didn't the file split on "\x{a}"? Isn't it the same as "/n"?$ perl -MCarp=verbose qifread.pl at /usr/local/lib/perl5/site_perl/5.8.4/Finance/QIF.pm line 124 Finance::QIF::parse('Finance::QIF', '!Type:Bank\x{d}\x{a}D09/0 +7/2004\x{d}\x{a}PDTE ENERGY PAYMENT\x{d}\x{a}MDTE ENERGY PAY...') cal +led at /usr/local/lib/perl5/site_perl/5.8.4/Finance/QIF.pm line 111 Finance::QIF::parse_file('Finance::QIF', 'dfcu0904.qif') calle +d at qifread.pl line 6
Thanks (as always).
20040909 Edit by ysth: change pre to code tags Sorry for the "chatty" question. Yes, I understand the sub would still choke on the carriage return character even if "\x{a}" were to be treated as "\n". I just thought maybe someone might explain when "\n" and "\x{a}" are the same in Perl and when they're different. Or maybe point out where in the docs to read--my searches haven't turned anything up.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: end of the line
by graff (Chancellor) on Sep 10, 2004 at 01:55 UTC | |
by RandomWalk (Beadle) on Sep 10, 2004 at 03:33 UTC | |
|
Re: end of the line
by simonm (Vicar) on Sep 09, 2004 at 22:28 UTC | |
|
Re: end of the line
by ikegami (Patriarch) on Sep 09, 2004 at 22:40 UTC |