Skip Menu |

This queue is for tickets about the File-Slurp CPAN distribution.

Report information
The Basics
Id: 63136
Status: resolved
Priority: 0/
Queue: File-Slurp

People
Owner: Nobody in particular
Requestors: sharyanto [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 9999.13
Fixed in: (no value)



Subject: an autochomp reading mode?
I read one-line files a lot. They usually contain a single variable/ parameter, and usually produced from the command-line, e.g. 'echo foo@bar Show quoted text
> email'. As such, they contain newline which I almost always have to
chomp. Adding something like 'autochomp' option would certainly convenient: read_file('foo.txt', autochomp => 1). Regards, Steven
On Fri Nov 19 01:14:47 2010, SHARYANTO wrote: Show quoted text
> I read one-line files a lot. They usually contain a single variable/ > parameter, and usually produced from the command-line, e.g. 'echo
foo@bar Show quoted text
> > email'. As such, they contain newline which I almost always have to
> chomp. > > Adding something like 'autochomp' option would certainly convenient: > > read_file('foo.txt', autochomp => 1). > > Regards, > Steven
Or chomp => 1, for that matter. Regards, Steven
CC: undisclosed-recipients: ;
Subject: Re: [rt.cpan.org #63136] an autochomp reading mode?
Date: Fri, 19 Nov 2010 01:22:37 -0500
To: bug-File-Slurp [...] rt.cpan.org
From: "Uri Guttman" <uri [...] StemSystems.com>
Show quoted text
>>>>> "shvR" == steven haryanto via RT <bug-File-Slurp@rt.cpan.org> writes:
Show quoted text
shvR> Fri Nov 19 01:14:47 2010: Request 63136 was acted upon. shvR> Transaction: Ticket created by SHARYANTO shvR> Queue: File-Slurp shvR> Subject: an autochomp reading mode? shvR> Broken in: 9999.13 shvR> Severity: Wishlist shvR> Owner: Nobody shvR> Requestors: sharyanto@cpan.org shvR> Status: new shvR> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=63136 >
Show quoted text
shvR> I read one-line files a lot. They usually contain a single variable/ shvR> parameter, and usually produced from the command-line, e.g. 'echo foo@bar
Show quoted text
>> email'. As such, they contain newline which I almost always have to
Show quoted text
shvR> chomp.
Show quoted text
shvR> Adding something like 'autochomp' option would certainly convenient:
Show quoted text
shvR> read_file('foo.txt', autochomp => 1).
that is in my todo queue. a new release is due soon with a lot of fixes and interesting improvements. that one will go into the next release. the problem with your idea is how do you autochomp multiple lines when slurping to a scalar? so that option will only work if you slurp to an array or array ref. thanx, uri -- Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
On Fri Nov 19 01:22:49 2010, uri@stemsystems.com wrote: Show quoted text
> shvR> Adding something like 'autochomp' option would certainly
> convenient: >
> shvR> read_file('foo.txt', autochomp => 1).
> > that is in my todo queue. a new release is due soon with a lot of > fixes > and interesting improvements. that one will go into the next release.
Nice to know that a new release is imminent! Show quoted text
> the problem with your idea is how do you autochomp multiple lines when > slurping to a scalar? so that option will only work if you slurp to an > array or array ref.
You don't. In a scalar context, we can just chomp the whole file once. That makes perfect sense for one-line files in my case, and doesn't make much sense in a multiple-line files anyway. Of course we can chomp each line in array context. Regards, Steven
CC: undisclosed-recipients: ;
Subject: Re: [rt.cpan.org #63136] an autochomp reading mode?
Date: Fri, 19 Nov 2010 02:30:24 -0500
To: bug-File-Slurp [...] rt.cpan.org
From: "Uri Guttman" <uri [...] StemSystems.com>
Show quoted text
>>>>> "shvR" == steven haryanto via RT <bug-File-Slurp@rt.cpan.org> writes:
Show quoted text
shvR> Queue: File-Slurp shvR> Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=63136 >
Show quoted text
shvR> On Fri Nov 19 01:22:49 2010, uri@stemsystems.com wrote: shvR> Adding something like 'autochomp' option would certainly
Show quoted text
>> convenient: >>
Show quoted text
shvR> read_file('foo.txt', autochomp => 1).
Show quoted text
>> >> that is in my todo queue. a new release is due soon with a lot of >> fixes >> and interesting improvements. that one will go into the next release.
Show quoted text
shvR> Nice to know that a new release is imminent!
i need to finish up some cleaning up of a couple of tests and docs. but it still takes time i don't seem to have! Show quoted text
>> the problem with your idea is how do you autochomp multiple lines when >> slurping to a scalar? so that option will only work if you slurp to an >> array or array ref.
Show quoted text
shvR> You don't. In a scalar context, we can just chomp the whole file once. shvR> That makes perfect sense for one-line files in my case, and doesn't shvR> make much sense in a multiple-line files anyway. Of course we can chomp shvR> each line in array context.
well, i can enable it for scalars but it will only make sense for one line files. i will doc it that way. uri -- Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
done. reinstall it from cpan