Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: passing a variable value to Unix command

by DrHyde (Prior)
on Oct 20, 2010 at 10:06 UTC ( [id://866283]=note: print w/replies, xml ) Need Help??


in reply to passing a variable value to Unix command

First, if you want to append a * to the value, it needs to be quoted:

my $name = $k."*";

Second, running that command several times, once for each element in the list, can be veeeeerrrryyyyy ssllllloooooooowwww. Most (all?) platforms' find utilities will let you do something like this ...

my $args = join(" -o ", map { "-name \"$_*\" -print" } @a); $x = `find . $cmd`;
and do it all in one go. Although obviously at some point you're going to run into command line length limitations.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-19 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found