CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: [FishMonger] storing all param for later use: Edit Log


Mar 18, 2013, 5:30 PM

Views: 689
Re: [FishMonger] storing all param for later use

I suppose at first I was asking after referencing this through perldoc and google, what is the most effective way to store all params into a array of hashes or hash for later use. Here is my example of what I'm trying to figure out.


# Define query
my $q = CGI->new;

# These field names are the form fields name
# and database column names I want to use
my @fields = (
{ what => 'newsdate' },
{ what => 'newshead' },
{ what => 'news' },

# Wanting to map the values of each param for later use
# in SELECT or INSERT statments

my @params = map { ($q->param($_->{what})) } @fields;

# Example: qq(INSERT INTO table (Col1, Col2, Col3) VALUES (join(', ', ('?') x @fields)));

# Package file..

sub new {
my $class = shift;
my $self = {
_date => $q->param('newsdate'),
_head => $q->param('newshead'),
_news => $q->param('news'),

# ^ instead of using $q->param('') for each, can i
# use from earlier reference such as $_->{what} ?

bless $self, ref( $class ) || $class;
return $self;

(This post was edited by hwnd on Mar 19, 2013, 8:14 AM)

Edit Log:
Post edited by recruiter (User) on Mar 19, 2013, 6:23 AM
Post edited by recruiter (User) on Mar 19, 2013, 8:14 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives