Darn -- I forgot to switch to plain text again. I hope this does not
appear twice -- I apologize if it does!

This works and produces the desired result (I've simplified it a bit):


$default= ((((`grep pat file-name`)[0])=~/[0-9]+/)[0]); 


Why does it take so many parentheses?


I don't think it should work, however.


(1) Why cannot I just index the results of the sub-process directly and
say `grep pat file-name`[0]? If Perl is confused I would think I might
need to explicitly convert it like this:
  @{`grep pat file-name`}[0] 
but that does not work. I think it should.


(2) I have the same question about the =~ operator -- it returns an
array too. So why cannot I just type
print @{$a=~/([0-9]+)/}[0] ?



Instead I have to type
 print (($a=~/([0-9]+/)[0]);


Why are the extra outer parens required?
Thanks,
Siegfried


--
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