RaduH has asked for the wisdom of the Perl Monks concerning the following question:
into blocks separated by space. Please note the white space in front of the rs_ starting strings (below "Reso" from the first line). That white space may or may not be there. I need to split the strings and I am using this:Resource Group: gr_shared_fs rs_ipaddr (heartbeat::ocf:IPaddr): Started lapg2-a rs_raid1_shared_fs (heartbeat::ocf:Raid1): Started lapg2- +a rs_fs_shared (heartbeat::ocf:Filesystem): Started lapg2- +a
but it seems if I do have that white space there the first element in @statusLineFields is whitespace. If the input lines do not have any leading space then the first element is some rs_ string. I really need to ignore that white space and have the first element be the rs_ string somehow.my @statusLineFields = split(/\s+/, $statusLine);
I have the feeling this is a 1-line quick and easy answer but I've been running circles around my tail and couldn't figure it. In addition to this, once I split the line, the elements of that array (with or without the first one being whitespace) are surrounded by one blank space on each side. That "Started" is actually " Started ". Why is this and how do I get rid of it?
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Another question about the split function
by FunkyMonk (Bishop) on Dec 11, 2007 at 23:10 UTC | |
by pfaut (Priest) on Dec 11, 2007 at 23:16 UTC | |
|
Re: Another question about the split function
by pfaut (Priest) on Dec 11, 2007 at 22:53 UTC | |
|
Re: Another question about the split function
by Fletch (Bishop) on Dec 11, 2007 at 22:54 UTC | |
|
Re: Another question about the split function
by almut (Canon) on Dec 11, 2007 at 22:57 UTC | |
|
Re: Another question about the split function
by downer (Monk) on Dec 11, 2007 at 23:15 UTC |