jerrygarciuh has asked for the wisdom of the Perl Monks concerning the following question:

I believe this snippet
next if ( $q->param("box$ post_number") );
Should cycle through my checkboxes and return their values which are then added to an array with push and joined before printing to my text file but it is always empty regardless of the state of the boxes. Do you see a problem with the snippet? The whole of the code is posted as an addendum to my original post here.
TIA
jg_____________________________________________________
If it gets a little bit out of hand sometimes, don't let it fool you into thinkin' you don't care.TvZ

Replies are listed 'Best First'.
Re: Shouldn't this return the named checkbox's value?
by dws (Chancellor) on Dec 05, 2001 at 10:01 UTC
    I believe this snippet
    next if ( $q->param("box$ post_number") );
    Should cycle through my checkboxes and return their values ...
    next works best within a looping construct. Your snippet doesn't have one. $post_number stays undef.

    Likewise, $_ never gets a value. That's why you're getting zero bytes when you write $_ into a newly-created file.

    You need to start with $post_number = 1, and count up until you don't find any valid parameters named "box$post_number", AND you need to grab valid parameters and stick them into $_.

Re: Shouldn't this return the named checkbox's value?
by atcroft (Abbot) on Dec 06, 2001 at 07:55 UTC
(ichimunki) Re: Shouldn't this return the named checkbox's value?
by ichimunki (Priest) on Dec 05, 2001 at 22:05 UTC
    dws may be right, but if you ask me "box$ post_number" looks like a typo unless you really want that space between $ and post_number.