For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > August 2005 > Re: perl cgi scrolling list within a forloop









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: perl cgi scrolling list within a forloop
Zentara

2005-08-12, 4:59 pm

On Wed, 10 Aug 2005 13:32:39 -0400, DBSMITH@OhioHealth.com wrote:


> foreach (@ARRAY With H strings)
> {
> print ('htapes99',[$_],5,'true',my %attributes);
> }
>
>It prints to the intranet with the scroll lisyt but it is not printing the
>actual H strings. Instead it is printing the array structure lie so:
>
>
> ARRAY(0x16bd90)5trueARRAY(0x16f974)5true
ARRAY(0x16bcf4)5trueARRAY(0x16bd90)5true
ARRAY(0x16f9)


All you need to do is dereference them and do whatever you want with
them.

foreach my $aref (@ARRAY With H strings)
{
my @arr = @$aref;
print ('htapes99', @arr ,5,'true',my %attributes);
}

Of course you will probably want to make a nested loop
to loop thru @arr instead of just printing it.



--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
DBSMITH@OhioHealth.com

2005-08-12, 4:59 pm


zentara
<zentara@highstre
am.net> To
Sent by: beginners-cgi@perl.org
Linux@lists.devel cc
ooper.com
Subject
Re: perl cgi scrolling list within
08/12/2005 09:13 a forloop
AM












On Wed, 10 Aug 2005 13:32:39 -0400, DBSMITH@OhioHealth.com wrote:


> foreach (@ARRAY With H strings)
> {
> print ('htapes99',[$_],5,'true',my %attributes);
> }
>
>It prints to the intranet with the scroll lisyt but it is not printing the
>actual H strings. Instead it is printing the array structure lie so:
>
>
> ARRAY(0x16bd90)5trueARRAY(0x16f974)5true
ARRAY(0x16bcf4)5trueARRAY(0x16bd90)5true
ARRAY(0x16f9)



All you need to do is dereference them and do whatever you want with
them.

foreach my $aref (@ARRAY With H strings)
{
my @arr = @$aref;
print ('htapes99', @arr ,5,'true',my %attributes);
}

Of course you will probably want to make a nested loop
to loop thru @arr instead of just printing it.



--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams




I was able to get it working without a foreach loop by using:

my @H99tapes = ( ## .. ##);

print $q->scrolling_list(-name=>'imported_tapes',
-values=>[@H99tapes],
-default=>[$H99tapes[0]],
-multiple=>1,
-override=>1,
-size=>10),"<br>";
print $q->submit(-name=>'action',-value=>'Delete'),
$q->submit(-name=>'action',-value=>'Add');


##--## Recover the new tape(s) from the Scroll List parameter
'imported_tapes' ##--##

my @imports = param('imported_tapes');


My original problem was I wanted to use splice to dynamically re-populate
an array or hash based off of what the user selected through this scroll
list, but could not get this to work.

Here s the pseucdode I am using:

as H numbers are submitted by user from a scroll list
remove selected elements from @H99tapes
repopulate new list into @UserH99tapes
print @UserH99tapes

OR

as H numbers are submitted by user from a scroll list
remove selected elements from @H99tapes
repush remaining elements into @H99tapes
print @H99tapes

Any ideas to help me with this problem?
basically dynamically splicing an array or hash. Note each element
contains unique data, H[0-1000] strings for example.


##--## BEGIN IMPORT
##--##
##--## AS H NUMBERS ARE SELECTED, REMOVE
SUBMITTED ELEMENTS FROM USER ARRAY ##--##
##--## REPOPULATE LIST INTO NEW ARRAY,
PRINT NEW ARRAY. ##--##

my @tape_imports_to_del =
$q->param(htapes99); ##--## SELECTED BY USER ##--#
my $tape_count = scalar
@tape_imports_to_del; ##--## COUNT ##--##

foreach (@tape_imports)
{
splice
(@H99tapes,0,$tape_count,@H99tapes)
}


thank you,

derek

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com