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>




Reply via email to