I have searched for several hours and I've found tons of resources, but I can't seem to put the info together for my purposes. I have a file with:
FirstName LastName
FirstName LastName
FirstName LastName
etc...
This is homework assigned to the class by students from their presentation. 99% of the code below is theirs from a template script, I'll comment where my contributions come in. I'm supposed to find all of the last names that begin with a vowel and output them into a text file. It seems that I'm having most of my trouble figuring out the regex for "vowel as first character of second field" - as well as some trouble with basic Perl I suppose. How do I do this? This isn't really worth much credit at all, but I'm just driving myself crazy trying to figure this out - Thanks a bunch for any help.
#!/usr/bin/perl
$input = 'names.txt';
open ($info, $input) or die "Could not open $input";
$output = 'hw.txt';
open($fh, '>>', $output) or die "Could not open $output";
@names = split(/\s/, $line); #MINE - probably wrong somehow
while( my $line = <$info>) {
if ($names[2] =~ /^AEIOU/){ #MINE - also probably wrong somehow
print $fh "$line";
}
}
close $info;
close $fh;