This is my version
#!/usr/bin/env perl
use warnings;
use strict;
my $string = "450x35+60+10";
if($string =~ m/(\d+)[x-](\d+)\+(\d+)\+(\d+)/)
{
my @list = $string =~ m/(\d+)[x-](\d+)\+(\d+)\+(\d+)/;
print scalar @list . ":" . " " . join(
Hi Klaus.
> my $re = qr/(\d+)[x](\d+)[+-](\d+)[+-](\d+)/;
> my @line = split(/$re/, $str);
You are using split the wrong way. The regexp shold only be the *delimiters*.
Here's my two alternative ways to accomplish the task:
# use the match operator with the regexp
my @l2 = $str =~ m/$re/;
say s
Hi,
with the script shown below I extract the four numbers from the string.
#!/usr/bin/perl
use 5.10.0;
use strict;
use warnings;
#
my $str = "760x35+10+20";
my $re = qr/(\d+)[x](\d+)[+-](\d+)[+-](\d+)/;
my @line = split(/$re/, $str);
say scalar(@line), ": ",join("=",@line);
for (@line)
{
say
3 matches
Mail list logo