Hi Monks,
I have a little problem at the moment which has got me stumped.
I'm submitting a form to a cgi script and would like to use one of the fields (a non-user-defined hidden field) submitted as a variable in the cgi script - specifically to create a file on a linux file system.
It appears however that there is something at the front of this variable but I cant in anyway see it....
Here's some simplified code to demonstrate:
my $field = $q->param("author");
$field =~ s/ /_/g;
open(OUTFILE,">"./$field.txt") || die($!);
print OUTFILE "blah";
close(OUTFILE);
The above creates the file perfectly but a
if ($item =~ /^$field\.(txt|foo|bar)$/i)
wont match until I remove the initial "^".
And if I
$field = "blah-$field";
before the creation of the "OUTFILE", the script dies while trying to create the file with the message
No such file or directory
Does anyone know of any issues concerning this or maybe how to check for some special characters in some way??
Cheers,
Reagen
Update:
OK, the form was pulling the hidden field value from a mysql database and then passing it onto the cgi script. I have now completely bypassed the form and am getting it straight from the database in the cgi script and it is still behaving in the same way. So it appears to be a mysql thing, but I have no idea what...
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.