Thread Ersatz fuer "IN"?: Pascal:if (i in (LISTE)then PERL? (8 answers)
Opened by mohk at 2004-01-29 14:10

esskar
 2004-01-30 07:19
#79648 #79648
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
[quote=eisbeer,29.01.2004, 13:40]Vielleicht ne exotische Variante:
Code: (dl )
1
2
3
4
5
6
7
$delm  = ';;';
@array = ('val1','val2','IchTanzeAusDerReihe','val4','val5');
$such  = 'IchTanzeAusDerReihe';

unless (index( $delm.join($delm,@array).$delm, $delm.$such.$delm ) == -1 ) {
  print "Gefunden ... !";
}


Code: (dl )
1
2
3
Benchmark: timing 1000000 iterations of grep, index...
    grep: 11 wallclock secs (10.22 usr +  0.00 sys = 10.22 CPU) @ 97895.25/s (n=1000000)
    index:  2 wallclock secs ( 2.28 usr +  0.00 sys =  2.28 CPU) @ 438020.15/s (n=1000000)
[/quote]
Code: (dl )
1
2
3
4
5
6
7
$delm  = ';;';
@array = ('val1','val2','IchTanze','AusDerReihe','val4','val5');
$such = 'IchTanze;;AusDerReihe';

unless (index( $delm.join($delm,@array).$delm, $delm.$such.$delm ) == -1 ) {
print "Gefunden ... !";
}


und jetzt? :)

View full thread Ersatz fuer "IN"?: Pascal:if (i in (LISTE)then PERL?