From: "Graeme St. Clair" <[EMAIL PROTECTED]>
> Or I thought so anyway.  Gurus are at liberty to think otherwise ;-)
> 
> I just had to make a single <form> with 4 submit buttons (each with
> the same 'value' legend) out of 4 <form>'s each with its own 'hidden'
> field.  I used the following to distinguish between them:-
> 
> my $request = defined $formData->param(q{Submit1}) ? q{serial} :
>               defined $formData->param(q{Submit2}) ? q{order} :
>               defined $formData->param(q{Submit3}) ? q{sql} :
>               defined $formData->param(q{Submit4}) ? q{user} :
>                                    q{Unknown};
> 
> Probably it could be still more obfuscated...

How about:

my %action = (
        Submit1 => 'serial',
        Submit2 => 'order',
        Submit3 => 'sql',
        Submit4 => 'user',
);
...

my ($request) = grep {defined $formData->param($_) and $action{$_}} 
keys %action;
$request ||= 'Unknown';


or 

my ($request) = map $action{$_}, (grep (defined($formData-
>param($_)), keys %action;
$request ||= 'Unknown';


I also think that your code would be more readable if you used '' 
instead of q{}.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to