Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$search help

Status
Not open for further replies.

msingle

MIS
Jul 15, 2002
22
US
I am modifying a script one of my predecessors wrote, and I am curious as to what this snippet means. In particular the '$line[7] portion means and is doing...

$search = '$line[7] =~ /' . "$JOBEND" . '/';
if (eval $search) {
# First check whether the bytecount is nonzero
if ($line[17] ne '0') {
$status{$current} = $statcode{$JOBEND};
} else {
$status{$current} = $statcode{$JOBFAIL};
};
$endtime{$current} = $line[2] . " ";
$endtime{$current} .= $line[3] . " ";
$endtime{$current} .= $line[4] . " ";
$endtime{$current} .= $line[5] . " ";
$endtime{$current} .= $line[6];
}
 
The line:
$search = '$line[7] =~ /' . "$JOBEND" . '/';
will set the $search-variable to a string containging '$line[7] =~ /' then the content of the $JOBEND-variable and then '/'.

So if $JOBEND contained the text "miffo" then $search would contain:
'$line[7] =~ /miffo/'

Then this pattern match is evaluated.

All this seems a bit awkward to me, it could be done simply using:
if ($line[7] =~ /$JOBEND/) {
....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top