[32853] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4119 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 19 11:09:34 2014

Date: Sun, 19 Jan 2014 08:09:03 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 19 Jan 2014     Volume: 11 Number: 4119

Today's topics:
        Please explain "and next" <dave@invalid.invalid>
    Re: Please explain "and next" <hjp-usenet3@hjp.at>
    Re: Please explain "and next" <news@lawshouse.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 19 Jan 2014 15:02:39 +0000 (UTC)
From: "Dave Saville" <dave@invalid.invalid>
Subject: Please explain "and next"
Message-Id: <fV45K0OBJxbE-pn2-gMQU8HdkRWTL@paddington.bear.den>

Came across this today

print "1 OK\n"             and next unless (length $line[0]);

Never seen that construct before. Is it just some perlish shorthand  
to get stuff on one line?

TIA
-- 
Regards
Dave Saville


------------------------------

Date: Sun, 19 Jan 2014 16:21:25 +0100
From: "Peter J. Holzer" <hjp-usenet3@hjp.at>
Subject: Re: Please explain "and next"
Message-Id: <slrnldnrbl.v4c.hjp-usenet3@hrunkner.hjp.at>

On 2014-01-19 15:02, Dave Saville <dave@invalid.invalid> wrote:
> Came across this today
>
> print "1 OK\n"             and next unless (length $line[0]);
>
> Never seen that construct before. Is it just some perlish shorthand  
> to get stuff on one line?

See perldoc perlop "Logical And" and perldoc -f next. 
You should be able to figure it out.

        hp

-- 
   _  | Peter J. Holzer    | Fluch der elektronischen Textverarbeitung:
|_|_) |                    | Man feilt solange an seinen Text um, bis
| |   | hjp@hjp.at         | die Satzbestandteile des Satzes nicht mehr
__/   | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel


------------------------------

Date: Sun, 19 Jan 2014 16:07:32 +0000
From: Henry Law <news@lawshouse.org>
Subject: Re: Please explain "and next"
Message-Id: <eY2dnUhvxJbYZUbPnZ2dnUVZ7oSdnZ2d@giganews.com>

On 19/01/14 15:02, Dave Saville wrote:
> Came across this today
>
> print "1 OK\n"             and next unless (length $line[0]);
>
> Never seen that construct before. Is it just some perlish shorthand
> to get stuff on one line?

Well, in a sense.  It saves coding this

unless ( length $line[0] ) {
   print "1 OK\n";
   next;
}

In fact you don't need those brackets round the test condition either.

Now to really understand why it works, do what Peter suggests and look 
up the "and" operator (and how it's different from &&).


-- 

Henry Law            Manchester, England


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 4119
***************************************


home help back first fref pref prev next nref lref last post