Scripting language programmingnbspassignment

Assignment Help Application Programming
Reference no: EM13362576

Scripting Language Programming, Assignment  Perl 

General Requirements

? Your coding style should conform to general Perl coding conventions. Your scripts should be clean, neat, and well-formatted (e.g. indention). Identifiers should also be properly named.

? Your scripts should be well-documented by using POD so users can easily understand your scripts and their usage by exporting POD as HTML, plain text or LaTeX.

? You should always properly validate data inputs (including command-line arguments) and display user-friendly error messages where applicable. For example, if a script is expecting only one argument which specifies a file, you should validate:

ü There is only one command line argument (or you should display the 'usage');

ü The specified argument is a file and is accessible.

Depending on what the script does, you should also make other reasonable validations, e.g., whether a specified directory is valid and accessible.

? If a standard output format is not specified, you are free to make your own assumptions so long as your output displays all required information and is in a neat and user-friendly format.

? Any standard Perl modules shipped with Perl 5.10 may be used. However, you should not use any module which is not available on RMIT CSIT Core Teaching Linux servers.

? If you fail to meet the aforementioned general requirements, you may lose up to 25% of marks available in each part of this assignment.

? You must attempt each part of this assignment progressively. For example, if you attempt Part D without first completing Part C, you will not get any marks for Part D.

 

Part A: Perl Script Analyser (PartA.pl)

Write a Perl script to analyse 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:

[user@csitprdap01 ~]$ ./PartA.pl /aaa/bbb/ccc/invalid_script.pl

Error: unable to analyse the specified file.

[user@csitprdap01 ~]$

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 this assignment:

? a keyword is a Perl function keyword, a Perl syntax keyword or a File Handles keyword listed on https://learn.perl.org/docs/keywords.html;

? a string always have single quotes or double quotes around them;

? a comment is the text from a # character until the end of the line, unless the # character is inside a string or a regular expression.

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.

To demonstrate the output format, we use the following sample script file hello.pl:

#!/usr/bin/env perl

use strict;

use warnings;

# assign variable

my $string = 'Hello World!';

# display value

print "$string\n";

The following output from PartA.pl is expected:

[user@csitprdap01 ~]$ ./PartA.pl /home/el2/eXXXXX/scripts/hello.pl

File: hello.pl

Lines: 8

Words: 19

Chars: 129

[Keywords]

use

my

print

[Strings]

'Hello World'

"$string\n"

[Comments]

# assign variable

# display value

[user@csitprdap01 ~]$

It is important that you display the results in the exact same sequence and format as your assignment submission may be assessed by an automated marking process.

 

This sample script and the expected output will be published in the Blackboard so you can compare if your script is producing an exact identical outcome. Please note this is only for the purpose of hecking output format. To verify if you have implemented the script correctly, you are expected to create more complex test cases yourself. 

Part B: Improved Perl Script Analyser (PartB.pl)

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 Analyser (PartC.pl)

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 https://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)

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.

Reference no: EM13362576

Questions Cloud

Five dimensions of cultural differencesthe case study : five dimensions of cultural differencesthe case study questions werewhat are the five dimensions of cultural
Assuming that the expectations theory is the correct theory : assuming that the expectations theory is the correct theory of the term structure calculate the interest rates in the
Recent change in us businesscould you help me in : recent change in us businesscould you help me in identifying one recent change in us businesses for economic social
Difference to valuation by us gaap vs ifrs apple philipsis : difference to valuation by us gaap vs ifrs apple philipsis there a difference in approach to valuation by us gaap and
Scripting language programmingnbspassignment : scripting language programmingnbspassignment nbsp-nbspperlnbspgeneral requirements ? your coding style should conform
Diversity in the workplace sample question- how does : diversity in the workplace sample question- how does cultural and racial diversity in the workforce benefit an
Preparing a presentation for a diverse group of : preparing a presentation for a diverse group of employeesyou have been recently promoted as junior vice president of
Example of revenue resulting in a temporary differencea can : example of revenue resulting in a temporary differencea can you give a specific example of revenue that might result in
Cultural differences in alliance teamsthis solutions is : cultural differences in alliance teamsthis solutions is nearly 400 words and includes one reference. the two questions

Reviews

Write a Review

Application Programming Questions & Answers

  Discussion htmlcssjavascript placementnbspplease respond to

discussion htmlcssjavascript placementnbspplease respond to the followingcompare and contrast the process of adding

  Problem descriptionyou are working as an engineer for a

problem descriptionyou are working as an engineer for a materials manufacturing research lab and have been asked to

  Produce a project plan and an interim description of the

produce a project plan and an interim description of the project developmentproblem 1. northern lights alert service.

  In this project you will create an application to run in

in this project you will create an application to run in the amazon ec2 service and you will also create a client that

  Project title computer sales and repair store system -

project title computer sales and repair store system - csrssit is required to design a relational database system for a

  Write a paper on mcdonaldsethics and social responsibility

write a paper on mcdonalds.ethics and social responsibility at mcdonaldspaper includesabout mcdonaldscorporate social

  Problem 1 write a program that will generate an array of 10

problem 1. write a program that will generate an array of 10 random 32-bit integers and that will show on the monitor

  Problem statementgiven two integers x and y compute the

problem statementgiven two integers x and y compute the product xy multiplication the quotient xy integer division and

  Part a question make a student inheritance hierarchy this

part a question make a student inheritance hierarchy. this must comprise the given requirementsi make the student

  Design a program that models the worms behavior in the

design a program that models the worms behavior in the subsequent scenarioa worm is moving toward an apple. each time

  Memory managementwrite a paper to provide depth knowledge

memory managementwrite a paper to provide depth knowledge of how memory is used in executing your programs and its

  Implement functions using x86 assembly in addition to

implement functions using x86 assembly. in addition to implementing procedures this assignment requires to pass

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd