[oak perl] new to Perl

David Fetter david at fetter.org
Mon Dec 4 09:18:04 PST 2006


On Mon, Dec 04, 2006 at 08:40:15AM -0800, Tabatchnick, Justin wrote:
> 
>    Hi ;
> 
> 
> I am new to Perl and I need some advice on how to execute a command
> within a Perl script. In particular I need to run HSPICE  ( an
> electrical simulator) followed by two arguments -i and the filename.
> Is this possible within Perl or do I have to create a Unix shell
> script ?

Justin,

Welcome to the world of Perl and to Oakland Perl Mongers :)

To execute the command without capturing its output, you'd do
something like:

    system("/path/to/hspice", "-i", $filename);

To capture the output, you could do:

    $output = `/path/to/hspice -i $filename`;

There are plenty of other options, but those two are the simplest and
clearest to start with.  You've obviously read this
<http://catb.org/esr/faqs/smart-questions.html> or have habits much
like what it suggests :)

I'd also recommend that you bookmark <http://www.cpan.org/>, the
biggest success of Object-Oriented programming in the sense of having
hugely many reusable components, including at least five which help
with SPICE.  Also get "Learning Perl" by Randal Schwartz and, as your
code bases get bigger, Perl Best Practices by Damian Conway, both from
O'Reilly <http://www.oreilly.com>.

Cheers,
Dave.
-- 
David Fetter <david at fetter.org> http://fetter.org/
phone: +1 415 235 3778        AIM: dfetter666
                              Skype: davidfetter

Remember to vote!


More information about the Oakland mailing list