There are multiple bugs in there. Off the top of my head, the
worst ones are:
- You're not assigning the return from "generatePassword" to a
variable, so there's no way that "pleaseGodWork" can do anything
with it.
- You need to make the change to the appropriate line in
@copy_this, e.g.
for (@copy_this) {
s{ \*\*\* password \*\*\* }{$password}xms;
}
- the "open (MYFILE" line is missing the '<' you need to
indicate read access, and while you're at it you might as well be
using open in the modern style:
open my $myfile_fh, '<', $readfile or die "Can't open $readfile
+for input: $!"
Further, it makes no sense to do those "close"
operations after the end of the sub. If you're going to do
them explicitly at all, put them inside the sub.
There are a number of other stylistic objections that could be
made: I would name the subs "generate_password" and "please_god_work"
myself, and I'd probably slurp the whole file into one string
like so:
undef $/; my $myfile = <$myfile_fh>;, so then the change could
be made in one step $myfile =~ s{\*\*\* password \*\*\*}{$password}xms;
Perhaps worst of all, you appear to be in the process of
inventing your own system of html templates, and you'd really be
better off using an existing one, e.g. Mason or Template::Toolkit.
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.