A Diumenge 03 Setembre 2006 03:09, chen li va escriure: > Dear all, > > I paste some data into textarea in a CGI script and > use param('data')to retrieve the data. I want to pass > the data into an array but what I find is that I only > one dimensional array. Can someone here give me a > hand? > > Thanks, > > Li > > data pasted into textarea: > > 1 1 1 > 2 2 2 > 3 3 3 > > (each column separated by tab and each row ended with > \n) > > after passed into script and processed the expected > result is > my @data=( > [1,1,1], > [2,2,2], > [3,3,3], > ); > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com
Sure, chomp the elements, then you put a delimiter before and after each entry ans use split function to separet those elements. Finally, assign them into an array so each element be one of your CGI data elements. The sintax of split operator is: @fields = split /separator/, $string (Ref: "Learning Perl, 4th. edition, Ed. O'Reilly). I hope this helps- -- Xavier Mas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>