Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^13: partial matching of lines in perl

by AnomalousMonk (Archbishop)
on Jun 16, 2020 at 08:41 UTC ( [id://11118124]=note: print w/replies, xml ) Need Help??


in reply to Re^12: partial matching of lines in perl
in thread partial matching of lines in perl

when i run the above code, it is showing the error-undefined variable $file1.please help me

c:\@Work\Perl\monks\Sidd@786>dir do.txt Volume in drive C is Acer Volume Serial Number is 9840-785B Directory of c:\@Work\Perl\monks\Sidd@786 File Not Found c:\@Work\Perl\monks\Sidd@786>perl #use strict; use warnings; $file1 = 'goodfile.txt'; $file2 = 'badfile.txt'; open $h2, '<', $file2 or die "cannot open file2"; @a2 = <$h2>; close $h2; chomp @a2; $match = join '|', @a2; $match = qr/$match/; open $f3,'>',"do.txt" or die "$!"; open $h1, '<', $file1 or die "cannot open file1"; my @a1 = <$h1>; close $h1; # print grep {$_ !~ $match} @a1; print $f3 grep {$_ !~ $match} @a1; __END__ c:\@Work\Perl\monks\Sidd@786>cat do.txt don't you
Problem solved!


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-25 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found