Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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 ( #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
Node Status?
node history
Node Type: note [id://657045]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2018-08-18 06:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (185 votes). Check out past polls.

    Notices?