Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Split string into array

by Anonymous Monk
on Dec 14, 2011 at 14:51 UTC ( [id://943560]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have the following string printed via DataDumper
$VAR1 = 'Printer1 Printer Printer 1 Printer2 Printer Printer 2 Store Printer Store printer ';
How can I split this string to get only the printer name (e.g. first word, skip the next two, next word, skip the next two) into an array? Thanks

Replies are listed 'Best First'.
Re: Split string into array
by Tux (Canon) on Dec 14, 2011 at 14:54 UTC
    my @printers = ($VAR1 =~ m{^ (\S+) }gmx);

    Enjoy, Have FUN! H.Merijn
      thanks, works perfectly.
Re: Split string into array
by moritz (Cardinal) on Dec 14, 2011 at 14:53 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://943560]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-23 09:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found