jerrygarciuh has asked for the wisdom of the Perl Monks concerning the following question:

OK, so my sub to parse form contents is called at runtime. On *nix if there was no form data, the script just continued on its merry way. On IIs I am getting this error: Bad name after what_ever_var' (Note single quote haning there) I have tried parsing the form with this:my %FORM = $q->Vars('topic','words','pass','textsize','topicsize','edit');
and
my %FORM = map { $_, @{[ param($_) ]} > 1 ? [ param($_) ] : param($_) } param();
and
my @labels = qw(topic words pass name textsize topicsize); my %form = map { $_ => $q->param($_) } @labels;

Any advice?
TIA
jg
here is the sub:
sub parse_form { my %FORM = map { $_, @{[ param($_) ]} > 1 ? [ param($_) ] : param( +$_) } param(); $name = $q->param('name') || "Agenda"; $name =~ s/\s/_/g; $words = $q->param('words'); $plain_words=$words; $words =~ s/\r\n/<BR>/g; while ($words=~ /<br>/gi ) {$line_break_count++} $topic= $q->param('topic'); $textcolor = $q->param('textcolor'); $textsize = $q->param('textsize'); $topicsize = $q->param('topicsize'); $textface = $q->param('textface'); $user = $ENV{'REMOTE_ADDR'}; $pass = $q->param('pass'); $edit = $q->param('edit'); if ($edit eq "done") { send_edit_form(); } elsif ($edit eq "yes") { make_edit_form(); } if ($line_break_count > $max_break_count) { seperate_page() } }
_____________________________________________________
If it gets a little bit out of hand sometimes, don't let it fool you into thinkin' you don't care.TvZ

Replies are listed 'Best First'.
Re: More Windows woes: Bad name after varname' at
by dash2 (Hermit) on Dec 13, 2001 at 15:39 UTC

    1. I expect you've done "man perldiag" and read down to the "bad name" diagnosis message. Haven't you?

    2. Even so, you're still confused, huh? I strongly suspect that this is due to Perl's old way of defining package namespaces. Instead of Foo::Bar (and $Foo::bar, @Foo::bar etc.), Perl used to allow Foo'Bar, $Foo'Bar etc. And this is still allowed for backwards compatibility. So, somewhere in your script, perl is interpreting a string quote as part of a variable name. (I don't know where because you haven't told me the real var name shown in the error.)

    The solution? More whitespace should help the interpreter out.

    dave hj~

Re: More Windows woes: Bad name after varname' at
by hakkr (Chaplain) on Dec 13, 2001 at 17:29 UTC
    Much easier to put all the params into a hash then you don't have to pass around loads of variables.
    my $sr; foreach my $str (qw(name words plain topic textcolor)) { $sr->{$str} =$q->param($str); }
    You can also use this loop to call some sort of sanitise/decode function for each param