oops forgot the code. Here it is.

foreach $offline (@offline)
{
    $mac = $offline =~ m/.* (....\.....\.....) .*/;
    push (@macs,$mac);
}


-----Original Message-----
From: Tucker, Ernie [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 14, 2002 12:07 PM
To: 'Janek Schleicher'; [EMAIL PROTECTED]
Subject: RE: parsing a variable


Would something like this work? I tried it but it returned all 1. Any ideas


Ernest P. Tucker II
 Network Technician



"The organization that can't communicate can't change, and the corporation
that can't change is dead."  
--Nido Qubein 


-----Original Message-----
From: Janek Schleicher [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 14, 2002 11:34 AM
To: [EMAIL PROTECTED]
Subject: RE: parsing a variable


Robert Hanson wrote at Fri, 14 Jun 2002 17:49:03 +0200:

> How about this?
> 
> # untested
> my @mac = map {/((?:[a-fA-F0-9]{4}\.){2}[a-fA-F0-9]{4})/ and $1} (
@offline );
> 
> Rob
> 

or perhaps a little bit more readable:

my $hexdigit = qr/[a-fA-F0-9]/;
my $hexword  = qr/$hexdigit{4}/;
my $mac      = qr/$hexword \. $hexword \. $hexword/x;

my @maclist  = map {/($mac)/x} @offline;

However, it isn't necessary to put the $1 into the map routine.

BTW, isn't @offline a strange name. @offline contains online data :-)


Cheerio,
Janek


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


 "The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from all
computers." 




 "The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from all
computers." 


Reply via email to