if ($volume =~ $vol_to_parse) {
####
if ($volume =~ /$vol_to_parse/) {
####
print "Using: "."vol: $vol_to_parse". " and " . "file: $file_to_parse" . "\n";
####
print "Using: vol: $vol_to_parse and file: $file_to_parse\n";
####
open(DAT, "<", $file_to_parse) || die "Could not open file! ($!)\n";
####
#!/usr/bin/perl
# Libraries
use strict;
use warnings;
use Getopt::Long;
# Globals and default arguments
my $vol_to_parse = "john";
my $file_to_parse = "file1.txt";
my @raw_data;
# Main program
process_args();
open_sesame();
pars0r();
# Subroutines
sub process_args {
GetOptions (
'v=s' => \$vol_to_parse,
'h=s' => \$file_to_parse,
) or die "syntax: $0 -v -h \n";
}
sub open_sesame{
open(DAT, "<", $file_to_parse) || die "Could not open file! ($!)\n";
chomp(@raw_data = );
close(DAT);
}
sub pars0r{
foreach my $volume (@raw_data) {
if ($volume =~ /$vol_to_parse/) {
print "$vol_to_parse got got \n";
}
}
}