Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Problem changing only first occurence of pattern in file

by japhy (Canon)
on Oct 17, 2006 at 13:25 UTC ( [id://578757]=note: print w/replies, xml ) Need Help??


in reply to Problem changing only first occurence of pattern in file

You're looping more than you mean to. I think you want to pare your code down to just:
my $flag = 0; local ($^I, @ARGV) = (".bak", "/var/ww/htdocs/cgi-bin/user.txt"); while (<>) { $flag = 1 if !$flag and s/\|No$/|Yes/; print; }

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-18 02:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found