A
A. Farber
Hello,
I have a CGI-script for creating new users.
You can either upload a CSV file for a batch
of users or fill out a web for for just 1 user.
So I have a ref to array which contains
either lines from the uploaded CSV file or
just 1 line constructed from the web form:
my $input = $fh ? [ <$fh> ] :
# trick: create a line as if a Lotus Notes CSV-file has
been uploaded
[ sprintf '%s;%s;;;%s;XXX;%s;;;XXX;%s-%s;;%s%s.
%[email protected];;XXX;;;;%s;',
$QUERY->param('last'),
$QUERY->param('first'),
$QUERY->param('pass'),
$QUERY->param('user'),
$QUERY->param('company'),
$QUERY->param('city'),
($QUERY->param('company') =~ /^mycompany$/i ? '' :
'ext-'),
$QUERY->param('first'),
$QUERY->param('last'),
($QUERY->param('inform') =~ /nobody/i ? '' : $QUERY-
my $loh = validate_input($input);
My problem above is that [ <$fh> ] seems
to be evaluated in a scalar context and
I get just 1 line instead of all.
Is there a nice way to force list context on it?
Thanks
Alex
I have a CGI-script for creating new users.
You can either upload a CSV file for a batch
of users or fill out a web for for just 1 user.
So I have a ref to array which contains
either lines from the uploaded CSV file or
just 1 line constructed from the web form:
my $input = $fh ? [ <$fh> ] :
# trick: create a line as if a Lotus Notes CSV-file has
been uploaded
[ sprintf '%s;%s;;;%s;XXX;%s;;;XXX;%s-%s;;%s%s.
%[email protected];;XXX;;;;%s;',
$QUERY->param('last'),
$QUERY->param('first'),
$QUERY->param('pass'),
$QUERY->param('user'),
$QUERY->param('company'),
$QUERY->param('city'),
($QUERY->param('company') =~ /^mycompany$/i ? '' :
'ext-'),
$QUERY->param('first'),
$QUERY->param('last'),
($QUERY->param('inform') =~ /nobody/i ? '' : $QUERY-
param('inform')) ];
my $loh = validate_input($input);
My problem above is that [ <$fh> ] seems
to be evaluated in a scalar context and
I get just 1 line instead of all.
Is there a nice way to force list context on it?
Thanks
Alex