Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gav (2710)

gav
  (email not shown publicly)
http://www.estey.com/
AOL IM: flufflegavin (Add Buddy, Send Message)

Hacker in NYC.

Journal of gav (2710)

Thursday July 18, 2002
12:22 PM

perverted contexts

[ #6459 ]
I had problems with reading XLS files with Spreadsheet::ParseExcel and ending up with a last row which was all undefs. I came up with:

next if @row == grep !$_, @row;

I think that looks quire nice :)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • >     next if @row == grep !$_, @row;

    I'm not familiar with that module, but unless it returns references,
    I can imagine zero being a valid value in a final row. If zero is
    represented by [0] instead of 0 then maybe that's a non issue.

    It sounds like you're expecting an empty string for an empty cell.
    In that case, you could check length or defined instead of truth.

    -matt
    • grep in scalar context returns the number of items in the array that matched. I'm trying to make sure that there is at least 1 non-false value in the row. A row of all zeros would cause it to be skipped, but then that's bad data anyway :)

      Probably this would have been more clear:

      next unless grep $_, @row;

      The module doesn't return rows in any nice way, it's a fantastically useful module but the interface seems too much like Visual Basic for my liking:

      foreach my $r ($sheet->{MinRow}+1 .. $sheet->{Ma

      • I like the DBD::Excel wrapper, myself, but it may not suit your purposes.

        --
        J. David works really hard, has a passion for writing good software, and knows many of the world's best Perl programmers