in reply to Optional Arguments..?

I would strongly suggest using Getopt::Long. It takes all the headaches out of processing command-line parameters. I'd go as far as saying that if you're processing a command-line, and you want to do anything other than accept a plain old list of filenames, then you're a fool not to use it. Unless of course, that would be disallowed by the guidelines for your assignment.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Optional Arguments..?
by davido (Cardinal) on Jun 03, 2012 at 08:12 UTC

    Only a guess, but I suspect at least some of the code is boilerplate supplied by the professor (the portions of the code lacking in syntax errors). Might be best to just stick to the assignment for now.

    Like I said... only a guess.


    Dave

Re^2: Optional Arguments..?
by dsheroh (Monsignor) on Jun 03, 2012 at 09:01 UTC
    I'm fairly sure that the assignment doesn't allow for use of modules not covered in the class.

    More to the point, though, so far as I'm aware, Getopt only recognizes options with a - or -- prefix. In this spec, the operation is specified with L, U, or D, not -L/-U/-D, so I don't think Getopt would even work here without changing the interface to the program.

      Hi guys, thanks for the posts. I'm currently back to work on my assignment. Anyway, all of the code that is from me is written by me. My lecturer only provided a module (is it called a module?) named ST2614, which helps encode and decode my hashes. Will update if I have more questions.

      Thanks a million!

      UPDATE: Okay, I managed to figure out what I want to ask. The problem is this: I have to decode the encrypted file of hashes, when I manage to decode it, I declare the result to a variable. Is this correct?

      Second, I want to first print only all hashes that match the argument "site name" where a user might enter 'a' and some example results are hashes with key names such as Yahoo or Facebook printed. How can I do this?

      Lastly, I would like to print all hashes that are decoded. However as I declared the decoded data into a variable, I don't think I can code the program like a typical print-all-hashes that Dave provided.. There seems like something I'm supposed to do, but honestly.. I'm clueless. So I'd like to ask how I could do this as well.

      For the last blank, D, it's meant to be able to delete hashes which key exactly matches the one stated by the user. I haven't started work on it, hence I left it blank.

      Once again thank you guys for the help. It's the holidays in my country over here, and I have trouble contacting my lecturer. This is why I cannot contact him for questions.