On Mon, Feb 25, 2013 at 2:38 PM, Brandon McCaig wrote:
> On Sun, Feb 24, 2013 at 11:17:40PM -0300, Brian Fraser wrote:
>> my $over = '';
>> while ( sysread( $fh, $over, 8192, length($over) ) ) {
>> while ( $over =~ /\R/ ) {
>> my $line = encode('UTF-8', substr($over, 0, $+[0], ''));
>
>
On Sun, Feb 24, 2013 at 11:17:40PM -0300, Brian Fraser wrote:
> my $over = '';
> while ( sysread( $fh, $over, 8192, length($over) ) ) {
> while ( $over =~ /\R/ ) {
> my $line = encode('UTF-8', substr($over, 0, $+[0], ''));
I think you meant decode. :) Decode input, encode output. The
int
ft to you. What you do with it is your gift back to God.
---
From: Tiago Hori
To: *Shaji Kalidasan*
Cc: "beginners@perl.org"
Sent: Sunday, 24 February 2013 9:11 PM
Subjec
On Fri, Feb 22, 2013 at 3:08 PM, Tiago Hori wrote:
> Hi All,
>
> One problem that often encounter is with line endings. I have to parse
> several kinds of files routinely and often these are generated in excel and
> therefore it is hard to anticipate which line ending I actually have. It
> seems t
do with it is your gift back to
> God.
>
> ---
>
>
>
> From: Dr.Ruud
> To: beginners@perl.org
> Sent: Sunday, 24 February 2013 4:51 PM
> Subject: Re: Line Endings
>
> On 2013
On 22/02/2013 18:08, Tiago Hori wrote:
What I was wondering is: is there any way to force perl to use other line
ending characters, like MacOS C
The script below will first read the file for 1000 characters and set
the value of $/.
You can then loop through the lines in the usual way.
#!/
o God.
---
From: Dr.Ruud
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/;
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;
On 2013-02-23 00:50, Jim Gibson wrote:
my $content = do { local $/; <$fh> };
Leaner written as:
my $content; { local $/; $content= <$fh> }
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
ji
> -----------
> Your talent is God's gift to you. What you do with it is your gift back to
> God.
> ---
>
>
> - Orig
ent is God's gift to you. What you do with it is your gift back to God.
-----------
- Original Message -
From: Jim Gibson
To: Perl Beginners
Cc:
Sent: Saturday, 23 February 2013 5:20 AM
Subject: Re: Line Endings
On F
On Feb 22, 2013, at 10:40 AM, Andy Bach wrote:
> On Fri, Feb 22, 2013 at 12:08 PM, Tiago Hori wrote:
>
>> What I was wondering is: is there any way to force perl to use other line
>> ending characters, like MacOS CR?
>>
Another approach is to read the entire file into a scalar and then split
On Fri, Feb 22, 2013 at 12:08 PM, Tiago Hori wrote:
> What I was wondering is: is there any way to force perl to use other line
> ending characters, like MacOS CR?
>
Perl's "magic" var "$/" or via "use English" $RS or
$INPUT_RECORD_SEPARATOR (Larry's mnemonic "as in poetry or think a mad
slashe
13 matches
Mail list logo