Call us +96895672917 | +917736882141

Project Description

Description
This assignment is an individual programming assignment using Perl. It addresses objectives 3, 4
and 8 as listed in the Subject Outline document.
No limits apply to the number of lines of code of the program.
Assignments are to be completed individually (this might be checked with the use of antiplagiarism
tools such as Turnitin). You should not receive help in the preparation of this
assignment, nor ask anyone else to prepare it on your behalf in any way.

 

 
Amongst the main strengths of the Perl programming language are its powerful text and arithmetic
manipulation features. In this assignment, you will put them to the use for writing a Perl
program which performs basic management of account usage.
These are the specifications for your Perl program:
1. The file with your program must be named accountmgr.pl
2. The program must be invoked as:
accountmgr.pl [option] account_file
The program must check that the account_file argument exists, is a file and is readable. If
not, it must print an error message to the standard output, and exit. The other argument to the
command is optional.
3. File account_file can have any arbitrary name. It must be a file of text with the following
format:
a. The file consists of an arbitrary number of lines (including, possibly, zero lines).
b. Each line must contain four fields separated by commas.
c. The four fields are: username, start time, end time and downloaded amount in
bytes.
d. The first field is a string of arbitrary (yet reasonably limited) length; the characters
in this string can be any of: uppercase letters, lowercase letters, decimal digits, the
underscore and the dot.
e. The start time and end time are strings in YYYY:MM:DD:hh:mm (year, month, day,
hour, minute) format. The hours are in 24-hour format (no am/pm added).
f. The downloaded amount in bytes is an integer limited between 0 and 42949672960
(40 * 230).
The following is an example of file account_file:
massimo.piccardi,2012:01:23:08:55,2012:01:25:12:45,1550008
zhang_thomas,2012:01:23:08:55,2012:01:23:08:59,18024
massimo.piccardi,2012:01:25:12:45,2012:01:25:14:30,1024
massimo.piccardi,2012:02:02:08:30,2012:02:02:20:30,2000000000
schmidt1974,2012:02:03:08:30,2012:02:21:07:55,230925000768
Very important note: your program is not expected to verify that file account_file complies with
the above specifications. You can also assume that the file meets the following specifications:
a. In each line, the end time is greater or equal than the start time.
Subject: 32547 UNIX Systems Programming, Autumn 2012 – Assignment
4
b. In each line, the start time is greater or equal than the start time of any previous line
(if any). This means that the lines are sorted in non-decreasing start time order.
c. For each user, the start time in any line is greater or equal than the end time of any
previous line (if any) for that same user. This means that the various sessions of
each user do not overlap.
4. Your program can be invoked without any options. In this case, it must print the following:
Found users:

Example with the example account_file given above:
Command line:
accountmgr.pl account_file
Output:
Found 3 users:
massimo.piccardi
zhang_thomas
schmidt1974
In the case in which file account_file is empty, your program must instead only print:
No users found
5. Your program can be invoked with option: –t. In this case, it must only print the following
string:
Total hours:minutes of
connection time
Example with the example account_file given above:
Command line:
accountmgr.pl –t account_file
Output:
Total 497:04 hours:minutes of connection time
(the above is the sum of the hours:minutes in all lines in this file)
In the case in which file account_file is empty, your program must print:
Subject: 32547 UNIX Systems Programming, Autumn 2012 – Assignment
5
Total 00:00 hours:minutes of connection time
6. Your program can be invoked with option: –d. In this case, it must only print the following
string:
Total MB downloaded
The number of megabytes is = number of bytes / 1048576. It must be expressed with 2
decimal digits with minimum truncation error (like Perl function printf “%.2f” does).
Example with the example account_file given above:
Command line:
accountmgr.pl –d account_file
Output:
Total 222136.09 MB downloaded
In the case in which file account_file is empty, your program must print:
Total 0.00 MB downloaded
7. Your program can be invoked with option: –u . In this case, it must print:
Total sessions
Total hours:minutes of
connection time
Total MB downloaded
Example with the example account_file given above:
Command line:
accountmgr.pl –u massimo.piccardi account_file
Output:
Total 3 sessions
Total 65:35 hours:minutes of connection time
Total 1908.83 MB downloaded
In the case in which file username is not present in account_file, your program must print:
User not found
8. Your program can be invoked with option: –s. In this case, it must only print your name,
surname and student ID in a format of your choice.
Subject: 32547 UNIX Systems Programming, Autumn 2012 – Assignment
6
9. The options cannot be used simultaneously. This means that your program can only be
invoked with no options or one of the options at a time.
10. If your program is invoked with a valid file argument, but any other syntax than what
specified above, it must only print the following string to the standard output:
Invalid command syntax
Example:
Command line:
accountmgr.pl -Z account_file
Output:
Invalid command syntax

 

================================================================================================

 

Answer with code and txt file

 

accountfile.txt includes

 

massimo.piccardi,2012:01:23:08:55,2012:01:25:12:45,1550008
zhang_thomas,2012:01:23:08:55,2012:01:23:08:59,18024
massimo.piccardi,2012:01:25:12:45,2012:01:25:14:30,1024
massimo.piccardi,2012:02:02:08:30,2012:02:02:20:30,2000000000
schmidt1974,2012:02:03:08:30,2012:02:21:07:55,230925000768

 

 

 

Perl program

 

 

#!/usr/bin/perl -w

# NOTE, please replace $name, $surname and $student_id with your own info

 

# Account management system

 

 

# Usage:

 

 

# perl accountmgr.pl nonexist_file.txt // output file does not exist

 

 

# perl accountmgr.pl account_file.txt // output all users

 

 

# perl accountmgr.pl -t account_file // output total connection time

 

 

# perl accountmgr.pl -d account_file // output total downloaded bytes

 

 

# perl accountmgr.pl -u massimo.piccardi account_file // output specific user info

 

 

# perl accountmgr.pl -s // output student info

 

use POSIX;

 

my $name = “Toby”;

 

 

my $surname = “HaHa”;

 

 

my $student_id = “123456”;

 

 

sub check {

 

 

my $file = shift;

 

 

if ((not -f $file) || (not -r $file)) {

 

 

die “$file does not exist or not readablen”;

 

 

}

 

 

}

 

 

sub count_users {

 

 

my $file = shift;

 

 

open(my $in, “<“, $file ) or die “Can’t open $file: $!”;

 

 

my $count = 0;

 

 

my @users;

 

 

while (<$in>) {

 

 

my ($name, $start, $end, $byte) = split(/,/, $_);

 

 

if (not grep {$_ eq $name} @users) {

 

 

$count += 1;

 

 

push @users, $name;

 

 

}

 

 

}

 

 

if (@users > 0) {

 

 

print “Found $count users:n”;

 

 

foreach (@users) {

 

 

the usages we added in the beginning of the code

One important NOTE, according to the pdf “it must only print your name, surname and student ID”
so client need replace $name, $surname and $student_id with his own info
that’s very easy, but important 🙂

 

Contact us for perl assignment help                     at             service@qualityassignmenthelp.com

 

For live chat          click here 

Project Details

  • Date April 2, 2015
  • Tags Perl

Leave a reply

sweet bonanza oynagates of olympus demoAviator oynasugar rush demoCasinoslotbig bass bonanza oynabig bass bonanza oynabayan escortTürkiye Escort Bayanbuca escortMaksibet Giriş TwitterPokerklas TwitterMelbet TwitterMercure Casino Giriş Twitterbornova escortfethiye escortmarsbahisEscortSaatlik escortManisa escortGümüşhane escortDeneme Bonusu Veren Sitelercasibomcasibom girişŞişli escortizmir escortDenizli escortMalatya Escortşanlıurfa escortHacklinkBeşiktaş escortAtaşehir escortBeylikdüzü escortkadıköy escortcialisViagraBahis siteleriEsenyurt escortmasözmasözantalya escortbetturkeycasibomdeneme bonusu veren sitelerdeneme bonusu veren siteler 2024casibombets10jojobet girişpusulabetbetmatik twitterbaywinGrandpashabetcasibomholiganbetbettilt girişcasibom girişslot sitelerisekabetbetmatikbetkanyonsekabetholiganbetbetmatikcasibomcasibomcasibomcasibomcasibomcasibomcasibomcasibomcasibomhitbetsahabetsahabetbettiltvdcasinoilbetcratosroyalbettümbetbaywindinamobetelexbetsekabetbetkanyonbetmatikbetinetumbetcasibomslot sitelericanlı casino sitelericasino sitelerislot siteleribahis siteleribaywinİnterbahiscasibomcasibomcasibombelugabahismadridbetartemisbetcasibomcasibomsweet bonanza oynagates of olympus demoAviator oynasugar rush demoCasinoslotbig bass bonanza oynabig bass bonanza oynabayan escortTürkiye Escort Bayanbuca escortMaksibet Giriş TwitterPokerklas TwitterMelbet TwitterMercure Casino Giriş Twitterbornova escortfethiye escortmarsbahisEscortSaatlik escortManisa escortGümüşhane escortDeneme Bonusu Veren Sitelercasibomcasibom girişŞişli escortizmir escortDenizli escortMalatya Escortşanlıurfa escortHacklinkBeşiktaş escortAtaşehir escortBeylikdüzü escortkadıköy escortcialisViagraBahis siteleriEsenyurt escortmasözmasözantalya escortbetturkeycasibomdeneme bonusu veren sitelerdeneme bonusu veren siteler 2024casibombets10jojobet girişpusulabetbetmatik twitterbaywinGrandpashabetcasibomholiganbetbettilt girişcasibom girişslot sitelerisekabetbetmatikbetkanyonsekabetholiganbetbetmatikcasibomcasibomcasibomcasibomcasibomcasibomcasibomcasibomcasibomhitbetsahabetsahabetbettiltvdcasinoilbetcratosroyalbettümbetbaywindinamobetelexbetsekabetbetkanyonbetmatikbetinetumbetcasibomslot sitelericanlı casino sitelericasino sitelerislot siteleribahis siteleribaywinİnterbahiscasibomcasibomcasibombelugabahismadridbetartemisbetcasibomcasibom
Wordpress themeseotakipçi satın alyol kapanıevden eve nakliyatseowordpress en iyi seo eklentilerikartal antika eşya alanlarwoocommerce baselpgcdpmsaantika alanlarantika alanlarAccident LawyerDental Implantiqosantika eşya alanlarAntika alan yerlergaziantep evden eve nakliyatsakarya evden eve nakliyatgaziantep evden eve nakliyatgaziantep evden eve nakliyatgaziantep evden eve nakliyatığdır evden eve nakliyateskişehir televizyon tamiriderince evden eve nakliyateskişehir protez saçEtimesgut evden eve nakliyatEtimesgut evden eve nakliyatankara gülüş tasarımımaltepe hayır lokmasıtuzla evden eve nakliyatvalizeskişehir web sitesieskişehir web sitesigaziantep evden eve taşımacılıkgaziantep evden eve nakliyatgaziantep evden eve nakliyatçekici ankaragaziantep evden eve taşımacılıkgaziantep evden eve nakliyatantika alanlarizmir evden eve nakliyatikinci el kitap alanlarçankaya evden eve nakliyatankara evden eve nakliyatkitap alanlareskişehir emlakEtimesgut evden eve nakliyatEtimesgut evden eve nakliyatEtimesgut evden eve nakliyathayır lokmasıankara evden eve nakliyatkartal evden eve nakliyattuzla evden eve nakliyatetimesgut evden eve nakliyatankara ofis taşımacılıgıoran evden eve nakliyatMedyumMedyumlarAnkara implant fiyatlarıkadıköy evden eve nakliyateskişehir uydu servisiçankırı evden eve nakliyatmamak evden eve nakliyatgaziantep nakliyatantika alanlareryaman evden eve nakliyatEskişehir uyduistanbul saç ekimidiş eti ağrısıAntalya Çitseo çalışmasıankara implant fiyatlarıankara gülüş tasarımımaldives online casinopoodleporselen kaplama dislerdis beyazlatmaniğde evden eve nakliyatAntika alan yerlerpoodlepomeraniandextools trendingdextools trending botfront run botdextools trending costdextools trending servicezibilyonbetpancakeswap botNewsHair Transplantankara eşya depolamadextools botdextools trending algorithmcoinmarketcap trending botpinksale trending botcoinmarketcap trendingfront running botpancakeswap sniper botuniswap botuniswap sniper botmev botpinksale trending botprediction botpancakeswap prediction botodunpazarı emlaksancaktepe evden eve nakliyatköpek ilanlarıMedyumWordpress themeseotakipçi satın alyol kapanıevden eve nakliyatseowordpress en iyi seo eklentilerikartal antika eşya alanlarwoocommerce baselpgcdpmsaantika alanlarantika alanlarAccident LawyerDental Implantiqosantika eşya alanlarAntika alan yerlergaziantep evden eve nakliyatsakarya evden eve nakliyatgaziantep evden eve nakliyatgaziantep evden eve nakliyatgaziantep evden eve nakliyatığdır evden eve nakliyateskişehir televizyon tamiriderince evden eve nakliyateskişehir protez saçEtimesgut evden eve nakliyatEtimesgut evden eve nakliyatankara gülüş tasarımımaltepe hayır lokmasıtuzla evden eve nakliyatvalizeskişehir web sitesieskişehir web sitesigaziantep evden eve taşımacılıkgaziantep evden eve nakliyatgaziantep evden eve nakliyatçekici ankaragaziantep evden eve taşımacılıkgaziantep evden eve nakliyatantika alanlarizmir evden eve nakliyatikinci el kitap alanlarçankaya evden eve nakliyatankara evden eve nakliyatkitap alanlareskişehir emlakEtimesgut evden eve nakliyatEtimesgut evden eve nakliyatEtimesgut evden eve nakliyathayır lokmasıankara evden eve nakliyatkartal evden eve nakliyattuzla evden eve nakliyatetimesgut evden eve nakliyatankara ofis taşımacılıgıoran evden eve nakliyatMedyumMedyumlarAnkara implant fiyatlarıkadıköy evden eve nakliyateskişehir uydu servisiçankırı evden eve nakliyatmamak evden eve nakliyatgaziantep nakliyatantika alanlareryaman evden eve nakliyatEskişehir uyduistanbul saç ekimidiş eti ağrısıAntalya Çitseo çalışmasıankara implant fiyatlarıankara gülüş tasarımımaldives online casinopoodleporselen kaplama dislerdis beyazlatmaniğde evden eve nakliyatAntika alan yerlerpoodlepomeraniandextools trendingdextools trending botfront run botdextools trending costdextools trending servicezibilyonbetpancakeswap botNewsHair Transplantankara eşya depolamadextools botdextools trending algorithmcoinmarketcap trending botpinksale trending botcoinmarketcap trendingfront running botpancakeswap sniper botuniswap botuniswap sniper botmev botpinksale trending botprediction botpancakeswap prediction botodunpazarı emlaksancaktepe evden eve nakliyatköpek ilanlarıMedyum