in reply to Re^2: Crafting a regex for a split() function...
in thread Crafting a regex for a split() function...

I didn't even know you could call a subroutine from inside a regex.

The replace expression of the substitution operator is treated as Perl code rather than a string literal when the e modifier is used.

Ref: perlop

Just to be certain, the value for the match of /(\d+.\d+)/ is $1 and is then carried into sub convert as the value $_ ?

No. A subroutine's arguments are found in @_ (no relation to $_). $_[0] (again, no relation to $_) is the first element of @_, so it's the first argument of the subroutine.

Ref: perlsub

Replies are listed 'Best First'.
Re^4: Crafting a regex for a split() function...
by chinamox (Scribe) on Nov 23, 2006 at 02:03 UTC

    Thank you very much for the explaination. Storing arguements in @_ makes a great deal of sense.

    -mox

      It's not a "makes sense" thing, it is a "what Perl does thing". Parameters to subroutines are passed in the special array @_ - that's what Perl does.

      Go back and read the perlsub link that ikegami gave. That is pretty fundamental and important stuff to understand about how Perl goes about business. Take special note that array and hash parameters are flattened - look for the description of that process. There is a lot to understand about how Perl manages parameter passing!


      DWIM is Perl's answer to Gödel