Front page | perl.beginners |
Postings from March 2008
Re: subroutine
Thread Previous
|
Thread Next
From:
Chas. Owens
Date:
March 26, 2008 09:40
Subject:
Re: subroutine
On Wed, Mar 26, 2008 at 12:32 PM, Bobby <cybercruiserz@yahoo.com> wrote:
> Chas,
>
> Thanks for all your pointers. I guess i should read a Perl book first before
> attempting to write codes in it :). I'm learning the hard way but making
> small progresses. I was using what little knowledge i have and duck taped my
> way around the problem. Maybe one day i will get this Perl thing down, look
> back and laugh at this.
>
> I got one more issue with this script that i don't know how to resolve yet,
> hopefully one of you could help me out. Using Chas's code:
>
>
> $strA =~ s/,([^,]+)/,(AND($strLevel:$1))/g;
>
> which produces
>
> a,(AND(PSC_L0:b)),(AND(PSC_L0:c)),(AND(PSC_L0:d))
>
> How do i put the (AND(PSC_L0:a)), for the first character in the $PSC_L0
> var? Right now the regex is substituting the text after the comma.
>
> Current out put:
> a,(AND(PSC_L0:b)),(AND(PSC_L0:c)),(AND(PSC_L0:d))
>
> Desired output:
> (AND(PSC_L0:a)), (AND(PSC_L0:b)),(AND(PSC_L0:c)),(AND(PSC_L0:d))
snip
$strA =~ s/([^,]+)/(AND($strLevel:$1))/g;
or possibly
$strA =~ s/([^,]+)/(AND($strLevel:$1))/g if $strA =~ /,/;
If you don't want lines that have no commas to be affected.
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
Thread Previous
|
Thread Next