in reply to Formatting Text

ruzam++ has given you some very good advice about how to organize your algorithm.

You don't say how much of perl you are expected to know or use. CPAN has lots of modules which would help, up to nearly solving the whole thing. I'll mention a couple which would help with discrete pieces of the problem.

You start by parsing an option from the command line. The Getopt::Long module provides the standard way of doing that. It works for multiple options and preserves input filenames listed on the command line. That is probably where you should get the name of the file to crunch. Getopt::Long is a base module distributed with perl, so if you are allowed any modules at all, it should be acceptable.

The roman numeral requirement for paging is an entertaining subproblem which your instructor may wish you to solve for yourself. There is the Math::Roman module to do it for you, however. You can increment a Math::Roman numeric variable and stringification will produce the roman representation. Math::Roman is not a base module, but is available from CPAN.

Good luck, and have fun. This seems like an enjoyable exercise to learn with.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Formatting Text
by Scott7477 (Chaplain) on May 12, 2006 at 22:10 UTC
    If the instructor is giving an assignment to write code in Perl, I would expect them to be aware of all Perl code that is commonly known to be available on the internet(i.e. CPAN). Assigning a problem where a known solution is posted on CPAN seems absurd to me. A better approach in my mind would be to say: study the Math::Roman module that can be found on CPAN and write a program that shows me you know how it works.

    If a person enjoys reinventing the wheel, they can do it on their own time, and more power to them. Making that a classroom assignment would be offensive to me.