bluethundr has asked for the wisdom of the Perl Monks concerning the following question:
But what I'm befuddled by is that the pattern match: $out =~ s/(\.\w+)?$/.out/; does not manipulate the output filename.#!/usr/bin/perl use strict; my $file = $ARGV[0]; if (!$file) { print "Hey! You didn't give me a file, sucka!\n"; } my $out = $file; open IN, "$file" or die "File did not open\n"; open OUT, "<$out" or die "File not available for write.\n"; $out =~ s/(\.\w+)?$/.out/; while (<IN>) { $out =~ s/fred/larry/gi; print OUT; }
fails to perform the substitution.while (<IN>) { $out =~ s/fred/larry/gi; print OUT; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pattern not manipulating file output
by NetWallah (Canon) on Feb 20, 2008 at 05:32 UTC | |
|
Re: Pattern not manipulating file output
by hipowls (Curate) on Feb 20, 2008 at 05:22 UTC | |
|
Re: Pattern not manipulating file output
by apl (Monsignor) on Feb 20, 2008 at 12:35 UTC | |
by bluethundr (Pilgrim) on Feb 20, 2008 at 23:09 UTC |