ulaksh has asked for the wisdom of the Perl Monks concerning the following question:
And my script look like this.------------------------------------------------------------------ Port Speed Duplex Flow Ctrl Link Name ---- ----- -------- --TX-----RX-- ------ ------ 1 10000 full no no down 1 2 10000 full no no down 2 3 10000 full no no down 3 4 10000 full no no down 4 5 10000 full no no down 5 6 10000 full no no down 6 7 10000 full no no down 7 8 10000 full no no down 8 9 10000 full no no down 9 10 10000 full no no down 10 11 10000 full no no down 11 12 10000 full no no down 12 13 10000 full no no down 13 14 10000 full no no down 14 15 10000 full no no down 15 16 10000 full no no down 16 17 1G/10G full no no down 17 18 1G/10G full no no down 18 19 1000 full no no up 19 20 10000 full no no down 20
I am getting the output like thisopen FILE,"interfacelink.txt" or die "cannot open file : $!"; #my $substring = "encap:"; #this is useful if search istring is long while(<FILE>) { $line ="$_\n"; $ind=$line=~ /up/; if ($ind){ #print "$line\n"; print "port is", $port, "=", substr($line,0,4)."\n"; print "speed is", $speed, "=", substr($line,7,5)."\n"; print "link is", $link, "=", substr($line,42,4)."\n"; } }
My expecting the output like port is= 19 speed is= 1000 link is= upport is=Port speed is=Speed link is=Link port is= 19 speed is= 1000 link is= up
|
|---|