in reply to Re: Problem With Split
in thread Problem With Split

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Problem With Split
by Happy-the-monk (Canon) on Jun 16, 2004 at 12:54 UTC

    Also my @splat = $thing =~ m/\d{4}/g; only sets @splt = ('1234');

    That's funny, because:

    my $thing = '12340019'; my @splat = $thing =~ m/\d{4}/g; print Dumper \@splat; __END__ $VAR1 = [ '1234', '0019' ];

    Cheers, Sören

Re^3: Problem With Split
by tinita (Parson) on Jun 16, 2004 at 13:13 UTC
    Well the number changes each time so I couldn't just use int '0019'.
    uh? so what's the problem? use int $num, like i showed you.
    $num can be anything you want. this code will take a string consisting of digits with leading zeros and remove them. why would you think that it works only on the string '0019'?
    Also my @splat = $thing =~ m/\d{4}/g; only sets @splt = ('1234');
    see Happy-the-monk's answer. maybe your perl is broken.

      It's not that I thought it only worked on the string '0019'. When I had first typed you code and did:

      foreach (@splat) { print $_, "\n" }

      I only saw 1234 printed, so I figured you then wrote the int '0019' because @splat = $thing =~ m/\d{4}/g; only sets the first one. However, I did it again, I really don't know what I changed, but it worked this time.

      Thanks. And sorry for the confusion.