I think your script is failing at the defined($line = <INPUT>).  So the hash
is not getting populated at all.  I think this because your call to open
didn't include a <, as in

open FH, "< your_file" or die $!;

Try adding that to your open call and see if it makes a difference.


>===== Original Message From Nicole Seitz <[EMAIL PROTECTED]> =====
>Hi there!
>
>I'm very new to Perl and just don't understand an error message I got.Hope
you
>can help me.
>
>Now, the file I'm working with contains the following data:
>
>;Structural Safety;Elsevier SD;;;
>;Structural Safety (95 ... );ZB-HP;Elsevier;nur online (HGF);
>;Subsurface sensing technologies and applications;ZB-HP;KluwerOnline;HGF;
>;Superlattices and Microstructures _(96 ... );ZB-HP;Academic;nur online;
>
>And here's the little script I've written so far:
>-----------------------------------------------------------------------------
---
>1    #!/usr/bin/perl -w
>2    use strict;
>3    my $line;
>4    my %titles;
>5    my $title;
>6    my $key;
>7    my $value;
>8
>9    open INPUT , "test"
>10   or die "Could not open file: $! ";
>11
>12   while (defined($line = <INPUT>)) {
>13       if ($line =~/^;([^;]+)\s?;Elsevier (SD);/) {
>14            #print "$1\t$2\n\n";
>15            $titles{$1}= $2;
>16            }
>17       elsif ($line =~/^;([^\(]+)\s?[^\)]+\)\s?;(ZB-HP);Elsevier;/  ){
>18            #print "$1\t$2\n\n";
>19            $title = $1;
>20            $title =~ s/\s$//;
>21            $titles{$title}= $2;
>22            }
>23                        }
>24   while ( ($key, $value) = each %titles) {
>25        print "$key => $value\n";
>26       }
>-----------------------------------------------------------------------------
---
>The only lines of interest in the working file are those containing the
>strings
>    ";Elsevier SD;"              and    ";ZB-HP;Elsevier;"   (see regexes in
>l.13
>                                                               and l.17)
>
>Key - value pairs like
>   Structural Safety => SD
>are to be stored in a hash.
>
>At first, my programm did not contain line 20.
>Therefore, %titles had these elements:
>
>    Structural Safety => SD
>    Structural Safety  => ZB-HP
>
>As keys of a hash are unique strings, I noticed that there is a whitespace
>character at the end
>of the string which  $1( see regex l.17) holds.That's why I inserted l.20.The
>two strings
>should now be exactly the same and the hash should have only one element:
>
>Structural Safety  => ZB-HP
>
>Instead, I get the following error output:
>
>Use of uninitialized value in concatenation (.) or string at test.pl line 25,
><INPUT> line 4.
>
>Can someone tell me why?I can't see the problem.
>
>Many thanx in advance!
>
>Nicole
>
>
>
>
>
>--
>Was immer du tun kannst oder erträumst zu können, beginne es.
>Kühnheit besitzt Genie, Macht und magische Kraft. Beginne es jetzt.
>(Johann Wolfgang Goethe)
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to