Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: GOTO considered (a necessary) evil?

by sedhed (Scribe)
on Jul 16, 2002 at 19:20 UTC ( #182206=note: print w/ replies, xml ) Need Help??


in reply to GOTO considered (a necessary) evil?

Without getting into the goto issue, may I offer the code I use for tieing a session using Apache::Session::*. It is not a loop at all, therefore no chance of an infinite loop. It makes two tries at a session, once using the supplied ID (if any), and if that fails it tries a second time using undef, to get a new session. Failing that, it dies.

# $id is either a cookie-passed session ID or undef # $sargs is a hashref of options eval { tie %session, 'Apache::Session::Postgres', $id, $sargs }; if ($@ =~ /^Object does not exist/) { # try to get a new session eval { tie %session, 'Apache::Session::Postgres', undef, $sargs }; die "Can't get new session: $@" if $@; } elsif ($@) { die "Can't get session. ID (if any): '$id' : $@"; }
cheers!


Comment on Re: GOTO considered (a necessary) evil?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2014-12-29 15:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (192 votes), past polls