Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Help syntax?

by kejohm (Hermit)
on Jul 12, 2010 at 09:36 UTC ( [id://848961]=note: print w/replies, xml ) Need Help??


in reply to Help syntax?

On a side note, might I suggest using the CGI module or similar to output HTML, instead of printing it yourself. It will probably make things a lot simpler. Here is an sample of your code rewritten using CGI (plus a few style changes):

use CGI qw(:standard); # use functions instead of OO interface sub build_select_field_from_db { # -------------------------------------------------------- # Builds a SELECT field from the database. my ( $column, $value, $name ) = @_; my ( $fieldnum, $found ) = ( 0, 0 ); for my $i (0 .. $#db_cols) { if ($column eq $db_cols[$i]) { $fieldnum = $i; $found = 1; last; } } if (!$found) { return q(error building select field: no fields specified!); } open my $DB, q(<), $db_file_name or cgierr(qq(unable to open $db_f +ile_name. Reason: $!)); my @lines = <$DB>; close $DB; my @selectfields; LINE: foreach my $line (@lines) { if ($line =~ /^#/) { next LINE; } # Skip comment lines. if ($line =~ /^\s*$/) { next LINE; } # Skip Blank Lines. chomp $line; my @fields = split_decode ($line); if(!(List::MoreUtils::any { $_ eq $fields[$fieldnum] } @select +fields)){ push @selectfields, $fields[$fieldnum]; } } my $output = popup_menu( -name => defined $name ? $name : $column, -values => [ '---', sort @selectfields ], -default => $value, ); return $output; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://848961]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 03:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found