perl -MO=Deparse -e 'for $i (1..4){;}' is the -MO=Deparse option explained anywhere ?
-----Original Message----- From: david [mailto:[EMAIL PROTECTED] Sent: Thursday, July 24, 2003 11:34 PM To: [EMAIL PROTECTED] Subject: Re: for/foreach question Peter Fleck wrote: > I just stumbled upon this in some perl I'm working on: > > for $arrayref (@datedbi) { > #do stuff > } > > It didn't look right and sure enough, it should be 'foreach'. > > But it worked fine and that's my question - why is this working? > > @datedbi's elements are references to lists and they all seem to be > getting processed the way I want whether I use 'for' or 'foreach' in > the code. Perl internally compiles 'for' into 'foreach' for you: [panda]$ perl -MO=Deparse -e 'for $i (1..4){;}' foreach $i (1 .. 4) { (); } -e syntax OK [panda]$ they are exactly the same. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]