Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: adding a variable definition to execution

by lostjimmy (Chaplain)
on May 21, 2009 at 22:29 UTC ( [id://765563]=note: print w/replies, xml ) Need Help??


in reply to adding a variable definition to execution

If I replace <STDIN> with 'filename' , it uses the file appropriately
Not quite. You actually have to replace <STDIN> with a file handle, not a filename.

If you get the filename from the command line like you want to, it ends up in @ARGV. The first argument on the command line is in $ARGV[0], the second in $ARGV[1], and so on. Using a simple shift like akho has suggested simply grabs (and removes) the first element off of @ARGV. You could also do this: $basename = $ARGV[0]

If you gave us some more information, we could offer much more advice. I have a feeling that these answers will only lead to more questions, so bring it on.

Replies are listed 'Best First'.
Re^2: adding a variable definition to execution
by akho (Hermit) on May 21, 2009 at 23:49 UTC
    You actually have to replace <STDIN> with a file handle, not a filename.

    I believe the original poster replaced the input with a hard-coded value; that is, wrote $basename = 'filename'. A filehandle would be an error, probably.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://765563]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2024-04-23 11:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found