http://www.perlmonks.org?node_id=1015065


in reply to grep in line and print

justbow:

That code certainly doesn't do what you think it does. Add a print $line,"\n"; statement just after foreach to see why.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: grep in line and print
by justbow (Initiate) on Jan 24, 2013 at 02:36 UTC
    do u mean like this :
    foreach print $line,"\n"; (@macall) {
    it will be error :D

      justbow:

      No, I meant like this:

      my @macall = qw(print @input); foreach $line (@macall) { print "<$line>\n"; if ($line =~ /C4:46:19:75:C1:55:\s+(\S+)/) { $id = $1; } } print "ID = $id"; return (0);

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.