in reply to prob keeping my floats floating

split expects a pattern; . is special to a pattern:

C:\Users\Peter>perl -we "print join ':', split('.', '2.3.4')" C:\Users\Peter>perl -we "print join ':', split('\.', '2.3.4')" 2:3:4

addendum: showing number of elements:

C:\Users\Peter>perl -we "print scalar split('.', '2.3.4', -1)" 6 C:\Users\Peter>perl -we "print scalar split('\.', '2.3.4', -1)" 3

Replies are listed 'Best First'.
Re^2: prob keeping my floats floating
by perl-diddler (Chaplain) on Feb 15, 2019 at 02:47 UTC
    Yeah, I thought I had a backslash before it. I fixed it a different way by changing the 1st arg to an explicit pattern: (this one shows the array ref):
    > perl -we ' use P; my @x = split( m{\.}, "$ARGV[0]"); P "\nargv0=%s", "$ARGV[0]"; P "(%s)\n", \@x' "2.3" argv0=2.3 ([2, 3])
    Thanks!