Hello justbow, and welcome to the Monastery!
Perhaps this is what you’re looking for:
#! perl
use strict;
use warnings;
while (my $line = <DATA>)
{
if ($line =~ /C4:46:19:75:C1:55/)
{
print "ID = ", (split /\s+/, $line)[0], "\n";
}
}
__DATA__
SS-ID VLAN MAC TIME IP RSSI MODE UAPSD BW GI WMOS DHCP IDENTITY
----- ---- --- ---- -- ---- ---- ----- -- -- ---- ---- --------
1-1 0 C4:46:19:75:C1:55 23m 192.168.5.253 -24 bgn no 20 S 4.9 ack*
1-2 0 5C:57:C8:69:8C:1E 3s 192.168.5.254 -38 bg no 20 L 4.8 ack*
Output:
12:28 >perl 495_SoPW.pl
ID = 1-1
12:28 >
Update: The following is probably clearer:
#! perl
use strict;
use warnings;
while (my $line = <DATA>)
{
chomp $line;
my @recs = split /\s+/, $line;
if ($recs[2] eq 'C4:46:19:75:C1:55')
{
print "ID = ", $recs[0], "\n";
}
}
__DATA__
SS-ID VLAN MAC TIME IP RSSI MODE UAPSD BW GI WMOS DHCP IDENTITY
----- ---- --- ---- -- ---- ---- ----- -- -- ---- ---- --------
1-1 0 C4:46:19:75:C1:55 23m 192.168.5.253 -24 bgn no 20 S 4.9 ack*
1-2 0 5C:57:C8:69:8C:1E 3s 192.168.5.254 -38 bg no 20 L 4.8 ack*
(Same output.)
See split.
Hope that helps,
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.