Re: Question from the perlmod man pages.




Jim Gibson wrote:
In article <1162052151.603188.40550@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
grocery_stocker <cdalten@xxxxxxxxx> wrote:

I'm sort of drawing a stump on the following:

"Perl packages may be nested inside other package names, so we can have
package names containing ::. But if we used that package name directly
as a filename it would make for unwieldy or impossible filenames on
some systems. Therefore, if a module's name is, say, Text::Soundex,
then its definition is actually found in the library file
Text/Soundex.pm."

Say I have a module name Text::Soundex. I use this in my Perl script
as:

use Text::Soundex;

I know there is a module called Soundex.pm. I also know there is a
directory
name with the name Text. However, would there also be a module named
Text.pm?

No, there need not be a module named Text.pm. The pattern A::B is a
naming convention, and does not establish a hierarchical relationship
between modules A and B or their symbol tables. See 'perldoc perlmod'
for details.

The source of this confusion stems from the following lines of code:

#!/usr/bin/perl

# change these two lines
$server_port = 1234;
$identification_phrase = 'insert phrase here';

# redirect error messages to a logfile
open(STDERR, ">>/tmp/logserver.log");

# code stolen liberally from Perl Cookbook

use IO::Socket;

$logfile = $ARGV[0];
open(LOG, "<$logfile");
# read to the current end of the log
while(<LOG>) {
}

$server = IO::Socket::INET->new(LocalPort => $server_port,
Type => SOCK_STREAM,
Reuse => 1,
Listen => 10 ) # or SOMAXCONN
or exit; # "Couldn't be a tcp server on port $server_port : $@\n";

while (($client,$client_address) = $server->accept()) {
($client_port, $client_ip) = unpack_sockaddr_in($client_address);
@decimal_address = unpack("C4", $client_ip);
$ip_number = join(".", @decimal_address);
warn "connection from $ip_number";
while(<$client>) {
last if /$identification_phrase/;
}
warn "connection from $ip_number gave pass phrase";
$lines = 0;
while(<LOG>) {
$lines++;
print $client $_;
}
warn "returned $lines lines to $ip_number";
close($client);
}

close($server);

Why go

use IO::Socket;

Why just not

use IO::Socket::INET;

in this case

.



Relevant Pages

  • Re: year not returned by Time::localtime
    ... internals of perl regarding memory management and hence the distinction ... Instead I suspect that you mean that the new package function should be ... Its not possible to disambiguate (identify the appropriate ... By the time I can explain it without confusing you, ...
    (perl.beginners)
  • Re: use Win32::TieRegistry if ($^O =~ /win32/i)
    ... Registry Package if I'm on Windows? ... Assuming you have a recent version of perl (I think 5.8.0 or higher, ... (See perldoc -f use) ... Not as arrogant as your reply. ...
    (comp.lang.perl.misc)
  • Re: use Win32::TieRegistry if ($^O =~ /win32/i)
    ... Registry Package if I'm on Windows? ... Assuming you have a recent version of perl (I think 5.8.0 or higher, ... Is this the error when the OS is Win32 or when the OS is NOT Win32 ?? ... But now I don't see the reference. ...
    (comp.lang.perl.misc)
  • RE: Request For Help - Perl DBI & DBD::mysql
    ... If you installed win32 perl from activestate then the activestate package ... install DBD-MySQL ... anti-virus service working around the clock, around the globe, visit: ...
    (perl.dbi.users)
  • Re: Using Python in ActiveX task - works when run as separate step
    ... when executing the package. ... Peter Yang, if you can detail some of what you did to get Perl working, I'd ... >> was trying to use Python in this case because I know it a little better than ... >>>You could execute the step in DTS package window. ...
    (microsoft.public.sqlserver.dts)