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

pattern matching

Status
Not open for further replies.

chilster

Programmer
Apr 26, 2002
8
0
0
US
Hello
I am a perl newbie so please bare with me!!!.
I have some code that starts an external program and i redirect the output to a text file
code:

system('ccm start /d \\\chil\ccmdb\billdemo /n bill /pw billly /nogui /m > debug.txt');
open(be,"debug.txt");
@messages=<be>;


This is some of that file-



CM Synergy server starting on host chil, using database \\chil\ccmdb\billdemo


Now I want to be able to strip out &quot;database&quot; and the database name and maybe print it in a file or to the console.
Ive tried this code but it doesnt work-
code:


foreach $cr(@messages){


chomp($cr);
#print &quot;this is arse $cr&quot;;
$cr =~ /database\s(.+?)\s/;
#$messages =~/database/;

$database = &quot;$1&quot;;

print($cr);
print &quot;this DATABASE $database&quot;;
# weed out comments


}


Any ideas?
Cheers


 
Are you getting *any* output?

Instead of

$cr =~ /database\s(.+?)\s/;

you might try

$cr =~ / database (\S+)/;

HTH. Hardy Merrill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top