Hello all,
I have a simple question regarding the behavior of split. Given a string following the pattern /w{2}.{4}/ I am getting an extra variable from split. I'm sure this is the correct behavior, I'm just not understanding why so can't correct it. see code:
#!/usr/bin/perl -w use strict; use Data::Dumper; my $string = "df5434vg7856fg3472sd1234jh45r5"; my @array = split(/(\w{2}.{4})/,$string); print Dumper(@array);
Output:
$VAR1 = ''; $VAR2 = 'df5434'; $VAR3 = ''; $VAR4 = 'vg7856'; $VAR5 = ''; $VAR6 = 'fg3472'; $VAR7 = ''; $VAR8 = 'sd1234'; $VAR9 = ''; $VAR10 = 'jh45r5';
Thanks in advance!
Thank You for the quick solution and explanation!
In reply to split() behavior SOLVED by gman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |