Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Use of grep and foreach

by crouchingpenguin (Priest)
on Aug 11, 2003 at 14:22 UTC ( #282885=note: print w/ replies, xml ) Need Help??


in reply to Use of grep and foreach

Give this a try:

#!/usr/bin/perl use strict; use warnings; use Tie::File; my @file; tie @file, 'Tie::File', '/tmp/filename' or die "Failed to tie file: $!"; foreach my $matching_line ( grep { m/^myLine/ } @file ){ $matching_line =~ s/^myLine/this_was_a_match/; }

cp
----
"Never be afraid to try something new. Remember, amateurs built the ark. Professionals built the Titanic."


Comment on Re: Use of grep and foreach
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (20)
As of 2014-07-30 16:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (235 votes), past polls