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

Sub return value

Expand Messages
  • Eduardo Adrian Perez
    Hi all. I have just joined the group, my name is Eduardo Perez from Buenos Aires, Argentina. Have a good day everybody ! Now, I have a question. I am beginning
    Message 1 of 3 , Mar 2, 2006
    View Source
    • 0 Attachment
      Hi all. I have just joined the group, my name is Eduardo Perez
      from Buenos Aires, Argentina.

      Have a good day everybody !

      Now, I have a question.

      I am beginning with application maintenance, and just beginning with perl .
      I was reading docs but I don't find answer.

      It is about calling a sub and take a return value from that.

      This the code:

      .....
      ( $u_id, $u_pass ) = get_cookie();
      .....

      sub get_cookie {
      $REGION = get_cfg_var('REGION');
      $SYSTEM = get_cfg_var('SYSTEM');
      $COOKIE_EXP = get_cfg_var('COOKIETIME');
      $wbs_user_info = "C_WBS_$REGION";
      %u_info = cookie($wbs_user_info);
      ($c_id, $c_pass) = each(%u_info);

      $c_key = "WBS_$SYSTEM_$REGION";

      my $d_des = new Crypt::TripleDES;
      my $u_pwd = $d_des->decrypt3 ( $c_pass, $c_key );
      #$u_pwd = $c_pass;
      $u_pwd = trimwsp($u_pwd);
      @ret_arry = ( $c_id, $u_pwd );
      }


      I can see that get_cookey sub returns more than a value.

      But, how is this implemented in perl?


      Thanks in advance.

      Eduardo
    • merlyn@stonehenge.com
      ... Eduardo But, how is this implemented in perl? What do you mean, implemented ? How does the C code that makes up /usr/bin/perl do it? That s a *long*
      Message 2 of 3 , Mar 2, 2006
      View Source
      • 0 Attachment
        >>>>> "Eduardo" == Eduardo Adrian Perez <eaplistas@...> writes:

        Eduardo> But, how is this implemented in perl?

        What do you mean, "implemented"? How does the C code that makes up
        /usr/bin/perl do it? That's a *long* answer. :)

        Or how do you return values from subroutines? Read "perldoc perlsub"
        and if that's still not clear, ask a more specific question.

        --
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
        <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
        Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
        See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
      • Eduardo Adrian Perez
        Hi Randal, thanks for your answer. Sorry, but english language is not my strength. reading perldoc perlsub give me the answer: ..... The return value of a
        Message 3 of 3 , Mar 2, 2006
        View Source
        • 0 Attachment
          Hi Randal, thanks for your answer.

          Sorry, but english language is not my strength.

          reading perldoc perlsub give me the answer:

          .....
          The return value of a subroutine is the value of the last expression
          evaluated by that sub, or the empty list in the case of an empty sub.
          More explicitly, a "return" statement may be used to exit the subrou-
          tine, optionally specifying the returned value, which will be
          evaluated
          in the appropriate context (list, scalar, or void) depending on the
          .....

          this sub returns an array (this is the last expression evaluated).

          Regards


          Randal L. Schwartz wrote:
          >>>>>> "Eduardo" == Eduardo Adrian Perez <eaplistas@...> writes:
          >>>>>>
          >
          > Eduardo> But, how is this implemented in perl?
          >
          > What do you mean, "implemented"? How does the C code that makes up
          > /usr/bin/perl do it? That's a *long* answer. :)
          >
          > Or how do you return values from subroutines? Read "perldoc perlsub"
          > and if that's still not clear, ask a more specific question.
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.