Re: The > symbol in a variable

2001-08-24 Thread Christopher Solomon




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]




Re: The > symbol in a variable

2001-08-24 Thread register

The system function runs a command in the OS shell.  Whatever is in the params
of system is never Perl code (well maybe it could be if you were using a perl
shell but that is another story) ... the '>' is a redirection operator to
redirect the output to a file or handle ..

hope this helps

On Thu, Aug 23, 2001 at 09:52:03AM -0700, Buffy Press shaped the electrons to read:
> 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.
> 
> Any help is appreciated.  
> 
> Thanks,
> Buffy
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

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




The > symbol in a variable

2001-08-24 Thread Buffy Press

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.

Any help is appreciated.  

Thanks,
Buffy

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




Re: The > symbol in a variable

2001-08-23 Thread Peter Scott

At 11:20 AM 8/23/01 -0700, 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.

That symbol is not going to be used by Perl.  The variable $runprog is 
being initialized to contain a command to be passed to your OS' command 
line interpreter (the Bourne shell on Unix-y systems).  You'll see $runprog 
used later in that program in either a system() or exec() function call, or 
between backticks (``) (or, less likely, in an open() call).

If you're unfamiliar with the Bourne shell, consult a reference such as 
"Unix Shell Programming" by Kochan & Wood, Hayden Books (happens to be on 
the shelf in front of me).

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com


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




The > symbol in a variable

2001-08-23 Thread Buffy Press

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.

Any help is appreciated.  

Thanks,
Buffy

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