Loading ...
Sorry, an error occurred while loading the content.

Re: Require-ing Code vs Functions in a Module (was Use Strict)

Expand Messages
  • James E Keenan
    Sean: Thanks again for taking the time to review my code. I ve tried out some of ... my $data_file = digest.data ; require $data_file; This works; requires
    Message 1 of 3 , Jun 2, 2001

      Thanks again for taking the time to review my code. I've tried out some of
      the suggestions and here's what I get:

      > "use" is generally preferred for a variety of reasons (see your camel book
      > for more in depth explanations).

      my $data_file = 'digest.data';
      require $data_file;

      This works; 'requires' can evaluate an expression. Substituting 'use' here
      generates a syntax error, because use apparently cannot evaluate an
      expression (Camel 3rd, pp 774, 822).

      > Currently, digest.data is a hash declaration. For a user to make use of
      > your program, they will have to understand (or hope they don't bungle it
      > during editing), how to declare a complicated perl data structure. This
      > be sub-optimal in the area of ease of use to anyone not comfortable with
      > perl, never mind programming.

      > This would allow anyone to potentially use your program, regardless of
      > skills, or programming experience. ...

      Good point. Since this program was designed primarily to satisfy my own
      obsessions, I wasn't focused on how a non-expert user would set the program
      up. A separate module to set the program up could, in principle, sidestep
      the question of whether the user understands Perl data structures, and it
      could automatically establish the correct directory structure as well.
      However, given that quite a few of the entries in %my_digests require
      precise typing


      or typing of long lines (such as the delimiters between messages), any
      user -- expert programmer or not -- would be better off doing this in a GUI
      text editor with cut-and-paste capabilities. Unfortunately, using Perl to
      design GUI interfaces is beyond me at this point.

      > Since you already require the directory to be provided as an argument, add
      > a BEGIN block to parse @ARGV, make sure the directory exists ...

      In the full code (not presented in the original message but available at
      http://www.concentric.net/~Jkeen/digest/digest.zip) I have a subroutine
      which checks the directory structure.

      In light of your comments, I'll be thinking about this question of ease of
      set-up for the less experienced user when embarking on my next project.

      ----- Original Message -----
      From: "Sean Quinlan" <seanq@...>
      To: "James E Keenan" <jkeen@...>
      Cc: "Perl Beginner Group" <perl-beginner@yahoogroups.com>
      Sent: Monday, May 28, 2001 3:47 PM
      Subject: Re: Require-ing Code vs Functions in a Module (was Use Strict)
    Your message has been successfully submitted and would be delivered to recipients shortly.