Home > Archive > PERL Beginners > August 2004 > finding out what is uninitialized
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
finding out what is uninitialized
|
|
| Tim McGeary 2004-08-03, 3:57 pm |
| 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
tim.mcgeary@lehigh.edu
| |
| Script Monkey 2004-08-03, 3:57 pm |
| 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
> tim.mcgeary@lehigh.edu
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
http://www.iowatelecom.net/~rodj/key.txt
| |
| Tim McGeary 2004-08-03, 3:57 pm |
| 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
tim.mcgeary@lehigh.edu
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:
>
> http://www.iowatelecom.net/~rodj/key.txt
>
| |
| Gunnar Hjalmarsson 2004-08-03, 3:57 pm |
| 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
| |
| James Edward Gray II 2004-08-03, 3:57 pm |
| On Aug 3, 2004, at 9:12 AM, Gunnar Hjalmarsson wrote:
>
> 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
| |
| Script Monkey 2004-08-03, 3:57 pm |
| 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:
>
>
> Is the warning pointing to the push() line though? One of those
> variables could be undef.
>
> James
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
http://www.iowatelecom.net/~rodj/key.txt
| |
| Tim McGeary 2004-08-03, 3:57 pm |
| 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:
>
> http://www.iowatelecom.net/~rodj/key.txt
>
>
| |
| Gunnar Hjalmarsson 2004-08-03, 3:57 pm |
| 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
| |
| Tim McGeary 2004-08-03, 3:57 pm |
| 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
tim.mcgeary@lehigh.edu
Gunnar Hjalmarsson wrote:
> Tim McGeary 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?
>
| |
| Gunnar Hjalmarsson 2004-08-03, 3:57 pm |
| [ 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:
>
> 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
| |
| Charles K. Clarkson 2004-08-03, 3:57 pm |
| From: Tim McGeary <mailto:tmm8@Lehigh.EDU> 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
| |
| Tim McGeary 2004-08-03, 3:57 pm |
| 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
tim.mcgeary@lehigh.edu
Charles K. Clarkson wrote:
> From: Tim McGeary <mailto:tmm8@Lehigh.EDU> 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
| |
| Charles K. Clarkson 2004-08-03, 3:57 pm |
| From: Tim McGeary <mailto:tmm8@Lehigh.EDU> 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
| |
| Tim McGeary 2004-08-03, 3:57 pm |
| 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
tim.mcgeary@lehigh.edu
Charles K. Clarkson wrote:
> From: Tim McGeary <mailto:tmm8@Lehigh.EDU> 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
| |
| Charles K. Clarkson 2004-08-03, 3:57 pm |
| Tim McGeary <tmm8@Lehigh.EDU> 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:tmm8@Lehigh.EDU> 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
--
Mobile Homes Specialist
254 968-8328
| |
| Tim McGeary 2004-08-03, 3:57 pm |
| 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
tim.mcgeary@lehigh.edu
Charles K. Clarkson wrote:
> Tim McGeary <tmm8@Lehigh.EDU> 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:tmm8@Lehigh.EDU> 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
| |
| Charles K. Clarkson 2004-08-03, 3:57 pm |
| From: Tim McGeary <mailto:tmm8@Lehigh.EDU> 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
| |
| Charles K. Clarkson 2004-08-03, 3:57 pm |
| Charles K. Clarkson <mailto:cclarkson@htcomp.net> wrote:
: From: Tim McGeary <mailto:tmm8@Lehigh.EDU> 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
| |
| Tim McGeary 2004-08-03, 3:57 pm |
| 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
tim.mcgeary@lehigh.edu
Charles K. Clarkson wrote:
> Charles K. Clarkson <mailto:cclarkson@htcomp.net> wrote:
>
> : From: Tim McGeary <mailto:tmm8@Lehigh.EDU> 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
| |
| Gunnar Hjalmarsson 2004-08-03, 3:57 pm |
| 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
| |
| Charles K. Clarkson 2004-08-04, 3:55 am |
| From: Tim McGeary <mailto:tmm8@Lehigh.EDU> 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__
| |
| Tim McGeary 2004-08-04, 3:56 pm |
| 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
tim.mcgeary@lehigh.edu
Charles K. Clarkson wrote:
> From: Tim McGeary <mailto:tmm8@Lehigh.EDU> 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
| |
| Tim McGeary 2004-08-04, 3:56 pm |
| 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
tim.mcgeary@lehigh.edu
Charles K. Clarkson wrote:
> From: Tim McGeary <mailto:tmm8@Lehigh.EDU> 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
|
|
|
|
|