Tiago,
|
To count multiple characters tr/// won't work.

So this uses a global match in list context, then assigns the result to a 
scalar, producing a count of the number of matches.

my $crlf =()= $content =~ /\r\n/g;


Note :- The above is the ordinary assignment operator. In a scalar context, it 
assigns the right operand's value to the left operand. In a list context, it 
assigns multiple values to the left array operand if the right operand is a 
list.
 

best,
Shaji 
-------------------------------------------------------------------------------
Your talent is God's gift to you. What you do with it is your gift back to God.
-------------------------------------------------------------------------------


________________________________
 From: Tiago Hori <tiago.h...@gmail.com>
To: *Shaji Kalidasan* <shajiin...@yahoo.com> 
Cc: "beginners@perl.org" <beginners@perl.org> 
Sent: Sunday, 24 February 2013 9:11 PM
Subject: Re: Line Endings
 
Hey Everybody,

Thanks again.

I just have a quick question. When you do the CRLF count (for windows
files) using a match with the binding operator, why is the $crlf variable
set to () first?

Thanks,

Tiago



On Sun, Feb 24, 2013 at 8:13 AM, *Shaji Kalidasan* <shajiin...@yahoo.com>wrote:

> Greetings,
>
> Thank you very much for your suggestions and alternatives Dr. Ruud.
>
> It is greatly appreciated.
>
> best,
> Shaji
>
> -------------------------------------------------------------------------------
> Your talent is God's gift to you. What you do with it is your gift back to
> God.
>
> -------------------------------------------------------------------------------
>
>
> ________________________________
>  From: Dr.Ruud <rvtol+use...@isolution.nl>
> To: beginners@perl.org
> Sent: Sunday, 24 February 2013 4:51 PM
> Subject: Re: Line Endings
>
> On 2013-02-23 01:51, *Shaji Kalidasan* wrote:
>
> > my $cr = $content =~ tr/\r/\r/;
> > my $lf = $content =~ tr/\n/\n/;
> > my $crlf = $content =~ s/\r\n/\r\n/g;
>
> See also 'perldoc -q count'.
>
> Alternatives:
>
>   my $cr = $content =~ tr/\r//;
>   my $lf = $content =~ tr/\n//;
>   my $crlf =()= $content =~ /\r\n/g;
>
> -- Ruud
>
>
> -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>



-- 
"Education is not to be used to promote obscurantism." - Theodonius
Dobzhansky.

"Gracias a la vida que me ha dado tanto
Me ha dado el sonido y el abecedario
Con él, las palabras que pienso y declaro
Madre, amigo, hermano
Y luz alumbrando la ruta del alma del que estoy amando

Gracias a la vida que me ha dado tanto
Me ha dado la marcha de mis pies cansados
Con ellos anduve ciudades y charcos
Playas y desiertos, montañas y llanos
Y la casa tuya, tu calle y tu patio"

Violeta Parra - Gracias a la Vida

Tiago S. F. Hori. PhD.
Ocean Science Center-Memorial University of Newfoundland

Reply via email to