#!/usr/bin/perl -w use strict; use File::Slurp; use File::Basename; my $input = $ARGV[0]; my @repos = glob("repos/*.txt"); # Store repos in hash my %hash; foreach my $repos_file (@repos) { my $text = read_file($repos_file); my $base = basename($repos_file,".txt"); $hash{$text} = $base; } # check input files: my $input_text = read_file($input); if ($hash{$input_text}) { print "File in our repos: $hash{$input_text}\.txt\n"; } else { print "no matching file\n"; }