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

RE: [PBML] Pass array to a subroutine

Expand Messages
  • lakshmi.sailaja@wipro.com
    Hello, As per your suggestion, I am to generate the correct output if used in ... my @arr = (1, 2, 3); xxx(@arr, aaa , bbb ); sub xxx { my ($str1, $str2,
    Message 1 of 11 , Jan 5, 2005
    • 0 Attachment
      Hello,

      As per your suggestion, I am to generate the correct output if used in
      the following way:

      ---------------------------------------
      my @arr = (1, 2, 3);

      xxx(@arr, "aaa", "bbb");

      sub xxx {
      my ($str1, $str2, @arr) = @_;

      print "str1 is $str1\n";
      print "str2 is $str2\n";
      print "array is @arr\n";
      }
      ---------------------------------------

      Output: (CORRECT)
      -------
      str1 is aaa
      str2 is bbb
      array is 1 2 3

      But, when I try calling the following way i.e, I am passing array as
      first parameter and then strings as the second and third parameter, the
      o/p is not the correct value:

      ---------------------------------------
      my @arr = (1, 2, 3);

      xxx(@arr, "aaa", "bbb");

      sub xxx {
      my (@arr, $str1, $str2) = @_;

      print "str1 is $str1\n";
      print "str2 is $str2\n";
      print "array is @arr\n";
      }
      ---------------------------------------

      Output: (INCORRECT)
      -------
      str1 is
      str2 is
      array is 1 2 3 aaa bbb

      Can you please tell me why does the above method doesn't generate the
      correct output? Please do provide a solution, if exists.

      Regards,
      Lakshmi

      -----Original Message-----
      From: Raghu Ram Murthy [mailto:me_rams@...]
      Sent: Wednesday, January 05, 2005 6:03 PM
      To: perl-beginner@yahoogroups.com
      Subject: RE: [PBML] Pass array to a subroutine


      sub xxx {
      my ($str1, $str2, @arr) = @_;
      }
      my @arr = (1, 2, 3);
      xxx("aaa", "bbb", @arr);


      --- lakshmi.sailaja@... wrote:

      > Hello Raghuram,
      >
      > Can you please illustrate the below example by
      > passing 2 strings along
      > with the array to the subroutine?
      >
      > Regards,
      > Lakshmi
      >
      > -----Original Message-----
      > From: Raghu Ram Murthy [mailto:me_rams@...]
      > Sent: Wednesday, January 05, 2005 5:28 PM
      > To: perl-beginner@yahoogroups.com
      > Subject: Re: [PBML] Pass array to a subroutine
      >
      >
      > You can pass an array to a sub routine in two ways.
      > One is passing entire array and another is passing
      > the
      > array reference.
      >
      > Passing array:
      >
      > sub give_me_array {
      > my @values = @_;
      > print "@values\n";
      > }
      >
      > my @arr = ( 1, 2, 3 );
      > give_me_array(@arr);
      >
      > Passing reference:
      >
      > sub give_me_array {
      > my $values = shift;
      > print "@$values\n";
      > }
      >
      > my @arr = ( 1, 2, 3 );
      > give_me_array(\@arr);
      >
      > Thanks & Regards
      > -Raghuram
      >
      > --- lakshmi.sailaja@... wrote:
      >
      > > Hello,
      > >
      > > Can anyone please tell me the way I can pass an
      > > array to a subroutine?
      > >
      > > It would be great if any code snippet is also
      > > provided?
      > >
      > > Regards,
      > > Lakshmi
      > >
      > >
      >
      >
      > =====
      > ----------------------------------------------
      > P.Raghu Ram Murthy, M-tech (Computer Science),
      > Member, Information Technology,
      > D E Shaw India Software Private Limited,
      > 6-3-879 & 879/B
      > Begumpet, Hyderabad 500 016
      > Andhra Pradesh
      > India
      >
      > Mobile: (+91) 98852 17928
      > ----------------------------------------------
      >
      > If it doesn't work, you're not hitting it with a big
      > enough hammer
      >
      >
      >
      > __________________________________
      > Do you Yahoo!?
      > Take Yahoo! Mail with you! Get it on your mobile
      > phone.
      > http://mobile.yahoo.com/maildemo
      >
      >
      > Unsubscribing info is here:
      > http://help.yahoo.com/help/us/groups/groups-32.html
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >
      >


      =====
      ----------------------------------------------
      P.Raghu Ram Murthy, M-tech (Computer Science),
      Member, Information Technology,
      D E Shaw India Software Private Limited,
      6-3-879 & 879/B
      Begumpet, Hyderabad 500 016
      Andhra Pradesh
      India

      Mobile: (+91) 98852 17928
      ----------------------------------------------

      If it doesn't work, you're not hitting it with a big enough hammer



      __________________________________
      Do you Yahoo!?
      The all-new My Yahoo! - Get yours free!
      http://my.yahoo.com




      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html
      Yahoo! Groups Links
    • Brad Lhotsky
      Perl list flattens your args in your sub routine call into one list which is accesible by @_ in the subroutine. The contents of that array are 1 2 3 aaa
      Message 2 of 11 , Jan 5, 2005
      • 0 Attachment
        Perl list flattens your args in your sub routine call into one list
        which is accesible by "@_" in the subroutine. The contents of that
        array are "1 2 3 aaa bbb". When you make the assignment:

        my (@list,$scalar) = @_;

        the @list variable consumes the entire list from its position onward,
        in this case, the beginning of the list.

        Recommended reading:

        perldoc perlintro
        perldoc perldata
        perldoc perlsub
        perldoc perldsc

        perldoc -q list

        On Wed, Jan 05, 2005 at 07:26:29PM +0530, lakshmi.sailaja@... wrote:
        >
        > Hello,
        >
        > As per your suggestion, I am to generate the correct output if used in
        > the following way:
        >
        > ---------------------------------------
        > my @arr = (1, 2, 3);
        >
        > xxx(@arr, "aaa", "bbb");
        >
        > sub xxx {
        > my ($str1, $str2, @arr) = @_;
        >
        > print "str1 is $str1\n";
        > print "str2 is $str2\n";
        > print "array is @arr\n";
        > }
        > ---------------------------------------
        >
        > Output: (CORRECT)
        > -------
        > str1 is aaa
        > str2 is bbb
        > array is 1 2 3
        >
        > But, when I try calling the following way i.e, I am passing array as
        > first parameter and then strings as the second and third parameter, the
        > o/p is not the correct value:
        >
        > ---------------------------------------
        > my @arr = (1, 2, 3);
        >
        > xxx(@arr, "aaa", "bbb");
        >
        > sub xxx {
        > my (@arr, $str1, $str2) = @_;
        >
        > print "str1 is $str1\n";
        > print "str2 is $str2\n";
        > print "array is @arr\n";
        > }
        > ---------------------------------------
        >
        > Output: (INCORRECT)
        > -------
        > str1 is
        > str2 is
        > array is 1 2 3 aaa bbb
        >
        > Can you please tell me why does the above method doesn't generate the
        > correct output? Please do provide a solution, if exists.
        >
        > Regards,
        > Lakshmi
        >
        > -----Original Message-----
        > From: Raghu Ram Murthy [mailto:me_rams@...]
        > Sent: Wednesday, January 05, 2005 6:03 PM
        > To: perl-beginner@yahoogroups.com
        > Subject: RE: [PBML] Pass array to a subroutine
        >
        >
        > sub xxx {
        > my ($str1, $str2, @arr) = @_;
        > }
        > my @arr = (1, 2, 3);
        > xxx("aaa", "bbb", @arr);
        >
        >
        > --- lakshmi.sailaja@... wrote:
        >
        > > Hello Raghuram,
        > >
        > > Can you please illustrate the below example by
        > > passing 2 strings along
        > > with the array to the subroutine?
        > >
        > > Regards,
        > > Lakshmi
        > >
        > > -----Original Message-----
        > > From: Raghu Ram Murthy [mailto:me_rams@...]
        > > Sent: Wednesday, January 05, 2005 5:28 PM
        > > To: perl-beginner@yahoogroups.com
        > > Subject: Re: [PBML] Pass array to a subroutine
        > >
        > >
        > > You can pass an array to a sub routine in two ways.
        > > One is passing entire array and another is passing
        > > the
        > > array reference.
        > >
        > > Passing array:
        > >
        > > sub give_me_array {
        > > my @values = @_;
        > > print "@values\n";
        > > }
        > >
        > > my @arr = ( 1, 2, 3 );
        > > give_me_array(@arr);
        > >
        > > Passing reference:
        > >
        > > sub give_me_array {
        > > my $values = shift;
        > > print "@$values\n";
        > > }
        > >
        > > my @arr = ( 1, 2, 3 );
        > > give_me_array(\@arr);
        > >
        > > Thanks & Regards
        > > -Raghuram
        > >
        > > --- lakshmi.sailaja@... wrote:
        > >
        > > > Hello,
        > > >
        > > > Can anyone please tell me the way I can pass an
        > > > array to a subroutine?
        > > >
        > > > It would be great if any code snippet is also
        > > > provided?
        > > >
        > > > Regards,
        > > > Lakshmi
        > > >
        > > >
        > >
        > >
        > > =====
        > > ----------------------------------------------
        > > P.Raghu Ram Murthy, M-tech (Computer Science),
        > > Member, Information Technology,
        > > D E Shaw India Software Private Limited,
        > > 6-3-879 & 879/B
        > > Begumpet, Hyderabad 500 016
        > > Andhra Pradesh
        > > India
        > >
        > > Mobile: (+91) 98852 17928
        > > ----------------------------------------------
        > >
        > > If it doesn't work, you're not hitting it with a big
        > > enough hammer
        > >
        > >
        > >
        > > __________________________________
        > > Do you Yahoo!?
        > > Take Yahoo! Mail with you! Get it on your mobile
        > > phone.
        > > http://mobile.yahoo.com/maildemo
        > >
        > >
        > > Unsubscribing info is here:
        > > http://help.yahoo.com/help/us/groups/groups-32.html
        > > Yahoo! Groups Links
        > >
        > >
        > >
        > >
        > >
        > >
        > >
        > >
        >
        >
        > =====
        > ----------------------------------------------
        > P.Raghu Ram Murthy, M-tech (Computer Science),
        > Member, Information Technology,
        > D E Shaw India Software Private Limited,
        > 6-3-879 & 879/B
        > Begumpet, Hyderabad 500 016
        > Andhra Pradesh
        > India
        >
        > Mobile: (+91) 98852 17928
        > ----------------------------------------------
        >
        > If it doesn't work, you're not hitting it with a big enough hammer
        >
        >
        >
        > __________________________________
        > Do you Yahoo!?
        > The all-new My Yahoo! - Get yours free!
        > http://my.yahoo.com
        >
        >
        >
        >
        > Unsubscribing info is here:
        > http://help.yahoo.com/help/us/groups/groups-32.html
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
        >
      • Raghu Ram Murthy
        Then you must pass array reference, as I ve mentioned in my first mail. No other option. Thanks -Raghuram ... === message truncated === ... P.Raghu Ram Murthy,
        Message 3 of 11 , Jan 5, 2005
        • 0 Attachment
          Then you must pass array reference, as I've mentioned
          in my first mail. No other option.

          Thanks
          -Raghuram

          --- lakshmi.sailaja@... wrote:

          > Hello,
          >
          > As per your suggestion, I am to generate the correct
          > output if used in
          > the following way:
          >
          > ---------------------------------------
          > my @arr = (1, 2, 3);
          >
          > xxx(@arr, "aaa", "bbb");
          >
          > sub xxx {
          > my ($str1, $str2, @arr) = @_;
          >
          > print "str1 is $str1\n";
          > print "str2 is $str2\n";
          > print "array is @arr\n";
          > }
          > ---------------------------------------
          >
          > Output: (CORRECT)
          > -------
          > str1 is aaa
          > str2 is bbb
          > array is 1 2 3
          >
          > But, when I try calling the following way i.e, I am
          > passing array as
          > first parameter and then strings as the second and
          > third parameter, the
          > o/p is not the correct value:
          >
          > ---------------------------------------
          > my @arr = (1, 2, 3);
          >
          > xxx(@arr, "aaa", "bbb");
          >
          > sub xxx {
          > my (@arr, $str1, $str2) = @_;
          >
          > print "str1 is $str1\n";
          > print "str2 is $str2\n";
          > print "array is @arr\n";
          > }
          > ---------------------------------------
          >
          > Output: (INCORRECT)
          > -------
          > str1 is
          > str2 is
          > array is 1 2 3 aaa bbb
          >
          > Can you please tell me why does the above method
          > doesn't generate the
          > correct output? Please do provide a solution, if
          > exists.
          >
          > Regards,
          > Lakshmi
          >
          > -----Original Message-----
          > From: Raghu Ram Murthy [mailto:me_rams@...]
          > Sent: Wednesday, January 05, 2005 6:03 PM
          > To: perl-beginner@yahoogroups.com
          > Subject: RE: [PBML] Pass array to a subroutine
          >
          >
          > sub xxx {
          > my ($str1, $str2, @arr) = @_;
          > }
          > my @arr = (1, 2, 3);
          > xxx("aaa", "bbb", @arr);
          >
          >
          > --- lakshmi.sailaja@... wrote:
          >
          > > Hello Raghuram,
          > >
          > > Can you please illustrate the below example by
          > > passing 2 strings along
          > > with the array to the subroutine?
          > >
          > > Regards,
          > > Lakshmi
          > >
          > > -----Original Message-----
          > > From: Raghu Ram Murthy [mailto:me_rams@...]
          > > Sent: Wednesday, January 05, 2005 5:28 PM
          > > To: perl-beginner@yahoogroups.com
          > > Subject: Re: [PBML] Pass array to a subroutine
          > >
          > >
          > > You can pass an array to a sub routine in two
          > ways.
          > > One is passing entire array and another is passing
          > > the
          > > array reference.
          > >
          > > Passing array:
          > >
          > > sub give_me_array {
          > > my @values = @_;
          > > print "@values\n";
          > > }
          > >
          > > my @arr = ( 1, 2, 3 );
          > > give_me_array(@arr);
          > >
          > > Passing reference:
          > >
          > > sub give_me_array {
          > > my $values = shift;
          > > print "@$values\n";
          > > }
          > >
          > > my @arr = ( 1, 2, 3 );
          > > give_me_array(\@arr);
          > >
          > > Thanks & Regards
          > > -Raghuram
          > >
          > > --- lakshmi.sailaja@... wrote:
          > >
          > > > Hello,
          > > >
          > > > Can anyone please tell me the way I can pass an
          > > > array to a subroutine?
          > > >
          > > > It would be great if any code snippet is also
          > > > provided?
          > > >
          > > > Regards,
          > > > Lakshmi
          > > >
          > > >
          > >
          > >
          > > =====
          > > ----------------------------------------------
          > > P.Raghu Ram Murthy, M-tech (Computer Science),
          > > Member, Information Technology,
          > > D E Shaw India Software Private Limited,
          > > 6-3-879 & 879/B
          > > Begumpet, Hyderabad 500 016
          > > Andhra Pradesh
          > > India
          > >
          > > Mobile: (+91) 98852 17928
          > > ----------------------------------------------
          > >
          > > If it doesn't work, you're not hitting it with a
          > big
          > > enough hammer
          > >
          > >
          > >
          > > __________________________________
          > > Do you Yahoo!?
          > > Take Yahoo! Mail with you! Get it on your mobile
          > > phone.
          > > http://mobile.yahoo.com/maildemo
          > >
          > >
          > > Unsubscribing info is here:
          > >
          > http://help.yahoo.com/help/us/groups/groups-32.html
          > > Yahoo! Groups Links
          > >
          > >
          > >
          > >
          > >
          > >
          > >
          > >
          >
          >
          > =====
          > ----------------------------------------------
          > P.Raghu Ram Murthy, M-tech (Computer Science),
          > Member, Information Technology,
          > D E Shaw India Software Private Limited,
          > 6-3-879 & 879/B
          > Begumpet, Hyderabad 500 016
          > Andhra Pradesh
          > India
          >
          > Mobile: (+91) 98852 17928
          > ----------------------------------------------
          >
          > If it doesn't work, you're not hitting it with a big
          > enough hammer
          >
          >
          >
          > __________________________________
          > Do you Yahoo!?
          > The all-new My Yahoo! - Get yours free!
          > http://my.yahoo.com
          >
          >
          >
          === message truncated ===


          =====
          ----------------------------------------------
          P.Raghu Ram Murthy, M-tech (Computer Science),
          Member, Information Technology,
          D E Shaw India Software Private Limited,
          6-3-879 & 879/B
          Begumpet, Hyderabad 500 016
          Andhra Pradesh
          India

          Mobile: (+91) 98852 17928
          ----------------------------------------------

          If it doesn't work, you're not hitting it with a big enough hammer



          __________________________________
          Do you Yahoo!?
          Meet the all-new My Yahoo! - Try it today!
          http://my.yahoo.com
        • lakshmi.sailaja@wipro.com
          Thanks for the information. Regards, Lakshmi ... From: Brad Lhotsky [mailto:brad@divisionbyzero.net] Sent: Wednesday, January 05, 2005 8:27 PM To:
          Message 4 of 11 , Jan 5, 2005
          • 0 Attachment
            Thanks for the information.

            Regards,
            Lakshmi


            -----Original Message-----
            From: Brad Lhotsky [mailto:brad@...]
            Sent: Wednesday, January 05, 2005 8:27 PM
            To: perl-beginner@yahoogroups.com
            Subject: Re: [PBML] Pass array to a subroutine


            Perl list flattens your args in your sub routine call into one list
            which is accesible by "@_" in the subroutine. The contents of that
            array are "1 2 3 aaa bbb". When you make the assignment:

            my (@list,$scalar) = @_;

            the @list variable consumes the entire list from its position onward,
            in this case, the beginning of the list.

            Recommended reading:

            perldoc perlintro
            perldoc perldata
            perldoc perlsub
            perldoc perldsc

            perldoc -q list

            On Wed, Jan 05, 2005 at 07:26:29PM +0530, lakshmi.sailaja@...
            wrote:
            >
            > Hello,
            >
            > As per your suggestion, I am to generate the correct output if used in
            > the following way:
            >
            > ---------------------------------------
            > my @arr = (1, 2, 3);
            >
            > xxx(@arr, "aaa", "bbb");
            >
            > sub xxx {
            > my ($str1, $str2, @arr) = @_;
            >
            > print "str1 is $str1\n";
            > print "str2 is $str2\n";
            > print "array is @arr\n";
            > }
            > ---------------------------------------
            >
            > Output: (CORRECT)
            > -------
            > str1 is aaa
            > str2 is bbb
            > array is 1 2 3
            >
            > But, when I try calling the following way i.e, I am passing array as
            > first parameter and then strings as the second and third parameter,
            the
            > o/p is not the correct value:
            >
            > ---------------------------------------
            > my @arr = (1, 2, 3);
            >
            > xxx(@arr, "aaa", "bbb");
            >
            > sub xxx {
            > my (@arr, $str1, $str2) = @_;
            >
            > print "str1 is $str1\n";
            > print "str2 is $str2\n";
            > print "array is @arr\n";
            > }
            > ---------------------------------------
            >
            > Output: (INCORRECT)
            > -------
            > str1 is
            > str2 is
            > array is 1 2 3 aaa bbb
            >
            > Can you please tell me why does the above method doesn't generate the
            > correct output? Please do provide a solution, if exists.
            >
            > Regards,
            > Lakshmi
            >
            > -----Original Message-----
            > From: Raghu Ram Murthy [mailto:me_rams@...]
            > Sent: Wednesday, January 05, 2005 6:03 PM
            > To: perl-beginner@yahoogroups.com
            > Subject: RE: [PBML] Pass array to a subroutine
            >
            >
            > sub xxx {
            > my ($str1, $str2, @arr) = @_;
            > }
            > my @arr = (1, 2, 3);
            > xxx("aaa", "bbb", @arr);
            >
            >
            > --- lakshmi.sailaja@... wrote:
            >
            > > Hello Raghuram,
            > >
            > > Can you please illustrate the below example by
            > > passing 2 strings along
            > > with the array to the subroutine?
            > >
            > > Regards,
            > > Lakshmi
            > >
            > > -----Original Message-----
            > > From: Raghu Ram Murthy [mailto:me_rams@...]
            > > Sent: Wednesday, January 05, 2005 5:28 PM
            > > To: perl-beginner@yahoogroups.com
            > > Subject: Re: [PBML] Pass array to a subroutine
            > >
            > >
            > > You can pass an array to a sub routine in two ways.
            > > One is passing entire array and another is passing
            > > the
            > > array reference.
            > >
            > > Passing array:
            > >
            > > sub give_me_array {
            > > my @values = @_;
            > > print "@values\n";
            > > }
            > >
            > > my @arr = ( 1, 2, 3 );
            > > give_me_array(@arr);
            > >
            > > Passing reference:
            > >
            > > sub give_me_array {
            > > my $values = shift;
            > > print "@$values\n";
            > > }
            > >
            > > my @arr = ( 1, 2, 3 );
            > > give_me_array(\@arr);
            > >
            > > Thanks & Regards
            > > -Raghuram
            > >
            > > --- lakshmi.sailaja@... wrote:
            > >
            > > > Hello,
            > > >
            > > > Can anyone please tell me the way I can pass an
            > > > array to a subroutine?
            > > >
            > > > It would be great if any code snippet is also
            > > > provided?
            > > >
            > > > Regards,
            > > > Lakshmi
            > > >
            > > >
            > >
            > >
            > > =====
            > > ----------------------------------------------
            > > P.Raghu Ram Murthy, M-tech (Computer Science),
            > > Member, Information Technology,
            > > D E Shaw India Software Private Limited,
            > > 6-3-879 & 879/B
            > > Begumpet, Hyderabad 500 016
            > > Andhra Pradesh
            > > India
            > >
            > > Mobile: (+91) 98852 17928
            > > ----------------------------------------------
            > >
            > > If it doesn't work, you're not hitting it with a big
            > > enough hammer
            > >
            > >
            > >
            > > __________________________________
            > > Do you Yahoo!?
            > > Take Yahoo! Mail with you! Get it on your mobile
            > > phone.
            > > http://mobile.yahoo.com/maildemo
            > >
            > >
            > > Unsubscribing info is here:
            > > http://help.yahoo.com/help/us/groups/groups-32.html
            > > Yahoo! Groups Links
            > >
            > >
            > >
            > >
            > >
            > >
            > >
            > >
            >
            >
            > =====
            > ----------------------------------------------
            > P.Raghu Ram Murthy, M-tech (Computer Science),
            > Member, Information Technology,
            > D E Shaw India Software Private Limited,
            > 6-3-879 & 879/B
            > Begumpet, Hyderabad 500 016
            > Andhra Pradesh
            > India
            >
            > Mobile: (+91) 98852 17928
            > ----------------------------------------------
            >
            > If it doesn't work, you're not hitting it with a big enough hammer
            >
            >
            >
            > __________________________________
            > Do you Yahoo!?
            > The all-new My Yahoo! - Get yours free!
            > http://my.yahoo.com
            >
            >
            >
            >
            > Unsubscribing info is here:
            > http://help.yahoo.com/help/us/groups/groups-32.html
            > Yahoo! Groups Links
            >
            >
            >
            >
            >
            >
            >
            >
            >
            > Unsubscribing info is here:
            http://help.yahoo.com/help/us/groups/groups-32.html
            > Yahoo! Groups Links
            >
            >
            >
            >
            >
            >
            >


            Unsubscribing info is here:
            http://help.yahoo.com/help/us/groups/groups-32.html
            Yahoo! Groups Links
          • lakshmi.sailaja@wipro.com
            Ok. Thank you Raghuram. Regards, Lakshmi ... From: Raghu Ram Murthy [mailto:me_rams@yahoo.com] Sent: Wednesday, January 05, 2005 8:54 PM To:
            Message 5 of 11 , Jan 5, 2005
            • 0 Attachment
              Ok. Thank you Raghuram.

              Regards,
              Lakshmi

              -----Original Message-----
              From: Raghu Ram Murthy [mailto:me_rams@...]
              Sent: Wednesday, January 05, 2005 8:54 PM
              To: perl-beginner@yahoogroups.com
              Subject: RE: [PBML] Pass array to a subroutine


              Then you must pass array reference, as I've mentioned
              in my first mail. No other option.

              Thanks
              -Raghuram

              --- lakshmi.sailaja@... wrote:

              > Hello,
              >
              > As per your suggestion, I am to generate the correct
              > output if used in
              > the following way:
              >
              > ---------------------------------------
              > my @arr = (1, 2, 3);
              >
              > xxx(@arr, "aaa", "bbb");
              >
              > sub xxx {
              > my ($str1, $str2, @arr) = @_;
              >
              > print "str1 is $str1\n";
              > print "str2 is $str2\n";
              > print "array is @arr\n";
              > }
              > ---------------------------------------
              >
              > Output: (CORRECT)
              > -------
              > str1 is aaa
              > str2 is bbb
              > array is 1 2 3
              >
              > But, when I try calling the following way i.e, I am
              > passing array as
              > first parameter and then strings as the second and
              > third parameter, the
              > o/p is not the correct value:
              >
              > ---------------------------------------
              > my @arr = (1, 2, 3);
              >
              > xxx(@arr, "aaa", "bbb");
              >
              > sub xxx {
              > my (@arr, $str1, $str2) = @_;
              >
              > print "str1 is $str1\n";
              > print "str2 is $str2\n";
              > print "array is @arr\n";
              > }
              > ---------------------------------------
              >
              > Output: (INCORRECT)
              > -------
              > str1 is
              > str2 is
              > array is 1 2 3 aaa bbb
              >
              > Can you please tell me why does the above method
              > doesn't generate the
              > correct output? Please do provide a solution, if
              > exists.
              >
              > Regards,
              > Lakshmi
              >
              > -----Original Message-----
              > From: Raghu Ram Murthy [mailto:me_rams@...]
              > Sent: Wednesday, January 05, 2005 6:03 PM
              > To: perl-beginner@yahoogroups.com
              > Subject: RE: [PBML] Pass array to a subroutine
              >
              >
              > sub xxx {
              > my ($str1, $str2, @arr) = @_;
              > }
              > my @arr = (1, 2, 3);
              > xxx("aaa", "bbb", @arr);
              >
              >
              > --- lakshmi.sailaja@... wrote:
              >
              > > Hello Raghuram,
              > >
              > > Can you please illustrate the below example by
              > > passing 2 strings along
              > > with the array to the subroutine?
              > >
              > > Regards,
              > > Lakshmi
              > >
              > > -----Original Message-----
              > > From: Raghu Ram Murthy [mailto:me_rams@...]
              > > Sent: Wednesday, January 05, 2005 5:28 PM
              > > To: perl-beginner@yahoogroups.com
              > > Subject: Re: [PBML] Pass array to a subroutine
              > >
              > >
              > > You can pass an array to a sub routine in two
              > ways.
              > > One is passing entire array and another is passing
              > > the
              > > array reference.
              > >
              > > Passing array:
              > >
              > > sub give_me_array {
              > > my @values = @_;
              > > print "@values\n";
              > > }
              > >
              > > my @arr = ( 1, 2, 3 );
              > > give_me_array(@arr);
              > >
              > > Passing reference:
              > >
              > > sub give_me_array {
              > > my $values = shift;
              > > print "@$values\n";
              > > }
              > >
              > > my @arr = ( 1, 2, 3 );
              > > give_me_array(\@arr);
              > >
              > > Thanks & Regards
              > > -Raghuram
              > >
              > > --- lakshmi.sailaja@... wrote:
              > >
              > > > Hello,
              > > >
              > > > Can anyone please tell me the way I can pass an
              > > > array to a subroutine?
              > > >
              > > > It would be great if any code snippet is also
              > > > provided?
              > > >
              > > > Regards,
              > > > Lakshmi
              > > >
              > > >
              > >
              > >
              > > =====
              > > ----------------------------------------------
              > > P.Raghu Ram Murthy, M-tech (Computer Science),
              > > Member, Information Technology,
              > > D E Shaw India Software Private Limited,
              > > 6-3-879 & 879/B
              > > Begumpet, Hyderabad 500 016
              > > Andhra Pradesh
              > > India
              > >
              > > Mobile: (+91) 98852 17928
              > > ----------------------------------------------
              > >
              > > If it doesn't work, you're not hitting it with a
              > big
              > > enough hammer
              > >
              > >
              > >
              > > __________________________________
              > > Do you Yahoo!?
              > > Take Yahoo! Mail with you! Get it on your mobile
              > > phone.
              > > http://mobile.yahoo.com/maildemo
              > >
              > >
              > > Unsubscribing info is here:
              > >
              > http://help.yahoo.com/help/us/groups/groups-32.html
              > > Yahoo! Groups Links
              > >
              > >
              > >
              > >
              > >
              > >
              > >
              > >
              >
              >
              > =====
              > ----------------------------------------------
              > P.Raghu Ram Murthy, M-tech (Computer Science),
              > Member, Information Technology,
              > D E Shaw India Software Private Limited,
              > 6-3-879 & 879/B
              > Begumpet, Hyderabad 500 016
              > Andhra Pradesh
              > India
              >
              > Mobile: (+91) 98852 17928
              > ----------------------------------------------
              >
              > If it doesn't work, you're not hitting it with a big
              > enough hammer
              >
              >
              >
              > __________________________________
              > Do you Yahoo!?
              > The all-new My Yahoo! - Get yours free!
              > http://my.yahoo.com
              >
              >
              >
              === message truncated ===


              =====
              ----------------------------------------------
              P.Raghu Ram Murthy, M-tech (Computer Science),
              Member, Information Technology,
              D E Shaw India Software Private Limited,
              6-3-879 & 879/B
              Begumpet, Hyderabad 500 016
              Andhra Pradesh
              India

              Mobile: (+91) 98852 17928
              ----------------------------------------------

              If it doesn't work, you're not hitting it with a big enough hammer



              __________________________________
              Do you Yahoo!?
              Meet the all-new My Yahoo! - Try it today!
              http://my.yahoo.com




              Unsubscribing info is here:
              http://help.yahoo.com/help/us/groups/groups-32.html
              Yahoo! Groups Links
            Your message has been successfully submitted and would be delivered to recipients shortly.