Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: UBB find user id code

by arturo (Vicar)
on Oct 10, 2001 at 00:08 UTC ( [id://117850]=note: print w/replies, xml ) Need Help??


in reply to UBB find user id code

I don't get why you're maintaining a lot of information that you're not going to use. That's a *lot* of variable declarations in there, some of which aren't needed through the whole routine. There's also a lot that can make your code more compact and elegant. Case in point:

my %cookies; #lots more code if (%cookies = fetch CGI::Cookie) {

Can be elegantly compacted into

if ( my %cookies = fetch CGI::Cookie ) { }

( warning: these aren't entirely equivalent, but since you're only interested in %cookies within that if block, you shouldn't notice the difference here.)

Note also that

if (CONDITION1) { if (CONDITION2) { } }

is equivalent to

if (CONDITION1 && CONDITION2) { }

IMO, the second is much easier to follow.

The main thing you're looking for: you want to stop once you've found the right line in the "members" file. So use last -- not break ( some C coder musta misremembered) -- to break out of the loop. It's not really use strict that causes the complaint, it's the fact that the parser doesn't recognize break as a keyword, and so thinks it's a bareword, which causes strict to complain. In reality, it's a syntax error.

while( my($login, $junkfile) = split /\|!!\|, <FH>) { if ($login eq $id) { chomp $junkfile; $exact_match = $junkfile; last; } }
perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-03-28 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found