Thread regexp als Funktionsparameter übergeben (1 answers)
Opened by Gast at 2006-10-06 13:43

J-jayz-Z
 2006-10-06 13:51
#70561 #70561
User since
2005-04-13
625 Artikel
BenutzerIn
[Homepage] [default_avatar]
Na ja, du kannst den regex mit qr übergeben:
Code: (dl )
waitFor(qr/OK|ERROR|\+CME ERROR: *(0-9)+/, 5.0);

Aus perldoc perlop:
Code: (dl )
1
2
3
4
5
6
 qr/STRING/imosx
This operator quotes (and possibly compiles) its STRING as a
regular expression. STRING is interpolated the same way as
PATTERN in "m/PATTERN/". If "'" is used as the delimiter, no
interpolation is done. Returns a Perl value which may be used
instead of the corresponding "/STRING/imosx" expression.
perl -Mstrict -Mwarnings -e 'package blub; sub new { bless {} } sub bar {my $self=shift; $self->{bla}="5065726c2d436f6d6d756e697479"; return $self->{bla};} my $foo=blub->new();print "Hallo ";print pack("H*",$foo->bar()); print "\n"'

http://perl-tutor.de

View full thread regexp als Funktionsparameter übergeben