Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Passing Arrays Between Subs

Expand Messages
  • merlyn@stonehenge.com
    ... Jeff His name is Randal. (Why does everyone add an l to the end of his Jeff name?) Sadly, it s the more common spelling. I blame my parents. :) Mom
    Message 1 of 7 , May 4, 2009
    • 0 Attachment
      >>>>> "Jeff" == Jeff Pinyan <japhy.734@...> writes:

      Jeff> His name is Randal. (Why does everyone add an 'l' to the end of his
      Jeff> name?)

      Sadly, it's the more common spelling. I blame my parents. :)

      Mom explains the single L as "but that's how it was spelled in the book of
      baby names we consulted". Therefore, I argue, it was a typo. :)

      --
      Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
      <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
      Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
      See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
    • yehezkielbs
      You need to change sub_a to : sub sub_a { my $x = Larry ; my $y = Moe ; my $z = Curly ; return ($x, $y, $z); } and sub_b to : sub sub_b { my @values = @_;
      Message 2 of 7 , May 4, 2009
      • 0 Attachment
        You need to change sub_a to :

        sub sub_a {
        my $x = "Larry";
        my $y = "Moe";
        my $z = "Curly";

        return ($x, $y, $z);
        }

        and sub_b to :

        sub sub_b {
        my @values = @_;

        ...
        }


        Regards,
        Yehezkiel

        --- In perl-beginner@yahoogroups.com, essential quint <quintessential1@...> wrote:
        >
        >
        > Hello Everyone:
        >
        > Can someone explain/correct what I have done wrong here? I want it to output all values (Larry, Moe and Curly), but it's only giving me the last one (Curly).
        >
        > #!/usr/bin/perl -Tw
        >
        > use strict;
        > use CGI;
        > use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
        >
        > ### SETUP MAIN DRIVER ###
        >
        > sub_a ();
        > my @values = sub_a ();
        > sub_b (@values);
        >
        > ### RUN SUBS ###
        >
        > sub sub_a {
        > my $x = "Larry";
        > my $y = "Moe";
        > my $z = "Curly";
        > }
        >
        >
        > sub sub_b {
        >
        > my @values = shift;
        > my $i;
        >
        > print "Content-Type: text/html\n\n";
        >
        > foreach $i (@values) {
        > print "$i\n\n";
        > }
        > }
        >
        > Thanks,
        >
        > quint
        >
        > _________________________________________________________________
        > Insert movie times and more without leaving HotmailĀ®.
        > http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd1_052009
        >
        > [Non-text portions of this message have been removed]
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.