dudley has asked for the wisdom of the Perl Monks concerning the following question:
$filein = "sample.txt"; open(FILE, $filein) or die "Couldn't open file $file"; while (<FILE>) { $line = $_; (@values) = split ( /(,)/ , $line); foreach $value(@values) { if ($value =~ /-\d{2}/) {$value =~ s/-/0/} elsif ($value =~ /-\d{3}/) {$value =~ s/-//} } push (@newfile,@values); print @values; } $filein=~ s/.txt/.tst/; open (NEW, ">$filein"); print NEW "@newfile"; close (NEW);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: printing to a file
by matija (Priest) on Apr 02, 2004 at 18:44 UTC | |
by Fletch (Bishop) on Apr 02, 2004 at 18:45 UTC | |
by calin (Deacon) on Apr 02, 2004 at 19:06 UTC | |
Re: printing to a file
by Plankton (Vicar) on Apr 02, 2004 at 18:45 UTC | |
Re: printing to a file
by DigitalKitty (Parson) on Apr 02, 2004 at 19:09 UTC | |
Re: printing to a file
by tinita (Parson) on Apr 03, 2004 at 16:15 UTC | |
Re: printing to a file
by dudley (Initiate) on Apr 02, 2004 at 19:05 UTC |