Perl Homework Help l Project l Perl Assignment

Hi, we are the only solutions for your Perl homework and will ensure that you receive an excellent grade that satisfies you.

Perl can be defined as a family of dynamic programming languages. Perl is a Practical Extraction and Reporting Language. The languages include Perl 5 and Perl 6. It is procedural in nature as it has expressions, variables, brace-delimited blocks, assignment statements, control structures, and subroutines. We can also say that the structure is derived from C language. Perl is a very important language across academic level as it has various practical applications and it is being used in various high traffic websites like IMDb, Craigslist, Priceline.com and LiveJournal.

As Perl has extensive applications, it is a very important subject at graduate and postgraduate level and it is must for students to score marks in Perl assignment and Perl homework to have a nice career in future. Many students worldwide find it difficult to work on Perl projects as they are very complicated. Taking the needs of our programming students into consideration, programmingassignments.com started Perl assignment help and Perl project help services.

Here’s an example Perl homework, that demonstrates the type of Perl homework help we can offer.

Perl script analyser

Part A: Perl Script Analyser (PartA.pl)

Write a Perl script to analyze another Perl script specified as the first command-line argument.

As part of pre-analysis validations, your script should check if the specified script file:

  • has an acceptable file extension (defined below); and
  • exists; and
  • is a readable text file; and
  • is not empty.

Acceptable file extensions are (case sensitive):

  • .pl
  • .pm

Your script should display the following error message and quit gracefully if the specified file failed any one (or more) of the pre-analysis validations:

\$ ./PartA.pl /aaa/bbb/ccc/invalid_script.pl

Error: unable to analyse the specified file.

\$

It is important that you display the exact same error message as your assignment submission may be assessed by an automated marking process.

Once a script file passed the pre-analysis validation, your script should perform the following tasks in order:

Display the number of lines, words, and characters in the file based on the output of an external Linux command of your choice, e.g. wc;

Identify the keywords in the script, and display them in the order as they first appeared in the file. If a keyword appeared multiple times in the script, only the first instance should be displayed. If there are more than 15 unique keywords in the file, display the first 15 keywords only;

Identify the strings in the script, and display them in the order as they appeared in the file. If there are more than 10 strings in the file, display the first 10 strings only;

Identify the comments in the script, and display them in the order as they appeared in the file. If there are more than 5 comments in the file, display the first 5 comments only.

For the purpose of Part A only, we assume:

Keywords appeared in strings and comments are still considered keywords;

A string is always on the same line, i.e. you do not need to consider multi-line strings;

# characters do not appear inside strings or regular expressions;

Single or double quoted strings do not appear in comments.

Part B: Improved Perl Script Analyser

Based on your PartA.pl, create a new script PartB.pl.

This new script should perform the same tasks as Part A but WITHOUT using any external command. It is also important to note that the assumptions (in the last paragraph on Page 2) for Part A is no longer valid in Part B. Therefore, in Part B:

Keywords appeared in strings and comments are not considered keywords;

Strings may appear on multiple lines, but they always have single quotes or double quotes around them;

# characters may appear inside strings or regular expressions;

Single or double quoted strings may appear in comments.

Part C: Advanced Perl Script Analyzer

Based on your PartB.pl, create a new script PartC.pl.

In addition to the existing features of Part B, you should also identify the numbers in the script using Regular Expressions, and display them in the order as they appeared in the file. If there are more than 10 numbers in the file, display the first 10 numbers only. The identified numbers should be displayed after the keywords section but before the strings section.

For the purpose of this assignment:

A number is a Perl numeric literal in any of the floating point or integer formats specified on http://perldoc.perl.org/perldata.html#Scalar-value-constructors except those within strings or comments.

A sample script and the expected output for Part C will be published in the Blackboard

Part D: Perl Script Syntax Highlighter

PartD.pl accepts two command line arguments, the Perl script to be syntax highlighted, and then an HTML output filename (with the file extension of either .htm or .html). The script should not produce any output to the screen unless there is an error. If the output file already exists, it will be overwritten.

The title of the generated HTML file should be the file name of the specified script.

The following HTML colour codes should be used to syntax highlight the Perl script in the HTML output:

  • Keywords – darkred
  • Numbers – darkcyan
  • Strings – royalblue
  • Comments – darkgreen

To maintain the format and readability, the entire script should be wrapped within a pair of HTML <pre> tags.

The most challenging thing for students is the implementation. Perl programs can be very sophisticated. Perl has large collection of modules, written in Perl and C and it is implemented as an essential interpreter.

PartA.pl

#!/usr/bin/perl

use strict;

=pod
=head2 Description

The code is used to analyse a Perl script 
specified as the first command-line argument

Acceptable file extensions are (case sensitive):
=item .pl
=item .pm

Input file should be readable and non-empty.

The input file's lines are read into array
with is further parsed.

External UNIX command wc is used to get 
lines, words and characters count.

Looping trough lines of code keywords, strings and comments
are matched using appropriate regular expressions and placed
in data arrays.

File's summary is printed on the screen.
=cut
# an array with perl's keywords
my @keywords = qw/
-AEND lengthsetpgrp
-B endgrent link setpriority
-b endhostent listen setprotoent
-C endnetent local setpwent
-c endprotoent localtime setservent
-d endpwent log setsockopt
-e endservent lstat shift
-f eof map shmctl
-g eval mkdir shmget
-k exec msgctl shmread
-l exists msgget shmwrite
-M exit msgrcv shutdown
-O fcntl msgsnd sin
-o fileno my sleep
-p flock next socket
-r fork not socketpair
-R format oct sort
-S formline open splice
-s getc opendir split
-T getgrent ord sprintf
-t getgrgid our sqrt
-u getgrnam pack srand
-w gethostbyaddr pipe stat
-W gethostbyname pop state
-X gethostent pos study
-x getlogin print substr
-z getnetbyaddr printf symlink
abs getnetbyname prototype syscall
accept getnetent push sysopen
alarm getpeername quotemeta sysread
atan2 getpgrp rand sysseek
AUTOLOAD getppid read system
BEGIN getpriority readdir syswrite
bind getprotobyname readline tell
binmode getprotobynumber readlink telldir
bless getprotoent readpipe tie
break getpwent recv tied
caller getpwnam redo time
chdir getpwuid ref times
CHECK getservbyname rename truncate
chmod getservbyport require uc
chomp getservent reset ucfirst
chop getsockname return umask
chown getsockopt reverse undef
chr glob rewinddir UNITCHECK
chroot gmtime rindex unlink
close goto rmdir unpack
closedir grep say unshift
connect hex scalar untie
cos index seek use
crypt INIT seekdir utime
dbmclose int select values
dbmopen ioctl semctl vec
defined join semget wait
delete keys semop waitpid
DESTROY kill send wantarray
die last setgrent warn
dump lc sethostent write
each lcfirst setnetent 
__DATA__ else lock qw
__END__ elsif lt qx
__FILE__ eq m s
__LINE__ exp ne sub
__PACKAGE__ for no tr
and foreach or unless
cmp ge package until
continue gt q while
CORE if qq xor
do le qr y
ARGV STDERR STDOUT
ARGVOUT STDIN/;

sub pre_analysis {

    unless ($_[0] =~ m/.pm$|.pl$/ && -e $_[0] && -r $_[0] && ! -z $_[0]) {
        die "Error: unable to analyse the specified file.\n";
    }
}

sub read_file {

    open my $datafile, '<', $_[0] or die "Can't open a file: $!\n";
    my @lines = <$datafile>;
    close $datafile or die "Can't close a file: $!\n";
    @lines;
}

#
# Main code starts here
#

my @matched_keywords;
my @matched_strings;
my @matched_comments;

# Check if there are enough arguments and abort if not
if (@ARGV != 1) {
    die "Usage: $0 <input file>\n";
}
my $filename = $ARGV[0];

pre_analysis $filename;
print "File: $filename\n";

# get file's contents
my @lines = read_file $filename;

# count lines, words and characters using shell wc command
my $stats = `wc $filename`;
my @stats = split(' ', $stats);

print "Lines: $stats[0]\n";
print "Words: $stats[1]\n";
print "Chars: $stats[2]\n";

for my $line (@lines) {
    # match keywords in a line
    for my $word (split(' ', $line)) {
        if ( (grep {$_ eq $word} @keywords) && ! (grep {$_ eq $word} @matched_keywords) ) {
            push @matched_keywords, $word;
        }
    }
    # match a string in a line
    if ($line =~ m/(".*"|'.*')/) {
        push @matched_strings, $1;
    }
    # match a comment in a line (do not count first line)
    if ($line =~ m/(#.*$)/ and $lines[0] ne $line)  {
        push @matched_comments, $1;
    }
}

print "[Keywords]\n";
my $n = @matched_keywords <= 15 ? @matched_keywords : 15;
for (@matched_keywords[0..$n-1]) {
    print "$_\n";
}

print "[Strings]\n";
my $n = @matched_strings <= 10 ? @matched_strings : 10;
for (@matched_strings[0..$n-1]) {
    print "$_\n";
}

print "[Comments]\n";
my $n = @matched_comments <= 5 ? @matched_comments : 5;
for (@matched_comments[0..$n-1]) {
    print "$_\n";
}

The two important factors in implementation are Compile time and run time. Most of the queries in Perl projects come on the implementation part. Our Perl experts focus on the requirements of the students and the challenges faced in solving Perl assignments before providing help with Perl assignment and Perl homework.

PartB.pl

#!/usr/bin/perl

use strict;

=pod
=head2 Description

The code is used to analyse a Perl script 
specified as the first command-line argument

Acceptable file extensions are (case sensitive):
=item .pl
=item .pm

Input file should be readable and non-empty.

The input file's lines are read into array
with is further parsed.

stats subroutine is used to get 
lines, words and characters count.

Looping trough lines of code keywords, strings and comments
are matched using apropriate regular expressions and placed
in data arrays.

File's summary is printed on the screen.

=cut

# an array with perl's keywords
my @keywords = qw/
-AEND lengthsetpgrp
-B endgrent link setpriority
-b endhostent listen setprotoent
-C endnetent local setpwent
-c endprotoent localtime setservent
-d endpwent log setsockopt
-e endservent lstat shift
-f eof map shmctl
-g eval mkdir shmget
-k exec msgctl shmread
-l exists msgget shmwrite
-M exit msgrcv shutdown
-O fcntl msgsnd sin
-o fileno my sleep
-p flock next socket
-r fork not socketpair
-R format oct sort
-S formline open splice
-s getc opendir split
-T getgrent ord sprintf
-t getgrgid our sqrt
-u getgrnam pack srand
-w gethostbyaddr pipe stat
-W gethostbyname pop state
-X gethostent pos study
-x getlogin print substr
-z getnetbyaddr printf symlink
abs getnetbyname prototype syscall
accept getnetent push sysopen
alarm getpeername quotemeta sysread
atan2 getpgrp rand sysseek
AUTOLOAD getppid read system
BEGIN getpriority readdir syswrite
bind getprotobyname readline tell
binmode getprotobynumber readlink telldir
bless getprotoent readpipe tie
break getpwent recv tied
caller getpwnam redo time
chdir getpwuid ref times
CHECK getservbyname rename truncate
chmod getservbyport require uc
chomp getservent reset ucfirst
chop getsockname return umask
chown getsockopt reverse undef
chr glob rewinddir UNITCHECK
chroot gmtime rindex unlink
close goto rmdir unpack
closedir grep say unshift
connect hex scalar untie
cos index seek use
crypt INIT seekdir utime
dbmclose int select values
dbmopen ioctl semctl vec
defined join semget wait
delete keys semop waitpid
DESTROY kill send wantarray
die last setgrent warn
dump lc sethostent write
each lcfirst setnetent 
__DATA__ else lock qw
__END__ elsif lt qx
__FILE__ eq m s
__LINE__ exp ne sub
__PACKAGE__ for no tr
and foreach or unless
cmp ge package until
continue gt q while
CORE if qq xor
do le qr y
ARGV STDERR STDOUT
ARGVOUT STDIN/;

sub pre_analysis {
    print "$_[0]\n";
    unless ($_[0] =~ m/.pm$|.pl$/ && -e $_[0] && -r $_[0] && ! -z $_[0]) {
        die "Error: unable to analyse the specified file.\n";
    }
}

sub read_file {

    #print "$_[0]\n";   debug
    open my $datafile, '<', $_[0] or die "Can't open a file: $!\n";
    my @lines = <$datafile>;
    close $datafile or die "Can't close a file: $!\n";
    @lines;
}

sub stats {

    my $lines = @_;

    my $words;
    for (@_) {
        $words += split(/\s+/, $_);
    }

    my $chars;
    for (@_) {
        $chars += length($_);
    }

    my @stats = ($lines, $words, $chars);
}

#
# Main code starts here
#

my @matched_keywords;
my @matched_strings;
my @matched_comments;

# Check if there are enough arguments and abort if not
if (@ARGV != 1) {
    die "Usage: $0 <input file>\n";
}
my $filename = $ARGV[0];

pre_analysis $filename;
print "File: $filename\n";

# get file's contents
my @lines = read_file $filename;

# count lines, words and characters using shell wc command
#my $stats = `wc $filename`;
my @stats = stats @lines;

print "Lines: $stats[0]\n";
print "Words: $stats[1]\n";
print "Chars: $stats[2]\n";

for my $line (@lines) {
    #print $line;   debug
    # match keywords in a line
    for my $word (split(' ', $line)) {
        #print "$word\n";
        if ( (grep {$_ eq $word} @keywords) && ! (grep {$_ eq $word} @matched_keywords) ) {
            # check if a keyword is not a part of comment or string
            unless ( ( $line =~ m/#.*$word/ ) or ( $line =~ m/(".*$word.*"|'.*$word.*')/ ) ) {
                push @matched_keywords, $word;
            }
        }
    }
    # match a string in a line
    if ($line =~ m/(".*"|'.*')/) {
        # check if a string is commented
        unless ($line =~ m/(#.*$1)/) {
            push @matched_strings, $1;
        }
    }
    # match a comment in a line (do not count first line)
    if ($line =~ m/(#.*$)/ and $lines[0] ne $line)  {
        # check if a comment is a part of a string or regex
        unless ( $line =~ m/(".*#.*"|'.*#.*')/ or $line =~ m/\/.*#.*\// ) {
            push @matched_comments, $1;
        }
    }
}

# match multiline strings
my $i = 0;
while ($i < $#lines) {
    if (! ($lines[$i] =~ m/";\n/) && ($lines[$i] =~ m/[^#]*("[^"]*\n)/) )
    {
        my $str = $1;
        $i++;
        while ( !($lines[$i] =~ m/(.*")[^"]*/) ) {
            $str .= $lines[$i++];
        }
        if ($lines[$i] =~ m/(.*")[^"]*/) {
            $str .= $1;
        }
        push @matched_strings, $str;
    }
    $i++;
}

print "[Keywords]\n";
my $n = @matched_keywords <= 15 ? @matched_keywords : 15;
for (@matched_keywords[0..$n-1]) {
    print "$_\n";
}

print "[Strings]\n";
my $n = @matched_strings <= 10 ? @matched_strings : 10;
for (@matched_strings[0..$n-1]) {
    print "$_\n";
}

print "[Comments]\n";
my $n = @matched_comments <= 5 ? @matched_comments : 5;
for (@matched_comments[0..$n-1]) {
    print "$_\n";
}

We started providing online Perl help as many students used to come to us with queries related to Perl and currently we are the market leaders in providing Perl assignment help and have worked on more than 300 Perl assignments / homework. Our highly qualified Perl experts have 10+ years on teaching experience in programming and hence we can assure you plagiarism free solution to your Perl homework. Our programming experts can provide you high quality solution to your Perl assignments even at a short notice.

PartC.pl

#!/usr/bin/perl

use strict;

=pod
=head2 Description

The code is used to analyse a Perl script 
specified as the first command-line argument

Acceptable file extensions are (case sensitive):
=item .pl
=item .pm

Input file should be readable and non-empty.

The input file's lines are read into array
with is further parsed.

stats subroutine is used to get 
lines, words and characters count.

Looping trough lines of code keywords, numbers, strings and comments
are matched using apropriate regular expressions and placed
in data arrays.

File's summary is printed on the screen.

=cut

# an array with perl's keywords
my @keywords = qw/
-AEND lengthsetpgrp
-B endgrent link setpriority
-b endhostent listen setprotoent
-C endnetent local setpwent
-c endprotoent localtime setservent
-d endpwent log setsockopt
-e endservent lstat shift
-f eof map shmctl
-g eval mkdir shmget
-k exec msgctl shmread
-l exists msgget shmwrite
-M exit msgrcv shutdown
-O fcntl msgsnd sin
-o fileno my sleep
-p flock next socket
-r fork not socketpair
-R format oct sort
-S formline open splice
-s getc opendir split
-T getgrent ord sprintf
-t getgrgid our sqrt
-u getgrnam pack srand
-w gethostbyaddr pipe stat
-W gethostbyname pop state
-X gethostent pos study
-x getlogin print substr
-z getnetbyaddr printf symlink
abs getnetbyname prototype syscall
accept getnetent push sysopen
alarm getpeername quotemeta sysread
atan2 getpgrp rand sysseek
AUTOLOAD getppid read system
BEGIN getpriority readdir syswrite
bind getprotobyname readline tell
binmode getprotobynumber readlink telldir
bless getprotoent readpipe tie
break getpwent recv tied
caller getpwnam redo time
chdir getpwuid ref times
CHECK getservbyname rename truncate
chmod getservbyport require uc
chomp getservent reset ucfirst
chop getsockname return umask
chown getsockopt reverse undef
chr glob rewinddir UNITCHECK
chroot gmtime rindex unlink
close goto rmdir unpack
closedir grep say unshift
connect hex scalar untie
cos index seek use
crypt INIT seekdir utime
dbmclose int select values
dbmopen ioctl semctl vec
defined join semget wait
delete keys semop waitpid
DESTROY kill send wantarray
die last setgrent warn
dump lc sethostent write
each lcfirst setnetent 
__DATA__ else lock qw
__END__ elsif lt qx
__FILE__ eq m s
__LINE__ exp ne sub
__PACKAGE__ for no tr
and foreach or unless
cmp ge package until
continue gt q while
CORE if qq xor
do le qr y
ARGV STDERR STDOUT
ARGVOUT STDIN/;

sub pre_analysis {

    unless ($_[0] =~ m/.pm$|.pl$/ && -e $_[0] && -r $_[0] && ! -z $_[0]) {
        die "Error: unable to analyse the specified file.\n";
    }
}

sub read_file {

    #print "$_[0]\n";   debug
    open my $datafile, '<', $_[0] or die "Can't open a file: $!\n";
    my @lines = <$datafile>;
    close $datafile or die "Can't close a file: $!\n";
    @lines;
}

sub stats {

    my $lines = @_;

    my $words;
    for (@_) {
        $words += split(/\s+/, $_);
    }

    my $chars;
    for (@_) {
        $chars += length($_);
    }

    my @stats = ($lines, $words, $chars);
}

#
# Main code starts here
#

my @matched_keywords;
my @matched_strings;
my @matched_comments;
my @matched_numbers;

# Check if there are enough arguments and abort if not
if (@ARGV != 1) {
    die "Usage: $0 <input file>\n";
}
my $filename = $ARGV[0];

pre_analysis $filename;
print "File: $filename\n";

# get file's contents
my @lines = read_file $filename;

# count lines, words and characters using shell wc command
#my $stats = `wc $filename`;
my @stats = stats @lines;

print "Lines: $stats[0]\n";
print "Words: $stats[1]\n";
print "Chars: $stats[2]\n";

for my $line (@lines) {
    #print $line;   debug
    # match keywords in a line
    for my $word (split(' ', $line)) {
        #print "$word\n";
        if ( (grep {$_ eq $word} @keywords) && ! (grep {$_ eq $word} @matched_keywords) ) {
            # check if a keyword is not a part of comment or string
            unless ( ( $line =~ m/#.*$word/ ) or ( $line =~ m/(".*$word.*"|'.*$word.*')/ ) ) {
                push @matched_keywords, $word;
            }
        }
    }
    # match a string in a line
    if ($line =~ m/(".*"|'.*')/) {
        # check if a string is commented
        unless ($line =~ m/(#.*$1)/) {
            push @matched_strings, $1;
        }
    }
    # match a comment in a line (do not count first line)
    if ($line =~ m/(#.*$)/ and $lines[0] ne $line)  {
        # check if a comment is a part of a string or regex
        unless ( $line =~ m/(".*#.*"|'.*#.*')/ or $line =~ m/\/.*#.*\// ) {
            push @matched_comments, $1;
        }
    }

    # match an integer or floating point number
    my @numbers = $line =~ m/([\d]?\.?[_0-9]*[eE][+-]?[_0-9]+|[\d]*\.[_0-9]+|[_0-9]+)/g;
    for (@numbers) {
        # check if a number is commented
        unless ($line =~ m/(#.*$_)/) {
            push @matched_numbers, $_;
        }
    }
}

# match multiline strings
my $i = 0;
while ($i < $#lines) {
    if (! ($lines[$i] =~ m/";\n/) && ($lines[$i] =~ m/[^#]*("[^"]*\n)/) )
    {
        my $str = $1;
        $i++;
        while ( !($lines[$i] =~ m/(.*")[^"]*/) ) {
            $str .= $lines[$i++];
        }
        if ($lines[$i] =~ m/(.*")[^"]*/) {
            $str .= $1;
        }
        push @matched_strings, $str;
    }
    $i++;
}

print "[Keywords]\n";
my $n = @matched_keywords <= 15 ? @matched_keywords : 15;
for (@matched_keywords[0..$n-1]) {
    print "$_\n";
}

print "[Numbers]\n";
my $n = @matched_numbers <= 10 ? @matched_numbers : 10;
for (@matched_numbers[0..$n-1]) {
    print "$_\n";
}

print "[Strings]\n";
my $n = @matched_strings <= 10 ? @matched_strings : 10;
for (@matched_strings[0..$n-1]) {
    print "$_\n";
}

print "[Comments]\n";
my $n = @matched_comments <= 5 ? @matched_comments : 5;
for (@matched_comments[0..$n-1]) {
    print "$_\n";
}

Even if you somehow manage to work on Perl assignments on your own, it is complicated to work on Perl projects. Hence Perl project help is one of the most sought after services as students frequently come to us for Perl project help due to our high quality solution provided by us. Our Perl tutors also provide you online Perl project assistance apart from working on your Perl project. If you are struggling to develop a Perl project then avail our Perl project help service to achieve excellent grades.

PartD.pl

#!/usr/bin/perl

use strict;

=pod
=head2 Description

The code is used to analyse a Perl script 
specified as the first command-line argument
and writes highlighted code into html file
specified as second argument.

Acceptable file extensions are (case sensitive):
=item .pl
=item .pm

Acceptable html file extensions are:
=item .html
=item .htm

Input file should be readable and non-empty.

The input file's lines are read into array
with is further parsed.

Looping trough lines of code keywords, numbers, strings and comments
are matched using apropriate regular expressions and placed
in data arrays.

Each of keywords, numbers, strings and comments are highlighted with
specific color in output html code.

=cut

# an array with perl's keywords
my @keywords = qw/
-AEND lengthsetpgrp
-B endgrent link setpriority
-b endhostent listen setprotoent
-C endnetent local setpwent
-c endprotoent localtime setservent
-d endpwent log setsockopt
-e endservent lstat shift
-f eof map shmctl
-g eval mkdir shmget
-k exec msgctl shmread
-l exists msgget shmwrite
-M exit msgrcv shutdown
-O fcntl msgsnd sin
-o fileno my sleep
-p flock next socket
-r fork not socketpair
-R format oct sort
-S formline open splice
-s getc opendir split
-T getgrent ord sprintf
-t getgrgid our sqrt
-u getgrnam pack srand
-w gethostbyaddr pipe stat
-W gethostbyname pop state
-X gethostent pos study
-x getlogin print substr
-z getnetbyaddr printf symlink
abs getnetbyname prototype syscall
accept getnetent push sysopen
alarm getpeername quotemeta sysread
atan2 getpgrp rand sysseek
AUTOLOAD getppid read system
BEGIN getpriority readdir syswrite
bind getprotobyname readline tell
binmode getprotobynumber readlink telldir
bless getprotoent readpipe tie
break getpwent recv tied
caller getpwnam redo time
chdir getpwuid ref times
CHECK getservbyname rename truncate
chmod getservbyport require uc
chomp getservent reset ucfirst
chop getsockname return umask
chown getsockopt reverse undef
chr glob rewinddir UNITCHECK
chroot gmtime rindex unlink
close goto rmdir unpack
closedir grep say unshift
connect hex scalar untie
cos index seek use
crypt INIT seekdir utime
dbmclose int select values
dbmopen ioctl semctl vec
defined join semget wait
delete keys semop waitpid
DESTROY kill send wantarray
die last setgrent warn
dump lc sethostent write
each lcfirst setnetent 
__DATA__ else lock qw
__END__ elsif lt qx
__FILE__ eq m s
__LINE__ exp ne sub
__PACKAGE__ for no tr
and foreach or unless
cmp ge package until
continue gt q while
CORE if qq xor
do le qr y
ARGV STDERR STDOUT
ARGVOUT STDIN/;

sub pre_analysis {

    unless ($_[0] =~ m/.pm$|.pl$/ && -e $_[0] && -r $_[0] && ! -z $_[0]) {
        die "Error: unable to analyse the specified file.\n";
    }
}

sub read_file {

    #print "$_[0]\n";   debug
    open my $datafile, '<', $_[0] or die "Can't open a file: $!\n";
    my @lines = <$datafile>;
    close $datafile or die "Can't close a file: $!\n";
    @lines;
}

sub write_file {
    open my $datafile, '>', $_[0] or die "Can't open a file: $!\n";
    print $datafile $_[1];
    close $datafile or die "Can't close a file: $!\n";
}

sub stats {

    my $lines = @_;

    my $words;
    for (@_) {
        $words += split(/\s+/, $_);
    }

    my $chars;
    for (@_) {
        $chars += length($_);
    }

    my @stats = ($lines, $words, $chars);
}

#
# Main code starts here
#

my @matched_keywords;
my @matched_strings;
my @matched_comments;
my @matched_numbers;

# Check if there are enough arguments and abort if not
if (@ARGV != 2) {
    die "Usage: $0 <input file> <output file>\n";
}
my $filename = $ARGV[0];
my $html_file = $ARGV[1];

unless ($html_file =~ m/.html$|.htm$/) {
    die "Error: invalid outplt file format.\n";
}

pre_analysis $filename;

# get file's contents
my @lines = read_file $filename;
my $contents = join('', @lines);

# count lines, words and characters using shell wc command
#my $stats = `wc $filename`;
my @stats = stats @lines;

for my $line (@lines) {
    #print $line;   debug
    # match keywords in a line
    for my $word (split(' ', $line)) {
        #print "$word\n";
        if ( (grep {$_ eq $word} @keywords) && ! (grep {$_ eq $word} @matched_keywords) ) {
            # check if a keyword is not a part of comment or string
            unless ( ( $line =~ m/#.*$word/ ) or ( $line =~ m/(".*$word.*"|'.*$word.*')/ ) ) {
                push @matched_keywords, $word;
            }
        }
    }
    # match a string in a line
    if ($line =~ m/(".*"|'.*')/) {
        # check if a string is commented
        unless ($line =~ m/(#.*$1)/) {
            push @matched_strings, $1;
        }
    }
    # match a comment in a line (do not count first line)
    if ($line =~ m/(#.*$)/ and $lines[0] ne $line)  {
        # check if a comment is a part of a string or regex
        unless ( $line =~ m/(".*#.*"|'.*#.*')/ or $line =~ m/\/.*#.*\// ) {
            push @matched_comments, $1;
        }
    }

    # match an integer or floating point number
    my @numbers = $line =~ m/([\d]?\.?[_0-9]*[eE][+-]?[_0-9]+|[\d]*\.[_0-9]+|[_0-9]+)/g;
    for (@numbers) {
        # check if a number is commented
        unless ($line =~ m/(#.*$_)/) {
            push @matched_numbers, $_;
        }
    }
}

# match multiline strings
my $i = 0;
while ($i < $#lines) {
    if (! ($lines[$i] =~ m/";\n/) && ($lines[$i] =~ m/[^#]*("[^"]*\n)/) )
    {
        my $str = $1;
        $i++;
        while ( !($lines[$i] =~ m/(.*")[^"]*/) ) {
            $str .= $lines[$i++];
        }
        if ($lines[$i] =~ m/(.*")[^"]*/) {
            $str .= $1;
        }
        push @matched_strings, $str;
    }
    $i++;
}

for (@matched_keywords) {
    $contents =~ s/\Q$_\E/<font color="darkred">$_<\/font>/g;
}
for (@matched_numbers) {
    $contents =~ s/\Q$_\E/<font color="darkcyan">$_<\/font>/;
}
for (@matched_strings) {
    $contents =~ s/\Q$_\E/<font color="royalblue">$_<\/font>/;
}
for (@matched_comments) {
    $contents =~ s/\Q$_\E/<font color="darkgreen">$_<\/font>/;
}

my $html_data = "<html>\n<head><title>\n".$filename."\n</title></head>\n";

$html_data .= "<body><pre>\n";
$html_data .= $contents;
$html_data .= "</pre></body>\n</html>\n";

write_file ($html_file, $html_data);

If you are looking for help with Perl project, then we can provide you with the solution, that is guaranteed plagiarism free.

We provide online Perl services across all academic levels from undergraduate, graduate to postgraduate. We are the market leaders in online Perl Help. So if you find Perl challenging then just drop us a mail mentioning your requirement and de-stress your mind from Perl assignment and Perl projects.

Perl Homework Help l Project l Perl Assignment

Hi, we are the only solutions for your Perl homework and will ensure that you receive an excellent grade that satisfies you.

Perl can be defined as a family of dynamic programming languages. Perl is a Practical Extraction and Reporting Language. The languages include Perl 5 and Perl 6. It is procedural in nature as it has expressions, variables, brace-delimited blocks, assignment statements, control structures, and subroutines. We can also say that the structure is derived from C language. Perl is a very important language across academic level as it has various practical applications and it is being used in various high traffic websites like IMDb, Craigslist, Priceline.com and LiveJournal.

As Perl has extensive applications, it is a very important subject at graduate and postgraduate level and it is must for students to score marks in Perl assignment and Perl homework to have a nice career in future. Many students worldwide find it difficult to work on Perl projects as they are very complicated. Taking the needs of our programming students into consideration, programmingassignments.com started Perl assignment help and Perl project help services.

Here’s an example Perl homework, that demonstrates the type of Perl homework help we can offer.

Perl script analyser

Part A: Perl Script Analyser (PartA.pl)

Write a Perl script to analyze another Perl script specified as the first command-line argument.

As part of pre-analysis validations, your script should check if the specified script file:

  • has an acceptable file extension (defined below); and
  • exists; and
  • is a readable text file; and
  • is not empty.

Acceptable file extensions are (case sensitive):

  • .pl
  • .pm

Your script should display the following error message and quit gracefully if the specified file failed any one (or more) of the pre-analysis validations:

\$ ./PartA.pl /aaa/bbb/ccc/invalid_script.pl

Error: unable to analyse the specified file.

\$

It is important that you display the exact same error message as your assignment submission may be assessed by an automated marking process.

Once a script file passed the pre-analysis validation, your script should perform the following tasks in order:

Display the number of lines, words, and characters in the file based on the output of an external Linux command of your choice, e.g. wc;

Identify the keywords in the script, and display them in the order as they first appeared in the file. If a keyword appeared multiple times in the script, only the first instance should be displayed. If there are more than 15 unique keywords in the file, display the first 15 keywords only;

Identify the strings in the script, and display them in the order as they appeared in the file. If there are more than 10 strings in the file, display the first 10 strings only;

Identify the comments in the script, and display them in the order as they appeared in the file. If there are more than 5 comments in the file, display the first 5 comments only.

For the purpose of Part A only, we assume:

Keywords appeared in strings and comments are still considered keywords;

A string is always on the same line, i.e. you do not need to consider multi-line strings;

# characters do not appear inside strings or regular expressions;

Single or double quoted strings do not appear in comments.

Part B: Improved Perl Script Analyser

Based on your PartA.pl, create a new script PartB.pl.

This new script should perform the same tasks as Part A but WITHOUT using any external command. It is also important to note that the assumptions (in the last paragraph on Page 2) for Part A is no longer valid in Part B. Therefore, in Part B:

Keywords appeared in strings and comments are not considered keywords;

Strings may appear on multiple lines, but they always have single quotes or double quotes around them;

# characters may appear inside strings or regular expressions;

Single or double quoted strings may appear in comments.

Part C: Advanced Perl Script Analyzer

Based on your PartB.pl, create a new script PartC.pl.

In addition to the existing features of Part B, you should also identify the numbers in the script using Regular Expressions, and display them in the order as they appeared in the file. If there are more than 10 numbers in the file, display the first 10 numbers only. The identified numbers should be displayed after the keywords section but before the strings section.

For the purpose of this assignment:

A number is a Perl numeric literal in any of the floating point or integer formats specified on http://perldoc.perl.org/perldata.html#Scalar-value-constructors except those within strings or comments.

A sample script and the expected output for Part C will be published in the Blackboard

Part D: Perl Script Syntax Highlighter

PartD.pl accepts two command line arguments, the Perl script to be syntax highlighted, and then an HTML output filename (with the file extension of either .htm or .html). The script should not produce any output to the screen unless there is an error. If the output file already exists, it will be overwritten.

The title of the generated HTML file should be the file name of the specified script.

The following HTML colour codes should be used to syntax highlight the Perl script in the HTML output:

  • Keywords – darkred
  • Numbers – darkcyan
  • Strings – royalblue
  • Comments – darkgreen

To maintain the format and readability, the entire script should be wrapped within a pair of HTML <pre> tags.

The most challenging thing for students is the implementation. Perl programs can be very sophisticated. Perl has large collection of modules, written in Perl and C and it is implemented as an essential interpreter.

PartA.pl

#!/usr/bin/perl

use strict;

=pod
=head2 Description

The code is used to analyse a Perl script 
specified as the first command-line argument

Acceptable file extensions are (case sensitive):
=item .pl
=item .pm

Input file should be readable and non-empty.

The input file's lines are read into array
with is further parsed.

External UNIX command wc is used to get 
lines, words and characters count.

Looping trough lines of code keywords, strings and comments
are matched using appropriate regular expressions and placed
in data arrays.

File's summary is printed on the screen.
=cut
# an array with perl's keywords
my @keywords = qw/
-AEND lengthsetpgrp
-B endgrent link setpriority
-b endhostent listen setprotoent
-C endnetent local setpwent
-c endprotoent localtime setservent
-d endpwent log setsockopt
-e endservent lstat shift
-f eof map shmctl
-g eval mkdir shmget
-k exec msgctl shmread
-l exists msgget shmwrite
-M exit msgrcv shutdown
-O fcntl msgsnd sin
-o fileno my sleep
-p flock next socket
-r fork not socketpair
-R format oct sort
-S formline open splice
-s getc opendir split
-T getgrent ord sprintf
-t getgrgid our sqrt
-u getgrnam pack srand
-w gethostbyaddr pipe stat
-W gethostbyname pop state
-X gethostent pos study
-x getlogin print substr
-z getnetbyaddr printf symlink
abs getnetbyname prototype syscall
accept getnetent push sysopen
alarm getpeername quotemeta sysread
atan2 getpgrp rand sysseek
AUTOLOAD getppid read system
BEGIN getpriority readdir syswrite
bind getprotobyname readline tell
binmode getprotobynumber readlink telldir
bless getprotoent readpipe tie
break getpwent recv tied
caller getpwnam redo time
chdir getpwuid ref times
CHECK getservbyname rename truncate
chmod getservbyport require uc
chomp getservent reset ucfirst
chop getsockname return umask
chown getsockopt reverse undef
chr glob rewinddir UNITCHECK
chroot gmtime rindex unlink
close goto rmdir unpack
closedir grep say unshift
connect hex scalar untie
cos index seek use
crypt INIT seekdir utime
dbmclose int select values
dbmopen ioctl semctl vec
defined join semget wait
delete keys semop waitpid
DESTROY kill send wantarray
die last setgrent warn
dump lc sethostent write
each lcfirst setnetent 
__DATA__ else lock qw
__END__ elsif lt qx
__FILE__ eq m s
__LINE__ exp ne sub
__PACKAGE__ for no tr
and foreach or unless
cmp ge package until
continue gt q while
CORE if qq xor
do le qr y
ARGV STDERR STDOUT
ARGVOUT STDIN/;

sub pre_analysis {

    unless ($_[0] =~ m/.pm$|.pl$/ && -e $_[0] && -r $_[0] && ! -z $_[0]) {
        die "Error: unable to analyse the specified file.\n";
    }
}

sub read_file {

    open my $datafile, '<', $_[0] or die "Can't open a file: $!\n";
    my @lines = <$datafile>;
    close $datafile or die "Can't close a file: $!\n";
    @lines;
}

#
# Main code starts here
#

my @matched_keywords;
my @matched_strings;
my @matched_comments;

# Check if there are enough arguments and abort if not
if (@ARGV != 1) {
    die "Usage: $0 <input file>\n";
}
my $filename = $ARGV[0];

pre_analysis $filename;
print "File: $filename\n";

# get file's contents
my @lines = read_file $filename;

# count lines, words and characters using shell wc command
my $stats = `wc $filename`;
my @stats = split(' ', $stats);

print "Lines: $stats[0]\n";
print "Words: $stats[1]\n";
print "Chars: $stats[2]\n";

for my $line (@lines) {
    # match keywords in a line
    for my $word (split(' ', $line)) {
        if ( (grep {$_ eq $word} @keywords) && ! (grep {$_ eq $word} @matched_keywords) ) {
            push @matched_keywords, $word;
        }
    }
    # match a string in a line
    if ($line =~ m/(".*"|'.*')/) {
        push @matched_strings, $1;
    }
    # match a comment in a line (do not count first line)
    if ($line =~ m/(#.*$)/ and $lines[0] ne $line)  {
        push @matched_comments, $1;
    }
}

print "[Keywords]\n";
my $n = @matched_keywords <= 15 ? @matched_keywords : 15;
for (@matched_keywords[0..$n-1]) {
    print "$_\n";
}

print "[Strings]\n";
my $n = @matched_strings <= 10 ? @matched_strings : 10;
for (@matched_strings[0..$n-1]) {
    print "$_\n";
}

print "[Comments]\n";
my $n = @matched_comments <= 5 ? @matched_comments : 5;
for (@matched_comments[0..$n-1]) {
    print "$_\n";
}

The two important factors in implementation are Compile time and run time. Most of the queries in Perl projects come on the implementation part. Our Perl experts focus on the requirements of the students and the challenges faced in solving Perl assignments before providing help with Perl assignment and Perl homework.

PartB.pl

#!/usr/bin/perl

use strict;

=pod
=head2 Description

The code is used to analyse a Perl script 
specified as the first command-line argument

Acceptable file extensions are (case sensitive):
=item .pl
=item .pm

Input file should be readable and non-empty.

The input file's lines are read into array
with is further parsed.

stats subroutine is used to get 
lines, words and characters count.

Looping trough lines of code keywords, strings and comments
are matched using apropriate regular expressions and placed
in data arrays.

File's summary is printed on the screen.

=cut

# an array with perl's keywords
my @keywords = qw/
-AEND lengthsetpgrp
-B endgrent link setpriority
-b endhostent listen setprotoent
-C endnetent local setpwent
-c endprotoent localtime setservent
-d endpwent log setsockopt
-e endservent lstat shift
-f eof map shmctl
-g eval mkdir shmget
-k exec msgctl shmread
-l exists msgget shmwrite
-M exit msgrcv shutdown
-O fcntl msgsnd sin
-o fileno my sleep
-p flock next socket
-r fork not socketpair
-R format oct sort
-S formline open splice
-s getc opendir split
-T getgrent ord sprintf
-t getgrgid our sqrt
-u getgrnam pack srand
-w gethostbyaddr pipe stat
-W gethostbyname pop state
-X gethostent pos study
-x getlogin print substr
-z getnetbyaddr printf symlink
abs getnetbyname prototype syscall
accept getnetent push sysopen
alarm getpeername quotemeta sysread
atan2 getpgrp rand sysseek
AUTOLOAD getppid read system
BEGIN getpriority readdir syswrite
bind getprotobyname readline tell
binmode getprotobynumber readlink telldir
bless getprotoent readpipe tie
break getpwent recv tied
caller getpwnam redo time
chdir getpwuid ref times
CHECK getservbyname rename truncate
chmod getservbyport require uc
chomp getservent reset ucfirst
chop getsockname return umask
chown getsockopt reverse undef
chr glob rewinddir UNITCHECK
chroot gmtime rindex unlink
close goto rmdir unpack
closedir grep say unshift
connect hex scalar untie
cos index seek use
crypt INIT seekdir utime
dbmclose int select values
dbmopen ioctl semctl vec
defined join semget wait
delete keys semop waitpid
DESTROY kill send wantarray
die last setgrent warn
dump lc sethostent write
each lcfirst setnetent 
__DATA__ else lock qw
__END__ elsif lt qx
__FILE__ eq m s
__LINE__ exp ne sub
__PACKAGE__ for no tr
and foreach or unless
cmp ge package until
continue gt q while
CORE if qq xor
do le qr y
ARGV STDERR STDOUT
ARGVOUT STDIN/;

sub pre_analysis {
    print "$_[0]\n";
    unless ($_[0] =~ m/.pm$|.pl$/ && -e $_[0] && -r $_[0] && ! -z $_[0]) {
        die "Error: unable to analyse the specified file.\n";
    }
}

sub read_file {

    #print "$_[0]\n";   debug
    open my $datafile, '<', $_[0] or die "Can't open a file: $!\n";
    my @lines = <$datafile>;
    close $datafile or die "Can't close a file: $!\n";
    @lines;
}

sub stats {

    my $lines = @_;

    my $words;
    for (@_) {
        $words += split(/\s+/, $_);
    }

    my $chars;
    for (@_) {
        $chars += length($_);
    }

    my @stats = ($lines, $words, $chars);
}

#
# Main code starts here
#

my @matched_keywords;
my @matched_strings;
my @matched_comments;

# Check if there are enough arguments and abort if not
if (@ARGV != 1) {
    die "Usage: $0 <input file>\n";
}
my $filename = $ARGV[0];

pre_analysis $filename;
print "File: $filename\n";

# get file's contents
my @lines = read_file $filename;

# count lines, words and characters using shell wc command
#my $stats = `wc $filename`;
my @stats = stats @lines;

print "Lines: $stats[0]\n";
print "Words: $stats[1]\n";
print "Chars: $stats[2]\n";

for my $line (@lines) {
    #print $line;   debug
    # match keywords in a line
    for my $word (split(' ', $line)) {
        #print "$word\n";
        if ( (grep {$_ eq $word} @keywords) && ! (grep {$_ eq $word} @matched_keywords) ) {
            # check if a keyword is not a part of comment or string
            unless ( ( $line =~ m/#.*$word/ ) or ( $line =~ m/(".*$word.*"|'.*$word.*')/ ) ) {
                push @matched_keywords, $word;
            }
        }
    }
    # match a string in a line
    if ($line =~ m/(".*"|'.*')/) {
        # check if a string is commented
        unless ($line =~ m/(#.*$1)/) {
            push @matched_strings, $1;
        }
    }
    # match a comment in a line (do not count first line)
    if ($line =~ m/(#.*$)/ and $lines[0] ne $line)  {
        # check if a comment is a part of a string or regex
        unless ( $line =~ m/(".*#.*"|'.*#.*')/ or $line =~ m/\/.*#.*\// ) {
            push @matched_comments, $1;
        }
    }
}

# match multiline strings
my $i = 0;
while ($i < $#lines) {
    if (! ($lines[$i] =~ m/";\n/) && ($lines[$i] =~ m/[^#]*("[^"]*\n)/) )
    {
        my $str = $1;
        $i++;
        while ( !($lines[$i] =~ m/(.*")[^"]*/) ) {
            $str .= $lines[$i++];
        }
        if ($lines[$i] =~ m/(.*")[^"]*/) {
            $str .= $1;
        }
        push @matched_strings, $str;
    }
    $i++;
}

print "[Keywords]\n";
my $n = @matched_keywords <= 15 ? @matched_keywords : 15;
for (@matched_keywords[0..$n-1]) {
    print "$_\n";
}

print "[Strings]\n";
my $n = @matched_strings <= 10 ? @matched_strings : 10;
for (@matched_strings[0..$n-1]) {
    print "$_\n";
}

print "[Comments]\n";
my $n = @matched_comments <= 5 ? @matched_comments : 5;
for (@matched_comments[0..$n-1]) {
    print "$_\n";
}

We started providing online Perl help as many students used to come to us with queries related to Perl and currently we are the market leaders in providing Perl assignment help and have worked on more than 300 Perl assignments / homework. Our highly qualified Perl experts have 10+ years on teaching experience in programming and hence we can assure you plagiarism free solution to your Perl homework. Our programming experts can provide you high quality solution to your Perl assignments even at a short notice.

PartC.pl

#!/usr/bin/perl

use strict;

=pod
=head2 Description

The code is used to analyse a Perl script 
specified as the first command-line argument

Acceptable file extensions are (case sensitive):
=item .pl
=item .pm

Input file should be readable and non-empty.

The input file's lines are read into array
with is further parsed.

stats subroutine is used to get 
lines, words and characters count.

Looping trough lines of code keywords, numbers, strings and comments
are matched using apropriate regular expressions and placed
in data arrays.

File's summary is printed on the screen.

=cut

# an array with perl's keywords
my @keywords = qw/
-AEND lengthsetpgrp
-B endgrent link setpriority
-b endhostent listen setprotoent
-C endnetent local setpwent
-c endprotoent localtime setservent
-d endpwent log setsockopt
-e endservent lstat shift
-f eof map shmctl
-g eval mkdir shmget
-k exec msgctl shmread
-l exists msgget shmwrite
-M exit msgrcv shutdown
-O fcntl msgsnd sin
-o fileno my sleep
-p flock next socket
-r fork not socketpair
-R format oct sort
-S formline open splice
-s getc opendir split
-T getgrent ord sprintf
-t getgrgid our sqrt
-u getgrnam pack srand
-w gethostbyaddr pipe stat
-W gethostbyname pop state
-X gethostent pos study
-x getlogin print substr
-z getnetbyaddr printf symlink
abs getnetbyname prototype syscall
accept getnetent push sysopen
alarm getpeername quotemeta sysread
atan2 getpgrp rand sysseek
AUTOLOAD getppid read system
BEGIN getpriority readdir syswrite
bind getprotobyname readline tell
binmode getprotobynumber readlink telldir
bless getprotoent readpipe tie
break getpwent recv tied
caller getpwnam redo time
chdir getpwuid ref times
CHECK getservbyname rename truncate
chmod getservbyport require uc
chomp getservent reset ucfirst
chop getsockname return umask
chown getsockopt reverse undef
chr glob rewinddir UNITCHECK
chroot gmtime rindex unlink
close goto rmdir unpack
closedir grep say unshift
connect hex scalar untie
cos index seek use
crypt INIT seekdir utime
dbmclose int select values
dbmopen ioctl semctl vec
defined join semget wait
delete keys semop waitpid
DESTROY kill send wantarray
die last setgrent warn
dump lc sethostent write
each lcfirst setnetent 
__DATA__ else lock qw
__END__ elsif lt qx
__FILE__ eq m s
__LINE__ exp ne sub
__PACKAGE__ for no tr
and foreach or unless
cmp ge package until
continue gt q while
CORE if qq xor
do le qr y
ARGV STDERR STDOUT
ARGVOUT STDIN/;

sub pre_analysis {

    unless ($_[0] =~ m/.pm$|.pl$/ && -e $_[0] && -r $_[0] && ! -z $_[0]) {
        die "Error: unable to analyse the specified file.\n";
    }
}

sub read_file {

    #print "$_[0]\n";   debug
    open my $datafile, '<', $_[0] or die "Can't open a file: $!\n";
    my @lines = <$datafile>;
    close $datafile or die "Can't close a file: $!\n";
    @lines;
}

sub stats {

    my $lines = @_;

    my $words;
    for (@_) {
        $words += split(/\s+/, $_);
    }

    my $chars;
    for (@_) {
        $chars += length($_);
    }

    my @stats = ($lines, $words, $chars);
}

#
# Main code starts here
#

my @matched_keywords;
my @matched_strings;
my @matched_comments;
my @matched_numbers;

# Check if there are enough arguments and abort if not
if (@ARGV != 1) {
    die "Usage: $0 <input file>\n";
}
my $filename = $ARGV[0];

pre_analysis $filename;
print "File: $filename\n";

# get file's contents
my @lines = read_file $filename;

# count lines, words and characters using shell wc command
#my $stats = `wc $filename`;
my @stats = stats @lines;

print "Lines: $stats[0]\n";
print "Words: $stats[1]\n";
print "Chars: $stats[2]\n";

for my $line (@lines) {
    #print $line;   debug
    # match keywords in a line
    for my $word (split(' ', $line)) {
        #print "$word\n";
        if ( (grep {$_ eq $word} @keywords) && ! (grep {$_ eq $word} @matched_keywords) ) {
            # check if a keyword is not a part of comment or string
            unless ( ( $line =~ m/#.*$word/ ) or ( $line =~ m/(".*$word.*"|'.*$word.*')/ ) ) {
                push @matched_keywords, $word;
            }
        }
    }
    # match a string in a line
    if ($line =~ m/(".*"|'.*')/) {
        # check if a string is commented
        unless ($line =~ m/(#.*$1)/) {
            push @matched_strings, $1;
        }
    }
    # match a comment in a line (do not count first line)
    if ($line =~ m/(#.*$)/ and $lines[0] ne $line)  {
        # check if a comment is a part of a string or regex
        unless ( $line =~ m/(".*#.*"|'.*#.*')/ or $line =~ m/\/.*#.*\// ) {
            push @matched_comments, $1;
        }
    }

    # match an integer or floating point number
    my @numbers = $line =~ m/([\d]?\.?[_0-9]*[eE][+-]?[_0-9]+|[\d]*\.[_0-9]+|[_0-9]+)/g;
    for (@numbers) {
        # check if a number is commented
        unless ($line =~ m/(#.*$_)/) {
            push @matched_numbers, $_;
        }
    }
}

# match multiline strings
my $i = 0;
while ($i < $#lines) {
    if (! ($lines[$i] =~ m/";\n/) && ($lines[$i] =~ m/[^#]*("[^"]*\n)/) )
    {
        my $str = $1;
        $i++;
        while ( !($lines[$i] =~ m/(.*")[^"]*/) ) {
            $str .= $lines[$i++];
        }
        if ($lines[$i] =~ m/(.*")[^"]*/) {
            $str .= $1;
        }
        push @matched_strings, $str;
    }
    $i++;
}

print "[Keywords]\n";
my $n = @matched_keywords <= 15 ? @matched_keywords : 15;
for (@matched_keywords[0..$n-1]) {
    print "$_\n";
}

print "[Numbers]\n";
my $n = @matched_numbers <= 10 ? @matched_numbers : 10;
for (@matched_numbers[0..$n-1]) {
    print "$_\n";
}

print "[Strings]\n";
my $n = @matched_strings <= 10 ? @matched_strings : 10;
for (@matched_strings[0..$n-1]) {
    print "$_\n";
}

print "[Comments]\n";
my $n = @matched_comments <= 5 ? @matched_comments : 5;
for (@matched_comments[0..$n-1]) {
    print "$_\n";
}

Even if you somehow manage to work on Perl assignments on your own, it is complicated to work on Perl projects. Hence Perl project help is one of the most sought after services as students frequently come to us for Perl project help due to our high quality solution provided by us. Our Perl tutors also provide you online Perl project assistance apart from working on your Perl project. If you are struggling to develop a Perl project then avail our Perl project help service to achieve excellent grades.

PartD.pl

#!/usr/bin/perl

use strict;

=pod
=head2 Description

The code is used to analyse a Perl script 
specified as the first command-line argument
and writes highlighted code into html file
specified as second argument.

Acceptable file extensions are (case sensitive):
=item .pl
=item .pm

Acceptable html file extensions are:
=item .html
=item .htm

Input file should be readable and non-empty.

The input file's lines are read into array
with is further parsed.

Looping trough lines of code keywords, numbers, strings and comments
are matched using apropriate regular expressions and placed
in data arrays.

Each of keywords, numbers, strings and comments are highlighted with
specific color in output html code.

=cut

# an array with perl's keywords
my @keywords = qw/
-AEND lengthsetpgrp
-B endgrent link setpriority
-b endhostent listen setprotoent
-C endnetent local setpwent
-c endprotoent localtime setservent
-d endpwent log setsockopt
-e endservent lstat shift
-f eof map shmctl
-g eval mkdir shmget
-k exec msgctl shmread
-l exists msgget shmwrite
-M exit msgrcv shutdown
-O fcntl msgsnd sin
-o fileno my sleep
-p flock next socket
-r fork not socketpair
-R format oct sort
-S formline open splice
-s getc opendir split
-T getgrent ord sprintf
-t getgrgid our sqrt
-u getgrnam pack srand
-w gethostbyaddr pipe stat
-W gethostbyname pop state
-X gethostent pos study
-x getlogin print substr
-z getnetbyaddr printf symlink
abs getnetbyname prototype syscall
accept getnetent push sysopen
alarm getpeername quotemeta sysread
atan2 getpgrp rand sysseek
AUTOLOAD getppid read system
BEGIN getpriority readdir syswrite
bind getprotobyname readline tell
binmode getprotobynumber readlink telldir
bless getprotoent readpipe tie
break getpwent recv tied
caller getpwnam redo time
chdir getpwuid ref times
CHECK getservbyname rename truncate
chmod getservbyport require uc
chomp getservent reset ucfirst
chop getsockname return umask
chown getsockopt reverse undef
chr glob rewinddir UNITCHECK
chroot gmtime rindex unlink
close goto rmdir unpack
closedir grep say unshift
connect hex scalar untie
cos index seek use
crypt INIT seekdir utime
dbmclose int select values
dbmopen ioctl semctl vec
defined join semget wait
delete keys semop waitpid
DESTROY kill send wantarray
die last setgrent warn
dump lc sethostent write
each lcfirst setnetent 
__DATA__ else lock qw
__END__ elsif lt qx
__FILE__ eq m s
__LINE__ exp ne sub
__PACKAGE__ for no tr
and foreach or unless
cmp ge package until
continue gt q while
CORE if qq xor
do le qr y
ARGV STDERR STDOUT
ARGVOUT STDIN/;

sub pre_analysis {

    unless ($_[0] =~ m/.pm$|.pl$/ && -e $_[0] && -r $_[0] && ! -z $_[0]) {
        die "Error: unable to analyse the specified file.\n";
    }
}

sub read_file {

    #print "$_[0]\n";   debug
    open my $datafile, '<', $_[0] or die "Can't open a file: $!\n";
    my @lines = <$datafile>;
    close $datafile or die "Can't close a file: $!\n";
    @lines;
}

sub write_file {
    open my $datafile, '>', $_[0] or die "Can't open a file: $!\n";
    print $datafile $_[1];
    close $datafile or die "Can't close a file: $!\n";
}

sub stats {

    my $lines = @_;

    my $words;
    for (@_) {
        $words += split(/\s+/, $_);
    }

    my $chars;
    for (@_) {
        $chars += length($_);
    }

    my @stats = ($lines, $words, $chars);
}

#
# Main code starts here
#

my @matched_keywords;
my @matched_strings;
my @matched_comments;
my @matched_numbers;

# Check if there are enough arguments and abort if not
if (@ARGV != 2) {
    die "Usage: $0 <input file> <output file>\n";
}
my $filename = $ARGV[0];
my $html_file = $ARGV[1];

unless ($html_file =~ m/.html$|.htm$/) {
    die "Error: invalid outplt file format.\n";
}

pre_analysis $filename;

# get file's contents
my @lines = read_file $filename;
my $contents = join('', @lines);

# count lines, words and characters using shell wc command
#my $stats = `wc $filename`;
my @stats = stats @lines;

for my $line (@lines) {
    #print $line;   debug
    # match keywords in a line
    for my $word (split(' ', $line)) {
        #print "$word\n";
        if ( (grep {$_ eq $word} @keywords) && ! (grep {$_ eq $word} @matched_keywords) ) {
            # check if a keyword is not a part of comment or string
            unless ( ( $line =~ m/#.*$word/ ) or ( $line =~ m/(".*$word.*"|'.*$word.*')/ ) ) {
                push @matched_keywords, $word;
            }
        }
    }
    # match a string in a line
    if ($line =~ m/(".*"|'.*')/) {
        # check if a string is commented
        unless ($line =~ m/(#.*$1)/) {
            push @matched_strings, $1;
        }
    }
    # match a comment in a line (do not count first line)
    if ($line =~ m/(#.*$)/ and $lines[0] ne $line)  {
        # check if a comment is a part of a string or regex
        unless ( $line =~ m/(".*#.*"|'.*#.*')/ or $line =~ m/\/.*#.*\// ) {
            push @matched_comments, $1;
        }
    }

    # match an integer or floating point number
    my @numbers = $line =~ m/([\d]?\.?[_0-9]*[eE][+-]?[_0-9]+|[\d]*\.[_0-9]+|[_0-9]+)/g;
    for (@numbers) {
        # check if a number is commented
        unless ($line =~ m/(#.*$_)/) {
            push @matched_numbers, $_;
        }
    }
}

# match multiline strings
my $i = 0;
while ($i < $#lines) {
    if (! ($lines[$i] =~ m/";\n/) && ($lines[$i] =~ m/[^#]*("[^"]*\n)/) )
    {
        my $str = $1;
        $i++;
        while ( !($lines[$i] =~ m/(.*")[^"]*/) ) {
            $str .= $lines[$i++];
        }
        if ($lines[$i] =~ m/(.*")[^"]*/) {
            $str .= $1;
        }
        push @matched_strings, $str;
    }
    $i++;
}

for (@matched_keywords) {
    $contents =~ s/\Q$_\E/<font color="darkred">$_<\/font>/g;
}
for (@matched_numbers) {
    $contents =~ s/\Q$_\E/<font color="darkcyan">$_<\/font>/;
}
for (@matched_strings) {
    $contents =~ s/\Q$_\E/<font color="royalblue">$_<\/font>/;
}
for (@matched_comments) {
    $contents =~ s/\Q$_\E/<font color="darkgreen">$_<\/font>/;
}

my $html_data = "<html>\n<head><title>\n".$filename."\n</title></head>\n";

$html_data .= "<body><pre>\n";
$html_data .= $contents;
$html_data .= "</pre></body>\n</html>\n";

write_file ($html_file, $html_data);

If you are looking for help with Perl project, then we can provide you with the solution, that is guaranteed plagiarism free.

We provide online Perl services across all academic levels from undergraduate, graduate to postgraduate. We are the market leaders in online Perl Help. So if you find Perl challenging then just drop us a mail mentioning your requirement and de-stress your mind from Perl assignment and Perl projects.