CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Cant use an undefined value as a symbol reference at modify_sql.pl line 17

 



laveena
Novice

Sep 7, 2006, 3:09 AM

Post #1 of 4 (266 views)
Cant use an undefined value as a symbol reference at modify_sql.pl line 17 Can't Post

Hello,
i seem to get the above error when a run a script
modify_sql.sh .i do not know if the function by which it is called in in a right manner or not(perl 'modify_sql_uc3.pl' '2111.sql' 1 312312)Line 17 is :open my $fh, "< $filename" or die "cannot open $filename for reading $!";

modify_sql.pl
#! /usr/bin/perl
use strict;
#use warnings;

my ($filename,$stelle,$wert) = @ARGV;
my @ARGV = 3 or die "usage : There must be only 3 arguments";
#my ($filename,$stelle,$wert) = @ARGV;


unless ( -e "$filename")
{
print "Sorry $filename is not existing \n";
exit(0);
}

open my $fh, "< $filename" or die "cannot open $filename for reading $!";

my @filename =<$fh>;

my $size = @filename;

$size++;

for(my $i=$size;$i>$stelle-1;$i--)
{
$filename[$i]=$filename[$i-1];

}
close $fh;

$filename[$stelle-1]="INSERT INTO product.p_tmpr VALUES ( $stelle ,$wert);\n";

for(my $i=$stelle;$i<$size;$i++)
{
my $h=$i+1;

$filename[$i]=~ s/$i/$h/;
}
open my $fn, "> $filename.mod" or die"cannot open $filename.mod $!";
foreach my $element( @filename)
{
defined $element or $element ="";
print $fn $element;
}
close $fn;

.......................................
modify_sql.sh

#!/bin/ksh
export ENT=/home/atw11w99/ent/uc3
cd $ENT

perl 'modify_sql.pl' '2111.sql' 1 312312

would be thankfull for any advice


davorg
Thaumaturge / Moderator

Sep 7, 2006, 7:42 AM

Post #2 of 4 (263 views)
Re: [laveena] Cant use an undefined value as a symbol reference at modify_sql.pl line 17 [In reply to] Can't Post

Which version of Perl are you using? The syntax that you are using:


Code
open my $file, "filename" or die $!;


was added in a very recent version of Perl (about 5.8.0, I'd guess). If you're using an earlier version then you'll need to go back to using explicit filehandles.


Code
local \*FILE; 
open FILE, "filename" or die $!;


--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks


laveena
Novice

Sep 8, 2006, 3:52 AM

Post #3 of 4 (257 views)
Re: [davorg] Cant use an undefined value as a symbol reference at modify_sql.pl line 17 [In reply to] Can't Post

Thank u,

its working fine


davorg
Thaumaturge / Moderator

Sep 8, 2006, 3:57 AM

Post #4 of 4 (256 views)
Re: [laveena] Cant use an undefined value as a symbol reference at modify_sql.pl line 17 [In reply to] Can't Post

I should also have added:

If you're using a hosting service that uses a version of Perl earlier than 5.8.0 (which is already over four years old) then I'd seriously consider moving elsewhere.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives