"when i do perl1.pl filename.txt i get the error ...."
What exactly are you "do"ing... and what it your current working directory when you do it?
Assuming from what you've provided that you're using some version of Windows, we still don't know for sure where and how you're executing the script:
- C:\Users\Girish\Desktop>perl1.pl filename.txt
- C:\>perl1.pl filename.txt
- C:\Documents and Settings\>perl perl1.pl filename.txt
- or, perhaps even from your file manager or somesuch?
In that last case, $ARGV[0] will almost certainly be undef and might, therefore, account for something somewhat similar to the error message you've cited.
The error you quote in your narrative appears to be inexact (or the script you posted is incomplete). There is no line 10 in the script you posted and unless you saved your script and the router file to the desktop (BAAAAD idea), the error message bears no obvious relationship to the rest of the information you've provided.
IOW, we'll be better able to offer reasonable help if you tell us what's really in the code and what's really happening.
As to what you did to solve " the problem by using"
open (FH_SECOND,"<",\$second_file) or die $!;
...yes, that should solve at least one problem. The less_than sign tells your program to open $second_file for READING; your previous iteration (inside the code block, using a greater_than sign tells the script to open it for WRITING.
Update: Fixed my errors in the pseudo-CLI list.
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.