Jim Hansen wrote:
>
> Sorry. Lousy explanation. I have a string that will have
> PSserver01...02, etc. I need to check for this string:
>
> $Printserver = "HP4000 [PSserver01]"
>
> I guess this can be as simple as
>
> $Printserver = "HP4000 [PSserver01]"
> if ( ! /PSserver/ ) {
> do
> }
Not quite sure what you want to do, but here's an example that could
cover several possible scenarios:
my $name, $type, $number;
if ($Printserver =~ /(\S+)\s+\[(\w+)(\d+)\]/) {
$name=$1;
$type=$2;
$number=$3;
}
else {
die "\$Printserver variable match error, stopped";
}
if ($name eq "HP4000") { #found exact string HP4000 in name field
...
}
if ($type !~ /PServer/) { #did not match PServer within type field
...
}
elsif ($number=2) { #found PServer02 (since match above
failed)
...
}
hope this helps.
robert
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs