I have the following code to get a substring inside an string, I'm using regular expressions but they seem not to work properly. How can I do it?
I have this string:
vlex.es/jurisdictions/ES/search?textolibre=transacciones+banco+de+bogota&translated_textolibre=,300,220,00:00:38,2,0.00%,38.67%,a??0.00
and I want to get this substring:
transacciones+banco+de+bogota
The code:
open my $info, $myfile or die "Could not open $myfile: $!";
while (my $line = <$info>) {
if ($line =~ m/textolibre=/) {
my $line =~ m/textolibre=(.*?)&translated/g;
print $1;
}
last if $. == 3521239;
}
close $info;
The errors:
Use of uninitialized value $line in pattern match (m//) at classifier.pl line 10, <$info> line 20007.
Use of uninitialized value $1 in print at classifier.pl line 11, <$info> line 20007.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…