This creates an array of arrays split at "!", potentially with empty entries at beginning or end. Similar to choroba's complex solution in Re^2: Separating array contents
use strict; use warnings; use Data::Dumper; my @arr = qw/ ! my name ! is ! Achint ! I need ! help ! /; my @out = ( [] ); for( @arr ) { if( /^!$/ ) { push @out, []; } else { push @{ $out[-1] }, $_; } } print Dumper \@out;
In reply to Re: Separating array contents
by hdb
in thread Separating array contents
by MynameisAchint
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |