ybiC has asked for the wisdom of the Perl Monks concerning the following question:
No doubt this is elementary to the many "real programmers" among the PM bretheren. The PM Tutorials suggest that a hash may do #1, but I'm at a loss on quite how to implement.
Thanks in advance for any direction or code examples.
cheers,
ybiC
#!/usr/bin/perl -w use strict; my $infile = "/dir/infilename"; my $outfile = "/dir/outfilename"; open (IN, "$infile") or die "Error opening $infile: $!\n"; open (OUT, ">$outfile") or die "Error opening $outfile: $!\n"; while (<IN>) { s/wahwah//g; # unwanted text s/blahblah//g; # more unwanted text s/yadayada//g; # still more unwanted text s/^\s+//g; # blank lines print OUT $_ or die "Error writing to $outfile: $!\n"; } close (IN) or die "Error closing $infile: $!\n"; close (OUT) or die "Error closing $outfile: $!\n"; # END
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: elementary hash
by ncw (Friar) on Sep 12, 2000 at 01:13 UTC | |
by jcwren (Prior) on Sep 12, 2000 at 02:03 UTC | |
by chromatic (Archbishop) on Sep 12, 2000 at 03:01 UTC | |
by tilly (Archbishop) on Sep 12, 2000 at 04:10 UTC | |
by ybiC (Prior) on Sep 12, 2000 at 01:57 UTC | |
by adamsj (Hermit) on Sep 12, 2000 at 02:22 UTC | |
|
Re: elementary hash
by adamsj (Hermit) on Sep 12, 2000 at 01:08 UTC | |
by ybiC (Prior) on Sep 12, 2000 at 01:15 UTC | |
by adamsj (Hermit) on Sep 12, 2000 at 01:27 UTC | |
by ybiC (Prior) on Sep 12, 2000 at 01:39 UTC |