Hi All,
I've got a long list of sub routines in a file, each containing different variable definitions and each saved into a hash like so:-
$hash->{subs}->[0] = sub {
$var1 = "a";
$var2 = "b";
}#sub 0
$hash->{subs}->[1] = sub {
$var1 = "c";
$var2 = "d";
}#sub 1
This file is loaded into my script and the appropriate sub routines for the operation is called. I've got a function in the script that allows you to edit and save an individual routine.
At the moment, I'm reading the file as a string, using a regexp to remove the old sub and replace it with a new one. Then saving the file.
I'm wondering... as I've already got the sub routines loaded into memory, whether it's possible to just redefine the new routine and save all the subroutines in the hash to the file (i.e. saving reading the file as a sting and running the regexp).
Can this be done?
Thanks in advance
Lyle
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.