in reply to Regular expression

Hi pravatka,

I am trying to print each number from variable x.

Maybe you could use something simpler than the example you chose, which demonstrates named captures?

use strict; use warnings; use feature qw/ say /; my $x = '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15'; say $x; my @matches = ( $x =~ m/\d+/g ); say for @matches; __END__

Hope this helps!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: Regular expression
by pravakta (Novice) on Oct 29, 2017 at 20:52 UTC

    Thanks nick, yes it definitely helped. I am new to perl so experimenting few things.