Gossamer Forum
Home : General : Perl Programming :

need help with code

Quote Reply
need help with code
ok, i'm posting here because it's a perl problem and there seems to be no activity on dbman board.

i'm using a subroutine to find fieldnames in a dbman cfg file. that part of cfg looks like this (excerpt):
Code:
%db_def = (
'Lock' => [ 0, 'alpha', -1, 5, 0, 'No', ''],
'Userid' => [ 1, 'alpha', 5, 255, 1, '', ''],
'Business_name' => [ 2, 'alpha', 20, 255, 0, '', ''],
'Firstname' => [ 3, 'alpha', 20, 255, 1, '', ''],
'Lastname' => [ 4, 'alpha', 20, 255, 1, '', ''],
...
'Balance_due' => [36, 'numer', 12, 10, 0, '', '\d+(?=\.\d\d)?$'],
'Mgt_council' => [37, 'alpha', 5, 3, 0, 'No', ''],
'Reserved' => [38, 'alpha', -1, 5, 0, 'xxxxx', '']
);
my subroutine is not getting the first field (Lock) and it doesn't get the last two fields. i have no idea why it isn't getting the first one. i'm guessing it quits after Balance_due because of the validation expression that contains quotes and parentheses. can someone tell me how to fix the sub:

Code:
$configfile = "members.def";
$configfile = $db_script_path . "/" . $configfile;
open(FILE, "<$configfile") || &cgierr("Cannot open $configfile.\n$!");
local $/;
#undef $/; # commented to fix a different problem!

while (<FILE>) { if (/(%db_def\s+=\s+\(\s+)('.*?)(\))/s) { $fields = $2;}}
close(FILE);

while ($fields =~ /(\n')(\w+)(')/g) { push (@db2_cols, $2); }
return (@db2_cols);
please help! thanks.
Subject Author Views Date
Thread; hot thread need help with code delicia 25116 Jan 13, 2010, 2:49 PM
Thread; hot thread Re: [delicia] need help with code
Andy 24748 Jan 14, 2010, 12:04 AM
Thread; hot thread Re: [Andy] need help with code
delicia 24710 Jan 14, 2010, 8:18 AM
Thread; hot thread Re: [delicia] need help with code
Andy 24676 Jan 14, 2010, 8:18 AM
Thread; hot thread Re: [Andy] need help with code
delicia 24794 Jan 14, 2010, 8:34 AM
Thread; hot thread Re: [delicia] need help with code
Andy 24639 Jan 14, 2010, 8:43 AM
Thread; hot thread Re: [Andy] need help with code
delicia 24636 Jan 14, 2010, 8:50 AM
Thread; hot thread Re: [delicia] need help with code
Andy 24714 Jan 14, 2010, 8:51 AM
Thread; hot thread Re: [Andy] need help with code
delicia 24607 Jan 14, 2010, 8:56 AM
Thread; hot thread Re: [delicia] need help with code
Andy 24671 Jan 14, 2010, 9:04 AM
Thread; hot thread Re: [Andy] need help with code
delicia 24755 Jan 14, 2010, 9:09 AM
Thread; hot thread Re: [delicia] need help with code
Andy 24656 Jan 14, 2010, 9:18 AM
Thread; hot thread Re: [Andy] need help with code
delicia 24755 Jan 14, 2010, 9:24 AM
Thread; hot thread Re: [delicia] need help with code
Andy 24594 Jan 14, 2010, 9:26 AM
Thread; hot thread Re: [Andy] need help with code
delicia 21414 Jul 15, 2014, 11:15 AM
Post; hot thread Re: [delicia] need help with code
Andy 21267 Jul 15, 2014, 11:57 AM
Thread; hot thread Re: [Andy] need help with code
delicia 24699 Jan 14, 2010, 9:00 AM
Post; hot thread Re: [delicia] need help with code
Andy 24687 Jan 14, 2010, 9:02 AM
Thread; hot thread Re: [delicia] need help with code
neves 24635 Jan 14, 2010, 3:49 AM
Post; hot thread Re: [neves] need help with code
delicia 24626 Jan 14, 2010, 8:17 AM