Showing posts with label Perl. Show all posts
Showing posts with label Perl. Show all posts

Nov 4, 2009

Perl Error - Error: Filehandle GEN0 opened only for output at Task.pm line 103.

Error:
Filehandle GEN0 opened only for output at Task.pm line 103.

Solution:
(W io) You tried to write on a read-only filehandle. If you intended it to be a read-write filehandle, you needed to open it with +< or +> or +>> instead of with < or nothing. If you intended only to write the file, use > or >>.

Perl Error - Can't use string ("2") as a HASH ref while "strict refs" in use

Error:
Can't use string ("2") as a HASH ref while "strict refs" in use

Solution:
Object representing class is assinged or having numeric value "2"

if will be calling like 2->method() that makes compiler yelling

Perl Error - Can't do inplace edit without backup.

Error :
Can't do inplace edit without backup.

Cause & Solution:
This is a perl one line command execution error.
You have to supply bakup filename if you want to edit the file in command line.
ex:
perl -i.bak -p -e 's/this/that/ig' *.txt


If you find this information helpful, please click the ads below

Perl Error - Unquoted string "callFunction" may clash with future reserved word at prg.pl line 4

Error:
Unquoted string "callFunction" may clash with future reserved word at prg.pl line 4.
Useless use of a constant in void context at prg.pl line 4.

Cause & Solution:
If you are calling a function without "&" as prefix (&FunctionName) and if that function is defined after this statement then this error will occur. Since Perl is a interpreted language it executes line by line. so it assumes function name as some bareword.


If you find this information helpful, please click the ads below

Oct 17, 2009

Perl Error - exists argument is not a HASH or ARRAY element at test.pl line 8.

Error:
exists argument is not a HASH or ARRAY element at test.pl line 8.

Solution:
Exists is for checking elements of array and hash. should not be used on scalar



If you find this information helpful, please click the ads below

Perl Error - Can't use string ("2") as a HASH ref while "strict refs" in use

Error:
Can't use string ("2") as a HASH ref while "strict refs" in use

Solution:
Object representing class is assinged or having numeric value "2"
it will be calling like 2->method() that makes compiler yelling

Perl Error - Can't locate object method "new" via package"

Error:
Can't locate object method "new" via package"

Solution:
Check the 'package' line in your module, and make sure that it _exactly_ matches (including case) the name in the 'use' statement.
I typically run into this after I've decided to rearrange some files, or I typo on a case-insensitive file system (so it finds the module, but the name doesn't match)

Define $DB::fork_TTY

Error:
  DB<1> Debugged program terminated.  Use q to quit or R to restart,
  use O inhibit_exit to avoid stopping after program termination,
  h q, h R or h O to get additional info.
######### Forked, but do not know how to change a TTY. #########
  Define $DB::fork_TTY
       - or a function DB::get_fork_TTY() which will set $DB::fork_TTY.
  The value of $DB::fork_TTY should be the name of TTY to use.
  On UNIX-like systems one can get the name of a TTY for the given window
  by typing tty, and disconnect the shell from TTY by sleep 1000000.

Cause
when a process is forked the program does not know which tty to use

Solution:
set  $DB::fork_TTY = 0;
set the tty for child = 0 or any particular tty you want to use