Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why can I not set use constant? 1

Status
Not open for further replies.

fergmj

Programmer
Joined
Feb 21, 2001
Messages
276
Location
US
Can someone tell me why the commented out lines of 'use constant' don't work when I take the commenting off?

Thanks

---------------------------


#!/usr/local/bin/perl5 -wT

use strict;
use CGI;

#use constant UPLOAD_DIR => "/usr/local/photo";
#use constant BUFFER_SIZE => 16_384;
#use constant MAX_FILE_SIZE => 1_048_576; #limits each upload to 1MB
#use constant MAX_DIR_SIZE => 100 * 1_048_576; #limits total uploads to 100 MB
#use constant MAX_OPEN_TRIES => 100;

$CGI::DISABLE_UPLOADS = 0;
$CGI::POST_MAX = 1_048_576;

my $q = new CGI;

#$q->cgi_error and error( $q, "Error transferring file: " . $q->cgi_error );

my $caption = $q->param("Caption");
my $type = $q->param("Image_Type");
my $format = $q->param("Image_Format");
my $background = $q->param("Image_Background");
my $category = $q->param("Category");
my $keywords = $q->param("Keywords");
my $source = $q->param("Source");
my $copyright = $q->param("Copyright");
my $permission = $q->param("Permission");
my $restrictions = $q->param("Restrictions");
my $initials = $q->param("Initials");
my $createdate = $q->param("Date_Created");
my $editdate = $q->param("Date_Edited");
my $id = $q->param("ID:");
my $newimage = $q->param( "New_Image" );
my $newmatte = $q->param("New_Matte");
my $link = $q->param("Link_ID");
my $buffer = "";

open (GB, ">>APGB.txt");
print GB "$caption|$type|";
print GB "$format|$background|";
print GB "$category|$keywords|";
print GB "$source|$copyright|";
print GB "$permission|$restrictions|";
print GB "$initials|$createdate|";
print GB "$editdate|$id|";
print GB "$newimage|$newmatte|$link\n";
close(GB);
 
I've never seen constants done like that before. The only way I've seen constants done is like this:
Code:
sub UPLOAD_DIR {return "/usr/local/photo"};
Perl will optimize this to inline code (i.e. a constant).
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Thank You! That worked perfectly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top