Gossamer Forum
Home : General : Perl Programming :

another perl question

(Page 1 of 2)
> >
Quote Reply
another perl question
hi andy,
you helped me with something similar before. i have a text file that contains the following lines:
Code:

%db_radio_fields = ( Graphics => 'Yes,No,Line,No Ad,Generic',Red_Flag => 'Yes,No',Jumbo => 'Jumbo,no',Table => 'Yes,No');

# Select fields. Field name => 'comma seperated list of drop down options'.
%db_select_fields = (
'AD_Size' => 'Line,Business Card,Quarter Page,Half Page,Full Page,No Ad,Inside Front Cover,Inside Back Cover,Back Cover,3x6 Banner,4x8 Banner,Digital Banner,Jumbo,Table',
'Art' => '--------Kenny-------,Pickup new art,------For Reps------,Use art on File,Waiting for art,Scott will make Ad,ASE will make Ad,No Ad,Line,Generic,---Art Department---,Working on art,Completed,Do not have art,---Banner---,We have the Banner,We do not have the Banner,The customer has the Banner,Use art on File',
'Graphics' => 'Yes,No,Line,xxx,Generic,Cancel,Retrieve,Change',
'Proof' => 'Art Dept to send Proof,Rep to send Proof,Proof Ready,Proof out,Approved,No Proof needed,Wrong Pagination,Poor Quality',
'Bump' => 'Yes'
);
i need to read the file and find the line that starts with %db_select_fields. the easiest thing for me would be to make %db2_select_fields = %db_select_fields so i can reference it the same way in a different database. is this possible? if not, how can i have a fieldname Art with the select options listed above?
thanks!
Quote Reply
Re: [delicia] another perl question In reply to
Hi,

It took a bit of playing around, but give this a go:

Code:
use File::Slurp;

# read it into a variable
my $file = read_file("/path/to/file/to/read.cfg");

my $values;
my %new_hash;
# grab the value back using a regex
$file =~ m/\%db_select_fields = \((.*?)\)/s and $values = $1;

# loop through the grabbed values, line by line - and the tweak and pass into a new variable
foreach (split /\n/, $values) {
my @tmp = split /\Q => /, $_;
$tmp[0] =~ s/^'|'$//g;
$tmp[1] =~ s/^'|',?$//g;
$new_hash{$tmp[0]} = $tmp[1];
}

# values are not in %new_hash

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] another perl question In reply to
guess i'm too dense. i'm testing with a file that contains:
Code:
# Radio fields. Field name => comma seperated list of radio buttons.
%db_radio_fields = (
'Category' => 'Suspense,Nonfiction,General,Biography',
'Display' => 'Yes,No',
'WishList' => 'Yes,No'
);

so i have the following sub:
Code:
sub get_radio_fields2 {
#-----------------------------------------------------
# pulls field names from the def file!
# check def file to be sure field names enclosed in single quotes!

use File::Slurp;

# read it into a variable
my $file = $configfile;

my $values;
my %new_hash;
# grab the value back using a regex
$file =~ m/\%db_radio_fields = \((.*?)\)/s and $values = $1;

# loop through the grabbed values, line by line - and the tweak and pass into a new variable
foreach (split /\n/, $values) {
my @tmp = split /\Q => /, $_;
$tmp[0] =~ s/^'|'$//g;
$tmp[1] =~ s/^'|',?$//g;
$new_hash{$tmp[0]} = $tmp[1];
}

}

so after calling the above sub i'm trying to print $new_hash{'Category'}, which i thought should print 'Suspense,Nonfiction,General,Biography' but isn't printing anything. what am i doing wrong?
Quote Reply
Re: [delicia] another perl question In reply to
Code:
my $file = $configfile;

Should be:

Code:
my $file = read_file($configfile);

Whistle

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] another perl question In reply to
i tried that but still can't figure out how to show values for Category
Quote Reply
Re: [delicia] another perl question In reply to
Try a dump of %new_hash, to see whats in it at the end:

Code:
use Data::Dumper;
print Dumper(%new_hash);

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [delicia] another perl question In reply to
Here it is with some extra debug in:

Code:
use File::Slurp;

print "Content-Type: text/html \n\n";

# read it into a variable
my $file = read_file($configfile);

print qq|Reading: $file \n<br>|;

my $values;
my %new_hash;
# grab the value back using a regex
$file =~ m/\%db_select_fields = \((.*?)\)/s and $values = $1;

print qq|GOT: $values \n\n<br><br>|;

# loop through the grabbed values, line by line - and the tweak and pass into a new variable
foreach (split /\n/, $values) {
my @tmp = split /\Q => /, $_;
$tmp[0] =~ s/^'|'$//g;
$tmp[1] =~ s/^'|',?$//g;
print qq|Adding: $tmp[0] ==> $tmp[1]\n<br>|;
$new_hash{$tmp[0]} = $tmp[1];
}

use Data::Dumper;
print qq|Now values:|;
print Dumper(%new_hash);

# values are not in %new_hash

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] another perl question In reply to
not getting anything. i have a main script calling the following sub
Code:
sub switch_to_books { # 08/10/2016
#-----------------------------------------------------
undef @db2_cols;
$configfile = "$_[0].def";
$configfile = $db_script_path . "/" . $configfile;
&get_fieldnames2($configfile);
&get_radio_fields2($configfile);
$db2_file_name = $db_script_path . "/books.db";
$db2_key_pos = '0';
$db2_delim = '|';
}
which calls
Code:
sub get_radio_fields2 {
#-----------------------------------------------------
# pulls field names from the def file!
# check def file to be sure field names enclosed in single quotes!

use File::Slurp;

# read it into a variable
my $file = read_file($configfile);

my $values;
my %new_hash;
# grab the value back using a regex
$file =~ m/\%db_radio_fields = \((.*?)\)/s and $values = $1;

# loop through the grabbed values, line by line - and the tweak and pass into a new variable
foreach (split /\n/, $values) {
my @tmp = split /\Q => /, $_;
$tmp[0] =~ s/^'|'$//g;
$tmp[1] =~ s/^'|',?$//g;
$new_hash{$tmp[0]} = $tmp[1];
}
use Data::Dumper;
print Dumper(%new_hash);
}

so my code that's calling switch_to_books isn't printing dumper. should switch_to_books have
Code:
%db2_radio_fields = &get_radio_fields2($configfile);
instead of
Code:
&get_radio_fields2($configfile);
i think i tried that before but it didn't help.
Quote Reply
Re: [Andy] another perl question In reply to
here's what printed:
Code:
Content-Type: text/html Reading: # books.def # Database Definition # -------------------------------------------------------- # Definition of your database. Format is # field_name => ['position', 'field_type', 'form-length', 'maxlength', 'not_null', 'default', 'valid_expr'] %db_def = ( 'RecordID' => [0, 'numer', -2, 8, 1, '', ''], 'Userid' => [1, 'alpha', -2, 15, 1, '', ''], 'Updated' => [2, 'timestamp', 12, 25, 1, &get_timestamp, ''], 'Title' => [3, 'alpha', 40, 255, 1, '', ''], 'TitleSort' => [4, 'alpha', 40, 255, 0, '', ''], 'AuthorID' => [5, 'alpha', 40, 255, 0, '', ''], 'Series' => [6, 'alpha', 40, 255, 0, '', ''], 'SeriesNum' => [7, 'alpha', 40, 255, 0, '', ''], 'Category' => [8, 'alpha', 40, 255, 0, '', ''], 'Display' => [9, 'alpha', -1, 3, 1, 'Yes', 'Yes|No'], 'WishList' => [10, 'alpha', 0, 3, 1, 'No', 'Yes|No'], 'URL' => [11, 'alpha', 40, 255, 0, 'http://', '^http://'], 'Description' => [12, 'alpha', 0, 1000, 0, '', ''], 'Reserved' => [13, 'alpha', -2, 5, 0, 'zzzzz', ''] ); # Select fields. Field name => 'comma seperated list of drop down options'. %db_select_fields = ( ); # Radio fields. Field name => comma seperated list of radio buttons. %db_radio_fields = ( 'Category' => 'Suspense,Nonfiction,General,Biography', 'Display' => 'Yes,No', 'WishList' => 'Yes,No' ); # Checkbox fields. Field name => Checkbox value. %db_checkbox_fields = ( ); # delicia added from autogenerate enhancement # Textarea fields. Field name => '[columns]x[rows]'. %db_textarea_fields = ( Description => '40x3' ); @db_approve_fields = ( Userid,Updated,Title,AuthorLast); @db_compare_fields = ( Title,AuthorLast); # @db_massmail_fields = ( Userid,Updated,Title); # =========================================================================== # Build up some variables from your definitions. Internal use only. foreach (sort { $db_def{$a}[0] <=> $db_def{$b}[0] } keys %db_def) { push (@db_cols, $_); $db_sort{$_} = $db_def{$_}[1]; $db_form_len{$_} = $db_def{$_}[2]; $db_lengths{$_} = $db_def{$_}[3]; $db_not_null{$_} = $db_def{$_}[4]; $db_defaults{$_} = $db_def{$_}[5]; $db_valid_types{$_} = $db_def{$_}[6]; ($_ eq $db_key) and $db_key_pos = $db_def{$_}[0]; } 1;
GOT:

Now values:
Quote Reply
Re: [delicia] another perl question In reply to
This is where using "strict" helps out ;)

You are doing:

Code:
%db2_radio_fields = &get_radio_fields2($configfile);

but in get_radio_fields2() you are not actually grabbing $configfile ;) Try:

Code:
sub get_radio_fields2 {
#-----------------------------------------------------
# pulls field names from the def file!
# check def file to be sure field names enclosed in single quotes!

use File::Slurp;

# read it into a variable
my $file = read_file($_[0]);
# ..rest of code here

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [delicia] another perl question In reply to
delicia wrote:
here's what printed:
Code:
Content-Type: text/html Reading: # books.def # Database Definition # -------------------------------------------------------- # Definition of your database. Format is # field_name => ['position', 'field_type', 'form-length', 'maxlength', 'not_null', 'default', 'valid_expr'] %db_def = ( 'RecordID' => [0, 'numer', -2, 8, 1, '', ''], 'Userid' => [1, 'alpha', -2, 15, 1, '', ''], 'Updated' => [2, 'timestamp', 12, 25, 1, &get_timestamp, ''], 'Title' => [3, 'alpha', 40, 255, 1, '', ''], 'TitleSort' => [4, 'alpha', 40, 255, 0, '', ''], 'AuthorID' => [5, 'alpha', 40, 255, 0, '', ''], 'Series' => [6, 'alpha', 40, 255, 0, '', ''], 'SeriesNum' => [7, 'alpha', 40, 255, 0, '', ''], 'Category' => [8, 'alpha', 40, 255, 0, '', ''], 'Display' => [9, 'alpha', -1, 3, 1, 'Yes', 'Yes|No'], 'WishList' => [10, 'alpha', 0, 3, 1, 'No', 'Yes|No'], 'URL' => [11, 'alpha', 40, 255, 0, 'http://', '^http://'], 'Description' => [12, 'alpha', 0, 1000, 0, '', ''], 'Reserved' => [13, 'alpha', -2, 5, 0, 'zzzzz', ''] ); # Select fields. Field name => 'comma seperated list of drop down options'. %db_select_fields = ( ); # Radio fields. Field name => comma seperated list of radio buttons. %db_radio_fields = ( 'Category' => 'Suspense,Nonfiction,General,Biography', 'Display' => 'Yes,No', 'WishList' => 'Yes,No' ); # Checkbox fields. Field name => Checkbox value. %db_checkbox_fields = ( ); # delicia added from autogenerate enhancement # Textarea fields. Field name => '[columns]x[rows]'. %db_textarea_fields = ( Description => '40x3' ); @db_approve_fields = ( Userid,Updated,Title,AuthorLast); @db_compare_fields = ( Title,AuthorLast); # @db_massmail_fields = ( Userid,Updated,Title); # =========================================================================== # Build up some variables from your definitions. Internal use only. foreach (sort { $db_def{$a}[0] <=> $db_def{$b}[0] } keys %db_def) { push (@db_cols, $_); $db_sort{$_} = $db_def{$_}[1]; $db_form_len{$_} = $db_def{$_}[2]; $db_lengths{$_} = $db_def{$_}[3]; $db_not_null{$_} = $db_def{$_}[4]; $db_defaults{$_} = $db_def{$_}[5]; $db_valid_types{$_} = $db_def{$_}[6]; ($_ eq $db_key) and $db_key_pos = $db_def{$_}[0]; } 1;
GOT:

Now values:

Can you paste what you see in the actual source code of the page? Trying to see the newlines, but hard to know where stuff starts and ends.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] another perl question In reply to
when i look at source it's easy read. but when i paste all the line returns go away. it's reading the entire file

Reading: # books.def # Database Definition # -------------------------------------------------------- # Definition of your database. Format is # field_name => ['position', 'field_type', 'form-length', 'maxlength', 'not_null', 'default', 'valid_expr'] %db_def = ( 'RecordID' => [0, 'numer', -2, 8, 1, '', ''], 'Userid' => [1, 'alpha', -2, 15, 1, '', ''], 'Updated' => [2, 'timestamp', 12, 25, 1, &get_timestamp, ''], 'Title' => [3, 'alpha', 40, 255, 1, '', ''], 'TitleSort' => [4, 'alpha', 40, 255, 0, '', ''], 'AuthorID' => [5, 'alpha', 40, 255, 0, '', ''], 'Series' => [6, 'alpha', 40, 255, 0, '', ''], 'SeriesNum' => [7, 'alpha', 40, 255, 0, '', ''], 'Category' => [8, 'alpha', 40, 255, 0, '', ''], 'Display' => [9, 'alpha', -1, 3, 1, 'Yes', 'Yes|No'], 'WishList' => [10, 'alpha', 0, 3, 1, 'No', 'Yes|No'], 'URL' => [11, 'alpha', 40, 255, 0, 'http://', '^http://'], 'Description' => [12, 'alpha', 0, 1000, 0, '', ''], 'Reserved' => [13, 'alpha', -2, 5, 0, 'zzzzz', ''] ); # Select fields. Field name => 'comma seperated list of drop down options'. %db_select_fields = ( ); # Radio fields. Field name => comma seperated list of radio buttons. %db_radio_fields = ( 'Category' => 'Suspense,Nonfiction,General,Biography', 'Display' => 'Yes,No', 'WishList' => 'Yes,No' ); # Checkbox fields. Field name => Checkbox value. %db_checkbox_fields = ( ); # delicia added from autogenerate enhancement # Textarea fields. Field name => '[columns]x[rows]'. %db_textarea_fields = ( Description => '40x3' ); @db_approve_fields = ( Userid,Updated,Title,AuthorLast); @db_compare_fields = ( Title,AuthorLast); # @db_massmail_fields = ( Userid,Updated,Title); # =========================================================================== # Build up some variables from your definitions. Internal use only. foreach (sort { $db_def{$a}[0] <=> $db_def{$b}[0] } keys %db_def) { push (@db_cols, $_); $db_sort{$_} = $db_def{$_}[1]; $db_form_len{$_} = $db_def{$_}[2]; $db_lengths{$_} = $db_def{$_}[3]; $db_not_null{$_} = $db_def{$_}[4]; $db_defaults{$_} = $db_def{$_}[5]; $db_valid_types{$_} = $db_def{$_}[6]; ($_ eq $db_key) and $db_key_pos = $db_def{$_}[0]; } 1; <br>GOT: <br><br>Now values:
Quote Reply
Re: [delicia] another perl question In reply to
Mmmm. Maybe table a "print screen" of your browser, and then cut out the correct section in a graphics editor (Paint, GIMP, or something like that) ? Then upload the image

Just popping out for a bit

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] another perl question In reply to
i'm popping out for a bit too!
dump1 is the page in browser. dumps2 & 3 are page source
Quote Reply
Re: [delicia] another perl question In reply to
Hi,

In this one:

http://www.gossamer-threads.com/...ment;postatt_id=2547

%db_select_fields is empty... which is probably why its not grabbing anything :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] another perl question In reply to
no. i changed that line to %db_radio_fields.
for testing i'm ignoring the subs and put code directly in script that was calling:
Code:
$configfile = "books.def";
$configfile = $db_script_path . "/" . $configfile;
use File::Slurp;

# print "Content-Type: text/html \n\n";

# read it into a variable
my $file = read_file($configfile);

print qq|Reading: $file \n<br>|;

my $values;
my %new_hash;
# grab the value back using a regex
$file =~ m/\%db_radio_fields = \((.*?)\)/s and $values = $1;

print qq|GOT: $values \n\n<br><br>|;

# loop through the grabbed values, line by line - and the tweak and pass into a new variable
foreach (split /\n/, $values) {
my @tmp = split /\Q => /, $_;
$tmp[0] =~ s/^'|'$//g;
$tmp[1] =~ s/^'|',?$//g;
print qq|Adding: $tmp[0] ==> $tmp[1]\n<br>|;
$new_hash{$tmp[0]} = $tmp[1];
}

use Data::Dumper;
print qq|Now values:|;
print Dumper(%new_hash);

# values are not in %new_hash

Last edited by:

delicia: Sep 7, 2016, 10:57 AM
Quote Reply
Re: [delicia] another perl question In reply to
Can you send over the books.def file, so I can play with it here?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [delicia] another perl question In reply to
Ah, I got it. Its because you have extra spaces in some parts of the def. I've tweaked the bits in red:


Code:
my $configfile = "./test.def";
use File::Slurp;

# print "Content-Type: text/html \n\n";

# read it into a variable
my $file = read_file($configfile);

print qq|Reading: $file \n<br>|;

my $values;
my %new_hash;
# grab the value back using a regex
$file =~ m/\%db_select_fields\s+=\s+\((.*?)\)/s and $values = $1;


# loop through the grabbed values, line by line - and the tweak and pass into a new variable
foreach (split /\n/, $values) {
s/^\s+|\s+$//g;
my @tmp = split /\s+\=\>\s+?/, $_;
$tmp[0] =~ s/^'|'$//g;
$tmp[1] =~ s/^'|',?$//g;
print qq|Adding: $tmp[0] ==> $tmp[1]\n<br>|;
$new_hash{$tmp[0]} = $tmp[1];
}

use Data::Dumper;
print qq|Now values:|;
print Dumper(%new_hash);

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] another perl question In reply to
ok here's part of browser window:

GOT:

Adding: ==>
Now values:$VAR1 = ''; $VAR2 = undef;


the reading part was same
Quote Reply
Re: [delicia] another perl question In reply to
oops. correction:

GOT: 'Category' => 'Suspense,Nonfiction,General,Biography', 'Display' => 'Yes,No', 'WishList' => 'Yes,No'

Adding: ==>
Adding: Category ==> Suspense,Nonfiction,General,Biography
Adding: Display ==> Yes,No
Adding: WishList ==> Yes,No
Now values:$VAR1 = ''; $VAR2 = undef; $VAR3 = 'Display'; $VAR4 = 'Yes,No'; $VAR5 = 'WishList'; $VAR6 = 'Yes,No'; $VAR7 = 'Category'; $VAR8 = 'Suspense,Nonfiction,General,Biography';
Quote Reply
Re: [delicia] another perl question In reply to
So it's not working ever with those changes? Maybe attach the whole .def file so I can try it with that. I just used the extract you gave in your opening post

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] another perl question In reply to
ok i think it's working! let me put it back in sub where it goes and make sure. thanks!!!
Quote Reply
Re: [delicia] another perl question In reply to
Cool. Maybe just add in:

Code:
next if $tmp[0] eq undef;

Just so it skips the first undef one

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] another perl question In reply to
ok, it works fine on my site. unfortunately, my friend's site gives an error. apparently slurp is not available there. was trying to read the file using code you gave me previously (thread need help with code), but so far not working:
Code:
# this worked to get %db_def
open(FILE, "<$configfile") || &cgierr("Cannot open $configfile.\n$!");
local $/;
my ($fields);
while (<FILE>) { if (/(%db_radio_fields\s+=\s+\(\s+)('.*?)(\);)/s) { $fields = $2;}}
close(FILE);
##
my $values;
my %new_hash;
# grab the value back using a regex
$file =~ m/\%db_radio_fields\s+=\s+\((.*?)\)/s and $values = $1;

# loop through the grabbed values, line by line - and the tweak and pass into a new variable
foreach (split /\n/, $values) {
s/^\s+|\s+$//g;
my @tmp = split /\s+\=\>\s+?/, $_;
next if $tmp[0] eq undef;
$tmp[0] =~ s/^'|'$//g;
$tmp[1] =~ s/^'|',?$//g;
$new_hash{$tmp[0]} = $tmp[1];
}

%db2_radio_fields = %new_hash;
Quote Reply
Re: [delicia] another perl question In reply to
I'm on my tablet now, so can't really do any code.

What you want to do in the while () is something like:

$contents .= $_

...then use that variable to run it on :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
> >