in reply to how to make dependent drop down in perl script

Hi Team,

Need your help on perl script:

I tried to short perl hash value based on Kay. Its work perfactly in separate file but when I integrate same code in my perl project it doesn't work.

please find the code in separate file and its output :

#!/usr/bin/perl use strict; use warnings; #use 5.010; my %folderhash2 = ( '1005' => 'SG', '1007' => 'NA', '1010' => 'Global', '0' => 'None', '1006' => 'Link', ); foreach my $folderMap2 (sort keys %folderhash2) { printf "%-8s %s\n", $folderMap2, $folderhash2{$folderMap2}; }

OUT PUT :

vmias62409 /v/region/na/appl/msim/imasg_env/data/imasgdev/bin/notify/s +ignOffPageOnDev 23$ ./temp.pm 0 None 1005 SG 1006 Link 1007 NA 1010 Global

in above the perl hash get shorted based on it's Id but when I added the same below code in my perl projet , it's gives us error

The below code I pasted in my project :

my %folderhash2 = ( '1005' => 'SG', '1007' => 'NA', '1010' => 'Global', '0' => 'None', '1006' => 'Link', ); foreach my $folderMap2 (sort keys %folderhash2) { printf "%-8s %s\n", $folderMap2, $folderhash2{$folderMap2}; }

Error :

[Fri Apr 28 07:13:49.446884 2023] [cgid:error] [pid 17180:tid 47883746 +555648] [client 138.20.34.173:26768] malformed header from script 'si +gnoff.cgi': Bad header: 0 None, referer:

Replies are listed 'Best First'.
Re^2: how to make dependent drop down in perl script (missing header)
by hippo (Archbishop) on Apr 28, 2023 at 14:11 UTC

    Best guess is that you forgot to print the Content-Type header before the loop you have shown us. Working SSCCE:

    #!/usr/bin/env perl use strict; use warnings; print "Content-type: text/plain\n\n"; my %folderhash2 = ( '1005' => 'SG', '1007' => 'NA', '1010' => 'Global', '0' => 'None', '1006' => 'Link', ); foreach my $folderMap2 (sort keys %folderhash2) { printf "%-8s %s\n", $folderMap2, $folderhash2{$folderMap2}; }

    🦛

      Thanks so much for quick reply : I have added the print "Content-type: text/plain\n\n"; but still the output is not as expected :
      0 None 1005 SG Desk Reports 1006 LN Desk Reports 1007 NA Desk Reports 1008 Saudi Desk Reports 1010 Global Reports
      Content-Type: text/html; charset=ISO-8859-1
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S"> <head> <title>MSIM Equity</title> <link rel="stylesheet" type="text/css" href="../css/master.css" /> <link rel="stylesheet" type="text/css" href="../css/basic.css" /> <link rel="stylesheet" type="text/css" href="../css/imasg-onelook.css" + /> <link rel="stylesheet" type="text/css" href="../css/imasg-eod.css" /> <script src="../js/signoff.js" type="text/javascript"></script> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body id="ctl00_Body"> <div id="header"><h1 class="logo"><img src="../images/ms-logo.gif" alt +="Morgan Stanley" /></h1><h1 class="logo-print"><img src="../images/m +s_logo_grey.gif" alt="" /></h1><h1 id="site-title">MSIM Equity Report +s Signoff</h1><div id="utility-nav"><ul><li style="color:#ccffff">Wel +come: Ajay Kumar Srivastava&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</ +li><br /><br /><li style="color:#ccffff">Contact Us: 212-762-0194 </l +i></ul></div></div><div id="navigation"><div id="primary-nav"><ul><li +><a title="Home" href="signoff.cgi?rm=main">Home</a></li><li><a title +="Delinquency Report" href="signoff.cgi?rm=delinq_report">Delinquency + Report</a></li><li><a title="View Report" href="signoff.cgi?rm=view_ +report&amp;fId=0&amp;rId=0">View Report</a></li></ul></div></div><br +/><br /><form method="post" action="/signOffPageOnDev/cgi/signoff.cgi +?rm=view_report&amp;fId=0&amp;rId=0" enctype="multipart/form-data" on +load="setDefaultFolderName()" name="reportDetails" id="reportDetails" +> <br /><div class="column-module"><div class="title-bar"><div class="te +xt">View Report</div></div><br /><br />1

        If your data is HTML then obviously print an HTML Content Type rather than a plain text one.

        print "Content-type: text/html\n\n";

        Your post is was confusing. Please enclose your output inside <code> tags so that we can tell what it really is.

        Updated - thanks Corion for editing the parent to add the code tags.


        🦛

Re^2: how to make dependent drop down in perl script
by marto (Cardinal) on Apr 28, 2023 at 14:07 UTC
    Bad header: 0

    Are you printing a header before printing your data?

      No , I am not printing header . I tried to print header but it doesn't allow me . giving error