Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Find partially matching line in file - print that line to another file

by glide (Pilgrim)
on Dec 14, 2007 at 15:03 UTC ( [id://657045]=note: print w/replies, xml ) Need Help??


in reply to Find partially matching line in file - print that line to another file

Hi,

my code it's a bit different, but it's working ... what is the problem?

use strict; my @fileone = qw/ 123456 123457 123458/; while (my $line = <DATA>) { foreach my $pattern(@fileone) { if ($line =~ /^$pattern/) {print $line."\n";} } } __DATA__ 123456 foo 123456 bar 123457 foobar 123455 this wouldn't be printed to new file
output
123456 foo 123456 bar 123457 foobar

Replies are listed 'Best First'.
Re^2: Find partially matching line in file - print that line to another file
by rkmase (Novice) on Dec 14, 2007 at 15:10 UTC
    This is exactly what I was looking for. I imagine it was the different order that I tried to process mine that did it.

    Thanks! Mason

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found