James Kipp wrote:
> 
> Hi

Hello,

> I want to split the string below into rows and then columns. I know i can do
> a couple of splits, push array refs onto a new array, regex it, etc.. But I
> was know the talented people on this list can shorten the code considerably.
> I want to split at each new line for the row, then split the row into
> columns, and get rid of the "%" on the third column. I can post my
> embarrassingly long code if you like.
> Thanks for any help
> Jim
> ----
> 
> $str = "
> /var                      0.99    50%
> /usr                      0.58    71%
> /tmp                      0.49     1%
> "


$ perl -le'
use Data::Dumper;
my $str = "
/var                      0.99    50%
/usr                      0.58    71%
/tmp                      0.49     1% 
";
print Dumper \$str;
my @new = map [ split ], split /%\s+/, $str;
print Dumper [EMAIL PROTECTED];
'
$VAR1 = \'
/var                      0.99    50%
/usr                      0.58    71%
/tmp                      0.49     1% 
';

$VAR1 = [
          [
            '/var',
            '0.99',
            '50'
          ],
          [
            '/usr',
            '0.58',
            '71'
          ],
          [
            '/tmp',
            '0.49',
            '1'
          ]
        ];



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to