[oak perl] new to Perl

Kester Allen kester at gmail.com
Mon Dec 4 09:11:09 PST 2006


Hi Justin--

This is pretty easy to do within Perl.  There are two ways to do it,
depending on whether you'd like to capture any output from the HSPICE
command

The first is using the Perl "system" command.  You'd take the HSPICE
command you want to run, e.g., "HSPICE -i somefilename.txt", and in a
Perl script, do this:

system "HSPICE -i somefilename.txt";

Perl will then run that command, and display the results just as if
you'd run it from the shell prompt.

To capture the STDOUT output (if there is any), you can use backticks.
 They do about the same thing, but return the STDOUT, which you can
then capture with a variable, like this:

my $hspice_text_output = `HSPICE -i somefilename.txt`;

Then the $hspice_text_output variable will have the STDOUT text.

You can see the difference with these two oneliners

perl -e 'system "ls"'
perl -e '$out = `ls`; print "$out"'

Or look at 'perldoc -f system' for more info.

Good luck!

Kester

On 12/4/06, Tabatchnick, Justin <justin.tabatchnick at intel.com> 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 ?
>
>
>
>
>
> Thanks
>
>
>
>
>
> Justin Tabatchnick
>
>
> Intel, Folsom,Ca
>
>
> 916-356-6912
> _______________________________________________
> Oakland mailing list
> Oakland at pm.org
> http://mail.pm.org/mailman/listinfo/oakland
>
>


More information about the Oakland mailing list