Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://983765]
help
Chatterbox?
[mz2255]: I'm trying to post a question to "seekers of perl wisdom" but always getting a permission denied when I want to submit. There are no links in my post...
[ambrus]: again? someone complained about this just a few days ago (although eventually they could post)
[choroba]: Can you post the question in mz2255's scratchpad?
[ambrus]: Corion, if you're here, can you check the spam filter logs to see what's triggering this time?
[ambrus]: Petroza had trouble posting yesterday, but has posted Issues Fetching URL with a variable token since.
[mz2255]: Yes, just edited the scratchpad. Not sure if I'm doing something wrong, it's my first time.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2017-10-19 15:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (255 votes). Check out past polls.

    Notices?