36 users online (0 members and 36 guests)  

Thread: Assignment


  Results 1 to 4 of 4
  1. #1
    culturaldissecti's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2006
    Posts
    2

    Assignment

    I have an assignment to do where one question is to create a Perl program, I'm not asking for anyone to do it for me, but to point me in the right direction, and I will be most grateful, I have to;

    "Create a Perl script which converts HTM tags into uppercase for a given file. When run, the script should prompt the user to enter name of the HTML file. This name should be varified to ensure the file extension is either .html or .htm (uppercase or lowercase is acceptable) and if not, an error message should be displayed and the user prompted to re-enter the name.

    On input of a validated name, the file should be processed (if it exists) and all lowercase tags, converted into uppercase. You should not convert any other text, and should and should also avoid converting tag attribute values.

    At the end of the processing, the original file should be renamed with the old extension, instead of .html or .htm, and the processed file be given the original file name.

    I have a few vague ideas about what I may do with some bits, but it seems a bit bizarre, can anybody help?
    Last edited by HTML; 10-20-2006 at 06:11 AM.

  2. #2
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: Assignment

    well... i am very rusty on my perl and have not really used it in applicaion purpises (i use it in web purpises)...

    anyway... i am not sure if you have ever delt with Regular Expressions, but when doing some of the matches like you want they are beautifol...

    for example... (.*) means any character 0 or more times... in other words anything
    so to match the type of file you can do something like:

    /(.*)(\.htm|\.html)/i

    that will search for "(anything).html" or .htm

    to check a file... well i havent used perl for a while, but i did drag some of my old work out and you should beable to just open the file to test it for example:

    open(ADD, "<$folderlocation/settings.txt")|| print "your file is un-readable or does not exist";
    close(ADD);

    to rename a file:

    rename("file.txt", "file-old.txt") || die "Cannot rename file.txt: $!";

    to check for html tas is also a regual expression thing... example:

    $string =~ s/<[0-9a-zA-Z_-]*( |>)(.*)/<[0-9A-ZA-Z_-]$1$2/g

    ^ is untested so not sure if it will work or not, but something like that.

    other than that you SHOULD beable to do the rest.

    -ALL

  3. #3
    culturaldissecti's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2006
    Posts
    2

    Re: Assignment

    Thank you, I had a feeling about using regular expressions, the part i was most stuck on was the renaming of the file

  4. #4
    nrupal's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2001
    Location
    baroda
    Posts
    1

    Re: Assignment

    Dear friend,
    You can get help from the following website.
    It has numerous codes and that can be downloaded and studied for.
    www. hotscripts.com

    Regards
    Nrupal
    nrupalakolkar@gmail.com
    nrupalakolkar@indiatimes.com



Tags for this Thread