[22825] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5046 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 27 11:06:50 2003

Date: Tue, 27 May 2003 08:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 27 May 2003     Volume: 10 Number: 5046

Today's topics:
    Re: a Bayesian intelligent e-mail autoresponder? <bwheeler@echip.com>
        comparing 2 files using perl (P. Egan)
        converting binary string to numbers <scare.crow@oz.land>
    Re: converting string of [01] to (binary) number news@roaima.freeserve.co.uk
    Re: converting string of [01] to (binary) number (Tad McClellan)
    Re: converting string of [01] to (binary) number <krahnj@acm.org>
    Re: converting string of [01] to (binary) number (Tad McClellan)
        Digest-SHA1-2.02 "make test" dumps core <clpm@oceanwave.com>
    Re: Error message with perl -MCPAN -e shell (Randy Kobes)
    Re: extracting records in an array <krahnj@acm.org>
        Makefile corrupted after running perl Makefile.PL. (ZorroFree)
    Re: Net::AIM help! <rm.mymail@NOSPAMHEREntlworld.com>
    Re: Perl Script to Caluclate Averages? (Anno Siegel)
    Re: scope of variable <ubl@schaffhausen.de>
    Re: Simple pattern matching question. (Tad McClellan)
    Re: Simple pattern matching question. <jurgenex@hotmail.com>
    Re: Simple pattern matching question. <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Simple pattern matching question. <jasonp@uq.net.au>
    Re: sprintf question (Tad McClellan)
    Re: string search problem <allanon@hotmail.com>
    Re: turning off output buffer does not work (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 27 May 2003 09:10:41 -0400
From: Bob Wheeler <bwheeler@echip.com>
Subject: Re: a Bayesian intelligent e-mail autoresponder?
Message-Id: <3ED363D1.7030301@echip.com>

I don't know about "evil," but it will cause you problems
if used to bounce spam, since you not only will double the
traffic, as observed below, but maybe tripple it since the
receiving server will likey reply with an unknown address
message which will fill your inbox.

Blue Squirrel offers a commercial product, Spam Sleuth,
which bounces this way if you choose. It uses a Bayesian
procedure to classify mail. I'm not sure, however, that
the procedure is superior to a simple discriminant function,
since there are only two categorise, spam, and non-spam.

Yeff wrote:
> On 26 May 2003 07:03:56 -0700, totojepast wrote:
> 
> 
>>Please can you tell me if anybody has tried to use ifile or a similar
>>Bayesian for an automatic e-mail autoresponder?
> 
> 
> If I grok what you're trying to do (automatically identify and bounce 
> spam?) then all I can say is that the concept is *evil*.
> 
> "Evil, pure and simple from the eighth dimension!"
> 
> You're doubling the amount of traffic generated by the spam and probably 
> bouncing your messages to bogus addresses (not the people who actually sent 
> the spam).
> 
> Evil.
> 
> -Jeff B.
> yeff at erols dot com


-- 
Bob Wheeler --- http://www.bobwheeler.com/
         ECHIP, Inc. ---
		A little fire is quickly trodden out;
		Which, being suffered, rivers cannot quench.
			WS-HVI,IV,viii,7



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

Date: 27 May 2003 07:18:29 -0700
From: poko_e@yahoo.com (P. Egan)
Subject: comparing 2 files using perl
Message-Id: <d5c97a1c.0305270618.218fb654@posting.google.com>

I have 2 files that I'm comparing...if there is no match in a string
from file1 to file2, I want to write file1.  I know this sounds like
grep, but grep isn't giving me what I'm looking for.  I am
reformatting file2 to look like file1(just the date portion is the
string that I'm comparing).

File1 looks like:
 ./home1/filenet/images/000004/00000410051998.log
 ./home1/filenet/images/000004/00000401011901.log
 ./home1/filenet/images/000016/00001601011901.log
 ./home1/filenet/images/000016/00001601211991.log
 ./home1/filenet/images/000016/00001605161986.log
 ./home1/filenet/images/000016/00001601021996.log

File2 looks like:
 ./00/00/16/1990_01_16.pdf
 ./00/00/16/1991_01_21.pdf
 ./00/00/16/1996_01_02.pdf
 ./00/00/16/1998_01_02.pdf
 ./00/00/16/1999_12_31.pdf

Thanks for any help I can get.

Poko


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

Date: Tue, 27 May 2003 16:06:58 +0200
From: Eric Moors <scare.crow@oz.land>
Subject: converting binary string to numbers
Message-Id: <pan.2003.05.27.16.06.58.221440.15371@oz.land>

I'm trying to split a string of n*8 characters
in their hexadecimal counterparts. A small example:

As input I have the ascii string:

"0000_0000_0011_0000_1010_1100"

and I want to convert this to the ascii string:

00
30
AC

So I first split the string in n byte parts,
But how can I convert each part to a number?
The code below works, but I cannot help thinking there
must be an easier way. (It's more C'ish than perl'ish)
I looked into (un)pack, but couldn't get any lifesign
out of that.

@bytes = /([01]{8})/g;
foreach (@bytes) {
	my @a = split(//, $_);
	$number = 0;
	$i = 7;
	foreach (@a) {
		$number |= ($_ << $i);
		$i--;
	}
	printf("%02X : %02X\n", $address / 8, $number);
	$address += 8;
}

Eric


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

Date: Tue, 27 May 2003 14:21:58 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: converting string of [01] to (binary) number
Message-Id: <mc5cq-vcg.ln1@moldev.cmagroup.co.uk>

Eric Moors <scare.crow@oz.land> wrote:
> I'm trying to split a string of n*8 characters
> in their hexadecimal counterparts. A small example:
> As input I have the ascii string:
> "0000_0000_0011_0000_1010_1100"

> and I want to convert this to the ascii string:
> 00
> 30
> AC

    my $a="0000_0000_0011_0000_1010_1100";

    my @nibbles = split (/_/, $a);
    while (my $byte = shift (@nibbles) . shift (@nibbles)) {
    	my $hex = uc sprintf "%02x", ord pack("B8","$byte");
	print "$hex\n"
    }

Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Tue, 27 May 2003 08:35:16 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: converting string of [01] to (binary) number
Message-Id: <slrnbd6qck.2fq.tadmc@magna.augustmail.com>

Eric Moors <scare.crow@oz.land> wrote:

> I'm trying to split a string of n*8 characters
> in their hexadecimal counterparts.


> But how can I convert each part to a number?


1) with a hash lookup (since there are only 16 possibilities)

2) with a different method of calculating the base-10 number


-------------------------------
#!/usr/bin/perl
use strict;
use warnings;

$_ = "0000_0000_0011_0000_1010_1100";
tr/_//d;

my %bin2hex = qw(
   0000   0    0001   1    0010   2    0011   3
   0100   4    0101   5    0110   6    0111   7
   1000   8    1001   9    1010   A    1011   B
   1100   C    1101   D    1110   E    1111   F
);

foreach ( /([01]{8})/g ) {
   print "$bin2hex{substr $_, 0, 4}$bin2hex{substr $_, 4}\n";
}

foreach ( /([01]{8})/g ) {
   my @a = reverse split //;
   my $num;
   $num += (2 ** $_) * $a[$_] foreach 0..7;
   printf "%02X\n", $num;
}
-------------------------------


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 27 May 2003 13:48:07 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: converting string of [01] to (binary) number
Message-Id: <3ED36C77.18C4FDC3@acm.org>

Eric Moors wrote:
> 
> I'm trying to split a string of n*8 characters
> in their hexadecimal counterparts. A small example:
> 
> As input I have the ascii string:
> 
> "0000_0000_0011_0000_1010_1100"
> 
> and I want to convert this to the ascii string:
> 
> 00
> 30
> AC
> 
> So I first split the string in n byte parts,
> But how can I convert each part to a number?
> The code below works, but I cannot help thinking there
> must be an easier way. (It's more C'ish than perl'ish)
> I looked into (un)pack, but couldn't get any lifesign
> out of that.
> 
> @bytes = /([01]{8})/g;
> foreach (@bytes) {
>         my @a = split(//, $_);
>         $number = 0;
>         $i = 7;
>         foreach (@a) {
>                 $number |= ($_ << $i);
>                 $i--;
>         }
>         printf("%02X : %02X\n", $address / 8, $number);
>         $address += 8;
> }


$ perl -le'print map{sprintf"%02X ",$_}map{oct"0b$_"}"0000_0000_0011_0000_1010_1100"=~/\d+/g'
00 00 03 00 0A 0C 


John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 27 May 2003 09:05:30 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: converting string of [01] to (binary) number
Message-Id: <slrnbd6s5a.2mj.tadmc@magna.augustmail.com>

Tad McClellan <tadmc@augustmail.com> wrote:
> Eric Moors <scare.crow@oz.land> wrote:
> 
>> I'm trying to split a string of n*8 characters
>> in their hexadecimal counterparts.


> my %bin2hex = qw(
>    0000   0    0001   1    0010   2    0011   3
>    0100   4    0101   5    0110   6    0111   7
>    1000   8    1001   9    1010   A    1011   B
>    1100   C    1101   D    1110   E    1111   F
> );


A cleaner way of populating the lookup hash might be:

   my %bin2hex = map { sprintf('%04b', $_), sprintf('%X', $_) } 0..15;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 27 May 2003 09:08:32 -0400
From: <clpm@oceanwave.com>
Subject: Digest-SHA1-2.02 "make test" dumps core
Message-Id: <86u1bgtu3z.fsf@smallberries.office.oceanwave.com>

I have a Solaris 9 machine with Sun's stock perl (yes, I know, but I
can't rip it out and replace it).  Among other things, I've installed
Solaris-PerlGcc-1.3, and I've set the environment variable PERL5LIB to
/usr/perl5/site_perl/5.6.1/Solaris/PerlGcc.  My compiler is gcc 3.2.3
from sunfreeware.com.  

I've compiled and tested other perl modules just fine, but
Digest::SHA1 is giving me issues.  It compiles ok, but make test dumps core:

> make
cp SHA1.pm blib/lib/Digest/SHA1.pm
/usr/bin/perl /usr/perl5/5.6.1/lib/ExtUtils/xsubpp  -typemap
/usr/perl5/5.6.1/lib/ExtUtils/typemap -typemap typemap  SHA1.xs > SHA1.xsc && mv SHA1.xsc SHA1.c
gcc -c    -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2
-fno-strict-aliasing    -DVERSION=\"2.02\"  -DXS_VERSION=\"2.02\"
-fPIC "-I/usr/perl5/5.6.1/lib/sun4-solaris-64int/CORE"   SHA1.c
Running Mkbootstrap for Digest::SHA1 ()
chmod 644 SHA1.bs
rm -f blib/arch/auto/Digest/SHA1/SHA1.so
LD_RUN_PATH="" gcc  -G SHA1.o  -o blib/arch/auto/Digest/SHA1/SHA1.so     
chmod 755 blib/arch/auto/Digest/SHA1/SHA1.so
cp SHA1.bs blib/arch/auto/Digest/SHA1/SHA1.bs
chmod 644 blib/arch/auto/Digest/SHA1/SHA1.bs
Manifying blib/man3/Digest::SHA1.3

> make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/badfile....dubious                                                         
        Test returned status 0 (wstat 138, 0x8a)
        test program seems to have generated a core
t/sha1.......dubious                                                         
        Test returned status 0 (wstat 138, 0x8a)
        test program seems to have generated a core
FAILED--2 test scripts could be run, alas--no output ever seen
*** Error code 2
make: Fatal error: Command failed for target est_dynamic'


Sure enough, there's a core generated by perl.

> file core
core:           ELF 32-bit MSB core file SPARC Version 1, from 'perl'



Here's the output of perl -V if it's at all useful:

Summary of my perl5 (revision 5.0 version 6 subversion 1)
configuration:
  Platform:
    osname=solaris, osvers=2.10, archname=sun4-solaris-64int
    uname='sunos localhost 5.9 sun4u sparc sunw,ultra-1'
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=undef
  Compiler:
    cc='gcc', ccflags ='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -fno-strict-aliasing',
    cppflags=''
    ccversion='GNU gcc', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=87654321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =''
    libpth=/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-R /usr/perl5/5.6.1/lib/sun4-solaris-64int/CORE'
    cccdlflags='-fPIC', lddlflags='-G'


Characteristics of this binary (from libperl): 
  Compile-time options: USE_64_BIT_INT USE_LARGE_FILES
  Locally applied patches:
     9676 Port the OpenBSD glob() security patch
     9678 Addendum to #9676: some missing changes from OpenBSD glob.c
     9679 Up $File::Glob::VERSION, add OpenBSD glob version note
     9693 $VERSION and Version() on same line provokes CPAN.pm warning
     9706 #7210 broke .packlist generation
     9707 ExtUtils::Installed doesn't quote regex metacharacters in paths
     9775 Typo in utf8.h
     9950 Revert integration of #8254,#8255 in #8620 (causes coredump)
    10021 Insecure regexes
    10091 $ref1 == $ref2 behaves unpredictably if not NV_PRESERVES_UV
    10093 Incorrect line numbers in AutoSplit
    10100 [20010514.027] PL_last_in_gv may not be GV if stale filehandle
    10145 [20010515.004] Segfaults from premature GC
    10203 Don't think about UTF8
    10250 [20010422.005] perl -e '{s//${}/; //}' segfaults
    10394 Leakage of file scope lexicals into predeclared subroutines
    10404 eval.t was relying on pre-#10394 buggy behavior
    10412 Rationalize locale handling to fix bugs uncovered by #10394
    10422 Potential buffer overrun if the radix separator > 1 byte
    10448 Lexicals outside eval weren't resolved correctly pre-#10394
    10450 Optimize #10448 slightly
    10543 Add LC_MESSAGES constant to POSIX module
    10667 #10449 broke visibility of lexicals inside DB::DB()
    10739 C<eval "/x$\r\n/x"> fails to compile correctly
    10939 Proposed fix for Pod::Man
    11169 Doc patch for Tie::Hash
    11374 Make h2ph grok ccsymbols fo the form 1234L, 1234ULL etc
    11427 t/harness wasn't picking up all the tests
    11428 run/runenv.t needs fflushNULL sanity
    11431 pod/*.t tests not picked up by t/TEST either
    11510 eval 'format foo=' would loop indefinitely
    11713 UTF8 wasn't printing for PVMGs
    11716 UTF8 flag should be meaningful only when POK
    11808 [20010831.002] Bug in Term::Cap on Solaris ansi terminal
    11847 Typo in perl_clone() code causes local(*foo) breakage
    12005 [20010912.007] substr reference core dump
    12024 Fix local() precedence bug in #8311
    12303 Fix 'local $!=0;undef*STDOUT;' segfault
    12304 Pod::Html makes a poor guess at author
    12350 Typo in IO::Seekable doc
    12496 Carp::shortmess_heavy() doesn't notice trailing newline
    12549 readline() doesn't work with 'our' variables
    12550 #12549 wasn't aware of strictures
    12752 croak(Nullch) wasn't printing the contents of ERRSV
    12811 [20011101.069] \stat('.') gives 'free unref scalar' error
    12812 Slight modification of #12811
    13149 Integrate #13147 from mainline (fixes nit in #10091)
    13261 Integrate #8340,#13260 from mainline
  Built under solaris
  Compiled at Apr  6 2002 14:45:34
  %ENV:
    PERL5LIB="/usr/perl5/site_perl/5.6.1/Solaris/PerlGcc"
  @INC:
    /usr/perl5/site_perl/5.6.1/Solaris/PerlGcc
    /usr/perl5/5.6.1/lib/sun4-solaris-64int
    /usr/perl5/5.6.1/lib
    /usr/perl5/site_perl/5.6.1/sun4-solaris-64int
    /usr/perl5/site_perl/5.6.1
    /usr/perl5/site_perl
    /usr/perl5/vendor_perl/5.6.1/sun4-solaris-64int
    /usr/perl5/vendor_perl/5.6.1
    /usr/perl5/vendor_perl


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

Date: 27 May 2003 14:32:24 GMT
From: randy@theoryx5.uwinnipeg.ca (Randy Kobes)
Subject: Re: Error message with perl -MCPAN -e shell
Message-Id: <slrnbd6su3.3ar.randy@theoryx5.uwinnipeg.ca>

On Wed, 28 May 2003 09:42:51 +1000, Alan <waty-spam@powerup.com.au> wrote:
>Hi Randy,
>
>This seemed to work pretty good. Now when I run the command perl -MCPAN -e
>shell  get the message:
>
>Use of uninitialized value at (eval 3) line 16, <TERMCAP> chunk 1.

That may be due to the TERM environment variable not
being set.

>cpan shell -- CPAN exploration and modules installation (v1.3901)
>ReadLine support available (try ``install Bundle::CPAN'')
>
>So I tried install Bundle::CPAN and got the message:
>
>Trying with "/usr/bin/ncftp -c" to get
>ftp://cpan.topend.com.au/pub/CPAN/authors/01mailrc.txt.gz
>
>And then the programme sits for ever doing nothing.

That may because cpan.topend.com.au isn't responding (I
just tried it, and it also didn't answer).

>I think I have messed up the configuration file. When I first ran
>per -MCPAN -e shell the programme asked me a lot of questions in order to
>write a config file. Would you know how I can get it to do this again, or
>alternatively what is the name of the file so I can edit it by hand? I
>believe I messed up the process as I deleted the directory
>/root/y/sources/MIRRORED.BY

At the CPAN shell prompt, type 'o conf init', which will
take you through the initialization dialogue again. Except
for the list of CPAN mirrors (and perhaps any proxy settings),
it's generally safe to accept the defaults. And you might
try a different mirror other than cpan.topend.com.au.

-- 
best regards,
randy


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

Date: Tue, 27 May 2003 13:28:30 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: extracting records in an array
Message-Id: <3ED367DE.165BA3E3@acm.org>

Abhi wrote:
> 
> I need to extract records from a log file, that look like the below sample.
> 
> The idea is to extract the range of lines between the patterns REQUEST DATA
> and END OF REQUEST DATA as a single array element, and repeat for the next
> record, so that in the end, I can parse and generate a summary of hits per
> hour, per user-agent.
> 
> print if m#REQUEST DATA#i .. m#END OF REQUEST DATA#i' does this ofcourse.
> How can I extract the records into an array ?
> 
> ***                 REQUEST DATA                              ***
> *****************************************************************
> *****************************************************************
>  *****************************
>  *       DateTimeData        *
>  *****************************
>   Arrival Date : 9-Dec-2002
>   Arrival Time : 3:38:13:1
>  *****************************
>  *    End of DateTimeData    *
>  *****************************
> 
>  *****************************
>  *       RequestHeaders      *
>  *****************************
>   user-agent : Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90)
>   cache-control : max-age=259200
>  *****************************
>  *   End of RequestHeaders   *
>  *****************************
> *****************************************************************
> *****************************************************************
> ***                 END OF REQUEST DATA                       ***


my ( $record, @data );
while ( <LOGFILE> ) {
    $record .= $_ if m#REQUEST DATA#i .. m#END OF REQUEST DATA#i;
    push @data, $record if m#END OF REQUEST DATA#i;
    }



John
-- 
use Perl;
program
fulfillment


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

Date: 27 May 2003 06:56:48 -0700
From: zorans@kekec2.e5.ijs.si (ZorroFree)
Subject: Makefile corrupted after running perl Makefile.PL.
Message-Id: <52f6973c.0305270556.11b04998@posting.google.com>

Good day there.

Although I am certaintly very new to anythink concerning Perl,
I think I've got a very essential Makefile corruption problem.
The problem allready occured to me when trying to build two
distinct products (actualy Time:HiRes module and SpamAssasin
anti spam utility).
When I commit perl Makefile.PL, as a result I get Makefile
which is very odd: single quotes are placed incorrectly arround
values to variables, some variables are set strange (most probably
vandalized) directory values (for example /u or ib/perl5) and
lines with suspicious meaning are inserted between other lines
that makes sense according to Makefile syntax.
When I run perl Makefile.PL, output tells everythink should be
fine but when I run make, I get an error. The overall output is

[root@kekec2 Time-HiRes-1.47]# perl Makefile.PL
Configuring Time::HiRes...
Checking for libraries...
Checking for -lposix4... NOT found.
You have no applicable extra libraries.
Looking for gettimeofday()... found.
Looking for setitimer()... found.
Looking for getitimer()... found.
You have interval timers (both setitimer and setitimer).
Looking for ualarm()... found.
Looking for usleep()... found.
Looking for nanosleep()... found.
You can mix subsecond sleeps with signals.
Checking if your kit is complete...
Looks good
Writing Makefile for Time::HiRes
Now you may issue 'make'.  Do not forget also 'make test'.
[root@kekec2 Time-HiRes-1.47]# make
Makefile:91: *** missing separator.  Stop.
[root@kekec2 Time-HiRes-1.47]#
 
 
Strange corrupted lines in Makefile looks like
 
 ...
LIB_EXT = .a'
libc='
 ...
 
or
 
 ...
installvendorlib='/usr/lib/perl5/vendor_perl/5.8.
INSTALLVENDORLIB = ib/perl5'
installusrbinperl='def
 ...
(note also single quotes)
 
or
 
 ...
SITELIBEXP = '/usr/lib/perl5/site_perl'
sit
SITEARCHEXP = /usr/lib/pe
 ...
(note the line containing text `sit' - what
should that be in context of Makefile)
 
I am not familiar with Perl, so also somethink simple could be wrong.
But
I ask an expert to give an opinion. I think files Makefile.PL were
somehow incorrect, but I do not know how, since I do not understand
Perl.
 
Than you very much.


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

Date: Tue, 27 May 2003 15:24:37 +0100
From: "Richard Mahoney" <rm.mymail@NOSPAMHEREntlworld.com>
Subject: Re: Net::AIM help!
Message-Id: <wyKAa.13586$Mu3.278663@newsfep4-glfd.server.ntli.net>

<news@roaima.freeserve.co.uk> wrote in message
news:a2mbq-v2f.ln1@moldev.cmagroup.co.uk...
> In comp.lang.perl.misc Richard Mahoney <rm.mymail@nospamherentlworld.com>
wrote:

> Try this instead:
> $aim = new Net::AIM;
> $conn = $aim->newconn (...);
>
> foreach my $i (0..14) { # Empirical 15s delay
>     $aim->do_one_loop || last;
>     sleep 1;
> }
>
> $aim->send_im (...);
> sleep 2;

Worked first time!
Thanks!!!
Rich.




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

Date: 27 May 2003 13:37:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl Script to Caluclate Averages?
Message-Id: <bavpm3$bmp$1@mamenchi.zrz.TU-Berlin.DE>

Sam Holden <sholden@cs.usyd.edu.au> wrote in comp.lang.perl.misc:

[...]

> There's also the dreaded "$i++; #increment i" type comment, but of course these
> comments are in fact designed to help those who don't have a complete
> understanding of syntax so I guess that it's fair game here :)

That is the one place where commenting what the code *does* is sensible:
Tutorial code meant to explain the workings of the language.

Unfortunately this means that beginners are first exposed to that style
of commenting, and as good students they imitate it...

Anno


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

Date: Tue, 27 May 2003 17:01:13 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: scope of variable
Message-Id: <bb01oe$r2g$1@news.dtag.de>

fatted wrote:
> With the strict pragma, the filehandle OUT is not available in the
> while block

The strict pragma does not change the scope of a variable.



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

Date: Tue, 27 May 2003 06:55:15 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Simple pattern matching question.
Message-Id: <slrnbd6kh3.2fq.tadmc@magna.augustmail.com>

Joe Creaney <mail@annuna.com> wrote:

> Simply how do I write if ($x contains "text") { ?


   if ( index($x, 'text') >= 0 )
or
   if ( $x =~ /text/ )
or
   if ( $x =~ /\btext\b/ )  # probably "best"


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 27 May 2003 13:41:14 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Simple pattern matching question.
Message-Id: <_VJAa.16760$8i4.12437@nwrddc02.gnilink.net>

Bernard El-Hagin wrote:
> Joe Creaney wrote:
>> Simply how do I write if ($x contains "text") { ?
>
> if ($x =~ /text/) { }

No, you don't.
What about if "text" contains any characters that are considered special in
regular expressions (assuming "text" is used as a generic placeholder in the
example and may have other values then the exact text "t", followed by "e",
followed by "x", followed by "t".)

Use
    if (index ($x, "text" >= 0 ) {....}
instead.

BTW: that will also be faster than REs.

jue




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

Date: Tue, 27 May 2003 13:46:35 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Simple pattern matching question.
Message-Id: <Xns9388A028E205elhber1lidotechnet@62.89.127.66>

Jürgen Exner wrote:

> Bernard El-Hagin wrote:
>> Joe Creaney wrote:
>>> Simply how do I write if ($x contains "text") { ?
>>
>> if ($x =~ /text/) { }
> 
> No, you don't.
> What about if "text" contains any characters that are considered
> special in regular expressions (assuming "text" is used as a generic
> placeholder in the example and may have other values then the exact
> text "t", followed by "e", followed by "x", followed by "t".)
> 
> Use
>     if (index ($x, "text" >= 0 ) {....}
> instead.


I'd rather do it my way without the syntax error.


;-)


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Tue, 27 May 2003 02:11:14 -0400
From: Jason Parker-Burlingham <jasonp@uq.net.au>
Subject: Re: Simple pattern matching question.
Message-Id: <87isrwdim5.fsf@freezer.burling>

Joe Creaney <mail@annuna.com> writes:

> Simply how do I write if ($x contains "text") { ?

Try C<index>:

	if (-1 < index $x, "text") {
	   print "yes\n";
	} else {
	   print "no\n";
	}

The test compares against -1 because C<index> will return zero if the
substring argument is found at the start of the string being searched
(if $x is "textual", for example).

I couldn't find this covered in any of the FAQs.

jason
-- 
``Oooh!  A gingerbread house!  Hansel and Gretel are set for life!''


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

Date: Tue, 27 May 2003 09:13:00 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: sprintf question
Message-Id: <slrnbd6sjc.2mj.tadmc@magna.augustmail.com>

Gilgames <gilgames@aol.coma> wrote:

> I always use the foolproof
                   ^^^^^^^^^
>  $form = "%0" . $DIGITS" . "d";


Heh.


-- 
   A common mistake that people make when trying to design 
   something completely foolproof is to underestimate the 
   ingenuity of complete fools.  --  Douglas Adams


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

Date: Tue, 27 May 2003 14:32:23 +0100
From: "Allanon" <allanon@hotmail.com>
Subject: Re: string search problem
Message-Id: <bavpdd$m3k@newton.cc.rl.ac.uk>


"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:bavna4$9hs$3@mamenchi.zrz.TU-Berlin.DE...
> Allanon <allanon@hotmail.com> wrote in comp.lang.perl.misc:
> >
> > "Marco" <ver_for@yahoo.it> wrote in message
> > news:da63f24c.0305270159.18aece5d@posting.google.com...
> > > Hi,
> > >
> > > I have a script that search some certain keywords in a file.
> > > The test to know if the keyword is present is the following one:
> > >
> > > if ($ligne=~ m/$keyword/gsi & $keyword_dans_ce_fichier==0)
> > >
> > > With this, if one of the keywords is "tur". The answer will positive
> > > if the word "turnover" is present in the file.
> >
> > if ($ligne=~ m/\b$keyword\b/gsi & $keyword_dans_ce_fichier==0)
>                                   ^
> The "&" operation performs a bit-wise logical and of its arguments.  Ii
> think you (and the OP) want "&&".

Oh yes.. I always use "and" myself.. would it matter in that context?

Allanon




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

Date: Tue, 27 May 2003 07:56:44 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: turning off output buffer does not work
Message-Id: <slrnbd6o4c.2fq.tadmc@magna.augustmail.com>

andipfaff <andreaspfaff@hotmail.com> wrote:

> I have writen a small script to test my homepage. Therefore I tried to
> turn off output buffering, 


You cannot turn buffering off.

You can turn autoflush on though, which makes it appear 
as if it is unbuffered.


> but that does not work 


It appears to be working as far a I can tell...

What were you _expecting_ your code to do?


> #!/usr/bin/perl


You should ask for all the help you can get:

   #!/usr/bin/perl
   use strict;
   use warnings;


> # Turn all buffering off.


It does not turn buffering off, it turns autoflush on.

It does not apply to "all", it applies only to the currently
select()ed filehandle (STDOUT in this case).


> $| = 0;
> print "Content-type: text/html\n\n";
> print "One<br>";
> sleep(3);
> print "Two";
> 
> After three seconds I will get the entire website. 


What does "get the entire website" mean?


> I have tried
> different methods like:


Have you tried running the program from the command line?


> $| = 0;
> select((select(STDOUT), $| = 1)[0]);
> but none of them worked! 
      ^^^^^^^^^^^^^^^^^^^

That is worthless information if you do not tell use what it is that
you were expecting it to do, and how that is different from what
it is actually doing.


> I sthat because I have a Windows-Environment?
> ActivState Perl and IIS?


Maybe. There is a server and a browser between you and your Perl
CGI program, maybe it is one of _them_ that is withholding display
until the entire document is available.

Running it from the command line will resolve that issue, since
those other programs are not between the program and the displaying
of the program's output.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

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


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