John, Thanks that was perfect..
Chad On Fri, 2003-10-10 at 03:11, John W. Krahn wrote: > Chad Kellerman wrote: > > > > Hello, > > Hello, > > > I am opening up a file (actually a my.conf). I only want 2 lines in > > the file. port and datadir > > > > The problem I am running into is that there is a port = 3324 in both > > the [client] section and the [mysqld] section. > > > > I want to open the file and go straight to the [mysqld] section and > > grab the values for port and datadir. > > > > Can anyone point me in the right direction? > > You could use a module like > http://search.cpan.org/author/WADG/Config-IniFiles-2.38/IniFiles.pm or > http://search.cpan.org/author/SHERZODR/Config-Simple-4.55/Simple.pm > > Or something like this may work: > > $/ = '['; > my ( $port, $datadir ); > while ( <FILE> ) { > if ( /mysqld]/ ) { > $port = $1 if /^port\s*=\s*(\d+)/m; > $datadir = $1 if /^datadir\s*=\s*(.+)/m; > } > } > > > > John > -- > use Perl; > program > fulfillment -- Chad Kellerman Systems Administration / Network Operations Manager Alabanza Inc. 10 E Baltimore Street Baltimore, Md 21202 Phone: 410-234-3305 Email: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]