469,625 Members | 1,089 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

passed params as filename

Hello, i'm new to this group and have a quick question, I tried to
search on this topic but was unsucessful.
I'm tring to use a parameter to name a file, actually multiple
parameters, and perl doesn't seem to like it. Can anyone tell me what I
am doing wrong?

[code]
my $employee = param('employee');
my $filename = "$employee.txt";
# if file exists then append to file
if (-e $filename) {
open(TIMELOG, ">>./$filename") || die "Can't open file.\n";

[code]

Thanks for your time.

Andrew

Jul 19 '05 #1
1 1642
Andrew wrote:
Hello, i'm new to this group and have a quick question, I tried to
search on this topic but was unsucessful.
I'm tring to use a parameter to name a file, actually multiple
parameters, and perl doesn't seem to like it. Can anyone tell me
what I am doing wrong?

[code]
my $employee = param('employee');


You are looking for the variable @ARGV, not for the function param().
From perldoc perlvar:
@ARGV The array @ARGV contains the command-line arguments intended for
the script. [...]

my $employee = $ARGV[0];

Or more perlish (will remove the argument from the argument list):
my $employee = shift; #shift() defaults to @ARGV outside of the lexical
scope of subroutines

jue
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Arif Khan | last post: by
2 posts views Thread by tomisarobot | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.