Perl System Calls

T

tweetiebirds

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.
 
S

Sherm Pendley

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--
 
T

tweetiebirds

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

Arndt Jonasson

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.
 
T

tweetiebirds

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
 
S

Sherm Pendley

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--
 
T

tweetiebirds

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
 
B

Big and Blue

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).
 
J

Joe Smith

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
 
J

Joe Smith

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: <[email protected]>
X-Trace: posting.google.com ...
X-Complaints-To: (e-mail address removed)

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top