Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: TexT::CSV and getline

by BillKSmith (Monsignor)
on Nov 04, 2020 at 21:43 UTC ( [id://11123411]=note: print w/replies, xml ) Need Help??


in reply to TexT::CSV and getline

Fix your constructor as GrandFather indicated, and your code 'works'. You probably did not intend to output a reference to a filehandle. I have made your test case the default input, and added one line to print $row.
BEGIN{ $ARGV[0] //= \qq(Importance,Company,Department,"Job Title"\n); } use v5.10 ; use strict; use warnings ; use Text::CSV ; use FileHandle ; my $csv = Text::CSV->new({binary => 1}) ; my $fh = new FileHandle ; open( $fh, "<", $ARGV[0]) or die "Can't open $ARGV[0]: $!\n" ; say $fh ; my $row = $csv->getline($fh) ; say do{ local $" = "\n"; "@$row" }; exit

OUTPUT

FileHandle=GLOB(0x8bba28) Importance Company Department Job Title

You do not need both FileHandle and open. Either one will do the job.

Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11123411]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2024-04-23 13:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found