Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Auto Incrementing Variable in While Statement

by logie17 (Friar)
on Jan 23, 2007 at 07:01 UTC ( [id://596037]=note: print w/replies, xml ) Need Help??


in reply to Auto Incrementing Variable in While Statement

It might help to post the code, however I think you're after something like this:
my $count = 0; while (..whatever..){ $count++; #do stuff last if $count == 3; }
Does this help?
s;;5776?12321=10609$d=9409:12100$xx;;s;(\d*);push @_,$1;eg;map{print chr(sqrt($_))."\n"} @_;

Replies are listed 'Best First'.
Re^2: Auto Incrementing Variable in While Statement
by logie17 (Friar) on Jan 23, 2007 at 07:37 UTC
    I may have misunderstood your message. Only use the last statement if you wish to exit the loop.Otherwise ikegami has the correct code/solution.
    apologies for any confusion
    s;;5776?12321=10609$d=9409:12100$xx;;s;(\d*);push @_,$1;eg;map{print chr(sqrt($_))."\n"} @_;
Re^2: Auto Incrementing Variable in While Statement
by htmanning (Friar) on Jan 24, 2007 at 20:38 UTC
    Okay, I'll try to be clearer here. I've stripped out some code but here is the basics of what I have:
    $SQL = "SELECT * FROM $database_table order by date DESC, ID DESC limi +t 10"; $sth = $dbh->prepare($SQL); $sth->execute; open(TXTFILE, ">$rootpath$categoryDir$frontPage"); while ($pointer = $sth->fetchrow_hashref) { $fullpath = $pointer->{'fullfilepath'}; $name = $pointer->{'filename'}; $thumbnail = $pointer->{'thumbnail'}; $image = $pointer->{'image'}; $imagewidth = $pointer->{'imagewidth'}; $headlinelink = $pointer->{'headlinelink'}; print TXTFILE <<TEXT; <a href=$url NOUNDERLINE id="headline"><font size="+1" face=arial>$tit +le</font></a><br> <font size="1">$category - $month $day, $year $catsiteshow</font><br> TEXT }
    That gives me one text file with 10 headlines formatted how I want it. I'd like to be able insert an ad after the thrid or 4th headline. So I either need a way to print each headline to a separate txt file so that I can include them all in the HTML page manually, or a way to write something into the txt file after the third headline. Make sense? Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://596037]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2024-04-25 05:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found