Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > one liner for f...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 7 Topic 11043 of 11064
Post > Topic >>

one liner for for and if

by rich.japh@[EMAIL PROTECTED] (Richard Lee) May 8, 2008 at 06:25 PM

#!/usr/bin/perl

use warnings;
use strict;

my @[EMAIL PROTECTED]
 = qw/one two three four/;

print "$_\n" for @[EMAIL PROTECTED]
 last if "$_" eq q/three/;


[root@[EMAIL PROTECTED]
 tmp]# ./!$
.././././testthis2.pl
syntax error at ././././testthis2.pl line 8, near "@[EMAIL PROTECTED]
 last "
Execution of ././././testthis2.pl aborted due to compilation errors.

Can someone fix my last statement on this program?

I thought maybe this will work   but guess not... is there no easy way 
to do this?

I don't want to do

for (@[EMAIL PROTECTED]
) {
     if .......
     }
}


just trying to see what the correct format is that for one liner that I 
am trying

thanks in advance.




 7 Posts in Topic:
one liner for for and if
rich.japh@[EMAIL PROTECTE  2008-05-08 18:25:55 
Re: one liner for for and if
anexpert@[EMAIL PROTECTED  2008-05-08 21:37:11 
Re: one liner for for and if
Uri Guttman <uri@[EMAI  2008-05-09 03:20:26 
Re: one liner for for and if
rob.dixon@[EMAIL PROTECTE  2008-05-09 04:29:21 
Re: one liner for for and if
rob.dixon@[EMAIL PROTECTE  2008-05-09 04:26:53 
Re: one liner for for and if
Uri Guttman <uri@[EMAI  2008-05-09 03:56:57 
Re: one liner for for and if
rich.japh@[EMAIL PROTECTE  2008-05-08 23:47:36 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue May 13 7:49:06 CDT 2008.