Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I'm looking for a way to replace some variables for example in perl I
do :

#replace all $LABEL variables with corresponding values from $SERVER
s/$LABEL/ exists $SERVER ? $SERVER : $1 /eg;
#replace $LANG var with the value of $lang

Re: replace wrote:
Quoted text here. Click to load it

What is the context of this? Are you talking about replacing literal  
"$LABEL" with the value of _$SERVER['label_name'] in a string?

If so, you could try this where $s is the string that has the content  
that will need the replacing:


Justin Koivisto, ZCE -

Re: replace

thanks Justin for responding

-What is the context of this?

I want to open an html file, parse it and replace all
$LABEL variables by the key values pairs who are placed
in an config config file I do this to *delete php code* in html page

for example to store in an hash table the keys values I do :

sub loadLanguage {
    $lang = $query->param("lang");
    $lang = uc ($lang);
    open (FILE, "<$dirLang/$lang.conf") or die "cannot open file
    while (<FILE>) {
    (local our  $label, local our  $value) = split(/=/);
    $SERVER = $value;    
    close (FILE);

Re: replace

then I open the corresponding page ( I don't want to change the way I
work in perl I want to do it in php right now)):

sub loadMixTape {
    open (FILE, "<$dir/mix_tape.html") or die "cannot open file
    local our $menu = loadMenu();
    my $string4 = weekNews ();
    local our $cats = getCat();
    local our $content;
    while (<FILE>) {
        s/$LABEL/ exists $SERVER ? $SERVER : $1 /eg;
        $content .= $_;
    $content = Compress::Zlib::memGzip($content)  if $can_do_gzip; ;
    print "Content-Length: ", length($content) , "\n";
    print "Content-Encoding: gzip\n" ;
    print "Content-Type: text/html\n\n";
    print $content;
    close (FILE);    

Site Timeline