Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Print array, splitting into 2 strings

by reasonablekeith (Deacon)
on Mar 24, 2006 at 11:20 UTC ( [id://538995]=note: print w/replies, xml ) Need Help??


in reply to Print array, splitting into 2 strings

no-one's given a printf example yet. I think it's a bit easier to read, without all the quotes and temporary variables...
my @array = ( 'binary_app=/usr/bin/true', 'config_file=/etc/inetd.conf', 'MOD_NAME="ABC"' ); printf qq|<input type=text name="%s" value="%s">\n|, split '=' for @ar +ray;
as mentioned above, you'll need to do something about those double quotes. Here's an example that will just swap all double quotes to singles...
printf qq|<input type=text name="%s" value="%s">\n|, map {s/"/'/g; $_} + split '=' for @array;
---
my name's not Keith, and I'm not reasonable.

Log In?
Username:
Password:

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

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

    No recent polls found