On 09-09-10 11:50, R.I.Pienaar wrote: >> In the function reference [1], I found a 'split' function for >> splitting a >> string into an array, but not a 'join' function for joining an array >> into >> a string. Why not? :) >> >> I have a list of IP addresses, that I use with ssh_authorized_key to >> restrict access. The list is now simply a comma-separated list in a >> string, but if I want to use the list for other purposes as well, I >> thought it might be better to store the list as an array and join() >> it >> with the proper glue whenever needed. >> >> What do you recommend? > > - you can write a join function and contribute it to the project, they are > very easy to write
I have added this function to my 'common' module: puppet$ cat modules/common/lib/puppet/parser/functions/join.rb module Puppet::Parser::Functions newfunction(:join, :type => :rvalue) do |args| args[0].join(args[1]) end end I didn't come up with it myself though, I found it on the web somewhere. Looking at the source for the 'split' function, I guess the function needs documentation and maybe some error checking, like the number of arguments. How would I contribute something like this to the project? > - you can use something like $ips = inline_template("<%= > ipaddress.split(/,/).join(' ') %>") > or use regex or something like that. Thanks! Martijn.
smime.p7s
Description: S/MIME Cryptographic Signature