[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Regexp substitution med variable?



Hejsa!

Kan man lave et regexp, hvor der indgår en almindelig variabel i
substitution-udtrykket.

Dvs:

-------------(snip)-------------------
# Lige et hash-array:
my $a;
$a->{"flæskesteg"} = "svin";
$a->{"andesteg"} = "and";

# Init af streng:
my $var = "Til jul spiser vi flæskesteg.";
# (Alternativt):
# my $var = "Til jul spiser vi andesteg.";

$var =~ s/spiser vi ([a-z]*)/æder vi $a->{$1}/;
-------------(snip)-------------------

Jeg vil gerne have det, så $var i ovenstående eksempel skal ende med at
indeholde strengen "Til jul æder vi svin." -- Kan dette lade sig gøre?

I min konkrete opgave står jeg med et hash-array med flere tusinde records
i, som jeg gerne vil slå op....

Nogle idéer?

M.v.h.
Morten 
 





 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 19:55 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *