Dear monks,
I have a sub that reads a part p1 of a file and produces the expected output o1. When I change one variable in the code, it reads the part p2 and produces the expected output o2. Everything happens as expected. However, when I am trying to produce o1 and o2, in the same execution, it does not work. This
ad hoc quasi-code resumes:
#!/usr/bin/perl -w
use strict;
our $select_job;
our $filehandle_in;
our $filehandle_out;
sub Job_selection{
$select_job = shift;
open (our $filehandle_in, "<", "input.txt") || die "Can't read inp
+ut.txt: $!";
open (our $filehandle_out, ">", "output_$select_job.txt") || die "
+Can't write output_$select_job.txt: $!";
#
#job is done here
#
close $filehandle_in;
close $filehandle_out;
}
Job_selection("1");
Job_selection("2");
So, to be clear as fresh water: if I run this code changing for
#Job_selection("1"); Xor #Job_selection("2"); it works; but it does not work when I call both
Job_selection("1");
Job_selection("2");
at the same execution.
Best regards!
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.