Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

muba already helped you with the basics, which were quite well explained. muba++. Text::CSV is a wrapper over Text::CSV_XS and Text::CSV_PP. Whatever is developed in Text::CSV_XS is copied into Text::CSV_PP making them behave exacly the same, but the XS version is up to 100 times as fast. Both act on streams of data, wheather that is a file or a pipe. That means that these modules do not allow to go "back" into the stream to look at previous lines. As muba already mentioned, getline_hr_all can be very handy here.

If you need to do many lookups, like in a spreadsheet or a database, consider using DBD::CSV (when you are acquainted with DBI) or Spreadsheet::Read, which enables you to look at CSV file with the eye of a spreadsheet and enables you to direct access any field in a CSV data structure.

One final remark about your original code. The "loop" could easily be shortened a lot:

my @ftpFiles =$ftp->ls (); + my $i = 0; while ($i < $#ftpFiles) { + if ($ftpFiles[$i] =~ m/andv/) { $ftp->get ($ftpFiles[$i]); $myfile = $ftp; } $i++; } $ftp->quit (); => foreach my $file (grep m/andv/ => $ftp->ls ()) { $ftp->get ($file); $myfile = $file; # <= your original code probably does not do what + you want } $ftp->quit ();

update: corrected mumba to muba. sorry.


Enjoy, Have FUN! H.Merijn

In reply to Re^7: Parse .csv file from FTP using Perl by Tux
in thread Parse .csv file from FTP using Perl by Sherlock Perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-03-19 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found