in reply to Array splitting
You need to use eq not ==,as the latter's used for numeric comparisons:
if(substr($_,0,1) eq 'A') { ...
Output:
Ape added to A Arg added to A Beep added to trash! Circus added to trash! Ape, Arg Beep, Circus
Another option is to use a regex to check the beginning character:
if(/^A/) { ...
Also, consider doing the following for your print statements:
... print "$_ added to A\n"; ... print "$_ added to trash!\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Array splitting
by bimleshsharma (Beadle) on Nov 01, 2012 at 08:05 UTC |