This is a discussion on "i am REALLY struggling" within the Other Programming Languages section. This forum, and the thread "i am REALLY struggling are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
i am REALLY struggling
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
i am REALLY struggling
I am learning perl through skills train, i have a coding assignment to do
this is the brief: write a perl program to analyse text files and obtain statistics when run the program should check if an argument has been provided. if not the prog should prompt and accept input of a file name from the keyboard the file name should be checked to ensure it is in MS-DOS format. The file name should be no longer than 8 characters and must begin with a letter of an underscore followed by upto 7 letters. the file extension should be optional, but if given it should be !.txt. if no extension is given .txt should be added if the file name provided is not in the correct format the program should display a asuitable error the program should then check to see if the file exists the file should be read and checked to display crude statistics on the number of words , characrters, lines, sentences and paragraphs you can assume the following: character count can include whitespace and punctuation characters each word is separated by a space, tab or new line character, except if the previous characrter was a space, tab or new line each line is separated be a new line character each sentence is ended either by a full stop, question mark or excalmation mark a paragraph is ended by two consecutive new line charaters this is what i have got so far:: #!c:\perl\bin\perl.exe my $stats = "Statistics For File: \n"; chomp($stats); my $chrs = "Characters: \n"; my $wds = "Words: \n"; my $lines = "Lines: \n"; my $snt = "Sentences: \n"; my $par = "Paragraphs: \n"; my $x; enter: { print("Please enter a file name: "); $ent = <STDIN>; chomp($ent); if($ent =~ m/(^\w{1,8})(\.txt?)$/) { open(READFILE, "$ent") || die "couldn't open file: $!"; } elsif($ent =~ m/(^\w{1,8})$/) { open(READFILE, "$ent.txt") || die "couldn't open file: $!"; } else { print("re-enter filename!\n"); redo enter; } } i would really appreciate some help here, i have the general idea of what i have to do but getting it down in code is vexing me PLEASE HELP close(READFILE); |
|
|
|
#2
|
|||
|
|||
|
Re: i am REALLY struggling
what assignment number/TMA is it for?
|
|
#3
|
|||
|
|||
|
Re: i am REALLY struggling
TMA10 in Perl
|
|
#4
|
|||
|
|||
|
Re: i am REALLY struggling
Sorry but you have lost me as you don't have to write a program for PERL TMA 10 however for PERL TMA 11A & TMA 11B you do have to.
|
|
#5
|
|||
|
|||
|
Re: i am REALLY struggling
its the last TMA in the perl section which is 10
|
|
#6
|
|||
|
|||
|
Re: i am REALLY struggling
With skillstrain it isn't it goes up to TMA 11, TMA 11A and TMA 11B and you don't have to write a program till TMA 11A & TMA 11B as I have just completed that part of the course and am waiting for Section 3 A to arrive.
|
|
#7
|
|||
|
|||
|
Re: i am REALLY struggling
yes skills train...
thats odd...what version is it...mine is 5.0 |
|
#8
|
|||
|
|||
|
Re: i am REALLY struggling
Same version look in the back of your study book and it should have TMA 11
|
|
#9
|
|||
|
|||
|
Re: i am REALLY struggling
nope just goes to 10
what is the brief for TMA11 |
|
#10
|
|||
|
|||
|
Re: i am REALLY struggling
the last lab i have is 12-1.pl using perl debugger
|
|
#11
|
|||
|
|||
|
Re: i am REALLY struggling
Here is a copy of my whole report
Student Progress Report Name College No Assignment Result Wayne CW PL TMA10 90% Number of times you have connected to Student World: 338 The date of your last visit to Student World: Friday, 29th June, 2007 Please continue to connect to Student World on a regular basis. You can now vote for Tutor Team Member of the Month via Student World. From Student World, please go to Classroom, then choose Cyberclass and from there select the Tutor Team Member of the Month link from the middle column. We very much value your opinion, so please make sure you enter your vote for Tutor Team Member of the Month. In addition, we have Student of the Month. As recognition of their achievements the winner of Student of the Month will receive a new PC, plus two runners-up will receive PC World vouchers, so this is certainly worth entering. You can do so within Student World: go to Classroom, then choose Cyberclass and select the Student of the Month Competition Entry. Thank you for submitting your work for Tutor Marked Assignment 10. Your work for this assignment is enclosed. Excellent result, well done. You obviously studied very hard to get this result; excellent. There are just a few small points that I would like to bring to your attention, these are noted below. If you have any queries on these please do not hesitate to contact me. I look forward to receiving your work for Tutor Marked Assignment 11 next. The access code for your next assignment is: 29175 Question 01: Relational databases organise data into formally defined what? A tables B files C filehandles D hashes Your answer, tables (A), is correct. A table can be thought of as a two-dimensional entity containing records in columns and rows. Data can be accessed concurrently. A table contains data that may relate to data in other tables. Question 02: Most databases support some form of SQL. What does SQL stand for? A Simple Question Language B Structured Question Language C Simple Query Language D Structured Query Language You said Structured Query Language (D), which is the right answer. Structured Query Language commands are used by the Database Interface module (DBI) to query databases. The DBI is composed of a common set of commands that facilitate the interaction of a Perl script with any database. Question 03: The Database Driver Module enables you to change databases by installing a different database driver, called a Database Interface Module. A true B false You said false (B), which is the correct answer. The Database Interface Module (DBI) enables you to change databases by installing a different database driver called a Database Driver Module (DBD). The DBD interacts directly with the database. Question 04: The _______ consists of a thin layer of method calls that are sent to a database specific driver for the database. The _______ translates the method calls into native methods for the target database. A DBI, SQL B DBD, SQL C DBD, DBI D DBI, DBD The correct answer is DBI, DBD (D), as you selected. Data can flow in both directions. The results are returned through the DBD layer to the DBI layer. The data is then passed to the Perl program. Question 05: What is the minimum number of parameters the dbi->connect() method requires to connect to a database? A one B two C three D four Your answer, three (C), is incorrect. Revise the connect Method topic within your course material and let me know if you have further trouble. The correct answer is one (A). Question 06: What method must be called prior to executing an SQL query? A parse B prepare C execute D practice The correct answer is prepare (B), as you selected. The prepare method of the database connection object parses the SQL statement, validates it, and returns a reference, known as a statement handle, $sth. After you have prepared an SQL query, it must be executed. Question 07: What extra information is required when connecting to a database which is located on a different server? A host name B network name C port number D username E password You said host name which is correct. This is the name of the computer which runs the database server. And port number which is also correct. The port number will depend on the database involved and its individual setup. Question 08: SQL has three types of commands, which are: A Data Description Language (DDL) B Data Definition Language (DDL) C Data Query Language (DQL) D Data Creation Language (DCL) E Data Manipulation Language (DML) F Data Management Language (DML) You said Data Definition Language (DDL) which is correct. Data Definition Language, DDL, is the part of SQL that is used to create a relational database, modify the database structure after it has been created, and delete it when it becomes obsolete. DDL provides the structure that contains the data and defines the data types for the columns in the table. And Data Query Language (DQL) which is also correct. Data Query Language (DQL) allows you to query the database for information that matches the criteria you specified. And Data Manipulation Language (DML) which is also correct. Data Manipulation Language (DML) allows you to enter data into a database, change data, or delete data from a database, using the INSERT, UPDATE and DELETE command types. Question 09: When creating a new database table, UNIQUE, NOT NULL and PRIMARY KEY are all known as what? A criteria B caveats C constricts D constraints Your answer to this question was constraints (D), which is correct. Constraints are optionally applied to the different fields within a database table when it is initially constructed. A constraint is a rule that all the data in that column must follow. Question 10: The underscore used in a select query represents a single character and the asterisk represents any character or string of characters. A true B false Your answer, false (B), is the right one. Although the asterisk is commonly used in applications as a wildcard character, representing any character or strings or characters, in SQL the percentage sign is used instead. |
|
#12
|
|||
|
|||
|
Re: i am REALLY struggling
my dtabase assignment is TMA09
but different questions |
|
#13
|
|||
|
|||
|
Re: i am REALLY struggling
Is this your questions that you are doing at the mo?
Question 1: Create a Perl program to acquire customer information for an optician’s practice. When the program is run, the user should be prompted to enter a four digit customer reference number. The user should then be prompted to enter new customer details. All inputs should be verified. Any input which fails the verification should result in a suitable error message being displayed, along with another prompt for the same item to be entered again. The date of birth input does not need to be checked for date validity, e.g. 99/99/9999 should be accepted. However, you should check that the digits and forward slash characters are in the DD/MM/YYYY form, e.g. 3/10/2004 should be rejected whereas 03/10/2004 is acceptable. Save this program in a file titled optician.pl. Your answer to this question is excellent, allowing the user to input customer information as required. Well done for following all the validations mentioned in the question. Question 2: Amend optician.pl so that entries of customer records are stored in a file called CustData.txt. The individual customer fields should be written separated by a comma, and each complete customer record terminated by a newline character. When the program is run, it should test for the existence of the CustData.txt file and create it if it doesn’t already exist. When the user enters a customer reference, the file should be checked to ascertain whether the customer reference is already in use. If it is, the customer details for that reference number should be displayed. If not, the details for a new customer should be input and written to the file. Save this program in a file titled optician2.pl. Print and submit a copy of CustData.txt showing five example customers using data of your choice. The solution to this question is excellent. Well done for testing the existence of the customer record and create it if it doesn’t already exist. Question 3: The optician will like to get some statistics regarding customers’ vision measurements. Create a separate program, called measurements.pl, which displays a breakdown of vision measurements. A count of the number of customers within vision ranges should be made and the results displayed in a table Overall, in this example there are 10 customers. The percentages should be calculated from the number within the range divided by the total number of customers, e.g. for the 21-30 range there are two customers so the percentage is (2/10)*100. Your solution to this question is excellent. Question 4: Amend the measurements.pl program so that it initially displays a prompt to allow the user to specify whether the output is displayed to the screen or to file (for example, by entering an ‘S’ or an ‘F’). If to file, the user should also be prompted to enter a suitable filename. This filename should be checked to ensure it complies with the listed rules: If the filename is invalid it should be rejected with a suitable error message being displayed, then input again. Once a valid filename is given, it should have the “.txt” extension added. This complete filename should then be checked to ensure that a file of that name does not already exist. If it does the user should be prompted as to whether the file should be overwritten or not by way of ‘Y’ or ‘N’ character input. If not, a new name should be prompted for and input. The answer to this question is excellent, displays a prompt to allow the user to specify whether the output is displayed to the screen or to file. Well done for following validations as specified in the question. |
|
#14
|
|||
|
|||
|
Re: i am REALLY struggling
nope:
you are to write a perl program that analyses text files to obtain statictics on their content. the program should operate as follows 1) when run the program should check if an argument has been provided. If not, the program should prompt for , and accept input of, a file name from the keyboard 2) the file name iethe r passewd as an argument or input from the key board should be checked to ensure it is in MS-DOs format. The filename part should be no longer than 8 characters and musy begin with a letter or an underscore followed by upto 7 letters digits or underscores the file extension should be optional, butif given it should be ".TXT" if no extension is given ".TXT" should be added to the end of the file name 3)if the filename is not the correct format the program should display a suitable error the program should check to see if the file exists the file should be read and checked to dispaly crude statistics on the number of characters, words, lines, sentences and paragraphs |
|
#15
|
|||
|
|||
|
Re: i am REALLY struggling
WOW! that isn't in any of my assignments for PERL at all, that is strange! The closest I could find was this question
Write a program which reads from a text file and counts the number of punctuation characters used within it. The name of the file should be prompted from the keyboard when the program is run. For example, if you provide the name of the file containing the given text. Produce screenshots of the output from your program, along with the source files used. At least one Perl script should be tested as an input file for your program. Your program has been designed to run as required although it would have been good to see both a test file and an output for the given test file. This aside some good work. I have the script for that above if any good? |
|
#16
|
|||
|
|||
|
Re: i am REALLY struggling
thats a very similar brief
|
|
#17
|
|||
|
|||
|
Re: i am REALLY struggling
is there any code i can see?
|
|
#18
|
|||
|
|||
|
Re: i am REALLY struggling
yea one min ill have to get in touch with my brother to go on my home comp and send me my files needed as im at work
|