#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; my $line = q{11/21/2010 05:02 AM 1,572,696,748 IN11-135.E05}; #11/21/2010 05:02 AM 1,572,696,748 IN11-135.E05 #1234567890 12345678 12345678901234567 # date A10 time +A8 size A18 filename the rest # x2 to ignore spaces between date and time my( $date, $time, $sizewithcommas, $name ) = unpack "A10 x2 A8 x1 A18 + A*", $line; dd( [ $date, $time, $sizewithcommas, $name ] ); my $raw = q{ 03/19/2011 04:01 PM 1,451 filename 09/07/2011 05:15 AM <DIR> dirname }; open my($fh), '<', \$raw ; while(<$fh>){ my( $datetime, $filesizeordirindicator, $filename ) = eval { unpack + 'A20 A18 x1 A*', $_ }; warn $@ if $@; dd([ $datetime, $filesizeordirindicator, $filename ]); } __END__ ["11/21/2010", "05:02 AM", " 1,572,696,748", "IN11-135.E05"] 'x' outside of string in unpack at crap line 22, <$fh> line 1. [undef, undef, undef] ["03/19/2011 04:01 PM", " 1,451", "filename"] ["09/07/2011 05:15 AM", " <DIR>", "dirname"]

In reply to Re: How to Remove Commas ? by Anonymous Monk
in thread How to Remove Commas ? by allendevans

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.