看板 Perl 關於我們 聯絡資訊
我有一個原始的@a,長度500 我想要產生5個不同的陣列,而其內容值為@a內容1~50 我的寫法... $count=0; while ($count < 10){ @b=@a[$count-9...$count]; @c=@a[$count-8...$count+1]; @d=@a[$count-7...$count+2]; @e=@a[$count-6...$count+3]; @f=@a[$count-5...$count+4]; $count+=1; } 也就是說我想要新產生的陣列的內容是依序遞增的。 ex: @a="aethcdthhyydxyhcxfhfsghsfhgfjlgkfjgiffs..." @b="aethcdthhy" @c="ethcdthhyy" @d="thcdthhyyd" @e="hcdthhyydx" @f="cdthhyydxy" 請問在while裡面(產生:@b~@f)是否可以寫成一個迴圈的型態呢? 感謝<_ _> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.146.203.213 ※ 編輯: bxorw 來自: 122.146.203.213 (04/24 20:03)
Keelungman:@a="aethc.." is a string scalar, not array!!! 04/24 21:58
Keelungman:all of your "aeth..." data are only for $a[0] 04/24 22:00
LiloHuang:用 array reference 儲存在變數裡面 變數用動態命名 04/24 22:31