[19561] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1756 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 16 18:05:40 2001

Date: Sun, 16 Sep 2001 15:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1000677911-v10-i1756@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 16 Sep 2001     Volume: 10 Number: 1756

Today's topics:
        (fixed?) Re: New upgrade perl problem (Toni)
        anonymous host on irc <zoetnet@wanadoo.nl>
    Re: AS Perl 629 Image::Magick makes Perl crash when out <soren.newsgroups@wonderstorm.com.INVALID>
    Re: Cannot run perl scripts in Apache when file opened  <rob_13@excite.com>
        canonical of a file path - how? <Neilmorris@btinternet.com>
    Re: canonical of a file path - how? (John J. Trammell)
    Re: canonical of a file path - how? (Randal L. Schwartz)
    Re: change dir the dir of Favorites.. <bwalton@rochester.rr.com>
    Re: change dir the dir of Favorites.. <the@executioner.tmfweb.nl>
        Discontinue the loop (uma shanker)
    Re: Discontinue the loop <dtweed@acm.org>
    Re: Discontinue the loop <rob_13@excite.com>
    Re: Discontinue the loop <bwalton@rochester.rr.com>
    Re: Discontinue the loop <bart.lateur@skynet.be>
        HELP!  ActivePerl for Win32:  How do I compare two text (codeslayer)
    Re: HELP!  ActivePerl for Win32:  How do I compare two  <bart.lateur@skynet.be>
    Re: home directory in use lib <soren.newsgroups@wonderstorm.com.INVALID>
        How can I authenticate a user's login password under a  <bopew2000@yahoo.com>
    Re: How can I authenticate a user's login password unde (David Efflandt)
    Re: image pixel dimensions using perl script but NOTsiz <soren.newsgroups@wonderstorm.com.INVALID>
    Re: IO::File->new_tmpfile <soren.newsgroups@wonderstorm.com.INVALID>
        irc  <zoetnet@wanadoo.nl>
    Re: Mail parser: Can it be faster? <newspost@coppit.org>
        Multithreading Information <raymond.mccrae@ntlworld.com>
    Re: Numbers and strings oddities question <bart.lateur@skynet.be>
    Re: Numbers and strings oddities question (Mark Jason Dominus)
    Re: Numbers and strings oddities question <gnarinn@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 16 Sep 2001 12:07:02 -0700
From: jacapaca@navegalia.com (Toni)
Subject: (fixed?) Re: New upgrade perl problem
Message-Id: <c03e0fbf.0109161107.2b343f4d@posting.google.com>

> It would have been easier to answer this question if you had said 
>which version of Perl your 5.00x is. The answer depends on x. 

Old version is 5.00503 
> >What can I do to reuse them? 
> > Look in the manual for the' CPAN' module. It has a feature called 
>' Autobundle' that is useful for reinstalling all of your old modules. 
> > Autobundle will be safe even if some of the old modules were not 
> compatible with 5.6.1, because it will automaitcally rebuild all the 
> modules. 

Thanks for the tip. In appearance, the problem is solved when I added 
to PERL5LIB env. var the new lib paths followed by the old paths, 
now I have a lot of duplicated libraries, but I needed a quick solution 

Thanks for your interest, any suggestion is welcome


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

Date: Sun, 16 Sep 2001 19:22:51 GMT
From: "Archie Ballantine" <zoetnet@wanadoo.nl>
Subject: anonymous host on irc
Message-Id: <f_6p7.135$lU1.1509@pollux.casema.net>

  Hi

I've been experimenting with the irctest example with NET::IRC - does anyone
know if there is a way to change the host/userhost before connecting to a
channel? for example to get around a host ban situation?

cheers

TomRipley
please respond to 079@pagina.nl






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

Date: 16 Sep 2001 20:39:33 GMT
From: "Soren A." <soren.newsgroups@wonderstorm.com.INVALID>
Subject: Re: AS Perl 629 Image::Magick makes Perl crash when outputting image  to  file
Message-Id: <Xns911EA944312B9sorenngroupswonder@198.99.146.10>

Per Kistler <kistler@gmx.net> wrote in news:3B8CB79A.ACD484BC@gmx.net on 29 Aug 2001:

> Hi Daniel
> 
> It could be, that the www page, which shows it the way you did
> it: http://www.simplesystems.org/ImageMagick/www/perl.html
> may be wrong. On unix one can open a file for writing twice.
> On window it's different (depending on the hacker's capabilities).
> 
> If you leave the open(DATA... stuff away and just do a
> $image->Write(filename=>$filename); then it might work.
> On Linux it swallows both versions, but why would it want
> the file name, if the file is already open?

This is a plausible answer. The documentation for ImageMagick (Perl-Magick) is notoriously full of errata. Its a huge piece of Open 
Source software maintained by a tiny crew who don't care for spending their time updating documentation (as unusual as that may 
sound ;-).

The form of the Write function I see in code that I wrote awhile ago (and which I know has worked on Win32) is like this instead of 
the above:

 my $returnval = $imageobj->Write('png:output.png');
 warn qq[ALWAYS check your return values from Image::Magick function calls! (IM sez: "$returnval")\n];

So maybe don't do that hash-assignment thing??

   HTH,
     Soren Andersen

-- 
{{ please note the munged e-mail addy, apologies to those who find it
 a moral atrocity .. remove the obvious parts to create the address:
 "soren.newsgroups" AT "wonderstorm" DOT "com" }}


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

Date: Sun, 16 Sep 2001 20:57:38 GMT
From: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: Cannot run perl scripts in Apache when file opened via Samba
Message-Id: <Xns911EAC7D71E48rock13com@64.8.1.227>

Alexander Farber (EED) <news:3BA499F7.9759A12E@eed.ericsson.se>:

> AcCeSsDeNiEd wrote:
>> If I have a perl file opened on my Win98 machine, it will not
>> run via the web (Apache) I do not need to save or change the
>> contents. Just opening it creates the problem. I can use any
>> program in Win98 to open the file. The problem is still there.
> 
>> [Fri Sep 14 00:27:05 2001] [error] (26)Text file busy: exec of
>> /cgi-bin/script.pl failed 
> 
> I believe, if a program opens file in Windows, 
> then you can't acccess it from another program

WinME and Apache 1.3.14 has no troubles when I have a script open 
in an editor and try to run it.

-- 
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/


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

Date: Sun, 16 Sep 2001 20:09:20 +0100
From: "Neil Morris" <Neilmorris@btinternet.com>
Subject: canonical of a file path - how?
Message-Id: <9o2tfu$fp6$1@plutonium.btinternet.com>

Hi
    I'm trying to work out, in perl, how to canonical a file path, for
security reasons, in perl and since I'm new to perl and regular expessions I
was hoping for some help from this newsgroup?

thanks in advance

Neil Morris




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

Date: 16 Sep 2001 19:24:56 GMT
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: canonical of a file path - how?
Message-Id: <slrn9q9v48.87a.trammell@haqq.hypersloth.net>

On Sun, 16 Sep 2001 20:09:20 +0100, Neil Morris wrote:
>     I'm trying to work out, in perl, how to canonical a file path, for
> security reasons, in perl and since I'm new to perl and regular expessions I
> was hoping for some help from this newsgroup?

perldoc File::Spec

-- 
Rule #0: Spam is theft.


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

Date: 16 Sep 2001 12:31:17 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: canonical of a file path - how?
Message-Id: <m1lmjfnda2.fsf@halfdome.holdit.com>

>>>>> "Neil" == Neil Morris <Neilmorris@btinternet.com> writes:

Neil>     I'm trying to work out, in perl, how to canonical a file
Neil> path, for security reasons, in perl and since I'm new to perl
Neil> and regular expessions I was hoping for some help from this
Neil> newsgroup?

With or without respect to a real filesystem's symbolic links?  The
problem is trivial if you ignore symbolic links (and can be performed
without stat'ing a path), but gets a bit hairy if you must account for
them.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sun, 16 Sep 2001 18:15:19 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: change dir the dir of Favorites..
Message-Id: <3BA4EC70.54317E82@rochester.rr.com>

The Executioner wrote:
> 
> How can I change the location of the dir of Favorites?
> 
> Thanks, Maarten

What is "Favorites" regarding Perl?  Never heard of it.  If you are
referring to Favorites on Windoze or a browser, maybe a Windoze or
browser newsgroup would be better?
-- 
Bob Walton


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

Date: Sun, 16 Sep 2001 20:35:19 +0200
From: "The Executioner" <the@executioner.tmfweb.nl>
Subject: Re: change dir the dir of Favorites..
Message-Id: <9o2rc1$pno$1@azure.nl.gxn.net>

It's got nothing to do with Perl. Sorry about that. Send it accidentally to
the wrong  newsgroup.

Maarten


"Bob Walton" <bwalton@rochester.rr.com> wrote in message
news:3BA4EC70.54317E82@rochester.rr.com...
> The Executioner wrote:
> >
> > How can I change the location of the dir of Favorites?
> >
> > Thanks, Maarten
>
> What is "Favorites" regarding Perl?  Never heard of it.  If you are
> referring to Favorites on Windoze or a browser, maybe a Windoze or
> browser newsgroup would be better?
> --
> Bob Walton




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

Date: 16 Sep 2001 12:56:09 -0700
From: asdf834@yahoo.com (uma shanker)
Subject: Discontinue the loop
Message-Id: <b4a4a838.0109161156.33c5171c@posting.google.com>

hello,
 what are the possible ways to come out of this loop. I searched the
docs, but found no special info.

 # I want to ignore the first element in @lines

 $ig = 0;
 foreach $line  (@lines)
     {
            if( $ig ==  "0")
             {
              $ig = 1;
              last;
           }
     .....
 }

/thanks
/uma
asdf834@yahoo.com


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

Date: Sun, 16 Sep 2001 20:46:48 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: Discontinue the loop
Message-Id: <3BA50E7A.B3F38F8D@acm.org>

uma shanker wrote:
>  what are the possible ways to come out of this loop. I searched the
> docs, but found no special info.
> 
>  # I want to ignore the first element in @lines

How about:
  foreach $line (@lines[1..$#lines]) {
     .....
  }

-- Dave Tweed


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

Date: Sun, 16 Sep 2001 21:04:52 GMT
From: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: Discontinue the loop
Message-Id: <Xns911EADB7518FBrock13com@64.8.1.227>

uma shanker
<news:b4a4a838.0109161156.33c5171c@posting.google.com>: 

> what are the possible ways to come out of this loop. I searched
> the docs, but found no special info. 
> 
> # I want to ignore the first element in @lines

Could do this:

$ig = 0;
foreach $line (@lines) {
  next if $ig == 0;
  $ig++;
 .....
}

If you don't need to keep @lines intact you could shift @lines 
before entering the loop.

-- 
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/


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

Date: Sun, 16 Sep 2001 21:27:02 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Discontinue the loop
Message-Id: <3BA51959.B540A5B4@rochester.rr.com>

"Rob - Rock13.com" wrote:
> 
> uma shanker
> <news:b4a4a838.0109161156.33c5171c@posting.google.com>:
> 
> > what are the possible ways to come out of this loop. I searched
> > the docs, but found no special info.
> >
> > # I want to ignore the first element in @lines
> 
> Could do this:
> 
> $ig = 0;
> foreach $line (@lines) {
>   next if $ig == 0;
>   $ig++;
> .....
> }

Surely you mean:

$ig = 0;
foreach $line (@lines) {
  $ig++;
  next if $ig == 1;
  .....
}

 ...
> --
> Rob
-- 
Bob Walton


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

Date: Sun, 16 Sep 2001 21:43:45 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Discontinue the loop
Message-Id: <u77aqts0pev7d99239rijk1tuacn5kbm5r@4ax.com>

uma shanker wrote:

># I want to ignore the first element in @lines

	shift @lines;
	foreach(@lines) { ... }

-- 
	Bart.


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

Date: 16 Sep 2001 12:57:46 -0700
From: weedmonster_99@yahoo.com (codeslayer)
Subject: HELP!  ActivePerl for Win32:  How do I compare two text files and output/print the differences only?
Message-Id: <4b459565.0109161157.6027f021@posting.google.com>

HELP!  ActivePerl for Win32:  How do I compare two text files and
output/print the differences only?
==============================================================================

After searching many posts, I have discovered that this is similar to
some queries out there, and thus, I hesitated to write this.  However,
there are major differences which require me to post this.

Firstly,  I simply want to take two (2) text files (or html, etc.),
compare their contents and print differences to a difference log file.
 I am using Active Perl ActivePerl on a Win32 (specifically WindowsME)
system, not UNIX.

Second,  the script offerings I have found will give a return code
only (not print the difference).   Here are some things I have tried
or read about already:

1)	diff
2)	testcmp
3)	File::Compare

4)	Algorithm::Diff

5)	Here is some code I tried to implement which I found
	in another post.   It didn't work.   I added the definitions
	of $file1 and $file2; the rest of this code is someone
	else's ( between double quotes):

"
# Step 1: scan file 1, and make an entry in the filelines{} hash array
# for each line of file 1. The whole text of the line is the array
# subscript, or hash key if you prefer. (If you have a choice, use
# the shorter file as file 1, since the memory used for the hash
# array will be proportional to the size of file 1.)


$file1= "C:/WINDOWS/Desktop/my_scripts.dir/testfile1.txt";
$file2 = "C:/WINDOWS/Desktop/my_scripts.dir/testfile2.txt";


 open(INFILE, "$file1") || die "Failed to read file1: $!\n";

     while (<INFILE>) {

        filelines{$_} = 1;		 # $_ is the line just read from INFILE

      } close(INFILE);

# Now, scan file 2, and print out every line that is found in
filelines{}.
# This is basically a string-keyed hash table lookup for each line,
# and ought to be quite fast.
# Note that we have no dependency at all on the ordering of the lines
# in the files, except that duplicate lines will be printed in the
# order that they appear in file 2.


open(INFILE, "file2") || die "Failed to read file2: $!\n";

while (<INFILE>) {

   if (filelines{$_}) {

     print $_;

   }

} close(INFILE);

# Grand total of twelve non-blank, non-comment lines of code...
# and I bet it will compare very favorably with the performance
# of a C-coded routine, let alone any sort of shell script. 
"

 ... but like I said, it didn't work.  ActivePerl doesn't seem to
recognize "filelines{$_}".

I don't really know what the $_ means.  No explanation I have found
thus far cleary explains this.   That may be one stumbling block for
me.

I even tried to write my own code from scratch, but that failed
miserably.   At this point, I feel that including my code in this post
would just muddy the issue.

Finally,  this is a plea to those familiar with ActivePerl:   Can
anyone help me please?

Thanks for any responses.


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

Date: Sun, 16 Sep 2001 21:55:08 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: HELP!  ActivePerl for Win32:  How do I compare two text files and output/print the differences only?
Message-Id: <ia7aqt8vdrsvs1604baedp0l9kdocskgr7@4ax.com>

codeslayer wrote:

>        filelines{$_} = 1;		 # $_ is the line just read from INFILE

>... but like I said, it didn't work.  ActivePerl doesn't seem to
>recognize "filelines{$_}".

Perhaps if you used "$filelines{$_}" instead?

But your code doesn't do "diff". You're merely checking for the
existence of each line in one file, in the other file, *irrespective of
their order*. So

	1
	3
	2

and

	1
	2
	3

would compare to be "the same". Which seems odd.

>I don't really know what the $_ means.  No explanation I have found
>thus far cleary explains this.   That may be one stumbling block for
>me.

I don't think it really is. You seem to have other problems.
 
But, here goes: $_ is a "default variable", which is good for short
term, localised manipulation of data. Commonly, there are shortcuts if
you make use of it: your code can be smaller, because it can assume your
data is in $_. You should not rely on it to remain the same for a long
period of time, because that would rather prevent you from using it on
other places in your code.

You can compare it to the CPU registers for machine code: all code makes
use of them to do their calculations, but you really shouldn't expect
them to remain fixed for the rest of the lifetime of your program,
because you would cripple the possibilities for writing code on other
places in the program. And once you've used up all your registers, the
rest of the code wouldn't be able to do anything at all.

-- 
	Bart.


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

Date: 16 Sep 2001 20:54:45 GMT
From: "Soren A." <soren.newsgroups@wonderstorm.com.INVALID>
Subject: Re: home directory in use lib
Message-Id: <Xns911EABD8080D4sorenngroupswonder@198.99.146.10>

jones1ai14@yahoo.com (Marty Jones) wrote in news:cb844878.0109011446.7c24d009@posting.google.com on 01 Sep 2001:

> However, what you had to say led me to the perl function glob() which
> I think may be even better than using getpwnam:
> 
> #!/usr/bin/perl -w
> use strict;
> use diagnostics;
> 
> my $home;
> BEGIN { $home = glob("~jones"); }
> use lib  "$home/perl/lib";
> use MyLib;

Since it's Perl, TMTOWTDI, and IMHO, that *is* actually pretty slick. Nice solution. It uses something that is already a part of Perl -
- the globbing of filenames -- instead of possibly re-inventing a wheel in non-robust manner. To me that is headed in the right 
direction (toward Perl 'elegance,' if that isn't a contradiction in terms ...).

    Soren Andersen

-- 
{{ please note the munged e-mail addy, apologies to those who find it
 a moral atrocity .. remove the obvious parts to create the address:
 "soren.newsgroups" AT "wonderstorm" DOT "com" }}


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

Date: Sun, 16 Sep 2001 16:56:05 GMT
From: "EriK W" <bopew2000@yahoo.com>
Subject: How can I authenticate a user's login password under a shadowed unix system?
Message-Id: <FQ4p7.18011$jY.375682@news1.rdc1.bc.home.com>

Hi guys,

I want to create a script or a cgi script which can authenticate the user
login with their unix system password.

I know I can use a getent() get the encrypted password, but how I am going
to authenticate a user login with this?

Thanks!




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

Date: Sun, 16 Sep 2001 19:41:12 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: How can I authenticate a user's login password under a shadowed unix system?
Message-Id: <slrn9qa02o.9gv.efflandt@typhoon.xnet.com>

On Sun, 16 Sep 2001 16:56:05 GMT, EriK W <bopew2000@yahoo.com> wrote:
> I want to create a script or a cgi script which can authenticate the user
> login with their unix system password.
> 
> I know I can use a getent() get the encrypted password, but how I am going
> to authenticate a user login with this?

Your subject line is too long.

It is easy to check a crypted password by crypting the plain text password 
using the crypted password as salt.

exit unless crypt($plainpw, $cryptpw) eq $cryptpw;

While initial salt is 2 characters, use the whole crypted password as salt 
when checking passwords.  Using a 2 character substring of the crypted 
password as salt is unnecessary and would fail with MD5 passwords.

The problem is, how do you obtain a user's crypted system shadow password?

efflandt@compaq:~ > perl -e '$_=(getpwnam "efflandt")[1]; print "$_\n";'
x

That just tells you the dummy password field of /etc/passwd.  Shadown
passwords are in a different file that only the superuser can access.
If you change that, you might as well not use shadow at all.

-- 
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: 16 Sep 2001 20:31:50 GMT
From: "Soren A." <soren.newsgroups@wonderstorm.com.INVALID>
Subject: Re: image pixel dimensions using perl script but NOTsize modulle
Message-Id: <Xns911EA7F53C329sorenngroupswonder@198.99.146.10>

[posted and mailed]

nospam_bca1000@hotmail.com (Brian A) wrote in news:3b8c0736.5658060@news.uk.worldonline.com on 28 Aug 2001:

> I need a script which will give the pixel dimensions of an image file.
> All I can find on the Net are ones which use the size module. These
> don't seem t work on the server I use (the module deosn't seem to be
> there). Support never reply  to emails so I am stuck. Any simple
> alternative scripts to achieve my aim?

I propose (not that we don't like hearing from you ;-) that your time would have been better spent looking for your answer to this 
particular sort of question on http://search.cpan.org/, where you'd likely have quickly found (by searching on "Image"):

Image::Info (from the "README" file:)
  | This Perl extention allows you to extract meta information from
  | various types of image files.  In this release the following file
  | formats are supported:
  | 
  |    JPEG (plain JFIF and Exif)
  |    PNG
  |    GIF
  |    PBM/PGM/PPM
  |    SVG
  |    XBM/XPM
  |    BMP/DIB/RLE
  | 
  | Usage is something like this:
  | 
  |    use Image::Info qw(image_info);
  | 
  |    @info = image_info("filename");
  |    $refto_hash_describing_1st_image = $info[0];
  |    $refto_hash_describing_2nd_image = $info[1];
  | 
  | TODO:
  |    - add support for more image formats
  |    - rational class
  |    - Image::TIFF should not need to slurp
  | 
  | 
  | Copyright 1999-2001 Gisle Aas.
  | 

Since this package doesn't use compiled C code (it is "pure Perl" as we say), you could probably install it in your user Web space (by 
simply uploading the files --in ASCII mode -- preserving the directory relative structure) ... and call it from your scripts using the 
means well known to those who use the Perl documentation, for `use'-ing modules from non-standard private user directories:

use lib '/usr/htdocs/freddykrueger/mymoduledir';
# try it at home first, prove to yourself that it works (remove this from any uploaded CGI code, natch):
print STDERR join qq[\n], @INC; 
# should show "/usr/htdocs/freddykrueger/mymoduledir" first, + whatever is standard for library search path on that server.

This is an FAQ ('how to use modules in my private dir'), so before asking for further details please try searching all the existing 
archived discussion of this (Google Grooups, etc.).

  HTH,
     Soren Andersen
 


-- 
{{ please note the munged e-mail addy, apologies to those who find it
 a moral atrocity .. remove the obvious parts to create the address:
 "soren.newsgroups" AT "wonderstorm" DOT "com" }}


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

Date: 16 Sep 2001 20:59:46 GMT
From: "Soren A." <soren.newsgroups@wonderstorm.com.INVALID>
Subject: Re: IO::File->new_tmpfile
Message-Id: <Xns911EACB1B7FB8sorenngroupswonder@198.99.146.10>


I really apreciated the time Bernie and Martien took to explain this in detail. I was long troubled by "not getting" it too -- the part 
detailed by Bernie about UNI* files was a revelation that made it all make sense at last. Until then I couldn't grasp what earthly use 
there could be for an "imaginary" file.

These write-ups should be incorporated into the POD for that module.

   Soren Andersen

-- 
{{ please note the munged e-mail addy, apologies to those who find it
 a moral atrocity .. remove the obvious parts to create the address:
 "soren.newsgroups" AT "wonderstorm" DOT "com" }}


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

Date: Sun, 16 Sep 2001 19:22:53 GMT
From: "Archie Ballantine" <zoetnet@wanadoo.nl>
Subject: irc 
Message-Id: <h_6p7.136$lU1.1596@pollux.casema.net>

Hi

i've been experimenting with the irctest example supplied with NET::IRC -
does anyone know if there is a way (on undernet) to modify the
hostname/userhost before joing a channel, for example to get around a host
ban?

Cheers

Tom

please reply to 079@pagina.nl





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

Date: Sun, 16 Sep 2001 14:41:56 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Mail parser: Can it be faster?
Message-Id: <3BA4F274.3020504@coppit.org>

Tassilo von Parseval wrote:

 > David Coppit wrote:
 >
 >> I've reimplemented the algorithm using Inline::C (uber-cool!) to get
 >> about a 30% speedup, depending on the machine. I've also tried various
 >> tweaks like sysread to get it to go faster, but haven't seen any
 >> improvement. (I even tried adapting the odd memory allocation scheme
 >> in GNU grep for my C implementation--I think it tries to allocate on
 >> page boundaries or something.)
 >
 > First of all, you are a little moderate with your module. ;-) My
 > benchmarks have shown that it is *at least* four times as quick as any
 > other Perl mail-parseing module.

Hey Tassilo,

Actually, I haven't compared the code to other mail parsers. I was just 
comparing my C implementation to my Perl implementation. :)

 > The problem with mbox-parsing is (according to the experiences with my
 > module) is any form of binary attachement. Since I use a few reg-exes 
on a
 > whole line, each of these REs is also applied to the encoded
 > attachements even though no real relevant information can be deduced from
 > that.

Hm... This gets me thinking though... Since a lot of the time is spent 
trying to read in attachments, I wonder if detecting attachments and 
then adjusting the reading would be faster. For example, I could sysread 
big chunks after an attachment is encountered. For course, this is still 
probably slower than just setting $/ = "From ".

 > Have you experimented with the "Content-length: "-field? It is not a
 > mandatory header-field but most emails have it. I thought of a mixture
 > between line- and character-wise reading:
 > (this is pseudo-code and not going to work)

Hm... Actually, this suggestion has several good sub-suggestions:
- Use the Content-length header to determine how much to read.
- Use the Content-length header to skip to the next email if
   I know I don't match.
- Use the Lines header to increment the line count when skipping

In my current implementation I read the entire email, even if I'm just 
matching against the header. What I should do it read the header, then 
either seek to the next email if I know the email doesn't match, or read 
the body if necessary.

Thinking along those lines... I wonder how much time I waste copying a 
big email to a scalar, then printing it. In other words, I wonder if I 
should change $/ back to "\n" when printing the body of an email so that 
only a small amount of memory would be used. Ug. but this probably blows 
away large buffer reads.

Anyone know if "print scalar <$File_Handle>" sends the read data 
directly to STDOUT without a temporary variable? ;) (I guess $_ is used, 
right?)

 >>     # See if we accidentally stopped on an unescaped "From my mother".
 >>     if ($NEXT_EMAIL !~ /^From\s.*\d:\d+:\d.* \d{4}/)
 >
 > Isn't the escaping of From-lines in the body the job of the
 > mail-transport agent? Not sure about it but I remember having read
 > something about that in RFC822.

They're supposed to escape the From, but I've encountered poorly escaped 
emails, so I thought I should handle them.

David



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

Date: Sun, 16 Sep 2001 16:37:11 +0100
From: Raymond McCrae <raymond.mccrae@ntlworld.com>
Subject: Multithreading Information
Message-Id: <eF3p7.21506$Pm5.4668793@news2-win.server.ntlworld.com>

Hi

Where can I find information (and a tutorial or two) about writing 
multithreaded applications?

Thank you

Raymond McCrae


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

Date: Sun, 16 Sep 2001 17:07:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Numbers and strings oddities question
Message-Id: <dom9qtkelpbtt14702opbvmloeu66dfbrb@4ax.com>

Jim Britain wrote:

>On Sun, 16 Sep 2001 11:57:15 GMT, Brian Farnell <bfarnell@gte.net>
>wrote:
>
>>Can anyone point me to a reference for why this happens or explain it?
>>
>>I was playing with the fact that Perl converts between numbers and
>>strings as needed depending on the operation and I got some unexpected
>>results:
>>
>>1) given $s = "fred", and these not being sequential lines in a program,
>>but done one at a time in an experiment:
>>
>>$s ++;  #yields free, that I understand

Magic autoincrement

>>$s --;  #yields -1 (?!)
>A string cannot be decremented the variable is converted to $numeric
>equivalent equal to zero, and then decremented.

Yup. No magic decrement.

>>$s += 1; #yields 1 , shouldn't that be the same as $s ++?
>No, increment is valid on both character and numeric values, but this
>is an addition operation.  Hence autovivication of the numeric
>variable $s -- there are actually two $s now, one numeric, and one
>string.

Eh ,no. This is the same case as with $s--: when "fred" is treated as a
number, its value is considered zero. With warnings enabled (put "-w" in
your shebang line), you'd get a warning that '"fred" is not numeric'.

>>$s += 5; #yields 5 (at least we have a pattern)
>AHA! -- (same as last time!!)

>>$s *=1;  #yields 0
>zero times one = ??

Yup.

>>$s *=3;  #yields 0 (again a pattern, but why?)
>(same as last time, except now we have 3 zeroes adding up to ??)

Yup.

For most operands, "fred" is treated as a number. Since it doesn't start
with any digits (or a '-' followed by digits), it's value is treated as
0.

Only '++' is different, with "magic" increment. For more info on the
latter, see perlop.

-- 
	Bart.


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

Date: Sun, 16 Sep 2001 17:08:25 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Numbers and strings oddities question
Message-Id: <3ba4dc88.317e$74@news.op.net>

In article <3BA493E3.B0E914C1@gte.net>,
Brian Farnell  <bfarnell@gte.net> wrote:
>Can anyone point me to a reference for why this happens or explain it?

Normally, when you use a string like a number, Perl converts the
string to a number.  It does this by looking at the beginning of the
string.  If there are no digits at the beginning of the string, it
uses 0.

That explains *all* of these:
>$s --;  #yields -1 (?!)
>$s += 1; #yields 1 , shouldn't that be the same as $s ++?
>$s += 5; #yields 5 (at least we have a pattern)
>$s *=1;  #yields 0
>$s *=3;  #yields 0 (again a pattern, but why?)

In each case $s is being treated like 0.  (Also, if you had warnings
turned on, you would have gotten a warning about how "fred" isn't numeric,)

There is one exception to this rule: The ++ operator, and only the ++
operator, is special.  If the string has some letters, possibly
followed by some digits, and nothing else, then ++ does something
unusual.  We call this the 'magic autoincrement'.  That is what is
happening here:

>$s ++;  #yields free, that I understand

++ is the only operator that is special this way.

>Also, where do I get the newsgroup FAQ for this group 

Tried searching at google for 'comp.lang.perl.misc faq'?
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Sun, 16 Sep 2001 17:16:27 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Numbers and strings oddities question
Message-Id: <1000660587.986340129747987.gnarinn@hotmail.com>

In article <3BA493E3.B0E914C1@gte.net>,
Brian Farnell  <bfarnell@gte.net> wrote:
>Can anyone point me to a reference for why this happens or explain it?

(snipped examles of string ++ being different than other numeric
operations when done on strings)

read the section 'Auto-increment and Auto-decrement' in 
perldoc perlop
it shows that there is special magic to ++

gnari


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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 1756
***************************************


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