View previous topic :: View next topic |
Author |
Message |
gigel Guru
Joined: 14 Jan 2003 Posts: 369 Location: .se/.ro
|
Posted: Mon Mar 31, 2003 3:38 pm Post subject: problems with perl |
|
|
how should i compile perl cause with USE ="perl ..."
and CFLAGS="-march=athlon -O2 -pipe -fomit-frame-pointer it's not working correctly
i mean when i type
#perl -e ' print "HELLO\n"'
HELLO (that means that it's working)
#perl -e '`/bin/ls`'
doesn't give any output...
that means taht i cannot execute programs in perl scripts..(and this is baaad)
so what can i do in order to make things work
so a command like perl -e '`/path/to/whoami`'
will ouptut the current user name (eg root,luser ..etc)
regards _________________ $emerge sux
|
|
Back to top |
|
|
avendesora Veteran
Joined: 16 Aug 2002 Posts: 1739 Location: Betelgeuse vicinity
|
Posted: Mon Mar 31, 2003 4:51 pm Post subject: |
|
|
You need to read a bit more about perl
If you backtick something, the output will go nowhere by default.
You need to grab the output explicitly, like:
Code: | #! /usr/bin/perl
my @files = `/bin/ls`;
print join("\t", @files); |
(Although there are far better ways of getting a file list.)
This also works:
Code: | saidar $ perl -e 'print `whoami`;' |
or
Code: | #! /usr/bin/perl
my $user = `/usr/bin/whoami`;
print "Hello, I am $user.\n"; |
|
|
Back to top |
|
|
gigel Guru
Joined: 14 Jan 2003 Posts: 369 Location: .se/.ro
|
Posted: Mon Mar 31, 2003 5:18 pm Post subject: |
|
|
thanx alot!!
yes i'm learning perl now...
the problem is the book is crapy!!
it's full of errors
thanx once more!! _________________ $emerge sux
|
|
Back to top |
|
|
Esben Apprentice
Joined: 29 Jun 2002 Posts: 244 Location: Copenhagen/Denmark
|
Posted: Mon Mar 31, 2003 6:09 pm Post subject: I think you just met error 40 |
|
|
... try writing
Code: | perl -e 'print `/bin/ls`' |
_________________ regards, Esben
True trade is honest, but not merciful. Politics is dishonest, no matter how merciful... and war is neither honest nor merciful.... therefore, choose trade above politics, but politics above war. |
|
Back to top |
|
|
gigel Guru
Joined: 14 Jan 2003 Posts: 369 Location: .se/.ro
|
Posted: Mon Mar 31, 2003 8:11 pm Post subject: Re: I think you just met error 40 |
|
|
Esben wrote: | ... try writing
Code: | perl -e 'print `/bin/ls`' |
|
a *little* bit too late _________________ $emerge sux
|
|
Back to top |
|
|
Esben Apprentice
Joined: 29 Jun 2002 Posts: 244 Location: Copenhagen/Denmark
|
Posted: Tue Apr 01, 2003 5:58 pm Post subject: Re: I think you just met error 40 |
|
|
mortix wrote: | Esben wrote: | ... try writing
Code: | perl -e 'print `/bin/ls`' |
|
a *little* bit too late |
I notice. It's a nasty habbit I have: When I get home, I click in at forums and open all remotely interesting headlines + any troubles I might be able to help with in separate tabs. Then I read a couple, emerge a kernel, patch some, hack up my particle simulator a little, go back and look at read some more post, and then answer some. Of course, it is essential that I remember to reload before answering... which I sometimes forget _________________ regards, Esben
True trade is honest, but not merciful. Politics is dishonest, no matter how merciful... and war is neither honest nor merciful.... therefore, choose trade above politics, but politics above war. |
|
Back to top |
|
|
|