Hi
I am trying to Push one line at a time from three different arrays into a new array
Here is a part of the code that is giving trouble: - my @result_line;
-
-
while ($entries >= 0 ){
-
@result_line = ();
-
push @result_line, $result_line1[$entries];
-
push @result_line, $result_line2[$entries];
-
push @result_line, $result_line3[$entries];
-
print "@result_line\n";
-
$entries--;
-
}
The code gets compiled with rest of the code and also gives me proper result But I am getting following (warning) message each time it loops through the while loop: Use of uninitialized value in join or string at search_IP.plx (for the line with the Print statement)
I have initialized the array @result_line then why is it happening?
Please help.
Thanks
4 1474
why is it happening?
Because you push() one or more undefined values into @result_line.
If that's not help enough, please post a short but complete program, that we can copy and run, and that demonstrates the issue.
Hi,
I did not paste the lines where I have aleady declared and initialized the arrays that i am pushing. - my @result_line1 = grep (/lease/, @result);
-
my @result_line2 = grep (/starts/, @result);
-
my @result_line3 = grep (/ends/, @result);
-
-
while ($entries >= 0 ){
-
@result_line = ();
-
push @result_line, $result_line1[$entries];
-
push @result_line, $result_line2[$entries];
-
push @result_line, $result_line3[$entries];
-
print "@result_line\n";
-
$entries--;
-
}
Actually there is no array or variable that is not initialized. Please help.
That's still not a complete program.
It's not about a variable, but at least one element in @result_line is undefined. - C:\home>type test.pl
-
use warnings;
-
my @array = ('blue', undef, 'yellow');
-
print "@array\n";
-
-
C:\home>test.pl
-
Use of uninitialized value in join or string at C:\home\test.pl line 3.
-
blue yellow
-
-
C:\home>
miller 1,089
Recognized Expert Top Contributor
Just because the arrays are initialized, does not mean that the scalar elements that you are trying to access are also initialized: -
my @result_line1 = grep (/lease/, @result);
-
my @result_line2 = grep (/starts/, @result);
-
my @result_line3 = grep (/ends/, @result);
-
-
warn "badness1" if $entries > $#result_line1;
-
warn "badness2" if $entries > $#result_line2;
-
warn "badness3" if $entries > $#result_line3;
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Will |
last post by:
Hi,
Sorry to be a pest...
But I can figure this out.
I'm pushing to a stack. then I need to check to see if the word is a
palindrome.
Is the code below correct?
if so, how can I check the...
|
by: Adrian |
last post by:
Hi all,
I am getting a warning compiling the following code using Borland C++
Builder 6, but I dont think I am doing anything wrong. When using g++ I
get no warnings at all with a g++ -Wall...
|
by: junky_fellow |
last post by:
Consider the following piece of code:
struct junk {
int i_val;
int i_val1;
char c_val;
};
int main(void)
{
|
by: Siemel Naran |
last post by:
I keep getting warning messages like these:
....\include\myfile.h(451) : warning C4251: 'MyClass::m_myvariable' : class
'CPtrArray' needs to have dll-interface to be used by
clients of class...
|
by: Rich Sienkiewicz |
last post by:
The C# compiler gives warnings about unused variables. I thin it needs a
warning about an unassigned reference. For instance, this compiles without
any warnings/errors, but of course blows up when...
| |
by: Charles Sullivan |
last post by:
I have a program written in C under Linux (gcc) which a user has
ported to run under AT&T SysV R4.
He sent me a copy of his makelog which displays a large number
of compiler warnings similar to...
|
by: Peter Ritchie [C# MVP] |
last post by:
I've purposely been ignoring a CA2122 warning in some C++ interop code I've
been working on for quite some time. I've just recently had the cycles to
investigate the warning. The warning message...
|
by: Terry |
last post by:
I am getting the following warning for the below function. I understand what
it means but how do I handle a null reference? Then how do I pass the
resulting value?
Regards
Warning 1...
|
by: ashnin |
last post by:
Hi,
Can anyone tell me, why am I getting this warning?
cc1plus: warning: command line option "-Wdeclaration-after-statement"
is valid for C/ObjC but not for C++
(Actually Im compiling a set...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |