in reply to Any idea to let Perl form data and scalar work in same page?

CGI.pm has a method called init which slurps all of STDIN. So if init is called, you can't read STDIN - it's already been read. (And STDIN is a one-time-only thing.)

param internally calls init.

Not sure why you want to be reading this data from STDIN anyway. Just do:

$Chassis=param('Chassis');
package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Replies are listed 'Best First'.
Re^2: Any idea to let Perl form data and scalar work in same page?
by GordonLim (Acolyte) on Mar 20, 2013 at 17:35 UTC
    Hi All, Thanks all of your help. The problem is solved after I disable
    read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'}); $buffer =~ tr/+/ /; $buffer =~ s/\r/ /g; $buffer =~ s/\n/ /g; @pairs = split(/&/,$buffer); foreach $pair(@pairs){ ($key,$value)=split(/=/,$pair); $formdata{$key}.="$value"; }
    and change all the $formdata to param(). Last time I did changed to param without disable read(STDIN... Is my silly mistake. Thank you all of your advise. :) appreciated so much. At the end thank tobyink remind me to try param () again.