Cywiz has asked for the wisdom of the Perl Monks concerning the following question:
ok I know there is a problem with the code itself but all so is it a good idea to call the sub or should I just add the code to the event? As you can tell im new to perl and any help would be greatly appreciated thank you..sub addbuddy { #add victim to buddy list #open names file open (FILE, "names.txt"); $list = <FILE>; close(DATA); #checks each name foreach $item (@list) { #remove lowercase and spaces from names $item =~ s/ //g; $item = lc ($item); } #check if name is in file if ($victim eq "$item") { } else { #if it does not exits add it open (DATA, ">names.txt"); print DATA "$victim\n"; Close (DATA); } #Notify the terminal print "A Buddy name was added.."; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with sub
by davorg (Chancellor) on Dec 29, 2002 at 06:56 UTC | |
|
Re: Problem with sub
by pg (Canon) on Dec 29, 2002 at 07:00 UTC | |
by Cywiz (Initiate) on Dec 29, 2002 at 09:35 UTC | |
by davorg (Chancellor) on Dec 29, 2002 at 13:00 UTC | |
|
Re: Problem with sub
by Zaxo (Archbishop) on Dec 29, 2002 at 07:10 UTC |