AltGrendel has asked for the wisdom of the Perl Monks concerning the following question:
Could someone explain what's going on here?
my @trace = split("\s",(`traceroute -w 2 -q 1 -i dmfe0 $ip_address`)); my @trace_out = ""; foreach (@trace){ $_ =~ s/\n//; if ( $_ =~ /some|checks|here/ ){ @trace_out = (split /\s+/, $_ ); } }
and
Both work, however, when I use the first I have one server that apparently has hidden characters that would cause the the line to split prematurely. I expect the problem is in the split() in the foreach, but since the open EXE works just fine I'm going with that anyway. Just curious.open EXE, qq{/usr/sbin/traceroute -q 1 -w 2 -i dmfe0 $ip_address |}; my @trace = <EXE>; my @trace_out = ""; foreach (@trace){ $_ =~ s/\n//; if ( $_ =~ /some|checks|here/ ){ @trace_out = (split /\s+/, $_ ); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: output difference between backtic and open().
by kcott (Archbishop) on Feb 25, 2014 at 19:19 UTC | |
by AnomalousMonk (Archbishop) on Feb 26, 2014 at 02:18 UTC | |
by kcott (Archbishop) on Feb 26, 2014 at 12:19 UTC | |
|
Re: output difference between backtic and open().
by karlgoethebier (Abbot) on Feb 25, 2014 at 20:06 UTC | |
|
Re: output difference between backtic and open().
by Anonymous Monk on Feb 26, 2014 at 05:11 UTC | |
|
Re: output difference between backtic and open().
by dave_the_m (Monsignor) on Feb 26, 2014 at 00:45 UTC | |
by AnomalousMonk (Archbishop) on Feb 26, 2014 at 02:30 UTC |