in reply to Re: Process file regardless of the platform it was created on
in thread Process file regardless of the platform it was created on
Will this work generally?$ cat unixordos.pl use strict; use warnings; my $fh = undef; open($fh, "<", "foo.txt") or die "failed to open 'foo.txt':$!"; while (my $line = <$fh>) { $line =~ s/\r\n/\n/g; chomp $line; ($line =~ m/^\d+$/) ? print qq{number ok:"$line"} : print qq{number error:"$line"}; print "\n"; } close($fh) or die "failed to close 'foo.txt':$!"; __END__ $ echo -e "123\n456\n789" > foo.txt $ perl unixordos.pl number ok:"123" number ok:"456" number ok:"789" $ unix2dos foo.txt unix2dos: converting file foo.txt to DOS format ... $ perl unixordos.pl number ok:"123" number ok:"456" number ok:"789" $
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Process file regardless of the platform it was created on
by almut (Canon) on May 20, 2008 at 08:36 UTC | |
|
Re^3: Process file regardless of the platform it was created on
by psini (Deacon) on May 20, 2008 at 08:32 UTC |