pedrete has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks!!
do you believe in ghosts? i have the following code:@ident=`whois ibm.com|grep ID`; my ($id) = grep(/ID/,@ident);
i have 2 identical Linux boxes.
if i execute this lines in box number 1 $id contains, as expected, the line containing the ID...
BUT if i execute this lines in box number 2 $id contains number 1, that corresponds to a grep in scalar context!!
in both servers the result of: `whois ibm.com|grep ID` is identical!
Why grep behaves as scalar context when it should behave as list conext? Thanks in advance! Pedrete
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: grep in list context behaves as scalar context
by hippo (Archbishop) on Jun 17, 2015 at 22:11 UTC | |
by pedrete (Sexton) on Jun 17, 2015 at 22:41 UTC |