Perl: Use of uninitiated value warning


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl: Use of uninitiated value warning
# 1  
Old 09-08-2011
Perl: Use of uninitiated value warning

Hi I am brand new to perl and I wrote following code.

Code:
#!/usr/bin/perl

use warnings;
 
 while (<>) {

 @arr1 = split(//);

 $i = 0;

 foreach (@arr1) {

$_ = $arr1[$i++];

@arr2 = ($arr1[$i],$arr1[$i+1],$arr1[$i+2]);

print "@arr2\n";
  
};}

But I am getting following error.
Code:
Use of uninitialized value $arr2[2] in join or string at Hello line 18, <> line 1.
h 
 
Use of uninitialized value $arr2[1] in join or string at Hello line 18, <> line 1.
Use of uninitialized value $arr2[2] in join or string at Hello line 18, <> line 1.

  
Use of uninitialized value $arr2[0] in join or string at Hello line 18, <> line 1.
Use of uninitialized value $arr2[1] in join or string at Hello line 18, <> line 1.
Use of uninitialized value $arr2[2] in join or string at Hello line 18, <> line 1.

whats wrong with my code?

thank you.
# 2  
Old 09-08-2011
Quote:
whats wrong with my code?
A logic. Try to write what you want to do in plain (but "algorithmic") English.
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies

2. AIX

Perl error : perl: warning: Setting locale failed.

This's my problem perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LC_ALL = "en_US.UTF-8", LC__FASTMSG = "true", LC_MESSAGES = "", LC_CTYPE = "en_US.UTF-8", LC_TYPE = "en_US.UTF-8", LANG = "EN_US"... (1 Reply)
Discussion started by: bobochacha29
1 Replies

3. Shell Programming and Scripting

PERL localtime Warning

Hello All, I am facing a warning "Argument "" isn't numeric in localtime at" what i m using is below my $timestamp = Timestamp(time); go_log("###############$timestamp###############"); can some one please suggest the way to avoid this message :confused: (6 Replies)
Discussion started by: NIMISH AGARWAL
6 Replies

4. Shell Programming and Scripting

redefine warning(Eval) in perl

Here is my perl Program: #!/usr/bin/perl -w my $a="sam"; my $b="ste"; my $c="abcdef"; my $d=931; $str=" @<<<<< @>>>>>>>>>> @|||||||||||||||||||| @######### \$a,\$b,\$c,\$d ."; open(FILE,">abc.txt"); $temp="format FILE = $str"; eval $temp; write FILE; print FILE "\n\n"; (3 Replies)
Discussion started by: sameerstephen
3 Replies

5. Shell Programming and Scripting

Getting warning in the Perl Script

Hello All, I have written the below perl script: #!/usr/bin/perl use strict; use warnings; if ($#ARGV != 2) { print "usage: merge_eod AP_filename IE_filename \n"; exit; } my($trg) = ".trg"; my($output_file) = $ARGV; my($ie_file) = $ARGV; my($ap_file) = $ARGV;... (4 Replies)
Discussion started by: pulkit
4 Replies
Login or Register to Ask a Question