Nicole Seitz wrote:
> 
> Hi there!

Hello,

> 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$//;
                          ^^^^^^^
Your problem is here.  The regular expression is setting $1 and $2 to undef.

       elsif ( $line =~ /^;([^\(]+?)\s*[^\)]+\)\s*;(ZB-HP);Elsevier;/ ) {
            $titles{$1}= $2;


> 21            $titles{$title}= $2;
> 22            }
> 23                        }
> 24   while ( ($key, $value) = each %titles) {
> 25        print "$key => $value\n";
> 26       }



John
-- 
use Perl;
program
fulfillment

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

Reply via email to