[Chicago-talk] messy scalar into an array.

Richard Reina richard at rushlogistics.com
Tue Mar 2 06:46:47 PST 2010

I'm sorry for asking what likely should be a simple question but after spending a fair amount of time playing with qw(), split(), join(), etc. I still have not figured it out.

I have some fairly messy system output which I have managed to isolate into a scalar with 

use strict;
my @received = `faxstat -r`;

I can't figure out how to neatly get this into an array so I can get the output into a database table;

I've gotten this far;

my $line;
my @fax;

foreach $line (@received) {
    if (substr($line,0,5) eq "-rw---") { # make sure it's an actual fax 
                                         # and not the title of the output

$line is exactly what I want but it's in the form of a scalar;  When I try to split it up into elements of an array with @fax=split("", $line); it does not work due to all the back to back white spaces.  If anyone can help me out with a better way to do this I would really appreciate it.



More information about the Chicago-talk mailing list