Re: should this old forumulation still work?

2015-01-20 Thread Charles DeRykus
On Tue, Jan 20, 2015 at 9:12 PM, Uri Guttman wrote: > On 01/20/2015 11:28 PM, Charles DeRykus wrote: >>> >>> ... >>> or something odd >>>my $contents = do { local $/; map { chomp } }; >>> >> I'm afraid this, while appealing, in my testing generates an >> incorrect result, ie, 1. >> >> >>

Re: should this old forumulation still work?

2015-01-20 Thread Uri Guttman
On 01/20/2015 11:28 PM, Charles DeRykus wrote: ... or something odd my $contents = do { local $/; map { chomp } }; I'm afraid this, while appealing, in my testing generates an incorrect result, ie, 1. What happens I suspect is that the map{ } is in void context, not the scalar context

Re: should this old forumulation still work?

2015-01-20 Thread Uri Guttman
On 01/20/2015 10:03 PM, Brandon McCaig wrote: Uri Guttman, the author of File::Slurp, insists that it performs much better than the standard Perl solution of setting $/ to undef. I don't have benchmarks to prove it, but I'm willing to trust his expertise on this. I imagine if you inspect the cod

Re: should this old forumulation still work?

2015-01-20 Thread Charles DeRykus
> ... > or something odd > my $contents = do { local $/; map { chomp } }; > I'm afraid this, while appealing, in my testing generates an incorrect result, ie, 1. What happens I suspect is that the map{ } is in void context, not the scalar context of the outer do{}. Remember parsers are no

Re: should this old forumulation still work?

2015-01-20 Thread Brandon McCaig
Andy: On Tue, Jan 20, 2015 at 05:56:26PM -0600, Andy Bach wrote: > my $contents = do { local $/; map { chomp } }; > > sorry, untested. chomp() returns a number representing the number of removed characters unfortunately. Your block would need to return $_ separately. (I find this rather annoy

Re: should this old forumulation still work?

2015-01-20 Thread Andy Bach
On Tue, Jan 20, 2015 at 4:10 PM, Harry Putnam wrote: > Randal responded: > >I just go: > >my $contents = do { local $/; }; > I think you misunderstood what "slurping" is here and, maybe, the potential for multiline scalars. perldoc perlvar has: You should be very careful when modifying

Re: should this old forumulation still work?

2015-01-20 Thread Andrew Solomon
Hi Harry I was about to try to explain it but sometimes a picture is worth a thousand words (even if it's a picture of code:) === 22:35 ~/tmp $ cat bar.txt this is a very long test 22:35 ~/tmp $ cat foo.pl #!/usr/bin/perl use strict; use warnings; my $arg

should this old forumulation still work?

2015-01-20 Thread Harry Putnam
I found this little snippet in a post (from 2000) by Randal L. Schwartz: http://www.perlmonks.org/?node_id=20235 The discussion was about: File::Slurp allows you read a filehandle into a scalar. However there is another way to do this without having to load an extra module at runtime. Th

Re: [perl-108] Fwd: Online Perl courses for PM list Newbies

2015-01-20 Thread Andy Bach
A while back Andrew Solomon wrote: > > For the last few years I've been developing Geekuni to provide an > >> automated online 'tutor-bot' to help new users learn Perl. > >> > >> I've been beta testing it on people at the London Perl Workshop as > >> well as graduate recruits at NET-A-PORTER - on

Re: Looping regexes against a list

2015-01-20 Thread Charles DeRykus
On Tue, Jan 20, 2015 at 9:47 AM, Mike Martin wrote: > Thanks for the idea about qr, I did try this before, but I've now relooked > at at it and got about 75% improvement. > > As regards the uninitialized point the errors were coming from regexes > (different ones) when the regex wasnt matching, so

Re: Looping regexes against a list

2015-01-20 Thread Shawn H Corey
On Tue, 20 Jan 2015 17:47:58 + Mike Martin wrote: > Take a load of Job Vacancy posts (xml files - loads of) > Parse the Information, getting rid of as much garbage as possible > Push a distinct list into a lookup hash If you're running Linux (or any POSIX), see `man sort` and search for /-u/

Re: Looping regexes against a list

2015-01-20 Thread Mike Martin
Thanks for the idea about qr, I did try this before, but I've now relooked at at it and got about 75% improvement. As regards the uninitialized point the errors were coming from regexes (different ones) when the regex wasnt matching, so testing the result of each regex match was not really an opti

Re: Looping regexes against a list

2015-01-20 Thread Shawn H Corey
What the OP should do is put the regexes in a Perl module and unroll the loop. That way, he can group them so that groups of tests are skipped: # strings containing "foo" if( /foo/ ){ return "food" if /food/; return "fool" if /fool/; return "foot" if /foot/; return "foo"; } --

Re: Looping regexes against a list

2015-01-20 Thread Shawn H Corey
On Tue, 20 Jan 2015 10:23:42 -0500 Brandon McCaig wrote: > On Tue, Jan 20, 2015 at 10:21 AM, Brandon McCaig > wrote: > > perldoc -f qr// > > I was sure that worked in my up-to-date perlbrew environments, but it > isn't working in Cygwin running perl 5.14.2 so in the event that it > doesn't work

Re: Looping regexes against a list

2015-01-20 Thread Brandon McCaig
On Tue, Jan 20, 2015 at 10:21 AM, Brandon McCaig wrote: > perldoc -f qr// I was sure that worked in my up-to-date perlbrew environments, but it isn't working in Cygwin running perl 5.14.2 so in the event that it doesn't work for you look at `perldoc -f qr' and `perldoc perlop' (then search for "q

Re: Looping regexes against a list

2015-01-20 Thread Brandon McCaig
On Tue, Jan 20, 2015 at 9:51 AM, Andrew Solomon wrote: > Aside from this lengthy rant^H^H^H^H discussion:) about where you put > your regex, have you made any progress on the performance problem you > put forward at the outset? I'm not quite sure that I understand what the OP is doing still, but

Re: Looping regexes against a list

2015-01-20 Thread Andrew Solomon
Hey Mike Aside from this lengthy rant^H^H^H^H discussion:) about where you put your regex, have you made any progress on the performance problem you put forward at the outset? cheers Andrew On Tue, Jan 20, 2015 at 6:41 AM, Danny Spell wrote: > For me, regex can be simple or complex. > It depen