Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Conditional Wierdness

by bikeNomad (Priest)
on Jul 29, 2001 at 19:42 UTC ( [id://100691]=note: print w/replies, xml ) Need Help??


in reply to Conditional Wierdness

In your case, what would the previously tested file actually be? Since there was no previously tested file, none of the file tests should return true...

Replies are listed 'Best First'.
Re: Re: Conditional Wierdness
by jlongino (Parson) on Jul 29, 2001 at 21:42 UTC
    bikeNomad -- Good question.

    I should probably apologize for the original question to begin with. It arose from a problem I recently encountered with a program that I borrowed and extensively rewrote. It has worked fine with few problems since 6/98 but recently stopped displaying daily and weekly links from the six-month calendar view. I did recently upgrade to Perl 5.6.1 (before anything broke) but am reluctant to jump to conclusions.

    I thought that I had brought home my Programming Perl book for the weekend but accidently grabbed Essential System Administration instead. Had I grabbed the right book I wouldn't have needed to ask the question at all.

    I narrowed down the problem to the (-s _) clause in question and felt that posting the larger snippet might raise a lot of questions rather than answer a simple one:

    foreach $day (@dow) { $TestDate = "$year$cur_month$link_num[$day]"; if ($Event_Hash{$TestDate} && (-s _)) { ### URL to display events for a single day. $cal_html = "$EVENT_SUM_URL?Qtype=day&"; $cal_html .= "BegDate=$year$cur_month$link_num[$day]\">"; s|^$day |$cal_html${day}${end_anchor} |; s| $day$| $cal_html${day}${end_anchor}|; s| $day | $cal_html${day}${end_anchor} |; $cal_html = "$CAL_LIST_URL_AUTH?date=$date\">"; } } if (/</) { ### URL to display events for the current week $Wk_HTML = "$EVENT_SUM_URL?Qtype=week&" . "BegDate=$year$cur_month$link_num[$First_DOW]&" . "EndDate=$year$cur_month$link_num[$Last_DOW]&" . "WeekNo=$CurrentWk\">"; $output_pub[$current_line] .= "$_ $Wk_HTML" . "w$end_anchor "; } else { $output_pub[$current_line] .= "$_ "; }
    I doubt that I wrote the (-s _) clause since I normally try to avoid cryptic code whenever possible. In any case it is unnecessary to perform a -s at this point since all the data read from files is already stored in hashes. The biggest mysteries are how I overlooked it to begin with and why did it work for three years without any noticed problems.

    The line in question has been reduced to:

    if ($Event_Hash{$TestDate}) {
    instead of:
    if ($Event_Hash{$TestDate} && (-s _)) {
    Thanks to all for responding.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-25 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found