Perl System Calls

Discussion in 'Perl Misc' started by tweetiebirds@gmail.com, May 13, 2005.

  1. Guest

    I know 2. saves the output from the system call, but if I don't care
    about the output which is a better solution? :


    1. system ("tar -xvf file.tar");


    or



    2. $untar = `tar -xvf file.tar`;



    (or
    3. I guess, use a tar module from CPAN )

    T.
     
    , May 13, 2005
    #1
    1. Advertising

  2. wrote:
    > I know 2. saves the output from the system call, but if I don't care
    > about the output which is a better solution? :
    >
    >
    > 1. system ("tar -xvf file.tar");


    Why are you asking tar to produce output you don't care about?

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, May 13, 2005
    #2
    1. Advertising

  3. Guest

    I wouldn't, I would use system but was wondering which was more
    'efficient' from a speed standpoint. thanks
     
    , May 13, 2005
    #3
  4. writes:
    > I wouldn't, I would use system but was wondering which was more
    > 'efficient' from a speed standpoint. thanks


    You wouldn't what?

    You didn't mention speed in the original question, only "better".
    The answer here is that it doesn't matter - what 'tar' does will
    greatly outweigh the effort of calling it.
     
    Arndt Jonasson, May 13, 2005
    #4
  5. Guest

    save the output in a variable.
    when i execute system the normal tar output will go to standard out in
    my shell which is all i want. thanks
     
    , May 13, 2005
    #5
  6. wrote:
    > save the output in a variable.


    What output? What variable?

    Please quote some context in your messages. Have you read the posting
    guidelines that appear here frequently?

    > when i execute system the normal tar output will go to standard out in
    > my shell which is all i want.


    Okay, system() does what you want. What's the question then?

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, May 13, 2005
    #6
  7. Guest

    Ok I'll read up on it. (guidelines)

    System does what i wat - I just wondered if it's the wise thing to use
    in this example, to do what I want. thanks
     
    , May 13, 2005
    #7
  8. Big and Blue Guest

    wrote:
    > I know 2. saves the output from the system call, but if I don't care
    > about the output which is a better solution? :
    >
    > 1. system ("tar -xvf file.tar");
    >
    > or
    >
    > 2. $untar = `tar -xvf file.tar`;


    Neither really.

    system qw( tar -xvf file.tar );

    will ensure you remember it is possible to avoid involving a shell in cases
    where you don't want to (although in this case it won't make much runtime
    difference).



    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
     
    Big and Blue, May 13, 2005
    #8
  9. wrote in news:1116006919.872951.102920
    @g47g2000cwa.googlegroups.com:

    > Ok I'll read up on it. (guidelines)


    One can only hope.

    Sinan
     
    A. Sinan Unur, May 13, 2005
    #9
  10. Joe Smith Guest

    wrote:
    > I wouldn't, I would use system but was wondering which was more
    > 'efficient' from a speed standpoint.


    It's *not* as speed issue.

    $dummy = `program_that_creates_many_megabytes_of_output`;
    system "program_that_creates_many_megabytes_of_output >/dev/null";

    One uses up many megabytes of memory needlessly, the other doesn't.
    -Joe
     
    Joe Smith, May 15, 2005
    #10
  11. Joe Smith Guest

    wrote:
    > I wouldn't, I would use system but was wondering which was more
    > 'efficient' from a speed standpoint. thanks


    What sort of person is it that creates a follow-up posting with
    absolutely no context?

    > Organization: http://groups.google.com
    > Message-ID: <>
    > X-Trace: posting.google.com ...
    > X-Complaints-To:


    Oh, it's one of those damnable Google postings.

    I have news for you tweetiebirds: Most of the people reading these
    USENET newsgroups are *not* using Google. When I read your posting,
    all I could see was the two lines quoted above, the ones starting with
    "I wouldn't". That makes no sense because you neglected to include
    "Why are you asking tar to produce output you don't care about?"
    in your post.

    -Joe
     
    Joe Smith, May 15, 2005
    #11
    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. Honne Gowda A
    Replies:
    2
    Views:
    893
    Karl Heinz Buchegger
    Oct 31, 2003
  2. andy6
    Replies:
    2
    Views:
    772
    andy6 via DotNetMonster.com
    Jun 9, 2006
  3. markus
    Replies:
    22
    Views:
    674
    Dances With Crows
    Sep 22, 2004
  4. Richard Tobin
    Replies:
    24
    Views:
    813
  5. Bob
    Replies:
    5
    Views:
    272
Loading...

Share This Page