N
Neil Shadrach
$ perl -wle 'foreach (q(/level1/level2/level3)=~m|/([^/]*)|g) { print }'
level1
level2
level3
What is the simplest way of determining from within the above loop whether it is the last iteration?
I could use an intermediate array ( below ) and compare a loop counter with $#a but I'm sure
some kind soul can point me at a neater way that is so obvious that I can't think of it
$ perl -wle '@a=q(/level1/level2/level3)=~m|/([^/]*)|g;foreach (@a) { print }'
level1
level2
level3
$
level1
level2
level3
What is the simplest way of determining from within the above loop whether it is the last iteration?
I could use an intermediate array ( below ) and compare a loop counter with $#a but I'm sure
some kind soul can point me at a neater way that is so obvious that I can't think of it
$ perl -wle '@a=q(/level1/level2/level3)=~m|/([^/]*)|g;foreach (@a) { print }'
level1
level2
level3
$