Thread wie ein array[0] nochmals aufspalten? (7 answers)
Opened by zieglerch at 2006-06-05 03:29

Ronnie
 2006-06-05 13:44
#66998 #66998
User since
2003-08-14
2022 Artikel
BenutzerIn
[default_avatar]
Die von renee gezeigte Variante ist sicher die üblichste und wahrscheinlich auch sinnvollste. Hier noch eine Variante mit einer getrennten Funktion first_match:
Code: (dl )
1
2
3
4
5
6
sub first_match ($@) {
my ($regex, @data) = @_;
my $result;
for (@data) { $result = $1 and last if /$regex/ }
return $result;
}

...
Code: (dl )
my $max = first_match qr/Current Attainable Rate -\s*(\d+)/, @lines;

Nachtrag: Bequemer kann man das ganze natürlich auch mit CPAN:List::Util haben.\n\n

<!--EDIT|Ronnie|1149500835-->

View full thread wie ein array[0] nochmals aufspalten?