Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Passing Multi Form Page as array to write CSV file

by Baffled (Acolyte)
on Jan 09, 2013 at 01:55 UTC ( #1012362=perlquestion: print w/replies, xml ) Need Help??
Baffled has asked for the wisdom of the Perl Monks concerning the following question:

Ok. First some preamble. I have a webpage that is loaded with a users saved CSV file containing a database of items, each row is one item with 15 fields of designated information about that item.
On this page the file is read and using a foreach loop to print out a small form for each item. Each form field is prefilled using the $title, $price, $shipping ect variables from the csv file.

Form for item one title, price, size, shipping
form for item two title, price, size, shipping
form for item three title, price, size, shipping
form for item four title, price, size, shipping
and so on until all lines are read.

I wish to have it so when a user edits the title for a item and pushes a save button it re-writes the CSV file with any new changes made. I was trying something like the following but I know its all wrong. When called it returns like as if it worked but yet nothing actually happens

my ($title, $reserve, $inc, $desc, $image1, $image2, $image3, $image4) $form{'RETURNPOLICY'} =~ s/\</\&lt\;/g; $form{'RETURNPOLICY'} =~ s/\>/\&gt\;/g; $form{'item'} = $rdata5; foreach $invrecord (@allrecords){ open (NEWSHT, ">>$config{'basepath'}$config{'inventory'}/spreadshe +ets/$form{'item'}.dat") or die "Could not edit your inventory spreads +heet file :$!\n"; print NEWSHT "$form{'TTITLE'}$fielddelimiter$form{'RESERVE +'}$fielddelimiter$form{'INC'}$fielddelimiter$form{'DESC'}$fielddelimi +ter$form{'IMAGE1'}$fielddelimiter$form{'IMAGE2'}$fielddelimiter$form{ +'IMAGE3'}$fielddelimiter$form{'IMAGE4'}"; close NEWSHT; }

Replies are listed 'Best First'.
Re: Passing Multi Form Page as array to write CSV file
by NetWallah (Canon) on Jan 09, 2013 at 04:59 UTC
    Do you have anything in @allrecords ?

    You iterate using $invrecord, but do not use that inside your 'for' loop.

    Can you print your $form{*} fields to the screen to verify that they contain what you expect ?

                 "By three methods we may learn wisdom: First, by reflection, which is noblest; Second, by imitation, which is easiest; and third by experience, which is the bitterest."           -Confucius

      Thanks, you didnt know it but you really helped me with a different problem. I never knew about $form{*} to print out all the form fields. When I saw it I hit myself up side the head.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1012362]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-07-22 22:33 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (456 votes). Check out past polls.