Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Need help to parse the text

by bibo (Pilgrim)
on Jun 17, 2004 at 04:31 UTC ( [id://367530]=note: print w/replies, xml ) Need Help??


in reply to Need help to parse the text

Hey GS, try this. It's not fancy, but it does the job...
#!/usr/bin/perl use strict; my $filename = "ifconfig.txt"; # my @junk; open(JUNK, $filename)|| die "Cannot open file $filename!"; @junk = <JUNK>; close(JUNK); my ($interface, $istatus, $item); foreach $item (@junk) { chop $item; $interface = $item if ($item =~ m/^[A-z][A-z][0-9]:/); $istatus=""; if ($item =~ m/status:/) { my @sjunk = split (/ /, $item); $istatus = $sjunk[$#sjunk]; $istatus = $sjunk[$#sjunk-1] . " " . $sjunk[$#sjunk] if ($istatus + ne "active"); } print "$interface $istatus\n" if ($istatus ne ""); }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-04-25 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found