[Chicago-talk] messy scalar into an array.

Alan Mead amead at alanmead.org
Tue Mar 2 07:24:24 PST 2010


Would this help?  (I don't understand what the line format is): $line =~ 
s/\s+/ /g;

On 3/2/2010 8:46 AM, Richard Reina wrote:
> 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
>          chomp($line);
>      }
> }
>
> $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.
>
> Thanks,
>
> Richard
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk
>
>    


-- 
Alan D. Mead, Ph.D.
Assistant Professor, Institute of Psychology
Scientific Adviser, Center for Research and Service
Illinois Institute of Technology
3101 South Dearborn, 2nd floor
Chicago IL 60616

Skype: alandmead
+312.567.5933 (Campus)
+815.588.3846 (Home Office)
+312.567.3493 (Fax)

http://mypages.iit.edu/~mead
http://www.center.iit.edu
http://www.alanmead.org

I slept and dreamt that life was joy.
I awoke and saw that life was service.
I acted and behold, service was joy.
  -- attributed to Rabindranath Tagore



More information about the Chicago-talk mailing list