On Jul 23, John W. Krahn said:
>Rich Busse wrote:
>>
>> I want to replace the last "#" with a newline. I've come up with a few ideas
>
>$_ = reverse;
>s/#/\n/;
>$_ = reverse;
Here's a (potential) Perl 5.8.1 way of doing it, which is likely to be
faster than the sexeger (reversing approach above)
Rich Busse wrote:
>
> I have a string that looks like
>
> Operator Overview#PGM#Report about all configured
> operators#/opt/OV/bin/OpC/call_sqlplus.sh all_oper#
>
> I want to replace the last "#" with a newline. I've come up with a few ideas
> like
>
> substr ($_, rindex ($_, "#"), 1) = "\n"
Doh! I forgot about using $! All I need is
s/#$/\n/ ;
Thanks to Tor & Tanton for getting my brain in gear...
> -Original Message-
> From: Busse, Rich
> Sent: Tuesday, 23 July, 2002 09:00
> To: 'Perl Beginners'
> Subject: Replace last # with
if you want to use s/// you can say
s/(.*)#/$1\n/;
- Original Message -
From: "Busse, Rich" <[EMAIL PROTECTED]>
To: "Perl Beginners" <[EMAIL PROTECTED]>
Sent: Tuesday, July 23, 2002 9:00 AM
Subject: Replace last # with \n
> I have a string that l
<[EMAIL PROTECTED]> wrote:
> I have a string that looks like
>
> Operator Overview#PGM#Report about all configured
> operators#/opt/OV/bin/OpC/call_sqlplus.sh all_oper#
>
> I want to replace the last "#" with a newline. I've come up with a few ideas
> like
>
> substr ($_, rindex ($_, "#"), 1)
I have a string that looks like
Operator Overview#PGM#Report about all configured
operators#/opt/OV/bin/OpC/call_sqlplus.sh all_oper#
I want to replace the last "#" with a newline. I've come up with a few ideas
like
substr ($_, rindex ($_, "#"), 1) = "\n" ;
or
substr ($_, length ($_) - 1, 1) =