http://qs321.pair.com?node_id=11108251


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!

Replies are listed 'Best First'.
Re^2: Extracting numbers from a text file
by PetreAdi (Acolyte) on Nov 02, 2019 at 18:54 UTC

    I have a variable my $content = get($url) (not array)