CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Simple (I think) for... question?

 



jsailor
Deleted

Aug 21, 2000, 11:51 AM

Post #1 of 2 (1873 views)
Simple (I think) for... question? Can't Post

I imagine this to be a pretty beginner question, but I can't find the answer anywhere...

I'm trying to read in a file, but stop at a certain length of the file, say line 1000...

is it possible to use "for" to meet 2 conditions??? I currently have this:

for ( $i = 1; $_ = <FILE>; $i++ )

but is there a way to say this:

for ( $1 = 1; $_ = <FILE> AND i < 1000; $i++ )




japhy
Enthusiast

Aug 21, 2000, 4:36 PM

Post #2 of 2 (1873 views)
Re: Simple (I think) for... question? [In reply to] Can't Post

It's very easy. Use the '&&' operator (or you can use the 'and' operator).

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


for ($i = 0; $_ = <FILE> and $i < 10; $i++) {
# ...
}
</pre><HR></BLOCKQUOTE>

Read perldoc perlop for information on the && operator.

------------------
Jeff "japhy" Pinyan -- accomplished author, consultant, hacker, and teacher


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives