I appreciate your intent to roll your on, but I instead suggest to use
Text::ParseWords, it's part of Perl standard distribution. You can learn the logic from there, or from other module suggested by other monks in this thread.
#!/usr/bin/perl
use strict;
use warnings;
use Text::ParseWords;
while (<DATA>) {
chomp;
my @parts = parse_line(',', 0, $_);
print join(' ', map { "[$_]" } @parts), "\n";
}
__DATA__
Submitted,"696,028","50,946","810,590","836,505","13,923,241","13,776,
+443","14,179,619","14,614,558","14,704,885","14,634,911","15,055,774"
+,"15,127,534","14,458,899","14,403,378","14,566,425","14,644,406","14
+,524,069"
Expired,245,275,273,248,240,295,353,316,371,398,387,352,310,288,405,27
+4,270
Less in,90.12%,90.49%,90.04%,89.55%,90.09%,90.63%,90.37%,90.48%,90.73%
+,90.59%,90.83%,90.40%,88.82%,90.71%,90.72%,90.69%,91.04%
Output:
[Submitted] [696,028] [50,946] [810,590] [836,505] [13,923,241] [13,77
+6,443] [14,179,619] [14,614,558] [14,704,885] [14,634,911] [15,055,77
+4] [15,127,534] [14,458,899] [14,403,378] [14,566,425] [14,644,406] [
+14,524,069]
[Expired] [245] [275] [273] [248] [240] [295] [353] [316] [371] [398]
+[387] [352] [310] [288] [405] [274] [270]
[Less in] [90.12%] [90.49%] [90.04%] [89.55%] [90.09%] [90.63%] [90.37
+%] [90.48%] [90.73%] [90.59%] [90.83%] [90.40%] [88.82%] [90.71%] [90
+.72%] [90.69%] [91.04%]
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
-
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.