in reply to Re^2: foreach loop and creating files with "$_"
in thread foreach loop and creating files with "$_"

For me, $_ is simply the current topic that's being talked about.

well, I think it is the problem. how about 2 topics happen at the same time? actually it's the biggest problem about $_ . think a topic you want to talk is the another topic (but happen at the same time).




I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

  • Comment on Re^3: foreach loop and creating files with "$_"

Replies are listed 'Best First'.
Re^4: foreach loop and creating files with "$_"
by AppleFritter (Vicar) on Jul 22, 2014 at 11:02 UTC

    That is simply one of Perl's restrictions. You can talk about several things at once, but you will have to name them explicity, rather than referring to all of as "this" and "that". At least you get one such pronoun, though; that's one more than in pretty much every other language out there.

    Given that programs aren't actually conversations, I don't think it's a terribly bothersome restriction either. In practice, programs more closely resemble instructions, recipes, that sort of thing. There's usually one thing you're working on at any given time; often it's referred to as "it", and (in recipes in particular), it's also often not explicitely referred to at all ("cook until tender" etc).

    I think the parallel to $_ is obvious.