in reply to Using Perl6::Junction for searching a element in a array
The lines you read from F1 go into $_ and not into $file. You check the wrong variable and/or you print the wrong error message.
I would rewrite your code as:
my $file = $_; my @tags=(qw(ct sect1 sect2 sect3 sect4 sect5 sect6)); my %allowed_tag = map { $_ => 1 } @tags; while (defined (my $line = <F1>)) { $line =~ /<([^>].+)>/ or die "Couldn't extract a tag from >>$line<<"; my $tag = $1; die "Incorrect entry >>$tag<< in >>$line<<" unless exists $allowed_tag{$tag}; print "Found tag $tag"; };
|
|---|