Home > Uncategorized > Notepad type program in Perl

Notepad type program in Perl

Whenever I learn a new programming language I write a notepad type program in said language. So here is the one in Perl:

#!usr/bin/perl
#
#Program to open a file and read its output and write to a file

#prints the statement
print "R to Read or W to Write: ";

#reads user input
my $choice = ;

#change R or W to lowercase
my $choicel = lc($choice);

print "where is the file located at? ";
my $fileloco = ;

if ($choicel eq "r\n") {
open(INFO, $fileloco) or die "File could not be open";
@lines = ;
close(INFO);
print @lines;
#added so it won't autoclose
;
}

elsif ($choicel eq "w\n") {
print "What would you like to add? ";
my $notes = ;
open(INFO, ">", $fileloco) or die "File could not be open";
print INFO $notes;
close(INFO);
;
}

This works under Linux and it should work under Windows. Everything that isn’t clear is commented. I don’t think I’ll be doing anything more in Perl. This program made me realize that I don’t like Perl as much as I thought.

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: