Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Is this code correct

by talexb (Chancellor)
on Jan 28, 2009 at 17:37 UTC ( [id://739654]=note: print w/replies, xml ) Need Help??


in reply to Is this code correct

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-04-23 12:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found