in reply to Extracting numbers from a text file
Hello PetreAdi,
Something like that?
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @array = ("aaa111bbb", "ab01ac d ab02ac ab03ac", "aaa222bbb", "ab04 +acab05ac r ab06ac", "aaa333bbb", "ab01ac t cab06acab10ac"); foreach my $str (@array) { my @all_nums = $str =~ /(\d+)/g; print Dumper \@all_nums; } __END__ $ perl test.pl $VAR1 = [ '111' ]; $VAR1 = [ '01', '02', '03' ]; $VAR1 = [ '222' ]; $VAR1 = [ '04', '05', '06' ]; $VAR1 = [ '333' ]; $VAR1 = [ '01', '06', '10' ];
On the Monastery it has been answered before this question (extracting number from string).
Seeking for Perl wisdom...on the process of learning...not there...yet!
In Section
Seekers of Perl Wisdom