Chad Kellerman wrote: > > 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?
Hi Chad. Does something like this help? It relies on both values actually being present in the section. Cheers, Rob use strict; use warnings; open CONF, 'my.conf' or die $!; $_ = <CONF> until /\Q[mysqld]/; my $port; my $datadir; while (<CONF>) { chomp; $port = $_ if /\bport\s*=/; $datadir = $_ if /\bdatadir\s*=/; last if $port and $datadir; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]