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"'

In reply to Re: UBB find user id code by arturo
in thread UBB find user id code by LeGo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.