Hello monks,
I have a really weird problem and I really don't know how to fix it.
I just have a simple txt file with HTML tags and some custom variables like #var1#. I'm reading that file line by line and replacing the #var1# with actual values, like a templating system.
The thing is I'm getting a: "Error reading line from file: Operation timed out" when reading the lines. It actually opens the file, got a FD and a handle but everytime i try to read it pufff if gives me that error for each line...
Any comments?
here is the file:
<HTML>
<HEAD>
<TITLE>Application auto-deployed</TITLE>
</HEAD>
<BODY>
<h1>Application information</h1><br><br>
<dl>
<dt>Status</dt><dd>#deploymentStatus#</dd>
<dt>Name</dt><dd>#applicationName#</dd>
<dt>Tag</dt><dd>#applicationTag#</dd>
<dt>Environment</dt><dd>#applicationEnvironment#</dd>
<dt>Triggered by</dt><dd>#triggeredBy#</dd>
<dt>Completion time</dt><dd>#timeToComplete#</dd>
</dl>
</BODY>
</HTML>
And this is the perl code:
my $isOpen = open($handle, $templateLocation);
if (!-e $templateLocation || !$isOpen) {
my $exception = MidTier::Exception->new("2", "Error op
+ening file for reading: $templateLocation", $self);
close($handle);
$exception->sendLog();
} else {
$logger->debug("File $templateLocation opened");
}
$logger->info("Building template: $template");
while(my $line = readline($handle)) {
if (!$line || $!) {
$logger->error("Error reading line from file: $!")
+;
} else {
if ($line =~ s/#((:?\w|\d)+)#/$templateValuesHash{
+$1}/g) {
$logger->debug("Replacing #$1# by $templateVal
+uesHash{$1} on template");
}
$compiledTemplate .= $line;
}
}
return $compiledTemplate;
Thanks for your wisdom.
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.