On Thu, 23 Aug 2001, Buffy Press wrote:

> Hello,
> 
> I am *very new* to Perl and to this list.  I have a question I am hoping
> someone can answer.  I am looking over an existing Perl script and came
> across this block of code:
> 
>  # Create the cmdfile
>   my $runprog = "$NexBase::idxBase/cmdfiles/$indexname > $cmdfile";
>   exit $? if system($runprog);
> 
> Can anyone tell me what the > symbol means here:
> 
> my $runprog = "$NexBase::idxBase/cmdfiles/$indexname > $cmdfile";
>                                                    
> I have looked in O'Reilly's Programming Perl book and found lots of
> information about the > symbol, but I could not see how it relates in
> the above variable.


Ok, here's what's happening.  That whole section in double-quotes is being
used as the parameter for the system() function, right?  Just so you know,
system() executes shell (command prompt) commands for you inside a perl
script, e.g. system("ls -al").

In shell-speak, the > operator is something of a redirect.  It has nothing
to do with Perl so to speak but has to do with the external command.  

Think of it as an arrow.
What is going to happen is that everything to the left of the 'arrow' will
be redirected to where the arrow is pointing.  In other words, the
"$NexBase::idx..." will be fed the the standard input of the
program/command "$cmdfile".  

One example of this could be:

ModuleFoo::Blah/bin/foobar > foomailer

This will (theoretically) mail someone the contents of the 'foobar' file
in the specified directory.

I hope this hasn't confused you even more.  

The short answer is that it's not a Perl thing, but rather, a shell thing.

;)

Chris 

> 
> Any help is appreciated.  
> 
> Thanks,
> Buffy
> 
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to