hello, I'm very new to perl and have come across an aggrivating issue which I have not been able to find a solution too. I'm writing test scripts that will pump messages into the application I'm testing. My design of the scripts was to have one larger framework.pl file that would include all the setup that every test will need. then I would have a test .pl file for every type of test and that perl file would just include (or require) the framework.pl file. every thing works fine until in one of the tests I need to be able to change a variable in the framework.pl file. My problem in the most basic form is this:
the framework.pl file:
package framework;
use strict;
my $date = "2001-11-12";
sub testcase1
{
print $date;
}
the test.pl file:
require "framework.pl";
$framework::date = "2001-12-05";
&framework::testcase1;
$framework::date = "2001-11-15";
&framework::testcase1;
the output after running this test is 2001-11-122001-11-12. the date is not being changed like I thought it would be. Does anybody know of an easy way for me to access and change frameworks $date variable from within the test.pl? Any help would be greatly appreciated.
thanks.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|