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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

regex match

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Joined
Feb 6, 2002
Messages
1,851
Location
IL
HI,

reading a line like
control_files = (E:\Orant\Oracle\MirroredControlFile\ctl1creo.ora, J:\Orant\Oracle\ControlFile\ctl2creo.ora)

from a file.
Then matching :
open (FILE,'D:\Ora816\DATABASE\initCreo.ora') || die "Could not open the initCreo.ora:$!";
while (<FILE>) {
$DRIVE_MIR = m/(.)\:\\Orant\\Oracle\\MirroredControlFile/g if (/control_files/);
$DRIVE_NON = m/(.)\:\\Orant\\Oracle\\ControlFile/g if (/control_files/);
}


the result expected would be "E" and "J",but actual result is "1".

Any ideas why ?

Long live king Moshiach !
 
This is untested, but maybe something like this:

Code:
while (<FILE>) {
  ($DRIVE_MIR)= $_=~m/control_files = (.)\:\\Orant\\Oracle\\MirroredControlFile/;
  ($DRIVE_NON)= $_ =~m/control_files = (.)\:\\Orant\\Oracle\\ControlFile/;    
}

This is wrapping in my display, but there are only 2 lines in the while statement, not 4 like it looks like.
 
you need to add the parenthesis like BrianAtWork showed above:

($DRIVE_MIR) =


to capture the match on the left side the way you are doing it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top