Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I have a file(s) with asimilar lines:
I want to split by /-/ but process each split separatly.1-2,3-4,2-5
So firstly $num1=1 and $num2=2 and do something with these. Then split the second set $num1=3 and $num2=4 and process these. The only problem here is that the number of splits is not consistent so i can not declare each variable. Is this possible?foreach (<>) { ($num1, $num2) = split(/-/; }
Edited by Arunbear: Changed title from 'split', as per Monastery guidelines
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to handle a variable number of results from split()?
by AReed (Pilgrim) on Jul 20, 2005 at 16:28 UTC | |
by Transient (Hermit) on Jul 20, 2005 at 17:17 UTC | |
by jdporter (Paladin) on Jul 20, 2005 at 18:43 UTC | |
by Anonymous Monk on Jul 21, 2005 at 08:20 UTC |
Back to
Seekers of Perl Wisdom