Re: using a library

Discussion in 'Perl Misc' started by Rainer Weikusat, Feb 28, 2014.

  1. Marek Novotny <> writes:
    > Another weird question. I am going over how to use a Perl script in which
    > I send the process to a library to process and then the library returns
    > the answer:


    [...]

    > My question is this. In the above example I take an array and convert it
    > to a string where it is passed to the library where the string is
    > converted back to an array. Then I process my answer, which is converted
    > to a string and returned back to the Perl script.
    >
    > Can I simply pass an array without conversion to a string??


    For the examples you gave, you could pass a list of arguments and return
    a list of values eg

    -----
    sub print_list
    {
    print(join("\n", @_), "\n");
    }

    sub getdivby2
    {
    return map { $_ / 2 } @_;
    }

    my @a = (1,2,3,4,5);

    print_list(getdivby2(@a));
    ------
     
    Rainer Weikusat, Feb 28, 2014
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mythran
    Replies:
    0
    Views:
    2,494
    Mythran
    Aug 24, 2004
  2. Alan Ferrandiz [MCT]
    Replies:
    0
    Views:
    471
    Alan Ferrandiz [MCT]
    Sep 11, 2004
  3. Sweep

    Library in library...

    Sweep, Dec 8, 2003, in forum: C++
    Replies:
    1
    Views:
    416
    Jack Klein
    Dec 9, 2003
  4. Replies:
    6
    Views:
    887
    red floyd
    May 10, 2005
  5. David Soukal

    library using library?

    David Soukal, May 14, 2004, in forum: C Programming
    Replies:
    10
    Views:
    646
    Brian Gough
    May 17, 2004
Loading...

Share This Page