przemek88 has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, sorry for my silly question. I need to get data from file, as variables, and send them by using form to cgi program. Unfortunatelly, I can't read them outside loop. I tried to write a subroutine and get them by using return function, but it didn't work. Any ideas? Thanks.
#!/usr/bin/perl -w use strict; use CGI::Carp qw(fatalsToBrowser); print "Content-type: text/html\n\n"; my $file; print "<input type=\"file\" name=\"$file\" size=\"40\"> "; open (FILE, "$file"); while (<FILE>) { chomp; my ($name1, $name2, $address, $phone) = split("\t"); } close (FILE); print '<FORM name="form" ACTION="cgi.pl" METHOD="POST">'; print "<input type=\"hidden\" name=\"name1\" value=\"$name1\"> "; print "<input type=\"hidden\" name=\"name2\" value=\"$name2\"> "; print "<input type=\"hidden\" name=\"address\" value=\"$address\"> "; print "<input type=\"hidden\" name=\"phone\" value=\"$phone\"> "; print '<input style="width: 70px; height: 20px "type="submit" value="O +K" />'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting variables from file
by GrandFather (Saint) on Jan 31, 2011 at 02:48 UTC | |
by thezip (Vicar) on Jan 31, 2011 at 04:31 UTC | |
|
Re: Getting variables from file
by wind (Priest) on Jan 31, 2011 at 06:47 UTC | |
|
Re: Getting variables from file
by kiz (Monk) on Jan 31, 2011 at 10:12 UTC |