[問題] 請問CGI檔的@array怎麼傳到.pl執行檔

看板Perl作者 (李崩子)時間13年前 (2010/10/25 23:08), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串1/1
是這樣的 以下是我其中CGI的一小段原始碼 while(<FH2>){ @class=split/\t/; chomp; if($name eq $class[2]){ push @test7,($class[3],$class[4],); } } `\./length.pl @test7`; print "Content-type: text/html\n\n"; .. ..(後略) ========================================================= 這是我的pl檔 #!/usr/bin/perl -w my@test7=shift; #這是接收CGI的 #push @test7,(400,410,533,599,1278,1332);##這我先#掉 for my $index(0..$#test7/2) { print $index,"=",$test7[2*$index],",",$test7[2*$index+1],"\n"; } ========================= 我把CGI的的一個陣列值丟到length.pl去執行 (就是有2個檔,一個是CGI:接收網頁的值去運算會得到一個陣列, 再把陣列丟到pl檔去執行) 大概解釋, 假設我在網頁輸入一個名字,例如王小美(這是假設) 他會去@class的第2行去找全部是王小美的字串,找到後 把所有第2行是王小美的第3行跟第4行丟到@test7裡面 舉個例我找到3組好了 我print出來是:400,410,533,599,1278,1332, 可是丟到.pl檔,只能丟一個,是不是因為我pl檔接收那邊,設成my@test7=shift; 因為之前我都是遇到單一元素,但是遇到多個(上面的6個數字)就死在那了 我改成my@test7=unshift;不能執行 但是單純執行pl檔是可以(把紅色字的#拿掉,然後把my@test7=shift; #掉) 結果印出來是: 0=400,410 1=533,599 2=1278,1332 代表我的pl檔沒問題才對,原因應該是卡在CGI丟到pl檔那邊 去google查過了,可能是我關鍵字找不好,花了1個周末= = 感謝大家幫忙解惑。謝謝。 -- -- ▂▂ ▂▂▂ ▂▄▅▅▄▆█ _█◣ ◢ (●) ◣/\\ 丫 │◥  ̄◤ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.215.116 ※ 編輯: sqrt1089 來自: 140.116.215.116 (10/25 23:10)

10/26 03:45, , 1F
my @test7 = @ARGV; #try it
10/26 03:45, 1F

10/26 14:57, , 2F
感恩!!
10/26 14:57, 2F
文章代碼(AID): #1CnPrtks (Perl)