Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Re: Use of uninitialized value in concatenation (.) or string Error

Reply
Thread Tools

Re: Use of uninitialized value in concatenation (.) or string Error

 
 
Sukhbir Dhillon
Guest
Posts: n/a
 
      04-05-2004
Hi! I'm trying to split the string from some file with | (pipe) seperated.
heres one of the string lines from data file.

Sukhbir Dhillon|(E-Mail Removed)|data.txt|Thank you|student|
I'm using following code to read and split
open (READ_DB, "$dbfile");
while (<READ_DB>)
{
$_ =~ tr/A-Z/a-z/;
($name, $value, $filename, $message, $position) = split(/\|/);
close(READ_DB);

and I found that $position is getting undef value and which gives lots of error mentioned in the subject.
I'm pretty new in perl so please excuse my ignorance.
Thank you
Sukhbir

 
Reply With Quote
 
 
 
 
Joe Smith
Guest
Posts: n/a
 
      04-05-2004
Sukhbir Dhillon wrote:

> Sukhbir Dhillon|(E-Mail Removed)|data.txt|Thank you|student|
> I'm using following code to read and split
> open (READ_DB, "$dbfile");
> while (<READ_DB>)
> {
> $_ =~ tr/A-Z/a-z/;
> ($name, $value, $filename, $message, $position) = split(/\|/);
> close(READ_DB);
>
> and I found that $position is getting undef value


Of course it is. Your program should expect that, and do something like
$message = "" unless defined $message;
$position = "" unless defined $position;

-Joe
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use of uninitialized value in concatenation (.) or string Amaninder Perl Misc 6 07-18-2006 05:29 PM
(Newbie) Use of uninitialized value in concatenation (.) or string Jesse Cary Perl Misc 2 10-15-2004 09:47 PM
Use of uninitialized value in concatenation smartins68 Perl 1 06-09-2004 05:46 AM
Use of uninitialized value in concatenation (.) or string S Perl Misc 3 02-03-2004 09:54 PM
Use of uninitialized value in concatenation (.) at register.pl line 38, <STDIN> line 10. G Kannan Perl 1 10-11-2003 11:58 AM



Advertisments