Hi there,
Have a simple script which runs a command on the system and returns the regex value
The question is, I only want to print the first value that it returned if more than one is found, but at the same work through each line. So if the resulting text of the command was:
__DATA__
Test1
Test6
Test5
Test1
I only want to print out the first Test1
Any help appreciated
Have a simple script which runs a command on the system and returns the regex value
Code:
my @val = `command here`;
foreach $line(@val) {
if ($line =~ /(test\d+)/){
print "$1\n";
}
}
__DATA__
Test1
Test6
Test5
Test1
I only want to print out the first Test1
Any help appreciated