Darren Birkett wrote:
OK, to be more specific, I'm using Net::Telnet:Cisco. When logged onto
a device I'm using the "show version" command, and storing the output in
an array. Each element of the array will therefore contain lots of
rubbish. I just want to match certain keyword(s) to determin
James Edward Gray II wrote:
Gunnar Hjalmarsson wrote:
if ( grep /my string/, @myarray ) {
some code
}
Ordinarily, I wouldn't even mention this, but since the
conversation is about what is fastest...
The OP was not about what is fastest at all. It was about whether
there is "a better
On Aug 24, 2004, at 9:14 AM, Gunnar Hjalmarsson wrote:
Isn't grep() "specific" enough?
Initially you said:
$line = join(' ',@myarray);
if ($line =~ /my string/) {
some code
}
The equivalent using grep() would be:
if ( grep /my string/, @myarray ) {
some code
}
Or
On Aug 24, 2004, at 7:48 AM, Darren Birkett wrote:
OK, to be more specific, I'm using Net::Telnet:Cisco. When logged onto
a device I'm using the "show version" command, and storing the output
in
an array. Each element of the array will therefore contain lots of
rubbish. I just want to match cer
Darren Birkett wrote:
I just want to match certain keyword(s) to determine device type.
I guess a for loop is the closest I'm going to get. I just thought
there would be a specific function for this.
Isn't grep() "specific" enough?
Initially you said:
$line = join(' ',@myarray);
if ($line
[EMAIL PROTECTED] (John W. Krahn) wrote in
news:[EMAIL PROTECTED]:
>
> If all the elements are unique then use a hash.
>
> if ( exists $hash{ 'my string' } ) {
> # do something
> }
>
>
> The most efficient way to determine if an element exists in an array
> is to use a for loop and
Darren Birkett wrote:
Hi,
Hello,
Is there a better way to search all elements of an array for a string
(without using a loop to test individual elements) than:
$line = join(' ',@myarray);
if ($line =~ /my string/) {
some code
}
I've seen map and grep used by some but also critisized by so
On Mon, 23 Aug 2004, Darren Birkett wrote:
Is there a better way to search all elements of an array for a string
(without using a loop to test individual elements) than:
$line = join(' ',@myarray);
if ($line =~ /my string/) {
some code
}
I've seen map and grep used by some but
Hi,
Is there a better way to search all elements of an array for a string
(without using a loop to test individual elements) than:
$line = join(' ',@myarray);
if ($line =~ /my string/) {
some code
}
I've seen map and grep used by some but also critisized by some. I thought
there might