Harry Putnam wrote:
Why is it that the first two splits do not produce any elements?

#!/usr/local/bin/perl

use strict;
use warnings;

my $var = 100421;
my @elems1 = split(/\d/,$var);
my @elems2 = split(/./,$var);
my @elems3 = split(//,$var);

split discards the pattern split on.  To keep it, place it in parentheses.

my @elems = split( /(\d)/, $var );

See `perldoc -f split`  http://perldoc.perl.org/functions/split.html


--
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to