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

Hi
It is probably a very basic question but it seems i cant figure out a simple way to do it.
I d like to have a tiny CGI script for debug issues that would output the variable he receives. I used
#!/usr/bin/perl -w use strict; use CGI::Lite; my $cgi = new CGI::Lite; my %in = $cgi->parse_form_data; my $text_value = ''; print "Content-type: text/html\n\n"; foreach my $k (keys %in) { $text_value .= "$k => $in{$k}\n\n"; } my $fichier = '../public_html/debug.html'; open (FICHIER, '>', $fichier) || die ("Writing $fichier failed"); print FICHIER $text_value; close (FICHIER);

But this script would need to be updated when more complex type of data are required
Is there a simple way to do what i want ?
thanks in advance

Replies are listed 'Best First'.
Re: displaying all data received on a web script
by choroba (Cardinal) on Dec 19, 2014 at 10:31 UTC
    What about using Data::Dumper and just
    $text_value = Dumper { $cgi->parse_form_data };
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: displaying all data received on a web script
by hippo (Archbishop) on Dec 19, 2014 at 12:10 UTC

    Since you are using CGI-Lite anyway, why not use the handy print_data method?

    use strict; use CGI::Lite; my $cgi = CGI::Lite->new; print "Content-type: text/plain\n\n"; $cgi->parse_form_data; $cgi->print_data;