Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Shell usable?

by axelrose (Scribe)
on Jul 02, 2002 at 15:30 UTC ( #178883=perlquestion: print w/replies, xml ) Need Help??

axelrose has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

do I use Shell.pm properly?
#!/usr/bin/perl -w use strict; use Shell qw( ls touch ); my $sh = Shell->new; $sh->touch( "dummy" ); $sh->ls( "dummy" ); $sh->ls( "dummy" );
This results in error messages
sh: -c: line 1: syntax error near unexpected token `Shell=SCALAR(0' sh: -c: line 1: `ls Shell=SCALAR(0x8109c4c) dummy'

I normally use system() but those errors in a core module are unexpected to me. The errors (?) pop up as soon as a Shell command is used a second time.

Thanks for your time,
Axel

Replies are listed 'Best First'.
Re: Shell usable?
by broquaint (Abbot) on Jul 02, 2002 at 15:46 UTC
    After a brief review of Shell.pm it looks like a bug where the callee reference isn't being shifted off @_. The reason this works the first time around is that the method is AUTOLOADed and the callee has already been dealt with. If this hasn't already been patched by 5.8.0 I'll submit one to p5p later on today. In the mean time just use the procedural interface as it doesn't seem to have the same problem.
    HTH

    _________
    broquaint

Re: Shell usable?
by amphiplex (Monk) on Jul 02, 2002 at 15:38 UTC
    Hi !

    I believe you are doing a bit too much here, this should work:
    #!/usr/bin/perl -w use strict; use Shell qw( ls touch ); touch( "dummy" ); ls( "dummy" );

    ---- kurt
      sorry, I misunderstood you saying "doing too much"
      I tried again not using OO style
      #!/usr/bin/perl -w use strict; use Shell qw( ls touch ); touch( "dummy" ) or die "touch: $!"; ls( "dummy" ) or die "first ls: $!"; ls( "dummy" ) or die "second ls: $!";
      and get different error messages:
      $ rm dummy $ perl shell-test.pl touch: Illegal seek at shell-test.pl line 6. $ touch dummy $ perl shell-test.pl touch: Illegal seek at shell-test.pl line 6.
      You're right. This is a silly example but imagine some intermedia processing with the dummy file ... the error pops up the second time I use the $sh->ls.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://178883]
Approved by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2020-03-29 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (171 votes). Check out past polls.

    Notices?