Edit Record In Perl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PilotinControl
    New Member
    • Oct 2014
    • 2

    Edit Record In Perl

    Hello Everyone!

    New member here and I have posted code below. The question is how do I go about editing on one screen not on several as it is being done in the code below which is a subroutine part of a larger script:

    Code:
    sub editcar {
    
    Title "Edit A Car";
    
    print("==============\n\n");
    print("| MAKE: |\n\n");
    print("           ==============\n\n\n\n\n\n\n\n\n\n\n\n");
     
    my $origMake = <STDIN>;
    $origMake = <STDIN> until defined $origMake;
    chomp $origMake;
    cls();
    
    print("================\n\n");
    print("| MODEL: |\n\n");
    print("                             ================\n\n\n\n\n\n\n\n\n\n\n\n");
     
    my $origModel = <STDIN>;
    $origModel = <STDIN> until defined $origModel;
    chomp $origModel;
    cls();
    
    print("                          ==================================\n\n");
    print("| YEAR : |\n\n");
    print("                          ==================================\n\n\n\n\n\n\n\n\n\n\n\n");
     
    my $origYear = <STDIN>;
    $origYear = <STDIN> until defined $origYear;
    chomp $origYear;
    cls();
    
    print("                          =============================\n\n");
    print("| NEW OWNER: |\n\n");
    print("                          =============================\n\n\n\n\n\n\n\n\n\n\n\n");
     
    my $newOwner = <STDIN>;
    $newOwner = <STDIN> until defined $newOwner;
    chomp $newOwner;
    cls();
    
    my $file = "cardata.txt";       
    
    local $^I = ".bak";
    local @ARGV = ($file);
    while (<>) {
    chomp;
    my ($Make,$Model,$Year,$Owner) = split(/\:/);
    if (($Make eq $origMake) && ($Model == $origModel)) {
    print "$Make:$Model:$Year:$newOwner\n";
    }
    else {
    print "$_\n";
    }
    }
    unlink("$file.bak");
    
    print("\n\n\n\n\n\n\n\n");    
    print("CAR UPDATED SUCCESSFULLY!!\n\n\n\n\n\n\n\n\n\n\n\n");
    
    } # END UPDATE CAR
    What I would like is to Enter the Owner on one screen and the next screen would list the cars owned by the owner and then highlight/select a car and the next screen would be the edit screen. Thanks for the help!
  • PilotinControl
    New Member
    • Oct 2014
    • 2

    #2
    Hello,

    I'll even be willing to pay someone for a working example of what I am in need of...thanks.

    Comment

    • onlinetuition
      New Member
      • Oct 2014
      • 10

      #3
      Better use a database table.

      Comment

      Working...