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

HI MONKS

i am writing a wml embeded in perl

my ($data,$rows) = &get_sms($dbh,$userid); my $k; foreach $k(@$data){ print<<_WML_; <?xml version='1.0'?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card title="smsbook" id="smsbook"> <p> @$k </p> </card> </wml> _WML_

can you tell how can i print multiple search rows which i will get after i will call get_sms function in the code which will return a arrayref. the code which i have written will just print only one search row not many.

Replies are listed 'Best First'.
Re: WML in perl
by Chady (Priest) on Feb 21, 2004 at 08:17 UTC

    It depends on what lies inside the $k elements of @$data, but either way, you may want to move your foreach loop to something roughly like:

    print<<_WML_; <?xml version='1.0'?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <card title="smsbook" id="smsbook"> _WML_ my ($data,$rows) = &get_sms($dbh,$userid); my $k; foreach $k (@$data){ print "<p>", @$k, "</p>\n"; } print " </card> </wml> ";

    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

    Chady | http://chady.net/
Re: WML in perl
by Anonymous Monk on Feb 21, 2004 at 08:13 UTC
    Your code does not compile the way you have it (missing a }). If it's printing only one whatever, then that's all $data contains.
    my $data = [ 1 .. 10 ]; foreach $k( @$data ){ print <<_WML_ Blah blah $k _WML_ } __END__ Blah blah 1 Blah blah 2 Blah blah 3 Blah blah 4 Blah blah 5 Blah blah 6 Blah blah 7 Blah blah 8 Blah blah 9 Blah blah 10