-Michael#!/usr/bin/perl use strict; use warnings; my $configFile = "tags.txt"; # <-- file containing the 'tags' (Tags ma +il, page, conf, test) my $line; my @array; my %tags; my $options; my @optionLine; my $totalTags = 0; my $totalNonTags = 0; open (CONFIG, "<", $configFile) or die "$configFile not found\n\n"; while (<CONFIG>) { if ($_ =~ m/Tags/) { chomp; $line = $_; $line =~ s/Tags //; while ($line =~ s/\s//){}; @array = split (',', $line); for (@array) { $tags{"$_"} = 1; } } } print STDERR "Enter tag(s): "; $options = <STDIN>; chomp $options; @optionLine = split (" ", $options); for (@optionLine) { print "$_ tag found\n" if defined $tags{$_}; print "$_ is not a tag!\n" unless defined $tags{$_}; $totalTags = $totalTags + $tags{$_} if defined $tags{$_}; $totalNonTags += 1 unless defined $tags{$_}; } print STDERR "$totalTags tags found in total\n"; print STDERR "$totalNonTags non-tags entered\n";
In reply to Re: Comparing Arrays
by mtmcc
in thread Comparing Arrays
by WorkerBee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |