Skip Menu |

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

Report information
The Basics
Id: 76945
Status: resolved
Priority: 0/
Queue: Text-xSV-Slurp

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

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



Subject: Please add support for <DATA>
It would be great if this program were to work: #!/usr/bin/perl -wT use strict; use warnings; use diagnostics; use Text::xSV::Slurp; my $t = xsv_slurp( shape => 'aoh', text_csv => { sep_char => '!' }, string => <DATA>, ); foreach (@{$t}) { print $_->{name}; print "\n"; } __END__ f1!f2!f3 v1!v2!v3 w1!w2!w3
(Sorry, not in a place where I can run this at the moment.) At a glance it looks like your losing all but the first line after __END__. What happens if you change this line from: string => <DATA>, To: string => join( '', <DATA>),sear Or: handle => \*DATA, - danboo
On Wed May 02 16:27:39 2012, DANBOO wrote: Show quoted text
> > string => join( '', <DATA>),sear
Odd, not sure where that 'sear' came from. That should read: string => join( '', <DATA> ),
Nice ideas, however both suggestions print this: Use of uninitialized value in print at ./slurp3 line 17, <DATA> line 5 (#1)
On Thu May 03 04:50:58 2012, NHORNE wrote: Show quoted text
> Nice ideas, however both suggestions print this: > > Use of uninitialized value in print at ./slurp3 line 17, <DATA> line 5
(#1) Ahh, you also need to change: print $_->{name}; To: print $_->{f1}; Or one of the other fields given.
D'oh. Of course you do - silly cut 'n' paste error! Thanks. Thanks - both options now work. Now if only I could work out how to get it to handle comment lines and ignore blank ones. My __DATA__ section would then be much more readable for humans. __END__ h1!h2!h3 v1!v2!v3 w1!w2!w3 # ignore me please x1!x2!x3
On Thu May 03 12:02:13 2012, NHORNE wrote: Show quoted text
> D'oh. Of course you do - silly cut 'n' paste error! Thanks. > > Thanks - both options now work. > > Now if only I could work out how to get it to handle comment lines and > ignore blank ones. My __DATA__ section would then be much more
readable Show quoted text
> for humans. > > __END__ > h1!h2!h3 > > v1!v2!v3 > w1!w2!w3 > # ignore me please > x1!x2!x3 > >
my $clean_xsv_string = join '', grep ! /^\s*(#|$)/, <DATA>;
That works a treat, thanks.