bazz
07-22-2005, 12:28 PM
Hi,
In an array there will be many Business names.
If the specific $client_reference is in the list, sub1 should run.
If the $client_reference is not in that list, I want to run the sub2.
Unfortunately, as I have written it, it prints the second sub for each of the files that do not eq $client_reference.
I can see why it does that but can't figure a way to print the second sub just once.
I tired flagging yesterday but it didn't work. probably my mistake so I'll try it again as it seems, to me, logical that it should do what I want.
Any pointers you may have would be very helpful this Friday.
here is the first code which repeats sub 2 as many times as there are files.
foreach my $key (sort @listOfFiles) {
unless ($key eq $client_reference) {
&new_client_details;
}
else {
&client_exists;
}
And here's the flagged code which gives the two subs together - the form to add a new client and also then, telling me that the client is already in the system. :rolleyes: (heh, heh, just realised the irony. That scenario is my 'H*ly Grail' :D )
foreach my $key (sort @listOfFiles) {
unless ($key eq $client_reference) {
&new_client_details;
}
else {
$exists = 1;
}
if ($exists = 1) {
&client_exists;
}
Bazz
In an array there will be many Business names.
If the specific $client_reference is in the list, sub1 should run.
If the $client_reference is not in that list, I want to run the sub2.
Unfortunately, as I have written it, it prints the second sub for each of the files that do not eq $client_reference.
I can see why it does that but can't figure a way to print the second sub just once.
I tired flagging yesterday but it didn't work. probably my mistake so I'll try it again as it seems, to me, logical that it should do what I want.
Any pointers you may have would be very helpful this Friday.
here is the first code which repeats sub 2 as many times as there are files.
foreach my $key (sort @listOfFiles) {
unless ($key eq $client_reference) {
&new_client_details;
}
else {
&client_exists;
}
And here's the flagged code which gives the two subs together - the form to add a new client and also then, telling me that the client is already in the system. :rolleyes: (heh, heh, just realised the irony. That scenario is my 'H*ly Grail' :D )
foreach my $key (sort @listOfFiles) {
unless ($key eq $client_reference) {
&new_client_details;
}
else {
$exists = 1;
}
if ($exists = 1) {
&client_exists;
}
Bazz