> I'm sure someone where will pipe in a better way, but you could pass via a
> hash, something like....
>
> ($result_code, $error) = submit_changes({ 'apache_request' = >$r,
> 'user_name' => \...@user_names,
> 'latest_news' => $latest_news_file, 'archived_news' =>$archived_news_file,
> 'cgi_obj' =>$q);
>
> sub submit_changes {
>   my $hash_ref = @_;
>  # $hash_ref->{'apache_request'} is $r
> # $hash_ref->{'user_name' } is the user arrayref
> # $hash_ref->{'archived_news' } may or may not be defined if it was passed
> in.. etc.
>
> }
>
> -Chris

Almost the same, but with some extra things:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#!/usr/bin/perl

use strict;
use warnings;

sub some {
        my %params = @_;

        print $params{p1}."\n";

        foreach my $e ( @{$params{p1sub}} ) {
                print "\t$e\n";
        }

        print "$params{p2}\n";


        my $result = {};

        $result->{error} = 'foo';
        $result->{someother} = 'baar';
        # etc

        return $result;
}


my $res = {};

$res = some(
                p1 => 'param1',
                p1sub => ['param1.1', 'param1.2', 'param1.3'],
                p2 => 'param2',
);

if ($res->{error}) {
        # ... do something
}

+++++++++++++++++++++++++++++++++++++++++++++++++++


Reply via email to