develooper Front page | perl.perl6.users | Postings from July 2017

String to array problem

Thread Next
From:
ToddAndMargo
Date:
July 16, 2017 23:41
Subject:
String to array problem
Message ID:
e96ecb40-b436-07ea-d1aa-505c45fd12ed@zoho.com
Hi All,

I have been scratching my head trying to figure out
how to turn a string with quotes in it into an array.

my $x='ls -al "Program Files" "Moe Curly Larry"';

Desired result:
my @y;
    $y[0] = 'ls';
    $y[1] = '-la';
    $y[2] = 'Program Files';
    $y[3] = 'Moe Curly Larry';

Any words of wisdom?

Many thanks,
-T

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About