After I run your code through perltidy, I get the following:

sub info() { my $nick = $_[0]; my $reply = $_[1]; my $val = admin($nick); if ( $reply =~ /a/ ) { if ( $val == 1 ) { @info; foreach my $n (@info) { writ1("$n"); } } } else { if ( $val == 1 ) { @info; foreach my $n (@info) { writ1("$n"); } } else { pm( $nick, "^B^C4,1[x] Not auhtorized to see this!^C^B" ); } } }

There are some problems with your code. First of all, I consider it bad form to access elements of @_; it's more natural for your prologue to be my ( $nick, $reply ) = @_.

As has already been pointed out, the lines with just @info; are meaningless. What are you trying to do there?

There's no need to put $n inside quotes. That line can just be writ1($n);, and I would probably just do foreach (@info) { writ1($_); }.

Finally, we have no idea whether the code works (that is, whether it's correct) because we have no idea what it's trying to accomplish -- there are no comments, nor have you provided anything to guide us as to what the inputs are (nickname and reply, but what's the context?). There's also no clue as to what the admin, writ1 or pm routines do.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds


In reply to Re: Is this code correct by talexb
in thread Is this code correct by hax0id

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.