Just to be on the safe side, I'd advice you to habitually use the strictures ,this is like the ABS system in a car and can really stabilize you from slipping into errors or typos:
use strict;
use warnings;
Another advice is to use the three argument form of open and show the open modes your files are accessed under (input, output, appending, piping...),
open (FH, '<', "saved_system.txt");
A third advice with
open is to provide for explanation/clues of errors that could ensue, like if the file couldn't be opened, didn't exist, didn't have access attributes and more importantly if system-errors where involved, these clues can be indicated from $!..
open(FH, '<', 'saved_system.txt')or die("Couldn't open file, $!");
to read the perlvar documentation for $! from the terminal prompt of your machine, "
perldoc perlvar $!"
Update:ikegami posted a wholesome example while I was writing these ideas :)...
Excellence is an Endeavor of Persistence.
Chance Favors a Prepared Mind.
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.