Modify during a while statement

M

mechanicscart

Hey all
Trying to modify a html file with a while statement and can't
see to get it to work just right. Here's what I'm trying to do


$change .= s/\%%$option_d_name%%/ ${$option_v_name}/g,;
# $changes will be multi lines
open (FILE, "<./$location") ||
&errorcode(__FILE__, __LINE__, "./
$location", "$!", "print", "FILE OPEN ERROR", "0");

while (<FILE>)
{
$changes;
s/\%%$option_d_name%%/ ${$option_v_name}/g;
#why does s/\%%$option_d_name%%/ ${$option_v_name}/g; work,
# but $changes does not?

$database_fields[$db{"options"}] .= $_;
}
close (FILE);
}

Thanks
 
M

Mazdack

Hey all
Trying to modify a html file with a while statement and can't
see to get it to work just right. Here's what I'm trying to do


$change .= s/\%%$option_d_name%%/ ${$option_v_name}/g,;
# $changes will be multi lines
open (FILE, "<./$location") ||
&errorcode(__FILE__, __LINE__, "./
$location", "$!", "print", "FILE OPEN ERROR", "0");

while (<FILE>)
{
$changes;
s/\%%$option_d_name%%/ ${$option_v_name}/g;
#why does s/\%%$option_d_name%%/ ${$option_v_name}/g; work,
# but $changes does not?

$database_fields[$db{"options"}] .= $_;
}
close (FILE);
}

Thanks

$changes=~s/\%%$option_d_name%%/${$option_v_name}/g;
 
T

Tad McClellan

$changes;
s/\%%$option_d_name%%/ ${$option_v_name}/g;
#why does s/\%%$option_d_name%%/ ${$option_v_name}/g; work,
# but $changes does not?


Because

s/\%%$option_d_name%%/ ${$option_v_name}/g;

is "code" and the contents of $changes is "data".

Code gets eval()uated. Data does not get evaluated.
 
T

Tad McClellan

Mazdack said:
<[email protected]> ???????/???????? ? ???????? ?????????:


$changes=~s/\%%$option_d_name%%/${$option_v_name}/g;


That is an absurd "answer".

Ignore it unless you want even more confusion.

I have no idea how Mazdack thought that that might do what you
are asking for.

The OP wants to match against the string in $_, not the string
in $changes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,135
Messages
2,570,783
Members
47,341
Latest member
hanifree

Latest Threads

Top