Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: problem with string substitution output

by Anonymous Monk
on May 23, 2008 at 20:14 UTC ( [id://688213]=note: print w/replies, xml ) Need Help??


in reply to Re^3: problem with string substitution output
in thread problem with string substitution output

Nevermind, I just solved it :)
use strict; use warnings; my $echo = "ECHO"; my ($dffname, $listname) = @ARGV; my $fh; my $key=undef; # read key/val lists open $fh, '<', $dffname or die "$dffname $!"; my %lijst = map { chomp; (split /\t/)[1,0] } <$fh>; close $fh; foreach $key (sort keys %lijst) { print "The value associated with key $key is $lijst{$key}\n";} # readfile list open $fh, '<', $listname or die "$listname $!"; my @listfiles = <$fh>; chomp @listfiles; close $fh; for my $file (@listfiles) { # read original file open $fh, '<', $file or die "$file $!"; local $/; my $content = <$fh>; close $fh; # modify content while( my ($key, $val) = each %lijst ) { next unless $val == 1; $content =~ s/^$key$/$echo$key/gms; $content =~ s/$echo$key/$key/; $content =~ s/$echo$key/$echo/g; } # write modified file open $fh, '>', "$file.out" or die "$file.out $!"; print $fh $content; close $fh; }
Matje

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://688213]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-25 20:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found