Perl One-liner de-compile?

2005-04-25 Thread Larsen, Errin M HMMA/IT
Hi everyone,

  Here is an example from the perlrun perldoc page:

perl -ane 'print pop(@F), \n;'

  is equivalent to
 
while() {
@F = split(' ');
print pop(@F), \n;
}


  My question is, can I get Perl to evaluate a command line (like above)
and print out the equivalent code that command line will produce?

  I hope that makes sense.  I thought I saw something similar to this on
this list before.

--Errin

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl One-liner de-compile?

2005-04-25 Thread Paul Johnson
On Mon, Apr 25, 2005 at 01:45:15PM -0500, Larsen, Errin M HMMA/IT wrote:

 Hi everyone,
 
   Here is an example from the perlrun perldoc page:
 
 perl -ane 'print pop(@F), \n;'
 
   is equivalent to
  
 while() {
   @F = split(' ');
   print pop(@F), \n;
 }
 
 
   My question is, can I get Perl to evaluate a command line (like above)
 and print out the equivalent code that command line will produce?
 
   I hope that makes sense.  I thought I saw something similar to this on
 this list before.

$ perl -MO=Deparse -ane 'print pop(@F), \n;'

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Perl One-liner de-compile?

2005-04-25 Thread Larsen, Errin M HMMA/IT
 -Original Message-
 From: Paul Johnson [mailto:[EMAIL PROTECTED] 
 Sent: Monday, April 25, 2005 1:53 PM
 To: Larsen, Errin M HMMA/IT
 Cc: beginners@perl.org
 Subject: Re: Perl One-liner de-compile?
 
 
 On Mon, Apr 25, 2005 at 01:45:15PM -0500, Larsen, Errin M 
 HMMA/IT wrote:
 
  Hi everyone,
  
Here is an example from the perlrun perldoc page:
  
  perl -ane 'print pop(@F), \n;'
  
is equivalent to
   
  while() {
  @F = split(' ');
  print pop(@F), \n;
  }
  
  
My question is, can I get Perl to evaluate a command line (like 
  above) and print out the equivalent code that command line will 
  produce?
  
I hope that makes sense.  I thought I saw something 
 similar to this 
  on this list before.
 
 $ perl -MO=Deparse -ane 'print pop(@F), \n;'
 
 -- 
 Paul Johnson - [EMAIL PROTECTED]
 http://www.pjcj.net
 


Ok ... So I tried this:

  # perl -MO=Deparse -nae 'print $f[4]' /some/directory/somefile
  LINE: while (defined($_ = ARGV)) {
  our(@F) = split( , $_, 0);
  print $f[4];
  }
  -e syntax OK

My question now is, where did the @f array come from?  I searched
through the perlvar perldoc page, but I only found an explanation for
the @F array.  Is this an example of Perl making a typo?  Or is the @f
array a secret array I'm not cleared to know about?

--Errin


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Perl One-liner de-compile?

2005-04-25 Thread Charles K. Clarkson
Larsen, Errin M HMMA/IT mailto:[EMAIL PROTECTED] wrote:
 
: Or is the @f array a secret array I'm not cleared to know about?


We could tell 'ya, but then we'd have to kill 'ya.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Perl One-liner de-compile?

2005-04-25 Thread Jeff 'japhy' Pinyan
On Apr 25, Larsen, Errin M HMMA/IT said:
$ perl -MO=Deparse -ane 'print pop(@F), \n;'
Note the @F, it's capital-F.
 # perl -MO=Deparse -nae 'print $f[4]' /some/directory/somefile
You're using a lowercase @f here.
 LINE: while (defined($_ = ARGV)) {
 our(@F) = split( , $_, 0);
 print $f[4];
 }
 -e syntax OK
Perl will magically produce the @F array for you, as shown.  It's up to 
YOU not to make the typo.

--
Jeff japhy Pinyan %  How can we ever be the sold short or
RPI Acacia Brother #734 %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %-- Meister Eckhart
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



RE: Perl One-liner de-compile?

2005-04-25 Thread Larsen, Errin M HMMA/IT


 -Original Message-
 From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED] 
 Sent: Monday, April 25, 2005 2:42 PM
 To: Larsen, Errin M HMMA/IT
 Cc: beginners@perl.org
 Subject: RE: Perl One-liner de-compile?
 
 SNIP
 
 You're using a lowercase @f here.
 
 SNIP
 
 Perl will magically produce the @F array for you, as shown.  
 It's up to 
 YOU not to make the typo.
 


  Ooops.  Hehe.

  Thx for the 2nd set of eyes, Jeff.

  --Errin

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Perl One-liner de-compile?

2005-04-25 Thread John W. Krahn
Larsen, Errin M HMMA/IT wrote:

 Ok ... So I tried this:

   # perl -MO=Deparse -nae 'print $f[4]' /some/directory/somefile
   ^
   LINE: while (defined($_ = ARGV)) {
   our(@F) = split( , $_, 0);
   print $f[4];
  ^
   }
   -e syntax OK

 My question now is, where did the @f array come from?  I searched
 through the perlvar perldoc page, but I only found an explanation for
 the @F array.  Is this an example of Perl making a typo?  Or is the @f
 array a secret array I'm not cleared to know about?
The @f array is there because YOU put it there.  Of course in this case it
will not contain anything.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response