kulua has asked for the wisdom of the Perl Monks concerning the following question:
I have a string in the xml file
<I want to extract the digit 72 from this file
Where is the mistake in the code ?
String is
<stlib:mem_bit>72</stlib:mem_bit>
use strict; use warnings; my $data = <<'EOD'; <stlib:mem_bit>72</stlib:mem_bit> EOD open my $fh, '<', \$data; while (my $line = <$fh>) { while ( $line =~ /.*st_mem_bit.*(\d+)/g ) { my $a= $1; } } print $a; close $fh;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Extract a string from the line
by choroba (Cardinal) on May 29, 2021 at 09:32 UTC | |
Re: Extract a string from the line
by LanX (Saint) on May 29, 2021 at 08:57 UTC | |
Re: Extract a string from the line
by Tux (Canon) on May 29, 2021 at 09:30 UTC | |
by LanX (Saint) on May 29, 2021 at 10:19 UTC | |
Re: Extract a string from the line
by hippo (Bishop) on May 29, 2021 at 11:20 UTC |
Back to
Seekers of Perl Wisdom