Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > passed params as filename

Reply
Thread Tools

passed params as filename

 
 
Andrew
Guest
Posts: n/a
 
      12-29-2003
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

 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      12-29-2003
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The filename set in the response.setHeader("Content-Disposition", "attachment; filename=test.csv") is being ignored! Ed Java 10 07-13-2010 12:43 PM
Stitch rar files ( filename.part01 and filename.part02) Please help ixgor Software 1 10-15-2006 02:33 AM
how to get 8.3 format filename from long filename jacobyv@sis.unibe.ch Java 1 06-15-2006 10:39 AM
params v.s. @params in rails? Barry Ruby 9 09-15-2005 03:12 AM
Extract filename from a filename typed by user =?Utf-8?B?Sm9l?= ASP .Net 1 08-23-2004 11:29 PM



Advertisments