Beefy Boxes and Bandwidth Generously Provided by pair Networks chromatic writing perl on a camel
We don't bite newbies here... much
 
PerlMonks  

Re^2: Chomp is removing the whole word instead of the newline

by slayedbylucifer (Scribe)
on Jul 26, 2012 at 03:49 UTC ( #983765=note: print w/ replies, xml ) Need Help??


in reply to Re: Chomp is removing the whole word instead of the newline
in thread Chomp is removing the whole word instead of the newline

So, I was quite frustrated with this easy looking task bugging me for the whole day long. I really appreciate everyone who responded.

Finaly I ended up using Text::CSV perl module and then calling each of the CSV field as array reference. There was no need left to run the chomp after using Text::CSV.

Here is the code:

#!/usr/bin/perl use warnings; use strict; use Text::CSV; my $csv = Text::CSV->new ( { binary => 1 } ) # should set binary attr +ibute. or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $fh, "<:encoding(utf8)", "vm.csv" or die "vm.csv: $!"; <$fh>; ## this is to remove the column headers. while ( my $row = $csv->getline ($fh) ) { print $row->[1]; }

and here is hte output:

fd1fd2fd3fd4

Later i was pulled these individual values and inserted into the DB.

Thanks everyone.


Comment on Re^2: Chomp is removing the whole word instead of the newline
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-04-21 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls