[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
 

Re: [PERL] Flere "substitutes" på én linie [NEWBIE]



Tak for hjælpen René. Det var ikke lige hvad jeg havde håbet på, men det er
bedre end ingenting ;-)

/Christian

----- Original Message -----
From: René Seindal <sslug@sslug>
To: <sslug@sslug>
Sent: Saturday, March 25, 2000 5:37 AM
Subject: Re: [PERL] Flere "substitutes" på én linie [NEWBIE]


> Helt på en linie er det ikke, men hvis du alligevel har de strenge du
> vil erstatte som nøgler i et hash, og du vil erstatte med værdien fra
> hashet, så kan du bruge:
>
>     my $regex = ('(' . join('|', map {quotemeta($_)} keys(%hash)) . ')'
> );
>     $text =~ s/$regex/$hash{$1}/ge;
>
> I dit tilfælde har du så %hash = ( Jan=>'01', Feb=>'02', Mar=>'03',
> ...);
>
> Christian Sandfeld wrote:
> >
> > Lad mig starte med at sige at jeg er en "Perl Newbiew", så jeg unskylder
på forhånd hvis spørgsmålet er banalt ;-)
> >
> > Er der nogen der kan fortælle mig hvordan jeg "erstatter" flere ting i
samme variabel på én linie ?
> >
> > Hvordan får jeg f.eks. dette over på én linie:
> > $month =~ s/Jan/01/g;
> > $month =~ s/Feb/02/g;
> > $month =~ s/Mar/03/g;
> >
> > Mvh.
> >
> > Christian
>
> --
> René Seindal (sslug@sslug) http://www.seindal.dk/rene/
>



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 19:52 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] *