Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: Output in variable

by Sombrerero_loco (Beadle)
on Jan 22, 2009 at 12:01 UTC ( [id://738126]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Output in variable
in thread Output in variable

maybe try this:

$PatternToMatch="^SELECT";
$tmpfile="pattern.txt";
open(MYFILE, "$tmpfile")|| die "Cannot create $tmpfile\n";
while (<MYFILE>) {
if (/$PatternToMatch/)
{
 push (@array, $_);
  
}
}

As you are reading the file, you need to push every time perl founds Select to and array, because the variable get overwritten with every success match. After that, recover all the data from the array when you need.
foreach $control (@array) {
   print "Line -> $control\n";
  }

Replies are listed 'Best First'.
Re^5: Output in variable
by Anonymous Monk on Jan 22, 2009 at 12:03 UTC
    Tanx Sombrerero loco.... its working :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2024-04-18 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found