Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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

Replies are listed 'Best First'.
Re: Shell usable?
by broquaint (Abbot) on Jul 02, 2002 at 15:46 UTC
    After a brief review of 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.


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 touch: Illegal seek at line 6. $ touch dummy $ perl touch: Illegal seek at 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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2023-12-11 21:50 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (41 votes). Check out past polls.