Important alert: (current site time 7/15/2013 8:48:03 PM EDT)
 

VB icon

AutoMax

Email
Submitted on: 11/26/2007 6:16:29 PM
By: Monika007 
Level: Beginner
User Rating: Unrated
Compatibility: 5.0 (all versions)
Views: 7231
(About the author)
 
     Very Basic Perl program, to insert clients and cars to a text file, also the script verify if the client or the car still exist in the text file.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
=**************************************
= Name: AutoMax
= Description:Very Basic Perl program, to insert clients and cars to a text file, also the script verify if the client or the car still exist in the text file.
= By: Monika007
=
=This code is copyrighted and has= limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=768&lngWId=6=for details.=**************************************

#!/usr/bin/perl
use warnings;
use strict;
use auto;
printf(" #######################################\n");
printf(" ########## AutoMaX Version 0.1 ########\n");
printf(" ############ Author :: Monika ##########\n");
printf(" ---------------------------------------\n");
sleep(1);
while(1) {
printf("WHAT DO YOU WANT TO DO\n");
printf(" * * * * *\n");
printf(" 1-Add new client\n");
printf(" 2-Add new car\n");
printf(" 3-Search client\n");
printf(" 4-Search car\n");
printf(" 5-Exit \n");
printf(" * * * * *\n");
my $choose = <STDIN>;
chomp($choose);
if($choose eq 1) { auto->client; }
elsif($choose eq 2) { car(); }
elsif($choose eq 3) { auto->search(); }
elsif($choose eq 4) { auto->car(); }
elsif($choose eq 5) { printf("Good Bye :-)\n"); exit(1);};
};
sub car {
printf(" ------------------------------\n");
printf(" | ADD NEW CAR|\n");
printf(" ------------------------------\n");
printf("\n");
printf("*Car Type : ");
my $type = <STDIN>; chomp $type;
printf("*Car color : ");
my $color = <STDIN>; chomp $color;
printf("*Car Year : ");
my $year = <STDIN>; chomp $year;
printf("*Car Price : ");
my $price = <STDIN>; chomp $price;
open(AA,'>>car.txt') or die "$!\n";
print AA "------ Type -----\n";
print AA " $type\n";
print AA "------ Color -----\n";
print AA " $color\n";
print AA "----- Year ------\n";
print AA " $year\n";
print AA "----- Price ----\n";
print AA " $price \n";
print AA "-----------------\n";
print AA "\n";
close(AA);
printf("Execution made successfully\n");
sleep(1);
};
1;
#This is the module, need to save it under other #new file, by the name auto.pm;
package auto;
sub client {
printf(" ------------------------------\n");
printf(" |ADD NEW CLIENT|\n");
printf(" ------------------------------\n");
printf("\n");
printf("*Client name : ");
my $client = <STDIN>; chomp $client;
printf("*Client Social Security Number : ");
my $social = <STDIN>; chomp $social;
printf("*Client Address : ");
my $address = <STDIN>; chomp $address;
printf("*Monthly Payment : ");
my $payment = <STDIN>; chomp $payment;
printf("*Total loan made : ");
my $loan = <STDIN>; chomp $loan;
open(AA,'>>client.txt') or die "$!\n";
print AA "------ Name -----\n";
print AA " $client\n";
print AA "------ Social Security -----\n";
print AA " $social\n";
print AA "----- Address ------\n";
print AA " $address\n";
print AA "----- Monthly Payment ------\n";
print AA " $payment\n\n";
print AA "----- TOTAL LOAN ----\n";
print AA " $loan\n";
print AA "-----------------\n";
print AA "\n";
close(AA);
printf("Execution made successfully\n");
sleep(1);
};
sub search {
printf(" ------------------------------\n");
printf(" |VERIFY CLIENT|\n");
printf(" ------------------------------\n");
printf("\n");
printf("Insert name of customer to verify\n");
my $client = <STDIN>; chomp($client);
open(BB,'client.txt') or warn("$!\n");
@a = <BB>;
close(BB);
foreach my $client2 (@a) {
if ($client2 =~ /$client/) { print("$client2"); }
else { print(""); };
}
};
sub car {
printf(" ------------------------------\n");
printf(" | VERIFY CAR |\n");
printf(" ------------------------------\n");
printf("\n");
printf("Insert name of car to verify\n");
my $car = <STDIN>; chomp($car);
open(BB,'car.txt') or warn("$!\n");
@a = <BB>;
close(BB);
foreach my $car2 (@a) {
if ($car2 =~ /$car/) { print("$car2"); }
else { print(""); };
}
};
1;


Other 3 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.