Kinda embarrassed to post this, I'm very new to coding, it's bound to be trivial and you guys seem a little beyond that! But here goes:

I'm trying to validate input from a form field by testing if the value's not null (ie has that form field has been filled in). However, the array is refusing to see anything at all, ie treating a filled-in field as though it hasn't been filled in. But a variable seeing the same field *can* see what's there.

form code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><title></title></head> <body> <FORM ACTION="tst.cgi" METHOD="post" ENCTYPE="multipart/form-data"> <INPUT TYPE="file" NAME="photo00"> <INPUT TYPE="submit" NAME="Submit" VALUE="Submit Form"> </FORM></body></html>

perl code:

#!usr/bin/perl -t use strict; use warnings; use CGI; use CGI::Carp qw/fatalsToBrowser/; use File::Basename; our $query = CGI->new; our @array = (); our $photo = $query->param("photo00"); # check if the field's not null, if not, array it if ($photo != "") {push(@array, $photo);} print "Content-type: text/html\n\n"; print "@array \n"; # this does nothing - how come? print "$photo \n"; # this prints to screen fine

Many thanks, and a very Happy New Year to you all from Spain


In reply to variable sees it, array doesn't - stumped! by shrdlu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.