[18139] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 307 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 17 18:06:25 2001

Date: Sat, 17 Feb 2001 15:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982451110-v10-i307@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 17 Feb 2001     Volume: 10 Number: 307

Today's topics:
    Re: Archive::Zip - any user comments? <tfbiv@SPAMMENOTerols.com>
        checking uploaded GIF / JPEG file size <info@just-me.de>
    Re: checking uploaded GIF / JPEG file size <perldomo@hotmail.com>
    Re: Drop-in replacement for XML::Parser ... comments? <matt@sergeant.org>
    Re: Drop-in replacement for XML::Parser ... comments? (Clinton A. Pierce)
    Re: Dynamically loading modules nobull@mail.com
    Re: Dynamically loading modules (Gwyn Judd)
    Re: e-mail notifier <tore@extend.no>
    Re: e-mail notifier <rick@akirapc.com>
        enumurating binaries in a dir and calling a function <nowhere@interesting.com>
    Re: enumurating binaries in a dir and calling a functio <nospam@jsoft.xs4all.nl>
    Re: enumurating binaries in a dir and calling a functio <callgirl@la.znet.com>
    Re: FAQ 4.39:   How can I remove duplicate elements fro <iltzu@sci.invalid>
    Re: free cgi's ? <todd@mrnoitall.com>
        Help with HTTP::Daemon, please <martinpk@mindspring.com>
    Re: Net::Ping problems (Garry Williams)
        Passing references to functions <nospam@jsoft.xs4all.nl>
        Project with a large amount of external data <gwhite@the-whites.net>
        PROPOSAL: Graphics::ColorNames <wlkngowl@unix.asb.com>
        public-key encryption <peukert@solutionsetc.de>
    Re: Question <c_clarkson@hotmail.com>
    Re: striping HTML <todd@mrnoitall.com>
    Re: striping HTML <iltzu@sci.invalid>
    Re: striping HTML <no@email.com>
    Re: striping HTML <flavell@mail.cern.ch>
    Re: striping HTML (Me)
    Re: three-part form submission using CGI.pm <bmb@ginger.libs.uga.edu>
    Re: three-part form submission using CGI.pm <flavell@mail.cern.ch>
        Uploading a File with CGI/Perl <mark_shutt@hotmail.com>
    Re: use strict and require <todd@mrnoitall.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 17 Feb 2001 15:25:23 -0500
From: Tom Bates <tfbiv@SPAMMENOTerols.com>
Subject: Re: Archive::Zip - any user comments?
Message-Id: <ient8t82mketk1n98ueulfa66ok9eaqrih@4ax.com>

I'm using the high level functions, where I just get the Zip directory
and extract files, so I'm not doing any file opens. Also, an
uncompressed Zip unzips ok.

Tom

On Mon, 12 Feb 2001 14:07:05 +0000, Matt Sergeant <matt@sergeant.org>
wrote:

>Tom Bates wrote:
>> 
>> I just tried using this module today, and have had problems. If I zip
>> an Access database with WinZip, the unzip in Archive::Zip creates a
>> corrupt database. It's short by about 2%, with all compression methods
>> except "none".
>
>Could you maybe not be using binmode to read/write the file(s)? I've used
>Archive::Zip on Linux with no troubles.



------------------------------

Date: Sat, 17 Feb 2001 20:22:33 +0100
From: "Alexander \"just me\" Apartsev" <info@just-me.de>
Subject: checking uploaded GIF / JPEG file size
Message-Id: <96ml3e$n3v$03$1@news.t-online.com>

Hi all,

I woluld like to check the size (in pixels, not the file size) of an
uploaded file (gif or jpeg) through the perl script which is handling the
submitted form. Is it possible?

Thanks

--
Alexander "just me" Apartsev
fon 030-88 55 45 55
fax 030-88 67 85 56
just-me@just-me.de




------------------------------

Date: Sat, 17 Feb 2001 13:47:23 -0800
From: "Montego" <perldomo@hotmail.com>
Subject: Re: checking uploaded GIF / JPEG file size
Message-Id: <t8tssr4hpk9sf1@corp.supernews.com>

I posted a similar question just yesterday. Somebody recommended Image::Size
module and it works perfectly for loading width and height into variables.
It can be found at:

http://search.cpan.org/search?module=Image::Size

--Montego--


"Alexander "just me" Apartsev" <info@just-me.de> wrote in message
news:96ml3e$n3v$03$1@news.t-online.com...
> Hi all,
>
> I woluld like to check the size (in pixels, not the file size) of an
> uploaded file (gif or jpeg) through the perl script which is handling the
> submitted form. Is it possible?
>
> Thanks
>
> --
> Alexander "just me" Apartsev
> fon 030-88 55 45 55
> fax 030-88 67 85 56
> just-me@just-me.de
>
>




------------------------------

Date: Sat, 17 Feb 2001 11:54:25 +0000
From: Matt Sergeant <matt@sergeant.org>
Subject: Re: Drop-in replacement for XML::Parser ... comments?
Message-Id: <3A8E6671.21BA89BB@sergeant.org>

"Clinton A. Pierce" wrote:
> 
> I have a project where I need to parse a machine-generated XML file.
> The data's very regular: there's no CDATA, Unicode, namespaces, external
> entities or anything else.  Just basic markup.   And it's always going to
> be well-formed.  But, it's a very, very large document.
> 
> XML::Parser turns out to be fairly expensive to get going, and what I
> wanted (essentially) was the output from XML::Simple (which uses
> XML::Parser).
> 
> I need this process to startup and shutdown in an awful hurry.  So,
> what I came up with is this program.  It's a drop-in replacement for
> XML::Simple::build_tree that doesn't require expat.  The benchmark hooks
> at the bottom tell this story:
> 
>         * element-for-element it runs at almost the same speed as
>           XML::Parser, about 5% slower over many iterations over the
>           same document.
>         * The startup costs are about 15-20% less than XML::Parser

It's pretty neat, of course I'd hesitate to put it on CPAN and call it an
"XML Parser". However you may be interested that there's a story in the
Orchard project to do an Orchard version of XML::Simple. Tests have shown
that Orchard ranges from 20 to 5 times faster than XML::Parser based
solutions in almost all cases. Maybe you'd like to help out with that
instead?

Regarding XML::Parser startup time, I think the different "Styles" in
XML/Parser.pm might contribute some to that, and I think they should be
removed, or autoloaded.

As far as speeding things up, it sure looks like you've run into the maximum
speed of the regexp engine. One thing that might be slowing it down is fix()
with it's /eg. However probably not if you don't have any entities in there.
But you could try writing that bit in C (or Inline.pm).

Finally, I think this:

sub start {
        my($element,$stack)=@_;
        $element=~s@(^\s+|/\s*$)@@;

Should have a /g modifier on it, no?

PS: Namespace processing is pretty simple. Ken MacLeod's SAX2 parser does
its own namespace processing, rather than letting XML::Parser do it, and its
only about 30 lines of code, in case you're interested.

-- 
<Matt/>

    /||    ** Founder and CTO  **  **   http://axkit.com/     **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // ** mod_perl news and resources: http://take23.org  **
     \\//
     //\\
    //  \\


------------------------------

Date: Sat, 17 Feb 2001 15:12:43 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Drop-in replacement for XML::Parser ... comments?
Message-Id: <Lxwj6.3624$0u5.673474@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <3A8E6671.21BA89BB@sergeant.org>,
	Matt Sergeant <matt@sergeant.org> writes:
> "Clinton A. Pierce" wrote:
> It's pretty neat, of course I'd hesitate to put it on CPAN and call it an
> "XML Parser". 

I wasn't going that far.  :)

> However you may be interested that there's a story in the
> Orchard project to do an Orchard version of XML::Simple. Tests have shown
> that Orchard ranges from 20 to 5 times faster than XML::Parser based
> solutions in almost all cases. Maybe you'd like to help out with that
> instead?

Maybe so.  Is there a top-level project page that's organizing efforts?
A quick googling of the web shows some support pages and mentions of it,
but nothing approaching organization.
 
> Regarding XML::Parser startup time, I think the different "Styles" in
> XML/Parser.pm might contribute some to that, and I think they should be
> removed, or autoloaded.

Amen.  This doesn't help convince people that Perl's a good XML processing
language when the canonical parser is a pig.  (Didn't seem to hurt CGI 
though!  :)

> As far as speeding things up, it sure looks like you've run into the maximum
> speed of the regexp engine. One thing that might be slowing it down is fix()
> with it's /eg. However probably not if you don't have any entities in there.
> But you could try writing that bit in C (or Inline.pm).

I was hoping I hadn't run into the limits of the regexp engine.  That maybe
I was doing something silly and stupid and triggering one of the many 
worst-case scenarios in the code.  Hopefully someone will spot that.
 
> Finally, I think this:
> Should have a /g modifier on it, no?

Yup, thank you!  :)  Didn't turn up in the particular data set we were using
but for general purposes, yeah.  

-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org         Perl Developer's Dictionary -- May 2001
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


------------------------------

Date: 17 Feb 2001 11:50:33 +0000
From: nobull@mail.com
Subject: Re: Dynamically loading modules
Message-Id: <u9ofw1a5py.fsf@wcl-l.bham.ac.uk>

tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:

> Subject: Dynamically loading modules

Popular question this one lately.  Been asked at least once a week for
the last month or two.  Have you considered reading before you post?

> Bear with me a little on this one. Imagine if you will that you have a
> need to load perl code from a particular directory. No problem, you just
> use 'use' right? But the problem is that you don't know the names of
> these modules at the time your script was written. In my case this is
> because these modules are like 'plug-ins' to my script and I just want
> to be able to drop a new one into the directory and have it be loaded
> and run correctly. So you'd do something like:
> 
> while (<some_dir/*>)
> {
>     eval 'require $_';

No need for eval here.

require $_;

> 
>     die $@ is $@;
> 
>     ($package) = m/^.*\/(.*)\.pm/;
> 
>     print "Package name is $package\n";
> 
> But this is not enough because these plug-ins declare certain variables
> and functions that you would like to access. You know the names of these
> variables, but since you don't know the name of the package at compile
> time how do you access them? Well this is what I came up with:
> 
>     # access some variables
>     my $var1 = eval "\$$package" . "::var1";

No need for eval here, simply use a symbolic ref.

my $var1 = do {
  no strict 'refs';
  ${"${package}::var1"};
}

> Anyway this all works but I was wondering if I'm missing something
> obvious here.

I asssume these packages would have exported these variables if you'd
use()d them.  Not totally obvious:

use vars qw( $var1 $var2 );
$package->import( qw( $var1 $var2));

> Is there a way to access package variables/functions if
> you don't know the name of the package at compile time?

Symbolic references.

For details see numerous recent threads on exactly the same subject.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Sat, 17 Feb 2001 20:06:48 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Dynamically loading modules
Message-Id: <slrn98tmek.fsn.tjla@thislove.dyndns.org>

I was shocked! How could nobull@mail.com <nobull@mail.com>
say such a terrible thing:
>tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:
>
>> Subject: Dynamically loading modules
>
>Popular question this one lately.  Been asked at least once a week for
>the last month or two.  Have you considered reading before you post

Who does that? :) *ducks and runs* Okay I feel officially chastised now.

>> Anyway this all works but I was wondering if I'm missing something
>> obvious here.
>
>I asssume these packages would have exported these variables if you'd
>use()d them.  Not totally obvious:
>
>use vars qw( $var1 $var2 );
>$package->import( qw( $var1 $var2));

That's exactly what I wanted. Almost:

undef *some_func;
$package->import( qw/$var1 $var2 some_func/ );

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Feeling nothing is worse than feeling pain.
-Peter Searls (contributed by Nathan Poznick)


------------------------------

Date: Sat, 17 Feb 2001 11:44:42 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: e-mail notifier
Message-Id: <MPG.14f874888a10ab09898b7@news.online.no>

In article <Pine.BSF.4.21.0102152344550.3755-100000@localhost>, 
rick@akirapc.com says...
> does anybody know of a module that can be used to monitor
> e-mail on a unix host and send you an instant message
> when new mail has arrived?

Have you searched for any modules on CPAN [1]?  Nah - I didn't think 
so...

[1] <URL:http://search.cpan.org/>


-- 
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/


------------------------------

Date: Sat, 17 Feb 2001 16:56:33 GMT
From: Rick Noelle <rick@akirapc.com>
Subject: Re: e-mail notifier
Message-Id: <Pine.BSF.4.21.0102171205110.12653-100000@localhost>

Hi,

On Sat, 17 Feb 2001, Tore Aursand wrote:

> In article <Pine.BSF.4.21.0102152344550.3755-100000@localhost>, 
> rick@akirapc.com says...
> > does anybody know of a module that can be used to monitor
> > e-mail on a unix host and send you an instant message
> > when new mail has arrived?
> 
> Have you searched for any modules on CPAN [1]?  Nah - I didn't think 
> so...

Everybody is so friendly around here.  How heart warming.  As a matter of
fact, I did search through all of the e-mail modules.  That is the whole
purpose of asking.  I wanted to know if anybody had any experience with a
particular e-mail module that performed these functions.

Sorry for asking.  

> Tore Aursand - tore@extend.no - http://www.extend.no/~tore/



------------------------------

Date: Sat, 17 Feb 2001 12:51:06 -0800
From: "Chris" <nowhere@interesting.com>
Subject: enumurating binaries in a dir and calling a function
Message-Id: <YwBj6.2663$GE.374919@news.uswest.net>

Hi--

This is definitely a newbie question, but I have to start somewhere! I am
attempting to open a directory and enumurate all of the files and take
the binaries only and run a function on them. (getting version info
specifically)  I think the tricky part is ignoring the non-binary files. I
know there is a filetest operator that does this.

Would the pseudo code would look something like this?

opendir (DIR, $path) || die "Couldn't open directory $path: $!\n";
for ( <*.dll> )

{ do function here }

Anyone have any ideas on a prefered way to write this loop?

Thanks in advance
Chris




------------------------------

Date: Sat, 17 Feb 2001 22:50:40 +0100
From: "Willem Joosten" <nospam@jsoft.xs4all.nl>
Subject: Re: enumurating binaries in a dir and calling a function
Message-Id: <96mrmu$n0$1@news.tudelft.nl>

Assuming your using Windows (never saw a .dll on Unix):

# don't add the \n, without it Perl will show the line number where the
error occured
# include $! it will show the reason while it failed
# use or instead of ||
opendir(DIR, $path) or die "Can't open $path, reason $!";

# use readdir(DIR) instead of the diamong operator, <> reads from files not
directories
while(defined (my $file = readdir(DIR)){
    # if you want to discriminate on the extension: (on Unix you can
discriminate on file attribute)
    if ($_ =~ /.*\.dll/){
        # we found a dll!! do something with it.
        print "The dll's name is $_\n";
    } elsif ($_ =~ /.*\.exe){
        # we found an exe!! do someting with it
        print "The exe's name is $_\n"
    }
}
closedir(DIR);

I don't know if there is a filetest on Windows for executables but regular
expression do the job.

Regards,
Willem Joosten

"Chris" <nowhere@interesting.com> wrote in message
news:YwBj6.2663$GE.374919@news.uswest.net...
> Hi--
>
> This is definitely a newbie question, but I have to start somewhere! I am
> attempting to open a directory and enumurate all of the files and take
> the binaries only and run a function on them. (getting version info
> specifically)  I think the tricky part is ignoring the non-binary files. I
> know there is a filetest operator that does this.
>
> Would the pseudo code would look something like this?
>
> opendir (DIR, $path) || die "Couldn't open directory $path: $!\n";
> for ( <*.dll> )
>
> { do function here }
>
> Anyone have any ideas on a prefered way to write this loop?
>
> Thanks in advance
> Chris
>
>




------------------------------

Date: Sat, 17 Feb 2001 14:50:22 -0800
From: Kira <callgirl@la.znet.com>
Subject: Re: enumurating binaries in a dir and calling a function
Message-Id: <3A8F002E.893C5BB8@la.znet.com>

Chris wrote:

(some snippage)

> I am attempting to open a directory and enumurate all of the files
> and take the binaries only and run a function on them. (getting 
> version info specifically)  I think the tricky part is ignoring 
> the non-binary files. I know there is a filetest operator that 
> does this.
 
> Would the pseudo code would look something like this?
 
> opendir (DIR, $path) || die "Couldn't open directory $path: $!\n";
> for ( <*.dll> )
 
> { do function here }
 
> Anyone have any ideas on a prefered way to write this loop?
 

Below my signature you will note a test script. This test
script doesn't perform exactly what you want. You have not
provided clear parameters regarding your goal. Nonetheless,
this test script displays a method you may adapt to your
specific needs.

Appears you want Dynamic Library Files only, but you are
not specific on this. Easy enough though to include a
little code to pull only those files. My test script
will pull only binary files. If you change my " -B "
to " -T ", it will ignore binary files and list files
which are 'text' in nature. Leaving out both switches,
B and T, will pull all files.

Research stat () and you will discover lots of
switches for pulling specific data which will
help you. My code simply pulls creation date
and last access date, both in epoch seconds.

Godzilla!
--

TEST SCRIPT:
____________

#!perl

print "Content-type: text/plain\n\n";

$directory = "c:/apache/users/test";
print "Binary Files In $directory are:\n\n";
opendir (DIRECTORY, $directory) or die "$dir: $!";
while (defined ($file = readdir DIRECTORY))
 {
  if (-B $file)
   {
    print "$file\n";
    ($created, $last_access) = (stat("$directory/$file")) [8,9];
    print "Created: $created Last Access: $last_access\n\n";
   }
 }
closedir (DIRECTORY);

exit;

PRINTED RESULTS:
________________

Binary Files In c:/apache/users/test are:

REGISTER.EXE
Created: 982396800 Last Access: 933032714

BIRD.GIF
Created: 982396800 Last Access: 836627046


------------------------------

Date: 17 Feb 2001 18:24:28 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: FAQ 4.39:   How can I remove duplicate elements from a list or array?
Message-Id: <982433680.8064@itz.pp.sci.fi>

[Posted and forwarded to original poster.]

In article <iRuj6.196$zN2.188834816@news.frii.net>, PerlFAQ Server wrote:
>+
>  How can I remove duplicate elements from a list or array?
>
>    There are several possible ways, depending on whether the array is
>    ordered and whether you wish to preserve the ordering.
>
>    a) If @in is sorted, and you want @out to be sorted: (this assumes all
>    true values in the array)
>            $prev = 'nonesuch';
>            @out = grep($_ ne $prev && ($prev = $_), @in);
>
>        This is nice in that it doesn't use much extra memory, simulating
>        uniq(1)'s behavior of removing only adjacent duplicates. It's less
>        nice in that it won't work with false values like undef, 0, or "";
>        "0 but true" is OK, though.

Okay, so _why_ does the FAQ answer have those limitations, when
they're so trivial to fix:

    $prev = "not equal to $in[0]";
    @out = grep($_ ne $prev && ($prev = $_, "true"), @in);

There, I even tried to make it slightly self-documenting.  It also
makes *sure* the initial value of $prev doesn't equal $in[0].

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"To use these conventions makes it too much like every other
 pseudo-medieval fantasy set in an oversized English garden."
                      -- Phideaux in rec.arts.sf.composition

Please ignore Godzilla and its pseudonyms - do not feed the troll.


------------------------------

Date: Sat, 17 Feb 2001 12:17:40 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Re: free cgi's ?
Message-Id: <3A8EC02D.EABF8477@mrnoitall.com>



nowayandnohow wrote:

> Hi ya'll, i was wondering if one of you could give me a link or two to a
> free cgi script page where i can download them, to brake them down to learn
> more about them (i.e. to learn more about CGI writing).
>
> I have been around the web and found some, but i figured some of you are
> better to show me the good stuff, since i can't make the difference between
> shiet and good.
>
> Thnx
>
> // Jo

Best
http://www.cgi-resources.com/



------------------------------

Date: Sat, 17 Feb 2001 09:30:24 -0600
From: Peter Martin <martinpk@mindspring.com>
Subject: Help with HTTP::Daemon, please
Message-Id: <B6B3F530.3D90%martinpk@mindspring.com>

Help! I'm new to HTTP server-side programming...

When I run the code below, from the HTTP::Daemon documentation, the script
receives requests from my browser, and sends a response, but the browser
doesn't see the response.

Configuration:
- MacPerl 5.004 on MacOS 9.0.4
- IE 5 Mac
- Script and browser running on same machine (same results on separate
machine)
- Connected to LAN or DSL, same results

Thanks for any help,
Peter

-----------
  use HTTP::Daemon;
  use HTTP::Status;

  $d = new HTTP::Daemon;
  print "Please contact me at: <URL:", $d->url, ">\n";
  while ($c = $d->accept) {
      $r = $c->get_request;
      if ($r) {
      if ($r->method eq 'GET' and $r->url->path eq "/xyzzy") {
              # this is *not* recommened practice
          $c->send_file_response("/etc/passwd");
      } else {
          $c->send_error(RC_FORBIDDEN)
      }
      }
      $c = undef;  # close connection
  }



------------------------------

Date: Sat, 17 Feb 2001 22:34:54 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Net::Ping problems
Message-Id: <i0Dj6.5$gw.1390@eagle.america.net>

On Fri, 16 Feb 2001 08:39:04 -0600, Daniel Berger <djberge@uswest.com>
wrote:
>Garry Williams wrote:
>> On Thu, 15 Feb 2001 14:46:43 -0600, Daniel Berger <djberge@uswest.com>
>> wrote:
>>
>> >What is going on?  Why is Net::Ping being such a pain in the arse?
>>
>> Net::Ping defaults to using the tcp echo request port on the remote
>> host.  The ping command sends an icmp echo reqest.  The remote host
>> may not allow tcp echo request connections.
>
># Here's the code.  It's nothing special or complex, that's why I didn't
>include it originally.
># It's really just a copy of what's in the Net::Ping docs.
>
>#!/usr/bin/perl -w
>
>use Net::Ping;
>use strict;
>
># On the command line, all 5 succeed.  With 'pingecho', the host "Drazi"
>fails.
># With Net::Ping's 'ping' method, "Vorlon" and "Drazi" both fail.
># Same result using hostnames or IP addresses (just in case DNS was an
>issue)
>my @hosts = qw(
>   Mimbari
>   Centauri
>   Narn
>   Vorlon
>   Drazi
>);
>
># I tried all three protocols - same results
>my $p = Net::Ping->new("icmp");

I assume you already know that this will require root access.  I don't
imagine that this is the problem because the module produces a self-
explanatory message when non-root attempts this.  

>foreach my $host(@hosts){
>
>   print "$host is ";
>   print "NOT " unless $p->ping($host);
>   print "reachable with 'ping()'\n";
>
>   print "\n$host is ";
>   print "NOT " unless pingecho($host);
>   print "reachable with 'pingecho()'\n";
>
>   sleep(1);
>
>}
>
>$p->close;

No clue.  The code above should produce the same result as the command
line ping.  

>Now, I did notice that the Net::Ping docs say that it uses its own
>routines to pack and unpack
>ICMP packets and that it would be better for a separate module to be
>written that understands
>all of the different kinds of ICMP packets.  Could that be the issue?

Not sure.  Only two kinds: echo request and echo reply.  Your code
works fine on my Solaris 2.7 server.  

-- 
Garry Williams


------------------------------

Date: Sat, 17 Feb 2001 22:35:54 +0100
From: "Willem Joosten" <nospam@jsoft.xs4all.nl>
Subject: Passing references to functions
Message-Id: <96mqr9$bn$1@news.tudelft.nl>

Hi,

I'm a bit confused how references work, what I try to do is write a callback
function which has the change of changing some variables. For example:

sub test {
    my $callback = $_[0];
    my $value = "String 1";
    if (&$callback(\$value)){
        print "New value = $value";
    } else {
        print "Value = $value";
}

sub changevalue {
    my $value = $_[0];
    $$value = "String 2";
    return 1;
}

Now when I do:

    test(\&changevalue);

It will print: "New value: SCALAR(0x<etc>)" instead of "New value: 2".

I found I can change the value using $_[0] = 2 (and not use \&value in the
callback but just &value). But I find this harder to read.

So is there a way to make the passing by reference work the way I expect it
to? (for the Delphi programmers, I except it to work like a var parameter).


Regards,
Willem Joosten





------------------------------

Date: Sat, 17 Feb 2001 12:37:13 -0500
From: "Greg White" <gwhite@the-whites.net>
Subject: Project with a large amount of external data
Message-Id: <qFyj6.8$nI3.2817@nntp0.chicago.il.ameritech.net>

I am a long time coder, recently adding Perl to my toolbelt.  I have a
fairly sophisticated project, it uses several module files, in addition I
have, some configuration and "templates" that are kept in external files
(about 10) as well as common subroutines.  The templates and configuration
files contain parts the end user will change occasionally.  Should I look to
merge all these parts into one or two files, or ???????  I want to keep the
user friendliness, but avoid the performance hit, or is the performance hit
of loading 10-15 files inconsequential?  I realize there is not one right
answer, but I am seeking opinions.

Greg




------------------------------

Date: Sat, 17 Feb 2001 15:51:04 -0500
From: Robert Rothenburg <wlkngowl@unix.asb.com>
Subject: PROPOSAL: Graphics::ColorNames
Message-Id: <3A8EE438.EB0043DD@unix.asb.com>




I think a module which has common color names would be useful. The 
initial version would return RGB codes for a given name. There's already
some duplication of this in various packages... but I see no reason for
a
module or script to require Tk, VRML, ANSI etc, to be installed just 
because one wants to say 'black' instead of (0, 0, 0).

I think 'Gaphics::NamedColors' is a good name for the module.

Comments? Criticisms? Is there already such a module?

(I recall posting a similar message about a year ago with no replies;
I'm working on a module which I would like to give the user an option
for named colors rather than RGB values, so this issue has come up
again...)


------------------------------

Date: Sat, 17 Feb 2001 09:34:57 +0100
From: Juergen Peukert <peukert@solutionsetc.de>
Subject: public-key encryption
Message-Id: <3A8E37B1.92771D90@solutionsetc.de>

Hi

I am looking for a perl-implementation of a public-key code like RSA.
Are there other public-key codes besides RSA?

Best regards
Juergen


------------------------------

Date: Sat, 17 Feb 2001 06:26:08 -0600
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: Question
Message-Id: <223DE35701255B15.AE20BC0D3DDC1758.E1DD3D186B36CD9A@lp.airnews.net>


"Copenhagen" <copenhagen@copenhagen.com> wrote:
: "Tore Aursand" <tore@extend.no> wrote:
: > In article <21si6.296$yps1.42336308@news.randori.com>,
: > copenhagen@copenhagen.com says...
: [SNIP
: ]> Now back to the problem;  How do you know what to select?  I'm not sure
: > that you are giving us all the details on the problem, or is it me that
: > can't understand what you're meaning?
: >
: >
:
: Here is the actual code.
:
: my $id = $q->param('id');
: my @entry = queryrow("SELECT * FROM customer, billing_address WHERE
: customer.id = '$id' and billing_address.id = '$id'");
: my @servicetype = queryrow("SELECT * FROM phone_service where id =
'$id'");
: my @options = queryrow("SELECT * FROM options where id ='$id'");
: my $sth = $dbh->prepare("SELECT * FROM switch WHERE id = '$id'");
:       $sth->execute();
: @switch = $sth->fetchrow_array;
: my
:
($sid,$imsi,$msidsn,$msisdn,$mscat,$ts1,$ts2,$ts3,$piccide,$substatus,$ts1p,
:
: $ts2p,$ts3p,$boca,$bocint,$bocpi,$bocssc,$bocintexclhplmn,$bocpe,$bica,
:
: $bicroam,$cfscfu,$cfscfb,$cfscfnr,$cfscfun,$udbcbdbsc,$udbboaoc,$udbbooic,
:
:
$udbbooicetthc,$udbboaic,$udbboaicwroh,$ccdcw,$ccdch,$mpdmp,$lidclipd,$lidcl
: ird) = @switch;
: $sth->finish;
: #generate the <select><option> for each yes no item of the switch table.
: my %hash =
:
(1,"ts1p",2,"ts2p",3,"ts3p",4,"boca",5,"bocint",6,"bocpi",7,"bocssc",8,"boci
: ntexclhplmn",
:
:
9,"bocpe",10,"bica",11,"bicaroam",12,"cfscfu",13,"cfscfb",14,"cfscfnr",15,"c
: fscfun",
:
:
16,"udbcbdbsc",17,"udbboaoc",18,"udbbooic",19,"udbbooicetthc",20,"udbboaic",
: 21,"udbboaicwroh",
:
: 22,"ccdcw",23,"ccdch",24,"mpdmp",25,"lidclipd",26,"lidclird");
: my $num = 1;
: my $item;
: my
:
($box_1,$box_2,$box_3,$box_4,$box_5,$box_6,$box_7,$box_8,$box_9,$box_10,$box
: _11,
:
:
$box_12,$box_13,$box14,$box15,$box16,$box_17,$box_18,$box_19,$box_20,$box_21
: ,
:       $box_22,$box_23,$box_24,$box_25,$box_26)='';
:
: foreach ($ts1p,$ts2p,$ts3p,$boca,$bocint,$bocpi,$bocssc,$bocintexclhplmn,
:
: $bocpe,$bica,$bicroam,$cfscfu,$cfscfb,$cfscfnr,$cfscfun,$udbcbdbsc,
:              $udbboaoc,$udbbooic,$udbbooicetthc,$udbboaic,$udbboaicwroh,
:               $ccdcw,$ccdch,$mpdmp,$lidclipd,$lidclird) {
: $item = $hash{$num};
: if ($thing eq "Y") {
:   $box."_".$num .= "<select size=\"1\" name= $item>";
:         $box."_".$num .= "<option value=\"Y\" selected>Yes</option>";
:         $box."_".$num .= "<option value=\"N\">No</option>";
:         $box."_".$num .= "</select>";
:  } else {
:      $box."_".$num .= "<select size=\"1\" name= $item>";
:         $box."_".$num .= "<option value=\"Y\">Yes</option>";
:         $box."_".$num .= "<option value=\"N\" selected>No</option>";
:         $box."_".$num .= "</select>";
:  }
: $num++;
: }
:
: Now that I am showing the BIGGER picture of what I need here maybe you can
: help.  Sorry bout b4 as my mind doesn't always work at 2AM as it should.
:
: what I want is the following
: if $ts1p is equal to Y then i want
:
: <select size = "1" name = "ts1p">
: <option> value = "Y" selected>Yes</option>
: <option> value = "N">Yes</option>
: </select>
:
:
: but if $ts1p not equal to Y
:
: <select size = "1" name = "ts1p">
: <option> value = "Y">Yes</option>
: <option> value = "N" selected>Yes</option>
: </select>
:
: and I need to do this for each of the 26 items that I am pulling from the
: array but instead of creating a if/then/else for each or the 26 items I
know
: that it can be done with a loop just not quite shure how to do it.  Again
: thanks for any help.

    I'm not used to using OO CGI.pm, so you may need to change
a few things:

my @select_names =
  qw/ts1p ts2p ts3p boca bocint bocpi bocssc bocintexclhplmn bocpe bica
        bicaroam cfscfu cfscfb cfscfnr cfscfun udbcbdbsc udbboaoc udbbooic
        udbbooicetthc udbboaic udbboaicwroh ccdcw ccdch mpdmp lidclipd
        lidclird/;
my $q = new CGI;
foreach my $num (10 .. 35) {
    print $q->popup_menu( -name => $select_names[$num - 10],
                                          -values=> ['Y','N'],
                                          -default=> $switch[$num] eq 'Y' ?
'Y' : 'N',
                                          -labels => {Y => 'Yes', N =>
'No'},
                                          -size => 1) . "\n";
}

prints out something like:

<select name="ts1p" size="1">
<option selected value="Y">Yes</option>
<option  value="N">No</option>
</select>

<select name="ts2p" size="1">
<option  value="Y">Yes</option>
<option selected value="N">No</option>
</select>

<select name="ts3p" size="1">
<option selected value="Y">Yes</option>
<option  value="N">No</option>
</select>

HTH,
Charles K. Clarkson





------------------------------

Date: Sat, 17 Feb 2001 12:16:02 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Re: striping HTML
Message-Id: <3A8EBFCC.5AABD7E5@mrnoitall.com>



Frank Miller wrote:

> I have a website where users can post text replies to questions.   I don't
> want them to be able to enter HTML in the messages, because that messes up
> my pages when I print the replies.
>
> Is there a good perl sub that will strip any HTML tags they put in the
> message?  It would be nice if they could do simple ones like <br>, <b> and
> other text formatting.  I don't want pictures, tables and font changes.
>
> Frank

  $val =~ s/<([^>]|\n)*>//g;




------------------------------

Date: 17 Feb 2001 21:12:51 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: striping HTML
Message-Id: <982443186.20837@itz.pp.sci.fi>

In article <cicj6.432448$U46.12652316@news1.sttls1.wa.home.com>, Frank Miller wrote:
>I have a website where users can post text replies to questions.   I don't
>want them to be able to enter HTML in the messages, because that messes up
>my pages when I print the replies.

You don't want to strip tags.  You want to HTML-escape the text:

  $text =~ s/&/&amp;/g;
  $text =~ s/</&lt;/g;


>Is there a good perl sub that will strip any HTML tags they put in the
>message?  It would be nice if they could do simple ones like <br>, <b> and
>other text formatting.  I don't want pictures, tables and font changes.

Okay.. well, as long as you don't mind them not being able to write a
literal "<br>", one solution would be to first escape the text just as
above, and then restore certain tags:

  $text =~ s!&lt;(br|/?[bi]|/?su[bp]|/?big|/?small)>!<$1>!ig;

But you'd _still_ need to check for unclosed tags, unless you want to
risk everything on the rest of the page appearing in bold italics.  (I
consider that a particularly bad way to handle this specific type of
broken HTML, but that's what nearly all existing browsers will do.)

On the other hand, have you considered handling line and paragraph
breaks simply by looking for short and blank lines respectively?  If
you wanted, you could come up with your own notation for typeface
changes too -- writing *bold* and _italic_ is one well established
convention.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"I just wish the country I lived in had a real name."
              -- John Kensmark in rec.arts.sf.composition about the U.S.

Please ignore Godzilla and its pseudonyms - do not feed the troll.


------------------------------

Date: Sat, 17 Feb 2001 21:44:10 GMT
From: "Frank Miller" <no@email.com>
Subject: Re: striping HTML
Message-Id: <KgCj6.437223$U46.12848308@news1.sttls1.wa.home.com>

Tell you what. You do it your way, I'll do it my way and we'll all live in
peace. I personally don't like the reply after the message. But, there is no
right or wrong way, just different ways. It's really sad that I come onto
this group to try and get help and am just flamed by people like you.
People are complex and interesting creatures. What makes us so interesting
is that we do thing differently from one another. Do you treat people in
real life like this? Or only on the Internet? Are you one of those people
that carries a baseball bat in their car and "flames" the driver in front of
you when he doesn't something you don't like? Probably not. So why do you
think you can do the virtual equivalent to me on-line. Why do you think that
your way is the right way? Why does some guy that posts a flaming rant on a
website suddenly get to be the dictator of what I do on the Internet. Unless
your name is Al Gore and you invented the Internet, I don't think you have
any more right to tell me how to post than I do to tell you how to post.

Now...back to perl.

"Scott R. Godin" <dontspamthewebmaster@webdragon.net> wrote in message
news:<96laou$2nv$1@216.155.33.113>...
> In article <pEoj6.435107$U46.12741080@news1.sttls1.wa.home.com>, "Frank
> Miller" <no@email.com> wrote:
>
> don't do this.. what I'm doing right here, and what you did right
> below.. it's called top-posting, and it's BAD. EVIL. UGLY, includes TONS
> of useless extra fluff (i.e. the ENTIRE BLOODY PREVIOUS ARTICLE (why the
> hell do you think there's such things as backreferences in newsgroups?
> look at the headers!) gets included) (see below where the reply BELONGS
> for explanation. Thanks!





------------------------------

Date: Sat, 17 Feb 2001 22:46:37 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: striping HTML
Message-Id: <Pine.LNX.4.30.0102172246050.11228-100000@lxplus003.cern.ch>

On Sat, 17 Feb 2001, Frank Miller blurted out without just cause:

> Tell you what. You do it your way, I'll do it my way and we'll all live in
> peace.

We surely will.  *plonk*




------------------------------

Date: 17 Feb 2001 22:13:19 GMT
From: me@nospam.com (Me)
Subject: Re: striping HTML
Message-Id: <Xns904B9B3382D4Fmememeyeahme@206.165.3.80>

Gerard Lanois <gerard@NOSPAMlanois.com> wrote in 
<u66iaw3dm.fsf@NOSPAMlanois.com>:

>Funny, I was just writing a stripper earlier today.

    	      	    	  	    	    	    	    	2/16/19101

Dear Savanna,

Thank you very much for the wonderful lap dance you provdided me with 
recently.  I have to say that I have never been so "moved" as when 
experiencing your dance.

I just thought I would write to tell you how much I appreciated it, and 
I'll be sure to stop by during your next shift.

Take care!



------------------------------

Date: Sat, 17 Feb 2001 10:10:00 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: three-part form submission using CGI.pm
Message-Id: <Pine.A41.4.21.0102170955140.17264-100000@ginger.libs.uga.edu>

On 17 Feb 2001, Scott R. Godin wrote:
> I could probably reduce the regexes to: 
> 
>     $fixee =~ s|\n\n|<br>|g;
>     $fixee =~ s|\r\r|<br>|g;
>     $fixee =~ s/\n|\r/<br>/g; # just in case
Scott,

I suspect I'm missing a key point, but what about:

$fixee =~ s/(?:[\r\n]{2})+/<br><br>/g;
$fixee =~ s/[\r\n]/<br>/g;

Brad



------------------------------

Date: Sat, 17 Feb 2001 16:43:57 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: three-part form submission using CGI.pm
Message-Id: <Pine.LNX.4.30.0102171627440.11228-100000@lxplus003.cern.ch>

On Sat, 17 Feb 2001, Brad Baxter wrote:

> I suspect I'm missing a key point, but what about:
>
> $fixee =~ s/(?:[\r\n]{2})+/<br><br>/g;

I think the on-topic part of this is that when you're reading input
from an HTTP protocol transaction (which is pretty-much analogous to
the sockets discussion in perldoc perlport) then you would do well to
binmode() the input and to do your matching on \015 and \012
(specifically CR and LF in ASCII, which are the mandated network
representations of the things you're supposed to be handling) rather
than on the logical concepts of newline and return, whose actual
representations are dependent on the programming platform.

As for the right-hand side, suffice it to say that once a line is
broken, it is broken.  Breaking it twenty times wouldn't make it any
more-broken.  But that's off-topic for this group.

all the best



------------------------------

Date: Sat, 17 Feb 2001 18:30:11 -0000
From: Mark <mark_shutt@hotmail.com>
Subject: Uploading a File with CGI/Perl
Message-Id: <t8tgpj6ucpf020@corp.supernews.com>

I've uploaded a file using <input type=file enctype=mutipart/form-data>. 
It is a binary file and I had to use binmode(file) before writing the data 
to a file to prevenet a 0Dh from being written before every 0A. However, 
every 25h (ASCII %) is being erased or changed to 0.000000 if it appears 
beforea  printable character. I don't understand why this is happening 
because I read when data is being sent with enctype=multipart/form-data it 
is not encrypted and I'm not decoding anything. I did modify the data to 
replace every % with %% and that correctly worked. But I have no way of 
doign this in a real world situation (I can't modify the data until the 
user uploads it) plus, I don't undestand why it is encoding/decoding 
anyway when i use multipart/form-data.

Can anyone help? Thanks.

Mark

--
Posted via CNET Help.com
http://www.help.com/


------------------------------

Date: Sat, 17 Feb 2001 12:57:04 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Re: use strict and require
Message-Id: <3A8EC965.3327B710@mrnoitall.com>



Beable van Polasm wrote:

> LXQ <lxq79@REMOVE.CAPITALS.hotmail.com> writes:
> > I am trying to make a config file like this:
> >
> > config.pl
> > #!/usr/bin/perl
> > $sendmail = "/usr/sbin/sendmail";
> >
> > And then all the other program can read from the config.pl, like:
> >
> > program.pl
> > #!/usr/bin/perl
> > require "config.pl";
> > print "Sendmail location is $sendmail";
> >
> > It works fine. But the problem is as my project getting bigger, I want to
> > use 'use strict'. I tried but failed, any conclusion for this? Thanks very
> > much.
>
> The easiest way would be to make your variables file into a module. The
> module would EXPORT the configuration variables that you want the programs
> to see. Then you can "use" the module to get access to the variables.
>
> Further reading:
> perldoc -q "how do i create a module"
>
> So for example, in your module you could put:
>     ...
>     @EXPORT_OK = ($sendmail);
>     ...
> And in your program you can put:
>
> ...
> use Module::Name qw($sendmail);
> ...
>

Question for Beable van Polasm...
Could I do tbis:

  @EXPORT_OK = (
$sendmail="usr/lib/sendmail";
$var2="definition2";
$var3="definition3";
$var4="definition4";
);



------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 307
**************************************


home help back first fref pref prev next nref lref last post