Thread aus string extrahieren (4 answers)
Opened by Froschpopo at 2007-02-12 02:10

GoodFella
 2007-02-12 07:17
#74238 #74238
User since
2007-01-09
192 Artikel
BenutzerIn
[default_avatar]
Bitte etwas mehr Info, was du machen möchtest. Ansonsten hier mal eine Quick n Dirty Lösung für ein Problem, dass aus sehr viel Eigeninterpretation deiner Beschreibung entstanden ist:
Code (perl): (dl )
1
2
3
4
5
6
7
#!/usr/bin/perl -w
use strict;

my $content = 'foto1=8&foto2=40&';
my (%hash, $skip, $old);
map { $skip++; $hash{$old} = $_ unless($skip == 1); $skip = 0 if ($skip == 2); $old = $_; } ($content =~ /foto(.)=([0-9]+)&/g);
print "Foto '$_' hat den Wert '$hash{$_}'\n" for (keys(%hash));


ergibt:

Code: (dl )
1
2
Foto '1' hat den Wert '8'
Foto '2' hat den Wert '40'


hth\n\n

<!--EDIT|GoodFella|1171257481-->

View full thread aus string extrahieren