Take the 2-minute tour ×

Thanks for your time, I got the a code off the internet and it isn't working exactly how I would expect.

I will only provide the portion of the code that is related to the irregular verbs. I've tried to comment what I understand is going on.:

my $irrVerbFile = "./IrregularVerbs.txt"; ##Changed!
my @verbList;

sub verbChangeInit(){
    open IRVF, $irrVerbFile;
    @verbList=<IRVF>; ##@verblist now contains irregular verbs and all the forms

sub changeVerbForm(){ ##Called by main script
    my $verb =lc(shift); ##Verb inputted first.  DOES THIS HAVE TO BE stem verb?
    my $isTense = shift; ##What tense is it
    my $reqTense =shift; ##What tense do you want it to be?
    my $irregLine = isIrregular($verb, $isTense); ##Call isIrregular $irregline is the line in the file that contains desired verb
    if($irregLine != -1){ # if $irregline doesn't equal -1 (-1 means the irreg verb line didn't contain the verb)
        return getIrregular($irregLine, $reqTense); ##call getIrregular
        return regularChangeVerbForm($verb, $isTense, $reqTense);

sub getIrregular(){
    my $lineNos = shift; ##line number
    my $reqTense = shift; ##Desired tense
    my @verbLine = split(/ /, $verbList[$lineNos]); ##split that line into words
    return $verbLine[$reqTense]; ##return desired word

sub isIrregular(){
    my $verb=shift; ##Get verb
    my $tense=shift; ##Get current tense
    my $i;
    for($i=0;$i<@verbList;$i++){ ##check all irregular verb
        my $vline = $verbList[$i];
        my @verbLine = split(/ /,$vline); ##Split line into words (each diff verbform)
        if($verbLine[$tense] eq lc($verb)){ ##The word corresponding to the tense (0-4) is the verb
            return $i; #Return line number
    return -1; #else return -1


The IrregularVerbs.txt looks like:

abide abode/abided abode/abided/abidden abides abiding 
arise arose arisen arises arising 
awake awoke awoken awakes awaking 

In my main script, I call the code like this:

require 'verbTenseChanger.pl';
my @verbforms = (
    map { changeVerbForm( $search_key, 0, $_ ) || (); } 1..4
foreach my $verbform (@verbforms) {


Please tell me if my understanding is correct. As a bonus, if you immediately see the problem, it would be greatly appreciated if you could give me a hint on how to fix it.(EDIT:fixed)

Thanks a lot! Don't hesitate to ask for more info, or if the question is unsatisfactory.


As mob pointed out, the subroutine, verbChangeInit(), was never called. I entered it at the beginning of my main script like so: verbChangeInit(); and got the following error:

[Thu Jun 23 15:34:45 2011] [error] [client ::1] readline() on closed filehandle IRVF at /Users/jon/Desktop/stanford-postagger-full-2011-04-20/verbTenseChanger.pl line 23.

Where line 23 is: @verbList=<IRVF>;

For fix, see comment below.

share|improve this question

closed as too localized by casperOne Aug 23 '12 at 12:29


When do you call &verbChangeInit? –  mob Jun 23 '11 at 19:24
Thanks a lot mob, I've tried implementing it, but there was an error, I've added an edit to the bottom of the question. –  Jon Jun 23 '11 at 19:42
OKAY! SOLVED! The ./IrregularVerbs.txt was changed to the full path, and then it worked perfectly. THANKS!!! –  Jon Jun 23 '11 at 19:45
add comment

Browse other questions tagged or ask your own question.