<indent>Are the modules in question .pm files being used (pulled in at compile time) or .pl files being required (at run time)?</indent>

Yes. These files are called script_name.pm with their first line containing package main; and every module that is being written is being called from the main script as use script_name. Now, I realize that this i s just basicly placing the namespace of each script into main:: which is fine but I am still not clear why my subs are being run at compile time.

Here is a portion of my code:

38 my %sn; # temporary 39 $sn{chanserv} = "ChanServ"; # temporary 40 41 my $_name = $sn{chanserv}; 42 my($_source,$_data) = (shift,shift); 43 44 $_data = &_cs_parse_raw_cmd($_data) if $_data; 45 &_sendit($_name,$_source,$_data); 46 47 # ************************************************************ 48 # sub routines 49 # ************************************************************ 50 51 # *** 52 # _send_it(): simple wrapper for chanserv to send data 53 # through the main socket. 54 # *** 55 56 sub _sendit 57 { 58 my $_channel = shift; 59 my $_message = shift; 60 61 # send_data(':%s ! %s :%s', $_name, $_channel, "I saw your + message: $_message"); 62 printf(":%s ! %s :%s\n", $_name, $_channel, "I saw your m +essage: $_message"); 63 } 64 65 66 # *** 67 # _cs_parse_raw_cmd() : parses out raw data from main destined 68 # for chanserv. This will parse the raw packet. 69 # *** 70 71 sub _cs_parse_raw_cmd 72 { 73 my ($cmd) = @_ ; 74 75 # Chanserv :test 76 # ChanServ@Services.Netfrag.Com :test 77 78 my ($_to_whom, 79 $_message) = split(/:/,$cmd); 80 81 # First, make sure that we are the right one getting call +ed 82 unless ( /\#/ ) { 83 if ( lc($_to_whom) !~ m/$_name/i ) { 84 &sendit($_source,"Please let an admin know that s +omething is broke."); 85 } 86 } 87 88 return($_message); 89 } 90 91 1;

Now. I have just spoken to the main coder about my issue and he made it clear that what I was doing was setting a scalar by calling a function which of course I was but that this was causing the problem. He also said that I needed to simply make a bunch of functions and not worry about creating any global scalars or arrays.

Everything makes sense to me now but Im still curious what the other monks think.

_ _ _ _ _ _ _ _ _ _
- Jim
Insert clever comment here...


In reply to Re: Re: A lil module creation advice by snafu
in thread A lil module creation advice by snafu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.