in reply to Re: Re: Datafile doesn't update before being read
in thread Datafile doesn't update before being read

Your'e welcome. I (and others doubtless) applaud your desire to be modular. How about this, then?: take your subroutine for printing output from an array. Not sure what you're calling this - say print_page. Now, instead of making @strmeta a global, make a local variable and pass a reference to it to the subroutine.

That is, call your subroutine like
my @strmeta = ..... [...] print_page(\@strmeta);
Then in the subroutine make the first line
my $strmeta = shift;
And thereafter, where before you had @strmeta use @$strmeta, and where you had $strmeta[$foo] put $strmeta->[$foo] - which will "de-reference" (i.e. get the data out of) your reference $strmeta.

Then, if you set it up like that, you can call the same subroutine from two different points in your script - (a) when you've created @strmeta from your form input, and (b) when you've created it from retrieved data. Your subroutine won't care where the data comes from, so long as it comes in an array reference.

For your last trick, put print_page() in a module, and use it in all your other scripts!

Enjoy!

§ George Sherston