[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: [PROGRAMMERING] bash script, substitution



Carsten Svaneborg <sslug@sslug> writes:

> /e betyder at "$1XXX$2" tolkes som perlcode og ikke
> strengen der skal substituteres ind, og $1 og $2 referere
> til hvad der matches af de to par af parenteser i det regulære
> udtryk.

Der er ingen grund til at bruge /e når indholdet bare er noget
der er pakket ind i dobbelt-quotes.

> Et simplere alternativ med split og join
>
> for hver linie:
> {
> @test = split "\t",$linie;
> $test[8]="XXX".$test[8];
> print join "\t",@test;
> }

Som med en one-liner ville kunne skrives:

  perl -anF'\t' -e '$F[8] = "XXX".$F[8]; print join"\t",@F'

-- 
 Peter Makholm     |                You know what the chain of command is?
 sslug@sslug |    It's the chain I go get and beat you with 'til you
 http://hacking.dk |             understand who's in ruttin' command here.
                   |                                         -- Jayne Cobb


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-02-01, 02:01 CET [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] *