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

Hi again, Many thanks for the help with my last problem Splitting a File - I now have a second part to that - to populate the data into a web template.

The following data is in array @allow_edit

binary_app=/usr/bin/true config_file=/etc/inetd.conf MOD_NAME="ABC"

I need to get the data from that array then split the lines at the = signs & keep the = signs, then put the rest of each line into a web form:

Once I have done this, I need to output the rest of each line after the = signs & print it to an HTML page ready for changing.

I have no idea where to start with this - can anyone offer assistance on this please? Many thanks, Terry

  • Comment on Populating a web template then pulling combining temp files & writing out to replace file
  • Download Code

Replies are listed 'Best First'.
Re: Populating a web template then pulling combining temp files & writing out to replace file
by bowei_99 (Friar) on Mar 20, 2006 at 22:16 UTC
    Since your configuration data isn't all that big of an array, I'd say make it more maintainable, robust and readable by putting the data into a hash instead of an array, i.e. for each configuration file line:
    my %lookup_param_by; ($name, $value) = split /=/, $_; $lookup_param_by{$name} = $value;
    Not sure how you want your form to be laid out, but to print the contents, you could have
    foreach (keys %lookup_param_by) { print "$_ $lookup_param_by{$_}\n"; }

    -- Burvil

      Hi again, Many thanks guys - I will & see if I can get something working from your hints.
Re: Populating a web template then pulling combining temp files & writing out to replace file
by Anonymous Monk on Mar 20, 2006 at 22:07 UTC

    You are difficult to understand. I cannot follow you what you mean with keeping the = signs.

    However, if you just need the right-hand part of each line in the array: (pseudo code following)

    1. iterate over the array 2. split on the = sign, which returns a list of two elements 3. keep the second element (i.e. the right-hand part) and print it out

    You are a grown-up boy. I'm sure you can handle that on your own.