Meaning of ` signs

T

Torch

Hey again all. I have progressed a great deal with the basics of perl.
I have however a question were I do not seem to get the awnser of.
It has to do with appointing a value to a variable. This is the last
part of a program which I am trying to understand

My question:
The value given to the variable $STR is given in between ` signs.
What does this mean?
my $STR = `sqlplus -s $ORASTR >$f <<END
SET NEWPAGE 0
SET SPACE 0
SET PAGESIZE 0
SET LINESIZE 127
SET HEADING OFF
SET FEEDBACK OFF
SET ECHO OFF
SET TAB OFF
SET COLSEP |
$Q
`;

When I try to display the value of $STR I get nothing

I am not really interested in what this variable does, I can probably
find that out myself. I am more interested in de function of the `
signs

Thx alot for all your help people! It really makes a difference!
 
K

Kasp

The value given to the variable $STR is given in between ` signs.
What does this mean?

They are called backquotes. It launches the shell which fires the command
inside the backquotes.
The program waits until the command executes. And the command output (if
any) is returned....that's coming here in $STR.

HTH
--
 
A

Anno Siegel

Torch said:
Hey again all. I have progressed a great deal with the basics of perl.
I have however a question were I do not seem to get the awnser of.
It has to do with appointing a value to a variable. This is the last
part of a program which I am trying to understand

My question:
The value given to the variable $STR is given in between ` signs.
What does this mean?
my $STR = `sqlplus -s $ORASTR >$f <<END
SET NEWPAGE 0
SET SPACE 0
SET PAGESIZE 0
SET LINESIZE 127
SET HEADING OFF
SET FEEDBACK OFF
SET ECHO OFF
SET TAB OFF
SET COLSEP |
$Q
`;

When I try to display the value of $STR I get nothing

I am not really interested in what this variable does, I can probably
find that out myself. I am more interested in de function of the `
signs

In short, `` executes the enclosed text as a system command and returns
the output of that command. For details, see "perldoc perlop and look
for "qr".

In this case, the system command is an sqlplus command which gets its
input from a shell "here document". As I read it, it will only work
if the variable $Q contains "END" at this point. It's a little
inconsistent to use $Q for the closing "END" and not for the opening one,
but I may be misreading the code that isn't there.

Anno
 
M

Master Web Surfer

[This followup was posted to comp.lang.perl.misc]

Hey again all. I have progressed a great deal with the basics of perl.
I have however a question were I do not seem to get the awnser of.
It has to do with appointing a value to a variable. This is the last
part of a program which I am trying to understand

My question:
The value given to the variable $STR is given in between ` signs.
What does this mean?
my $STR = `sqlplus -s $ORASTR >$f <<END
SET NEWPAGE 0
SET SPACE 0
SET PAGESIZE 0
SET LINESIZE 127
SET HEADING OFF
SET FEEDBACK OFF
SET ECHO OFF
SET TAB OFF
SET COLSEP |
$Q
`;

When I try to display the value of $STR I get nothing

I am not really interested in what this variable does, I can probably
find that out myself. I am more interested in de function of the `
signs

Thx alot for all your help people! It really makes a difference!


The backtick operator (`) is used to trap the output of an external
command executed by your perl script.

$output_of_program = `name_of_command parameter1 ... parameter_n`;
 
G

Glenn Jackman

Anno Siegel said:
In short, `` executes the enclosed text as a system command and returns
the output of that command. For details, see "perldoc perlop and look
for "qr".

That should be, look for "qx"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,141
Messages
2,570,818
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top