Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
problems with perl
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
gigel
Guru
Guru


Joined: 14 Jan 2003
Posts: 369
Location: .se/.ro

PostPosted: Mon Mar 31, 2003 3:38 pm    Post subject: problems with perl Reply with quote

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
:D
Back to top
View user's profile Send private message
avendesora
Veteran
Veteran


Joined: 16 Aug 2002
Posts: 1739
Location: Betelgeuse vicinity

PostPosted: Mon Mar 31, 2003 4:51 pm    Post subject: Reply with quote

You need to read a bit more about perl :wink:
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
View user's profile Send private message
gigel
Guru
Guru


Joined: 14 Jan 2003
Posts: 369
Location: .se/.ro

PostPosted: Mon Mar 31, 2003 5:18 pm    Post subject: Reply with quote

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
:D
Back to top
View user's profile Send private message
Esben
Apprentice
Apprentice


Joined: 29 Jun 2002
Posts: 244
Location: Copenhagen/Denmark

PostPosted: Mon Mar 31, 2003 6:09 pm    Post subject: I think you just met error 40 Reply with quote

... try writing

Code:
perl -e 'print `/bin/ls`'


:twisted:
_________________
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
View user's profile Send private message
gigel
Guru
Guru


Joined: 14 Jan 2003
Posts: 369
Location: .se/.ro

PostPosted: Mon Mar 31, 2003 8:11 pm    Post subject: Re: I think you just met error 40 Reply with quote

Esben wrote:
... try writing

Code:
perl -e 'print `/bin/ls`'


:twisted:

a *little* bit too late ;)
_________________
$emerge sux
:D
Back to top
View user's profile Send private message
Esben
Apprentice
Apprentice


Joined: 29 Jun 2002
Posts: 244
Location: Copenhagen/Denmark

PostPosted: Tue Apr 01, 2003 5:58 pm    Post subject: Re: I think you just met error 40 Reply with quote

mortix wrote:
Esben wrote:
... try writing

Code:
perl -e 'print `/bin/ls`'


:twisted:

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 :oops:
_________________
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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum