FAQ:
$ perldoc -q "with system"
Found in /usr/local/lib/perl5/5.8.0/pod/perlfaq8.pod
Why can't I get the output of a command with system()?
--
Steve
Just do:
my $output = `ifconfig`;
Then parse $output.
Cheers,
Rob
Why don't you just read the man page for the functions you are using?
perldoc -f system
and the answer to your question is right there in the third paragraph
jue
> system("ifconfig");
> there any way to assign the content of STDOUT to a variable
perldoc -f system
*plonk*
--
Tad McClellan SGML consulting
ta...@augustmail.com Perl programming
Fort Worth, Texas
> Stephan Bour <sb...@niaid.nih.gov> wrote:
>
>> system("ifconfig");
>
>> there any way to assign the content of STDOUT to a variable
>
>
> perldoc -f system
>
>
> *plonk*
>
Thanks to those who actually provided help. I realize that most of the
newbie questions I (and others) ask can be solved by reading a FAQ or help
file somewhere. What you pros have to understand is that beginners don't
always know where and how to look for those simple answers. I never post a
question before doing my very best to answer it myself with the resources I
have. Please forgive me if that sometimes is not good enough.
Cheers,
Stephan.
You're welcome.
( the help I offered was: you should read the docs for the functions
that you use, else you will not know what to expect when you
call them.
)
> I realize that most of the
> newbie questions I (and others) ask can be solved by reading a FAQ or help
> file somewhere. What you pros have to understand is that beginners don't
> always know where and how to look for those simple answers.
I already do understand that.
I don't killfile for asking a FAQ (and that isn't what you did).
I killfile people that sign contracts without reading them,
which _is_ what you did.
Now I know that in the real world folks don't read the docs for
the functions they invoke, but at the *very first* sign of
trouble they should know to go fix that.
Those that don't will be a time-sink that draws time away from
more deserving posters.
> I never post a
> question before doing my very best to answer it myself with the resources I
> have. Please forgive me if that sometimes is not good enough.
Are you saying that you did not know how to look up Perl functions?
I do consider telling me about perldoc help, so thanks. I didn't know about
that resource and I'm glad it was pointed out to me. In my struggle to learn
my first programming language I mostly rely on books but sometimes even the
simplest explanations in those beginner books are unclear to me because I
have no programming experience. I am a scientist making an exciting but
sometimes painful transition to bioinformatics and I'm pretty isolated. The
fact is, everyone struggles with the post or don't post question: should I
ask a question to the list if I know I could possibly find the answer myself
with two hours of intense guess work while it would take a knowledgeable
person 5 minutes to point me in the right direction? You tell me.
Cheers,
Stephan.
>> Are you saying that you did not know how to look up Perl functions?
>>
>
> I do consider telling me about perldoc help, so thanks.
You're welcome. If you didn't know that, then there are likely to
be other helpful tidbits in the Posting Guidelines:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
> I didn't know about
> that resource and I'm glad it was pointed out to me. In my struggle to learn
> my first programming language I mostly rely on books
Books are a third level resource.
First is the documentation that came with the software you are using.
Second is a Google groups search.
> but sometimes even the
> simplest explanations in those beginner books are unclear to me because I
> have no programming experience.
The usual Perl tutorial book recommendation for non-programmers is:
"Elements of Programming with Perl" by Andrew Johnson
Is that one of the books you have?
> fact is, everyone struggles with the post or don't post question: should I
> ask a question to the list if I know I could possibly find the answer myself
> with two hours
You are not expected to spend 2 hours before posting, more like 10 minutes.
> of intense guess work
I think the problem we're having here is that not reading the docs
for a function that you use is so fundamental that a programmer
cannot envision someone that does not know that, so it "looks like"
the Bad Kind Of Lazy ie. you want us to look it up for you.
We should perhaps keep in mind that not being able to envision
something does not mean that the something does not exist. :-)
(how's that for a triple negative? Makes your head hurt, doesn't it?)
> while it would take a knowledgeable
> person 5 minutes to point me in the right direction?
5 minutes from the answerer
200 minutes for every reader of the group to scan the question
(6 seconds: 0.1 * 2000 people)
205 minutes to get your answer.
The Questioner and the Answerer are not the only participants.
Snip... I have: Learning Perl (O'Reilly), Perl A Beginner's Guide (Osborne),
Perl 5 Pocket Reference (O'Reilly), Programming Perl (O'Reilly) and Perl
Cookbook (O'Reilly). I guess I need one more...
Thanks.