On Tue, 31 Mar 2009 04:49:17 +1000, John W. Krahn <jwkr...@shaw.ca> wrote:

Or instead of using arrays you could store the 1s and 0s in strings:
 $ perl -le'
my $string = "10110111001";
print $-[0] while $string =~ /0/g;
'
1
4
8
9

Hi John,

Could you explain how the above code works please? I looked up perl -l in man perl and the argument is for octal. Why is that necessary?

I also looked up $-, which is the variable for the "number of lines left on the page". Is this an array, since you use it as $-[0]?

Thank you,

Dave

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to