Hi,
I'm sending data through the POST from HTML and then try to save it as YAML.
This is a form to create data
<form action="/send.pl" method="POST">
<input name="product" size="50">
<input type="submit" value="Go">
</form>
here is the processing of the data in send.pl:
use YAML::Syck;
use CGI::Fast ':standard';
while ( my $q = new CGI::Fast ) {
my $data;
$data->{'product'}=$q->param('product');
$data->{'product_test'}="test product"; #for test that YAML is working
DumpFile( 'test.yml', $data );
print "Content-type: text/html\n\n";
print "q=".$q->param('product'); # this is for test only
}
The result on the screen is perfect. q contains what ever it should contain.
But the YAML file is bad.
---
product: ~
product_test: "test product"
Why the data are destroyed?
UPD: The problem was solved by switching from YAML::Syck to YAML::Dumper library.
In reply to YAML problem
by luxs
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.