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

Report information
The Basics
Id:
43806
Status:
resolved
Priority:
Low/Low
Queue:

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

BugTracker
Severity:
Unimportant
Broken in:
(no value)
Fixed in:
0.61



Subject: Documentation of print() method
Hello Merijn, the documentation of the print() method says: Note, this implies that the following is wrong: open FILE, ">", "whatever"; $status = $csv->print (\*FILE, $colref); The glob "\*FILE" is not an object, thus it doesn’t have a print method. But the following script works as expected: #!/usr/bin/perl use strict; use Text::CSV_XS; my $csv = Text::CSV_XS->new({eol => "\012"}); open my $FILE, ">", "whatever" or die $!; $csv->print($FILE, [1..10]); __END__ $ perl csv.pl $ cat whatever 1,2,3,4,5,6,7,8,9,10 I vaguely remember that one can use methods on file globs if IO::Handle or something similar was loaded before. Regards, Slaven
Subject: Re: [rt.cpan.org #43806] Documentation of print () method
Date: Tue, 3 Mar 2009 13:09:19 +0100
To: bug-Text-CSV_XS@rt.cpan.org
From: "H.Merijn Brand" <h.m.brand@xs4all.nl>
On Tue, 03 Mar 2009 06:31:07 -0500, "Slaven_Rezic via RT" <bug-Text-CSV_XS@rt.cpan.org> wrote:
Show quoted text
> I vaguely remember that one can use methods on file globs if IO::Handle > or something similar was loaded before.
IO::Handle is automatically loaded when needed since version 0.36, which has changed the requirements just a little bit. Text-CSV_XS 108 > perl5.10.0 test.pl Text-CSV_XS 109 > perl5.8.0 test.pl Text-CSV_XS 110 > perl5.8.0 test.pl Text-CSV_XS 111 > perl5.6.2 test.pl Useless use of hash element in void context at /pro/lib/perl5/site_perl/5.6.2/i686-linux-thread-multi-64int/Text/CSV_XS.pm line 91. Text-CSV_XS 112 > perl5.00504 test.pl Can't call method "print" on unblessed reference at test.pl line 6. Text-CSV_XS 113 > cat test.pl #!/pro/bin/perl use strict; use Text::CSV_XS; my $csv = Text::CSV_XS->new ({eol => "\012"}); open FILE, ">whatever.csv" or die $!; $csv->print (\*FILE, [1..10]); $csv->error_diag; close FILE; unlink "whatever.csv"; Text-CSV_XS 114 > I have changed that section like so: --8<--- =head2 print $status = $csv->print ($io, $colref); Similar to combine, but it expects an array ref as input (not an array!) and the resulting string is not really created, but immediately written to the I<$io> object, typically an IO handle or any other object that offers a I<print> method. Note, this implies that the following is wrong in perl 5.005_xx and older: open FILE, ">", "whatever"; $status = $csv->print (\*FILE, $colref); as in perl 5.005 and older, the glob C<\*FILE> is not an object, thus it doesn't have a print method. The solution is to use an IO::File object or to hide the glob behind an IO::Wrap object. See L<IO::File(3)> and L<IO::Wrap(3)> for details. For performance reasons the print method doesn't create a result string. In particular the I<$csv-E<gt>string ()>, I<$csv-E<gt>status ()>, I<$csv->fields ()> and I<$csv-E<gt>error_input ()> methods are meaningless after executing this method. -->8--- -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, SuSE 10.1, 10.3, and 11.0, AIX 5.2, and Cygwin. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.