Re: finding out what is uninitialized
Thank you, Charles. I appreciate that! Just by reading through your re-write, I'm learning a bunch more! Tim Tim McGeary Senior Library Systems Specialist Lehigh University 610-758-4998 [EMAIL PROTECTED] Charles K. Clarkson wrote: From: Tim McGeary mailto:[EMAIL PROTECTED] wrote: : I don't get any errors either with the sample.pl and : sample files. So I wonder if the data is bad in the : middle of the file. I guess that has to be it since : I get the errors with sample.pl and the full data file. : : What is the best way to redirect that bad data to a : different file or array? The @fund_array array doesn't contain information about the raw data used to create it. For that reason, it would be difficult to report the raw data while manipulating @fund_array without changing its structure. Here's a rewrite of sample.pl. It does the same thing you were doing without the arrays. It is not exactly the same output. I left the trailing pipe off the end of each record. It is uncommon for it to be there. You should be able to find the line number of sample.txt from the uninitialized error you are receiving. I unsuccessfully tried to reproduce your error by corrupting the data myself. Let us know if you find the error in your data. HTH, Charles K. Clarkson -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
A little merging of this new sample file and my whole file and it works like a charm! Thank you all for teaching me some new tricks. I'm happier with perl now. :) Special thanks to Charles. Tim Tim McGeary Senior Library Systems Specialist Lehigh University 610-758-4998 [EMAIL PROTECTED] Charles K. Clarkson wrote: From: Tim McGeary mailto:[EMAIL PROTECTED] wrote: : I don't get any errors either with the sample.pl and : sample files. So I wonder if the data is bad in the : middle of the file. I guess that has to be it since : I get the errors with sample.pl and the full data file. : : What is the best way to redirect that bad data to a : different file or array? The @fund_array array doesn't contain information about the raw data used to create it. For that reason, it would be difficult to report the raw data while manipulating @fund_array without changing its structure. Here's a rewrite of sample.pl. It does the same thing you were doing without the arrays. It is not exactly the same output. I left the trailing pipe off the end of each record. It is uncommon for it to be there. You should be able to find the line number of sample.txt from the uninitialized error you are receiving. I unsuccessfully tried to reproduce your error by corrupting the data myself. Let us know if you find the error in your data. HTH, Charles K. Clarkson -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
finding out what is uninitialized
I have two arrays that I am printing to a file and I get the Use of uninitialized value... warning. But I get that for less than 100 of 3000+ lines. Is there a way that I can log what data is uninitialized. Here's the snippet of code I am using: foreach $coded (@fund_array) { printf (FILE $coded\n); } where the @fund_array is defined by : push(@fund_array,$cat_key\|$title\|$url\|$code\|); I can't for the life of my figure out why I am getting this error for only a handful. TIA, Tim -- Tim McGeary Senior Library Systems Specialist Lehigh University 610-758-4998 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
Here is what I do for uninitialized variables: foreach $coded (@fund_array) { if (defined($coded) { printf (FILE $coded\n); }else{ printf(FILE,\n); } } or drop off the else statement if you don't want the blank line. Rod, On Aug 3, 2004, at 8:48 AM, Tim McGeary wrote: I have two arrays that I am printing to a file and I get the Use of uninitialized value... warning. But I get that for less than 100 of 3000+ lines. Is there a way that I can log what data is uninitialized. Here's the snippet of code I am using: foreach $coded (@fund_array) { printf (FILE $coded\n); } where the @fund_array is defined by : push(@fund_array,$cat_key\|$title\|$url\|$code\|); I can't for the life of my figure out why I am getting this error for only a handful. TIA, Tim -- Tim McGeary Senior Library Systems Specialist Lehigh University 610-758-4998 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response http://www.iowatelecom.net/~rodj/key.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
So if I don't have this, what is printed to my file? Nothing? Just an error to the screen? What I don't understand is that if the data wasn't there, I wouldn't have pushed it to the array previously. And I've gone over that code in depth and everything is being set before it's push together into the array. This really bugs me. (no pun intended) Tim Tim McGeary Senior Library Systems Specialist Lehigh University 610-758-4998 [EMAIL PROTECTED] Script Monkey wrote: Here is what I do for uninitialized variables: foreach $coded (@fund_array) { if (defined($coded) { printf (FILE $coded\n); }else{ printf(FILE,\n); } } or drop off the else statement if you don't want the blank line. Rod, On Aug 3, 2004, at 8:48 AM, Tim McGeary wrote: I have two arrays that I am printing to a file and I get the Use of uninitialized value... warning. But I get that for less than 100 of 3000+ lines. Is there a way that I can log what data is uninitialized. Here's the snippet of code I am using: foreach $coded (@fund_array) { printf (FILE $coded\n); } where the @fund_array is defined by : push(@fund_array,$cat_key\|$title\|$url\|$code\|); I can't for the life of my figure out why I am getting this error for only a handful. TIA, Tim -- Tim McGeary Senior Library Systems Specialist Lehigh University 610-758-4998 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response http://www.iowatelecom.net/~rodj/key.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
Tim McGeary wrote: I have two arrays that I am printing to a file and I get the Use of uninitialized value... warning. But I get that for less than 100 of 3000+ lines. Is there a way that I can log what data is uninitialized. Here's the snippet of code I am using: foreach $coded (@fund_array) { printf (FILE $coded\n); } Why are you using the printf() function? If you don't know, try print() instead. where the @fund_array is defined by : push(@fund_array,$cat_key\|$title\|$url\|$code\|); If that's the only way @fund_array gets populated, there is no way it can contain undefined elements. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
On Aug 3, 2004, at 9:12 AM, Gunnar Hjalmarsson wrote: where the @fund_array is defined by : push(@fund_array,$cat_key\|$title\|$url\|$code\|); If that's the only way @fund_array gets populated, there is no way it can contain undefined elements. Is the warning pointing to the push() line though? One of those variables could be undef. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
Good point. Tim, how are $cat_key, $title, $url, and $code being populated? SM On Aug 3, 2004, at 9:14 AM, James Edward Gray II wrote: On Aug 3, 2004, at 9:12 AM, Gunnar Hjalmarsson wrote: where the @fund_array is defined by : push(@fund_array,$cat_key\|$title\|$url\|$code\|); If that's the only way @fund_array gets populated, there is no way it can contain undefined elements. Is the warning pointing to the push() line though? One of those variables could be undef. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response http://www.iowatelecom.net/~rodj/key.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
Ok, here's the code that is pushing $cat_key, $title, $url, and $code into the @fund_array: @sirsi_array has a DB_key, a Title and data which is either a code or a URL, in such a manner: 101|Journal of Nature|PBIO| 101|Journal of Nature|http://www.nature.org/| 102|Journal of Crap|PBIO| 102|Journal of Crap|http://www.crap.org/| 102|Journal of Crap|http://www.jstor.org/crap/| Each of the above rows is what the @sirsi_array would have. Here's the pseudocode for the real code below: Split array element. Check to see if we have a new DB_key If yes, check to see if code matches allowed codes. If yes, then set $code=$data and $titles=1. Else, $titles=0, push to @reject_array and move on. If no, set $title check for jstor or prola in $data If yes, append (archive) to $title set $url with $ezproxy prefix set $cat_key with simple algorithm based on # of titles push $cat_key, $title, $url, and $code to @fund_array increment $titles Real code: my $preCat = 0; my $titles = 0; my $title = ''; my $code = ''; my $url = ''; my @fund_array; my @reject_array; foreach $item (@sirsi_array) { my ($temp_key, $temp_title, $data) = split (/\|/, $item); if ($preCat != $temp_key) { # new record $titles = 0; for (keys %codes_hash) { if ($data =~ /$_/) { $found = 1; last; } } if ($found) { $titles = 1; $code = $data; } else { $titles = 0; push(@reject_array,$temp_key\|$temp_title\|); next; } $preCat = $temp_key; $found = 0; } else { $title = $temp_title; if ($data =~ /jstor/) { $title = $title(archive); } elsif ($data =~ /prola/) { $title = $title(archive); } $url = $ezproxy$data; $cat_key = $titles * $cat_value + $temp_key; push(@fund_array,$cat_key\|$title\|$url\|$code\|); $titles = $titles + 1; } } Thanks, Tim Script Monkey wrote: Good point. Tim, how are $cat_key, $title, $url, and $code being populated? SM On Aug 3, 2004, at 9:14 AM, James Edward Gray II wrote: On Aug 3, 2004, at 9:12 AM, Gunnar Hjalmarsson wrote: where the @fund_array is defined by : push(@fund_array,$cat_key\|$title\|$url\|$code\|); If that's the only way @fund_array gets populated, there is no way it can contain undefined elements. Is the warning pointing to the push() line though? One of those variables could be undef. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response http://www.iowatelecom.net/~rodj/key.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
Tim McGeary wrote: Ok, here's the code that is pushing $cat_key, $title, $url, and $code into the @fund_array: Before digging into it, and so we know which problem we are helping you to solve: *Is* the warning referring to the push() statement? -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
No, the warning statement is when I'm printing to the file. In both case, it refers to the process of writing to a file from the foreach $item (@fund_array) process. Tim Tim McGeary Senior Library Systems Specialist Lehigh University 610-758-4998 [EMAIL PROTECTED] Gunnar Hjalmarsson wrote: Tim McGeary wrote: Ok, here's the code that is pushing $cat_key, $title, $url, and $code into the @fund_array: Before digging into it, and so we know which problem we are helping you to solve: *Is* the warning referring to the push() statement? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
[ Please type your replies below the quoted part of the message you respond to. Please only quote what's needed to give context. ] Tim McGeary wrote: Gunnar Hjalmarsson wrote: Before digging into it, and so we know which problem we are helping you to solve: *Is* the warning referring to the push() statement? No, the warning statement is when I'm printing to the file. In both case, it refers to the process of writing to a file from the foreach $item (@fund_array) process. Well, in that case the reason for the warning is to be found anywhere else in your code. I would suggest that you write and post a *short* but *complete* program, including sample data, that people can copy and run, and that illustrates the problem you are encountering. When doing so, don't forget to enable strictures and declare *all* variables you are using. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: finding out what is uninitialized
From: Tim McGeary mailto:[EMAIL PROTECTED] wrote: : Ok, here's the code that is pushing $cat_key, $title, : $url, and $code into the @fund_array: : : @sirsi_array has a DB_key, a Title and data which : is either a code or a URL, in such a manner: : : 101|Journal of Nature|PBIO| : 101|Journal of Nature|http://www.nature.org/| : 102|Journal of Crap|PBIO| : 102|Journal of Crap|http://www.crap.org/| : 102|Journal of Crap|http://www.jstor.org/crap/| : : Each of the above rows is what the @sirsi_array : would have. Here's the pseudocode for the real code : below: : : Split array element. : Check to see if we have a new DB_key : If yes, check to see if code matches allowed codes. : If yes, then set $code=$data and $titles=1. : Else, $titles=0, push to @reject_array and move on. : If no, set $title : check for jstor or prola in $data : If yes, append (archive) to $title : set $url with $ezproxy prefix : set $cat_key with simple algorithm based on # of titles : push $cat_key, $title, $url, and $code to @fund_array : increment $titles : : Real code: : : my $preCat = 0; : my $titles = 0; : my $title = ''; : my $code = ''; : my $url = ''; : my @fund_array; : my @reject_array; You have 'strict' turned off. Not a good idea. You'll need to present a working example or more code (all of it?). I added this, but there is still more missing. my @sirsi_array = ( '101|Journal of Nature|PBIO|', '101|Journal of Nature|http://www.nature.org/|', '102|Journal of Crap|PBIO|', '102|Journal of Crap|http://www.crap.org/|', '102|Journal of Crap|http://www.jstor.org/crap/|', ); This part of the code doesn't look like it has an error, but with all those global variables running around, we can't be sure. We'll need to see more code to help you find the error you're getting. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
Here are two sample data files and the full script minus a bunch of comments that aren't needed.. Thanks, Tim Tim McGeary Senior Library Systems Specialist Lehigh University 610-758-4998 [EMAIL PROTECTED] Charles K. Clarkson wrote: From: Tim McGeary mailto:[EMAIL PROTECTED] wrote: : Ok, here's the code that is pushing $cat_key, $title, : $url, and $code into the @fund_array: : : @sirsi_array has a DB_key, a Title and data which : is either a code or a URL, in such a manner: : : 101|Journal of Nature|PBIO| : 101|Journal of Nature|http://www.nature.org/| : 102|Journal of Crap|PBIO| : 102|Journal of Crap|http://www.crap.org/| : 102|Journal of Crap|http://www.jstor.org/crap/| : : Each of the above rows is what the @sirsi_array : would have. Here's the pseudocode for the real code : below: : : Split array element. : Check to see if we have a new DB_key : If yes, check to see if code matches allowed codes. : If yes, then set $code=$data and $titles=1. : Else, $titles=0, push to @reject_array and move on. : If no, set $title : check for jstor or prola in $data : If yes, append (archive) to $title : set $url with $ezproxy prefix : set $cat_key with simple algorithm based on # of titles : push $cat_key, $title, $url, and $code to @fund_array : increment $titles : : Real code: : : my $preCat = 0; : my $titles = 0; : my $title = ''; : my $code = ''; : my $url = ''; : my @fund_array; : my @reject_array; You have 'strict' turned off. Not a good idea. You'll need to present a working example or more code (all of it?). I added this, but there is still more missing. my @sirsi_array = ( '101|Journal of Nature|PBIO|', '101|Journal of Nature|http://www.nature.org/|', '102|Journal of Crap|PBIO|', '102|Journal of Crap|http://www.crap.org/|', '102|Journal of Crap|http://www.jstor.org/crap/|', ); This part of the code doesn't look like it has an error, but with all those global variables running around, we can't be sure. We'll need to see more code to help you find the error you're getting. HTH, Charles K. Clarkson PACT|11| PART|6| PBIO|12| PCEM|13 PCHE|14| PCIE|15| PCOM|16| PECO|17| PEDN|8| PEES|7| PELE|18| PENG|19| PFIN|20| PHIS|22| PINE|21| PINR|23| PJRN|24| PLAW|25| PLIR|1| PMAR|26| PMAT|3| PMEH|27| PMLL|28| PMSE|9| PMUS|4| PPHL|2| PPHY|29| PPOL|10| PPSY|30| PREL|31| PSOC|32| PTHE|33| PUND|1| PSTF|100|#!/s/sirsi/Unicorn/Bin/perl # # etexts.pl # Tim McGeary use warnings; use Time::Local; my $fund_file = codes.txt; my $sirsi_file = sample.txt; my $fundcoded_file = ej.title;# only data that had a valid fund code my $etexts = etexts.data; # data that will be imported into etext table my $disEtexts = disEtexts.data; # mapping file of etexts to disciplines my $cat_value = 1000; my $reject_file = reject.title; ## DATE # getting date my ($sec,$min,$hour,$mday,$mon,$year, $wday,$yday,$isdst) = localtime time; $mon += 1; $year += 1900; my $date = $year-$mon-$mday; ## END DATE ## BEGIN read in fund.codes ## # opens and reads in the fund code file # open (FUND, $fund_file) or die Cannot open $fund_file; print Opening $fund_file \n; my %codes_hash; while (FUND) { chomp; my ($code, $id) = split /\|/; $codes_hash{$code} = $id; } print Closing $fund_file \n; close (FUND); ## END read in fund.codes ## ## BEGIN read in Sirsi data ## # reads in Sirsi data that is created by prtentry. The format is the # following: # |cat_key|Title|Fund_Code or URL| # # Some records will have more than one URL so it will either be a # two or three line record # # Therefore the cat_key will have to be compared line by line to see # where the next record starts # # Also, an algorithm to keep unique DB_IDs will be 1000+cat_key # open (SIRSI,$sirsi_file) or die Cannot open $sirsi_file; print Opening $sirsi_file to push into array \n; my @sirsi_array; # push each line of this file to an array while (SIRSI) { chomp; push(@sirsi_array, $_); } print Closing $sirsi_file \n; close (SIRSI); ## END read in Sirsi data ## ## BEGIN Separating Sirsi data ## # pull out unique data from the prtentry data we have my $preCat = 0; my $titles = 0; my $title = ''; my $code = ''; my $url = ''; my @fund_array; my @reject_array; my $ezproxy = http://ezproxy;; # snipped for security purposes print Sorting sirsi data into fundcoded information... \n; foreach $item (@sirsi_array) { my ($temp_key, $temp_title, $data) = split (/\|/, $item); if ($preCat != $temp_key) { # new record $titles = 0; for (keys %codes_hash) { if ($data =~ /$_/) { $found = 1; last; } } if ($found) { $titles = 1; $code = $data; } else { $titles = 0; push(@reject_array,$temp_key\|$temp_title\|); next; } $preCat = $temp_key;
RE: finding out what is uninitialized
From: Tim McGeary mailto:[EMAIL PROTECTED] wrote: : Here are two sample data files and the full script : minus a bunch of comments that aren't needed.. When I ran the sample.pl script I got this. The errors can be eliminated by deleting the blank line in sample.txt. I didn't get any errors for line 136. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 Use of uninitialized value in numeric ne (!=) at sample.pl line 94. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in pattern match (m//) at sample.pl line 97. Use of uninitialized value in concatenation (.) or string at sample.pl line 108. Opening codes.txt Closing codes.txt Opening sample.txt to push into array Closing sample.txt Sorting sirsi data into fundcoded information... Opening ej.title Saving data to ej.title Closing ej.title Opening reject.title Saving data to reject.title Closing reject.title Organizing etexts and disEtexts data Closing etexts.data and disEtexts.data -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
The blank line was my mistake of pulling a limited amount of data. There is no blank line at the end of my real data file. Tim McGeary Senior Library Systems Specialist Lehigh University 610-758-4998 [EMAIL PROTECTED] Charles K. Clarkson wrote: From: Tim McGeary mailto:[EMAIL PROTECTED] wrote: : Here are two sample data files and the full script : minus a bunch of comments that aren't needed.. When I ran the sample.pl script I got this. The errors can be eliminated by deleting the blank line in sample.txt. I didn't get any errors for line 136. HTH, Charles K. Clarkson -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
I am still having an error, though. Should I send my full data file? It's a bit large. Tim Tim McGeary Senior Library Systems Specialist Lehigh University 610-758-4998 [EMAIL PROTECTED] Charles K. Clarkson wrote: Tim McGeary [EMAIL PROTECTED] wrote: : The blank line was my mistake of pulling a limited amount : of data. There is no blank line at the end of my real : data file. Then there is also no error. So, what's your question? : Charles K. Clarkson wrote: : : From: Tim McGeary mailto:[EMAIL PROTECTED] wrote: : : : : : Here are two sample data files and the full script : : : minus a bunch of comments that aren't needed.. : : : : : : : : When I ran the sample.pl script I got this. The : : errors can be eliminated by deleting the blank line : : in sample.txt. I didn't get any errors for line 136. Charles K. Clarkson -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: finding out what is uninitialized
From: Tim McGeary mailto:[EMAIL PROTECTED] wrote: : I am still having an error, though. Should I send my full data : file? It's a bit large. Send it to me off-list. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: finding out what is uninitialized
Charles K. Clarkson mailto:[EMAIL PROTECTED] wrote: : From: Tim McGeary mailto:[EMAIL PROTECTED] wrote: : : : I am still having an error, though. Should I send my full : : data file? It's a bit large. : : Send it to me off-list. After receiving the file I get three errors. Which, as someone already pointed out, is because you are using 'printf' where you should be using 'print'. But I still do not get the other print error you started the thread with. Are you getting it when you run samlple.pl? Can you show us what is being printed when you run the script with this data? Invalid conversion in printf: %r at sample.pl line 99. Invalid conversion in printf: %r at sample.pl line 126. Invalid conversion in printf: %r at sample.pl line 126. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
I don't get any errors either with the sample.pl and sample files. So I wonder if the data is bad in the middle of the file. I guess that has to be it since I get the errors with sample.pl and the full data file. What is the best way to redirect that bad data to a different file or array? Tim Tim McGeary Senior Library Systems Specialist Lehigh University 610-758-4998 [EMAIL PROTECTED] Charles K. Clarkson wrote: Charles K. Clarkson mailto:[EMAIL PROTECTED] wrote: : From: Tim McGeary mailto:[EMAIL PROTECTED] wrote: : : : I am still having an error, though. Should I send my full : : data file? It's a bit large. : : Send it to me off-list. After receiving the file I get three errors. Which, as someone already pointed out, is because you are using 'printf' where you should be using 'print'. But I still do not get the other print error you started the thread with. Are you getting it when you run samlple.pl? Can you show us what is being printed when you run the script with this data? Invalid conversion in printf: %r at sample.pl line 99. Invalid conversion in printf: %r at sample.pl line 126. Invalid conversion in printf: %r at sample.pl line 126. HTH, Charles K. Clarkson -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: finding out what is uninitialized
Tim McGeary wrote: I don't get any errors either with the sample.pl and sample files. So I wonder if the data is bad in the middle of the file. I guess that has to be it since I get the errors with sample.pl and the full data file. There is no way line 136 can result in an uninitialized warning with the code you have shown us. That's true irrespective of which data you are using. What is the best way to redirect that bad data to a different file or array? Which bad data??? And why didn't you enable strictures before posting your code? And why didn't you replace printf() with print() ? And why do you keep top posting with full-quotes? :( -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: finding out what is uninitialized
From: Tim McGeary mailto:[EMAIL PROTECTED] wrote: : I don't get any errors either with the sample.pl and : sample files. So I wonder if the data is bad in the : middle of the file. I guess that has to be it since : I get the errors with sample.pl and the full data file. : : What is the best way to redirect that bad data to a : different file or array? The @fund_array array doesn't contain information about the raw data used to create it. For that reason, it would be difficult to report the raw data while manipulating @fund_array without changing its structure. Here's a rewrite of sample.pl. It does the same thing you were doing without the arrays. It is not exactly the same output. I left the trailing pipe off the end of each record. It is uncommon for it to be there. You should be able to find the line number of sample.txt from the uninitialized error you are receiving. I unsuccessfully tried to reproduce your error by corrupting the data myself. Let us know if you find the error in your data. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 #!/s/sirsi/Unicorn/Bin/perl use strict; use warnings; use Time::Local; use POSIX 'strftime'; use constant CAT_VALUE = 10_000_000; use constant DATE = strftime( '%Y-%m-%d', localtime() ); use constant LCD= 0; my %codes; my $file = 'codes.txt'; open FH, $file or die qq(Cannot open $file: $!); while (FH) { chomp; my( $code, $id ) = split /\|/; $codes{ $code } = $id; } close FH; $file = 'ej.title'; open CODED, $file or die qq(Cannot open $file: $!); $file = 'etexts.data'; open ETEXT, $file or die qq(Cannot open $file: $!); $file = 'disEtexts.data'; open DIS_ETEXT, $file or die qq(Cannot open $file: $!); $file = 'reject.title'; open REJECT, $file or die qq(Cannot open $file: $!); $file = 'sample.txt'; open FH, $file or die qq(Cannot open $file: $!); my $prev_key= 0; my $title_count = 0; my $code= ''; while ( FH ) { my( $key, $title, $data ) = split /\|/; if ( $prev_key != $key ) { $title_count = 0; if ( exists $codes{ $data } ) { $title_count= 1; $prev_key = $key; $code = $data; } else { print REJECT $key|$title\n; } } else { $title = $title(archive) if $data =~ /jstor|prola/; my $cat_key = $title_count * CAT_VALUE + $key; my $ezproxy = 'http://foo'; print CODED join( '|', $cat_key, $title, $ezproxy . $data, $code, ), \n; print ETEXT join( \t, $cat_key, $title, $ezproxy . $data, # url $ezproxy . $data, # description $code, DATE, LCD, ), \n; print DIS_ETEXT join( \t, $codes{ $code }, $cat_key, ), \n; $title_count++; } } close FH; close CODED; close ETEXT; close DIS_ETEXT; close REJECT; __END__ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response