[18190] in Perl-Users-Digest
Perl-Users Digest, Issue: 358 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 26 11:08:50 2001
Date: Mon, 26 Feb 2001 08:05:08 -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: <983203508-v10-i358@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 26 Feb 2001 Volume: 10 Number: 358
Today's topics:
Re: Array length (Victor Eijkhout)
Re: Array length <joe+usenet@sunstarsys.com>
Blowfish error msg admin@cdns.ca
Re: delete the own directory (Tad McClellan)
Re: delete the own directory <bart.lateur@skynet.be>
Re: Difficult Split Question <joe+usenet@sunstarsys.com>
Error installing Libnet module <don@lclcan.com>
Re: Executing perl on Win98 <bart.lateur@skynet.be>
Help with sockets <dennis.kowalsk@daytonoh.ncr.com>
Image::Magick <bberube@versus.com>
maybe an Exchange srv. question or Mail::POP3Client que <tony@irt.no>
New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
Re: regexp clarification (Tad McClellan)
Re: regexp clarification <bart.lateur@skynet.be>
Re: regexp clarification (Abigail)
S File Test ? <seppy@chartermi.net>
Re: S File Test ? (Anno Siegel)
Re: simple question on array splice hack (Anno Siegel)
Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 26 Feb 2001 08:50:06 -0500
From: victor@eijkhout.net (Victor Eijkhout)
Subject: Re: Array length
Message-Id: <1epfhkz.3j3eyp18jzu3wN%victor@eijkhout.net>
Beable van Polasm <beable@my-deja.com> wrote:
> perldoc perldata
>
> It says:
> The length of an array is a scalar value. You may find
> the length of array @days by evaluating $#days, as in csh.
I love how the documentation covers all bases.
Not all arrays are "@samething". If $a{b} is an array, how do I get the
length? The docs were absolutely no help. After a lot of experimenting I
found $#{$a{b}}. Is that the best way? I never found anything looking
like this in the docs. Then, perl is not a full-time occupation of mine.
Hour a week at most. So it could be in the docs but I haven't found it
yet.
So what's a rule for getting array length that works for anything that
is an array?
--
Victor Eijkhout
"the time comes for everyone to do deliberately what
he used to do by mistake" [Quentin Crisp]
------------------------------
Date: 26 Feb 2001 10:56:21 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Array length
Message-Id: <m366hx4evu.fsf@mumonkan.sunstarsys.com>
victor@eijkhout.net (Victor Eijkhout) writes:
> I love how the documentation covers all bases.
>
> Not all arrays are "@samething". If $a{b} is an array, how do I get the
> length?
$a{b} is a scalar, and never an array. However it could be an array
reference, in which case the array in question is
@{ $a{b} }
placing this expression in a scalar context will return the length of
the array:
my $length = @{ $a{b} };
> The docs were absolutely no help. After a lot of experimenting I found
> $#{$a{b}}. Is that the best way?
No, but $#{$a{b}} + 1 usually works as well.
> So what's a rule for getting array length that works for anything that
> is an array?
scalar @samething;
See
% perldoc perlref
for more bases covered.
HTH
--
Joe Schaefer "You can't depend on your eyes when your imagination is out of
focus."
--Mark Twain
------------------------------
Date: 26 Feb 2001 14:29:32 GMT
From: admin@cdns.ca
Subject: Blowfish error msg
Message-Id: <97dp8c$p6q$1@news.netmar.com>
Hi:
I'm trying to implement posting from one server to another, using Blowfish to
encrypt.
I have tested thoroughly, including live tests, and everything works fine.
However, I have some instances of some errors being produced by some users.
The code I am using is this:
use Crypt::Blowfish;
my $PRIVATE_KEY = "[112 character long private key here]";
my $c_key = pack("H16", $PRIVATE_KEY);
my $cipher = new Crypt::Blowfish $c_key;
$ccd = 4551222354459865; # a 16 digit number
$first__8 = substr($ccd,0,8);
$second_8 = substr($ccd,8,8);
$ciphertext2 = $cipher->encrypt($second_8); # NB - 8 bytes
$ciphertext = $cipher->encrypt($first__8); # NB - 8 bytes
my $sock = new IO::Socket::INET (PeerAddr => '[server is here]',
PeerPort => '80',
Proto => 'tcp'
);
$sock -> autoflush();
print $sock "GET
/cgi-bin/post.cgi?ciphertext2=$ciphertext2&ciphertext=$ciphertext&cc_expiry=$
cc_expiry&send_price=$send_price HTTP/1.0\n\n";
#program on the other server returns some XML output
#get that output
while ($line = <$sock>) {
chomp $line;
if ($line =~ /<results>/) {
$line =~ s/<results>//;
$line =~ s/<\/results>//;
$cc_results = $line;
}
}
-close $sock;
# ... continue based on output
#################################################
###Program decrypting on the other end
my $PRIVATE_KEY = [112 character matching private key];
my $ciphertext = $FORM{ciphertext};
my $ciphertext2 = $FORM{ciphertext2};
my $cc_key = pack("H16", $PRIVATE_KEY);
my $cipher = new Crypt::Blowfish $cc_key;
my $plaintext = $cipher->decrypt($ciphertext);
my $plaintext2 = $cipher->decrypt($ciphertext2);
$card = $plaintext . $plaintext2;
####### ... continue with processing
So, here's the problem
SOMETIMES, and only sometimes, the receiving server has this error:
input must be 8 bytes long at ...blah blah.. Blowfish.pm
and, of course, no results are received
I can't figure out what's causing it. I did have in the sending server code,
$sock->autoflush(1); before, and changed it to just $sock->autoflush();
thinking that maybe that might have something to do with it. Probably not.
This is my first stab at encryting and decrypting, and it seems to work,
except for these sometimes errors.
I'm at a real loss, and was hoping some guru here could help with that error
problem.
Secondly, a straight up question, is the "pack" in the code correct to
make
use of the full encryption strength for Blowfish -- simply, have I got this
right?
Thanks,
Eric
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: Mon, 26 Feb 2001 08:20:05 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: delete the own directory
Message-Id: <slrn99km05.6uc.tadmc@tadmc26.august.net>
Christian Gersch <c.gersch@team.isneurope.com> wrote:
>The following situation:
>The Perlscript "script.pl" has been executed and deleted itsself by "unlink
><script.pl>;".
>
>Okay, now the directory where the script _was_ is empty.
>
>How can I realize it to delete the empty directory, when the script has
>already deleted itsself.
That will not be a problem. The program was loaded from disk before
it started running. Deleting the file that it was loaded from will
have no effect on execution (the copy in memory is what is executing).
>...and what's the command to delete a directory...I think "unlink" is only
>for files...?
The description for unlink() in perlfunc.pod says what the command
to delete a directory is, so why are you asking us?
perldoc -f unlink
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 26 Feb 2001 14:24:07 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: delete the own directory
Message-Id: <9lpk9tk3b8lv28m33kp251ou3cek0jtu6g@4ax.com>
Christian Gersch wrote:
>The Perlscript "script.pl" has been executed and deleted itsself by "unlink
><script.pl>;".
>
>Okay, now the directory where the script _was_ is empty.
>
>How can I realize it to delete the empty directory, when the script has
>already deleted itsself.
The compiled script is still in memory.
>The name of the directory is not know for the script - but there is a
>variable, isn't it?
Eh... it depends on the platform. I assume you run the script with a
relative path, or even no path at all. In that case, try the Cwd module,
that should be pretty portable.
--
Bart.
------------------------------
Date: 26 Feb 2001 10:36:11 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Difficult Split Question
Message-Id: <m3ae794ftg.fsf@mumonkan.sunstarsys.com>
Ian Boreham <ianb@ot.com.au> writes:
> Joe Schaefer wrote:
>
> > IMHO split() isn't feasible for splitting on quotes("), since I think
> > it would require variable-width lookbehinds to see if you're inside a
> > quoted region. However I think it can be done in OP's case since a
> > (negative) lookahead can accomplish this for parentheses.
>
> It's certainly not possible to do the task (splitting on unquoted
> commas) as nicely as the FAQ version, but depending on your
> assumptions, I believe it can be done.
You are right- I wrote that before coming up with a split solution myself.
After thinking about the solution, I had a feeling that quotes could be
reasonably handled as well (although naively I would have expected a
simpler regexp than the one you discovered here.)
> I certainly wouldn't recommend using this solution, though, because
> for long strings it would get very slow (and why bother when there's a
> FAQ to use as a basis?), but I was just curious to try it
> out. However, in my experimentation, I found some strange behaviour in
> the FAQ solution, which it might pay to be aware of if you're using
> it.
Drawing from your results, here's a few strings the FAQ fails on:
'String "with embedded quotes, commas" in it, will fail,'
'"Starting but not ending" with a quote, will fail'
'String, at the end, that will fail: "hello, how are you"'
That's quite a miserable state of affairs unless your data never contains
stuff like this. Certainly the FAQ answer needs repair.
In fairness, here's one the FAQ gets right, but that yours
(and Text::Parsewords::quotewords) fails on:
'String with sole, trailing slash \\'
Here the FAQ and yours behave similarly, but the Text::ParseWords
behavior is arguably more correct:
'Should escaped commas, like this one \\, be ignored?'
> The assumptions I have made are:
>
> . Fields can include quoted regions that may include commas.
>
> . Fields can include escaped (\) characters.
^^
, which should be ignored for splitting purposes.
* consecutive (or leading or trailing) commas are split as empty strings
(the FAQ splits them as undef's)
> . All quoted sections are terminated (no trailing unclosed quotes) -
> there is no perfect solution solution to this problem; the data is
> bad, so there just needs to be defined behaviour for the user to
> expect (this solution does not handle it very gracefully). The string
> should be validated beforehand, or the solution should reject the
> string during processing.
I think it's enough just warn that "the behavior is undefined for
invalid strings".
> What I found strange about the FAQ answer as it stands (although it
> could be modified to suit, since it is less restrictive than the split
> solution, and some of this is merely my aesthetic opinion) is:
>
> . Quotes surrounding a whole field are stripped, but internal quotes
> are left alone, and escaped characters retain the escape slash; this
> just seems inconsistent. (I think leaving the escaped characters alone
> is fine, but I think the quotes should be left alone too.)
>
> . A section starting with quotes but with the quotes terminated
> internally is split into the quoted part and the unquoted remainder,
> even though there is no comma separating them. Adding a second quoted
> part just makes it start to give surprising results.
>
> . An unclosed quote (which looks like it can only happen if it is the
> final quote character) is ignored. I'd prefer it to effectively quote
> the remainder of the string. (My split-based solution is no better;
> probably worse, depending on how you define worse when there is no
> right solution other than "die".)
I'm not sure I completely agree with your aesthetic criticisms of the
FAQ answer, but they're certainly reasonable points. (Text::ParseWords
behavior is adjustable but not entirely compatible with your comments).
[...]
> Well, I thought it was an interesting exercise, although I wouldn't
> use it. I probably wouldn't use the FAQ as it stands, though, either.
> I'd define my requirements for a particular use, and then rewrite it
> with tests to make sure it did what I wanted.
Agreed, but perhaps it would be worthwhile to continue this discussion
and prepare a decent replacement of the FAQ answer?
--
Joe Schaefer "It is easier to stay out than get out."
--Mark Twain
------------------------------
Date: Mon, 26 Feb 2001 10:13:54 -0500
From: Don <don@lclcan.com>
Subject: Error installing Libnet module
Message-Id: <3A9A72B2.D998FE4D@lclcan.com>
Hi,
I am running Perl on a SCO UNIX OS 5.0.5 machine and trying to install
the libnet module. When I execute the line --> perl Makefile.PL, I get:
Checking for Socket...ok
Checking for IO::Socket...Segmentation fault (core dumped)
Yikes!!! How do I trouble shoot this?
------------------------------
Date: Mon, 26 Feb 2001 14:20:26 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Executing perl on Win98
Message-Id: <9gpk9t8g4vb8qn7ffk90r7vo0kf62aeflf@4ax.com>
Brian McCann wrote:
> is there a way to run the script without calling the interpreter
>before the filename?
Use the utility pl2bat that came with Perl, see in the "bin" directory
in perl's file tree, to wrap the pl file into a BAT file. That's the
only way you can actually "drop" files on the script, and make perl run
the script with those file paths in @ARGV.
--
Bart.
------------------------------
Date: Mon, 26 Feb 2001 10:25:37 -0500
From: "Dennis Kowalski" <dennis.kowalsk@daytonoh.ncr.com>
Subject: Help with sockets
Message-Id: <3a9a7571$1@rpc1284.daytonoh.ncr.com>
I am trying to write a script that connects to a server program, send data
to it and get output back.
I have a C program that does it, but now I am trying in Perl.
I seem to connet to the server module OK.
I build a message and send it.
Then I receive off of the socket.
The data I get, seems to be what I sent
Can anybody look at the following code and tell me what is wrong?
Doe anybode have some sample code that des what I am trying to do?
SAMPLE CODE
use IO::Socket;
$port = '18059';
$ip = 'IP ADDRESS WAS HERE';
my $socket = new IO::Socket::INET (PeerAddr => $ip,
PeerPort => $port,
Proto => 'tcp')
or die "Can not connect to server.\n";
$socket->autoflush(1);
# msg is built here
# send the msg to the server
print $socket $output_rec;
&read_socket;
exit;
# routine to read the socket
sub read_socket
{
# read 2 byte vli, unpack it and subtract 2
$rcvrec = read ($socket,$vlib,2);
$vli = unpack("n",$vlib);
$vli2 = $vli -2;
$buffin = 0;
# read data portion from the socket
$rcvrec = read ($socket,$buffin,$vli2);
if ($buffin)
{
print RCV $vlib;
print RCV $buffin;
}
0;
}
------------------------------
Date: Mon, 26 Feb 2001 10:22:16 -0500
From: "Neb" <bberube@versus.com>
Subject: Image::Magick
Message-Id: <Jwum6.134118$Z2.1802290@nnrp1.uunet.ca>
Hi,
thanks to those who helped me out with my previous post on the subject. I
simply have a small question about efficient use of Image::Magick.
Suppose that I use this lib to dynamically create image thumbnails everytime
a user access an image (I get the full size image from a database, then use
Magick to resize, then send by the image to the client using
"content-type:image/gif"). I read somewhere that Image::Magick can be quite
a memory eater. I need to resize only image of format .gif and .jpg. Is
this technik used by someone or can be used efficiently ?
Thanks for any advice.
Neb
------------------------------
Date: Mon, 26 Feb 2001 16:01:38 +0100
From: "Tony K" <tony@irt.no>
Subject: maybe an Exchange srv. question or Mail::POP3Client question
Message-Id: <Qcum6.3538$t21.86624@news3.oke.nextra.no>
use Mail::POP3Client;
$pop = new Mail::POP3Client( USER => "Administrator",
PASSWORD => "passwdX",
HOST => "192.168.1.66" );
This works just fine, since the Mail box on my exchange server for
"Administrator" is named "Administrator".
But when I try to do the same thing for user "tk" which mailbox name is
"TonyK2", I recive :
"PASS failed: -ERR There is no such mailbox on this server"
any good advice , Or should I post this in an Exchange newsgroup ?
Tony K.
------------------------------
Date: Mon, 26 Feb 2001 15:56:35 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <t9kv5jtkbsra13@corp.supernews.com>
Following is a summary of articles from new posters spanning a 7 day
period, beginning at 19 Feb 2001 15:52:16 GMT and ending at
26 Feb 2001 14:24:07 GMT.
Notes
=====
- A line in the body of a post is considered to be original if it
does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
- All text after the last cut line (/^-- $/) in the body is
considered to be the author's signature.
- The scanner prefers the Reply-To: header over the From: header
in determining the "real" email address and name.
- Original Content Rating (OCR) is the ratio of the original content
volume to the total body volume.
- Find the News-Scan distribution on the CPAN!
<URL:http://www.perl.com/CPAN/modules/by-module/News/>
- Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
- Copyright (c) 2001 Greg Bacon.
Verbatim copying and redistribution is permitted without royalty;
alteration is not permitted. Redistribution and/or use for any
commercial purpose is prohibited.
Totals
======
Posters: 139 (41.1% of all posters)
Articles: 231 (22.9% of all articles)
Volume generated: 424.1 kb (22.6% of total volume)
- headers: 187.7 kb (3,764 lines)
- bodies: 231.6 kb (7,567 lines)
- original: 162.8 kb (5,662 lines)
- signatures: 4.5 kb (131 lines)
Original Content Rating: 0.703
Averages
========
Posts per poster: 1.7
median: 1 post
mode: 1 post - 83 posters
s: 1.2 posts
Message size: 1879.9 bytes
- header: 832.2 bytes (16.3 lines)
- body: 1026.7 bytes (32.8 lines)
- original: 721.5 bytes (24.5 lines)
- signature: 20.0 bytes (0.6 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
7 11.5 ( 6.0/ 5.3/ 3.8) Ren Maddox <ren@tivoli.com>
6 11.3 ( 5.3/ 6.0/ 2.7) "Joseph Pepin" <jdpepin@optonline.net>
6 10.5 ( 5.4/ 5.1/ 4.6) "Trahojen" <dev@trahojen.REMOVETHIS.com>
5 11.7 ( 4.4/ 7.3/ 6.4) "Chile" <abcd@ntlworld.com>
5 6.2 ( 4.1/ 2.1/ 1.1) John Smith <jsmith@cecioni.com>
4 4.4 ( 3.2/ 1.2/ 0.8) "Peter Søgaard" <peter.s@tjgroup.dk>
4 7.3 ( 2.6/ 4.6/ 3.8) Jayant V Rajan <jrajan@red.seas.upenn.edu>
3 9.7 ( 1.8/ 7.9/ 3.3) "cryofan" <cryofan@msn.com>
3 2.8 ( 2.0/ 0.7/ 0.7) "Dan" <ge@do.com>
3 21.7 ( 3.5/ 17.7/ 4.8) SJ Straith <straith@modusvarious.org>
These posters accounted for 4.6% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
21.7 ( 3.5/ 17.7/ 4.8) 3 SJ Straith <straith@modusvarious.org>
14.6 ( 1.8/ 12.8/ 11.6) 3 Eric Provence <infinityzone@hotmail.com>
14.5 ( 1.0/ 13.4/ 13.1) 1 "Peter Loraditch" <execworks@hotmail.com>
11.7 ( 4.4/ 7.3/ 6.4) 5 "Chile" <abcd@ntlworld.com>
11.5 ( 6.0/ 5.3/ 3.8) 7 Ren Maddox <ren@tivoli.com>
11.3 ( 5.3/ 6.0/ 2.7) 6 "Joseph Pepin" <jdpepin@optonline.net>
10.5 ( 5.4/ 5.1/ 4.6) 6 "Trahojen" <dev@trahojen.REMOVETHIS.com>
10.1 ( 3.6/ 6.5/ 2.2) 3 "Joseph M. Suprenant" <laclac@global2000.net>
9.7 ( 1.8/ 7.9/ 3.3) 3 "cryofan" <cryofan@msn.com>
7.6 ( 0.9/ 6.7/ 6.7) 1 cdh <cdh@ala.net>
These posters accounted for 6.6% of the total volume.
Top 10 Posters by OCR (minimum of three posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
1.000 ( 2.3 / 2.3) 3 erb <erbmicha@msu.edu>
1.000 ( 0.7 / 0.7) 3 "Dan" <ge@do.com>
0.922 ( 2.4 / 2.6) 3 Betastar <insq@yahoo.com>
0.910 ( 11.6 / 12.8) 3 Eric Provence <infinityzone@hotmail.com>
0.901 ( 4.6 / 5.1) 6 "Trahojen" <dev@trahojen.REMOVETHIS.com>
0.872 ( 6.4 / 7.3) 5 "Chile" <abcd@ntlworld.com>
0.824 ( 3.8 / 4.6) 4 Jayant V Rajan <jrajan@red.seas.upenn.edu>
0.748 ( 1.3 / 1.7) 3 Erland Nylend <nylend@nextra.com>
0.716 ( 3.8 / 5.3) 7 Ren Maddox <ren@tivoli.com>
0.667 ( 0.8 / 1.2) 4 "Peter Søgaard" <peter.s@tjgroup.dk>
Bottom 10 Posters by OCR (minimum of three posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.546 ( 0.5 / 1.0) 3 Joachim Rose <joachim.rose@psi.ch>
0.532 ( 1.1 / 2.1) 5 John Smith <jsmith@cecioni.com>
0.471 ( 1.7 / 3.5) 3 sam@illuminated.co.uk
0.454 ( 2.7 / 6.0) 6 "Joseph Pepin" <jdpepin@optonline.net>
0.450 ( 0.9 / 2.0) 3 Rick Meldrum <richard.meldrum@fmr.com>
0.418 ( 3.3 / 7.9) 3 "cryofan" <cryofan@msn.com>
0.396 ( 0.7 / 1.8) 3 Tim Hammerquist <tim@vegeta.ath.cx>
0.337 ( 2.2 / 6.5) 3 "Joseph M. Suprenant" <laclac@global2000.net>
0.306 ( 0.9 / 3.0) 3 mfearby@yahoo.com
0.273 ( 4.8 / 17.7) 3 SJ Straith <straith@modusvarious.org>
20 posters (14%) had at least three posts.
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
39 comp.lang.perl.modules
9 gnu.emacs.help
9 comp.lang.tcl
9 alt.perl
7 comp.lang.perl
5 comp.programming
5 comp.mail.misc
4 comp.lang.python
3 comp.unix.shell
2 comp.unix.solaris
Top 10 Crossposters
===================
Articles Address
-------- -------
10 "TeKno" <TeKno@supportinfo.com>
4 Frederic BONNET <fredericbonnet@free.fr>
3 sam@illuminated.co.uk
3 Jeffrey Porter <jandkporter@mediaone.net>
2 minagant@ececs.uc.edu
2 Hugo =?iso-8859-1?Q?Gonz=E1lez?= Monteverde <hugonz@hugonz.net>
2 Ilmari Karonen <usenet11379@itz.pp.sci.fi>
2 "Termix" <termix@earthlink.net>
2 "Ben L." <haunaguy@cablespeed.com>
1 erb <erbmicha@msu.edu>
------------------------------
Date: Mon, 26 Feb 2001 08:10:17 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regexp clarification
Message-Id: <slrn99kldp.6uc.tadmc@tadmc26.august.net>
Inkswamp <inkswamp@nas.com> wrote:
>In article <slrn99k81c.jlu.rgarciasuarez@rafael.kazibao.net>, Rafael
>Garcia-Suarez <rgarciasuarez@free.fr> wrote:
>
>> \b is not a character, it's a "zero-length assertion" :
Just like it says in perlre.pod right before the first mention of \b:
"Perl defines the following zero-width assertions:"
>> in other words,
>> a marker introduced in regular expressions to modify the matcher
>> automaton to verify additional constraints.
It may help to think of anchors as matching "positions", rather
than "characters" in the string. You might also think of them
as matching (some) "empty strings".
>> \b matches not only where a
>> space is next to a letter, but also at the beggining of a string like
>> "catharsis ".
Where \b matches is described in perlre.pod as well:
------------------------------
A word boundary (C<\b>) is a spot between two characters
that has a C<\w> on one side of it and a C<\W> on the other side
of it (in either order), counting the imaginary characters off the
beginning and end of the string as matching a C<\W>.
------------------------------
>> Those features are extensively described in the
>> perlre section of the docs. Hope this helps.
>
>Thanks! That helps a great deal.
Seems that most of the help was already there on your hard disk...
>BTW, I should have said in my previous post that I don't have access to
>a machine
Perl is free, you can download it from the internet.
If you have a computer and an internet connection, you can have perl.
Download it and install it on whatever computer you are using
to post these Usenet articles.
This will also allow you to post Perl questions to the Perl newsgroup.
(as the standard docs are included in the download and you are
required to check them before posting here.
)
>or web server
A web server is not required to run Perl programs!
All you need to run Perl programs is the perl interpreter.
>where I can test this out
If you should happen to be using Perl in a CGI environment
(many, probably "most", Perl programs are not CGI programs)
you *can* test them out without a web server (if you are
using the CGI.pm module).
For even more realistic testing of CGI programs, whether written
in Perl or some other language, you can download and install one
of the free web servers on your local computer too.
Get Perl and a web server on your computer, then you can do the
complete development cycle without reliance on an ISP or even
on an internet connection. Development will go much faster
if you can do nearly all of it locally.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 26 Feb 2001 14:18:08 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: regexp clarification
Message-Id: <napk9ts3p2u584f5karc7ecqq5parqbjn0@4ax.com>
Inkswamp wrote:
> $pet =~ s/\bcat\b/feline/ig;
>
>The example is supposed to demonstrate replacing the word "cat" with
>the word "feline" and the \b (non-word character) around the "cat" is
>there to avoid replacing occurences of "cat" in words like "catharsis"
>and "staccato".
\b is not a character. A non-word character is \W. Try that in your
regex, and you'll see how close to the truth your really got. \b matches
an edge between a word and anything but a word character (non-word,
start of text, end of text), in either direction. Therefore, it has no
width; it doesn't actually match any characters.
--
Bart.
------------------------------
Date: 26 Feb 2001 14:57:12 GMT
From: abigail@foad.org (Abigail)
Subject: Re: regexp clarification
Message-Id: <slrn99krm8.1mt.abigail@tsathoggua.rlyeh.net>
Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMDCCXXXVI
September MCMXCIII in <URL:news:slrn99kjlv.gro.mgjv@martien.heliotrope.home>:
()
() Of course, if you don't have a computer, then you can't install Perl.
() But then the question remains: What did you use to post to Usenet? And
Well, there's always webtv. And internet cafe's, terminals in shopping
centra, and Burgerkings' "20 minutes of of internet with your value meal".
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: Mon, 26 Feb 2001 10:53:02 -0500
From: "Brian E. Seppanen" <seppy@chartermi.net>
Subject: S File Test ?
Message-Id: <3A9A7BDE.DECE4A68@chartermi.net>
I'm writing a basic script to test a file. I want to use the s file
test to determine the size of the file. The programmers guide indicates
-s returns the size of the file, but I'm not sure how I would capture
what is returned and then compare it. Is the returned value placed in
$_?
--
Brian Seppanen
Charter Communications
Regional Data Center 906-228-4226 ext 23
Marquette, MI seppy@chartermi.net
------------------------------
Date: 26 Feb 2001 15:50:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: S File Test ?
Message-Id: <97du0h$afp$2@mamenchi.zrz.TU-Berlin.DE>
According to Brian E. Seppanen <seppy@chartermi.net>:
> I'm writing a basic script to test a file. I want to use the s file
> test to determine the size of the file. The programmers guide indicates
> -s returns the size of the file, but I'm not sure how I would capture
> what is returned and then compare it. Is the returned value placed in
> $_?
No, "-s $file" (or "-s HANDLE") is an expression and returns a value.
so "my $size = -s $file" and "if ( -s $file > $max ) { ..." and
similar all work.
Anno
------------------------------
Date: 26 Feb 2001 15:34:16 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: simple question on array splice hack
Message-Id: <97dt1o$afp$1@mamenchi.zrz.TU-Berlin.DE>
According to David Bakhash <cadet@alum.mit.edu>:
> hi,
>
> this is really easy, but for some odd reason I blanked on a simple
> one-liner to do this:
>
> I have an array of hashrefs. each hashref in the array has a field
> which is either defined() or undefined. At most one of the hashrefs
> will have this field as defined. What's the simplest way to move that
> guy to the front (i.e. index 0) of the array?
One-liner? Well...
unshift @a, splice @a, (grep defined $a[ $_]->{ $swap_this}, 0 .. $#a)[0], 1;
Your array is @a, the key to test is in $swap_this. Of course, the right
way is to get the index first
my ( $i) = grep defined $a[ $_]->{ $swap_this}, 0 .. $#a;
...and then move the array element about
@a[ 0, $i] = @a[ $i, $0]; # this swaps the elements
...or
unshift @a, splice @a, $i, 1; # this rotates the first $i+1 elements
Anno
------------------------------
Date: Mon, 26 Feb 2001 15:56:31 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <t9kv5f7ai4k611@corp.supernews.com>
Following is a summary of articles spanning a 7 day period,
beginning at 19 Feb 2001 15:52:16 GMT and ending at
26 Feb 2001 14:24:07 GMT.
Notes
=====
- A line in the body of a post is considered to be original if it
does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
- All text after the last cut line (/^-- $/) in the body is
considered to be the author's signature.
- The scanner prefers the Reply-To: header over the From: header
in determining the "real" email address and name.
- Original Content Rating (OCR) is the ratio of the original content
volume to the total body volume.
- Find the News-Scan distribution on the CPAN!
<URL:http://www.perl.com/CPAN/modules/by-module/News/>
- Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
- Copyright (c) 2001 Greg Bacon.
Verbatim copying and redistribution is permitted without royalty;
alteration is not permitted. Redistribution and/or use for any
commercial purpose is prohibited.
Excluded Posters
================
perlfaq-suggestions\@(?:.*\.)?perl\.com
faq\@(?:.*\.)?denver\.pm\.org
Totals
======
Posters: 338
Articles: 1008 (402 with cutlined signatures)
Threads: 267
Volume generated: 1875.5 kb
- headers: 831.5 kb (16,232 lines)
- bodies: 990.0 kb (32,093 lines)
- original: 637.3 kb (22,408 lines)
- signatures: 53.0 kb (1,232 lines)
Original Content Rating: 0.644
Averages
========
Posts per poster: 3.0
median: 1.0 post
mode: 1 post - 176 posters
s: 5.1 posts
Posts per thread: 3.8
median: 2 posts
mode: 2 posts - 75 threads
s: 5.0 posts
Message size: 1905.3 bytes
- header: 844.7 bytes (16.1 lines)
- body: 1005.7 bytes (31.8 lines)
- original: 647.4 bytes (22.2 lines)
- signature: 53.9 bytes (1.2 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
39 81.9 ( 33.7/ 48.2/ 34.2) "Godzilla!" <godzilla@stomp.stomp.tokyo>
32 55.9 ( 24.0/ 31.9/ 13.1) Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
30 44.2 ( 26.5/ 17.5/ 10.9) Bart Lateur <bart.lateur@skynet.be>
29 43.2 ( 22.3/ 16.6/ 10.4) Gwyn Judd <tjla@guvfybir.qlaqaf.bet>
27 69.7 ( 27.1/ 37.6/ 36.3) abigail@foad.org
23 65.4 ( 14.0/ 48.2/ 32.1) Chris Stith <mischief@velma.motion.net>
21 54.1 ( 18.2/ 31.7/ 20.2) mgjv@tradingpost.com.au
19 42.8 ( 16.1/ 21.0/ 12.2) Uri Guttman <uri@sysarch.com>
18 35.6 ( 19.9/ 15.7/ 6.9) "Charles K. Clarkson" <c_clarkson@hotmail.com>
16 26.9 ( 13.1/ 13.7/ 7.8) egwong@netcom.com
These posters accounted for 25.2% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
81.9 ( 33.7/ 48.2/ 34.2) 39 "Godzilla!" <godzilla@stomp.stomp.tokyo>
69.7 ( 27.1/ 37.6/ 36.3) 27 abigail@foad.org
65.4 ( 14.0/ 48.2/ 32.1) 23 Chris Stith <mischief@velma.motion.net>
55.9 ( 24.0/ 31.9/ 13.1) 32 Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
54.1 ( 18.2/ 31.7/ 20.2) 21 mgjv@tradingpost.com.au
48.1 ( 15.2/ 32.9/ 24.9) 15 ianb@ot.com.au
44.2 ( 26.5/ 17.5/ 10.9) 30 Bart Lateur <bart.lateur@skynet.be>
43.2 ( 22.3/ 16.6/ 10.4) 29 Gwyn Judd <tjla@guvfybir.qlaqaf.bet>
42.8 ( 16.1/ 21.0/ 12.2) 19 Uri Guttman <uri@sysarch.com>
35.6 ( 19.9/ 15.7/ 6.9) 18 "Charles K. Clarkson" <c_clarkson@hotmail.com>
These posters accounted for 28.8% of the total volume.
Top 10 Posters by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.968 ( 1.8 / 1.8) 6 Another Way <anotherway83@aol.com>
0.966 ( 36.3 / 37.6) 27 abigail@foad.org
0.901 ( 4.6 / 5.1) 6 "Trahojen" <dev@trahojen.REMOVETHIS.com>
0.872 ( 6.4 / 7.3) 5 "Chile" <abcd@ntlworld.com>
0.840 ( 2.0 / 2.4) 7 "Fabian Thorbjörnsson" <fabian@markisspecialisten.com>
0.764 ( 3.8 / 5.0) 6 "Jonas Nilsson" <jonni@ifm.liu.se>
0.757 ( 24.9 / 32.9) 15 ianb@ot.com.au
0.749 ( 10.1 / 13.5) 6 Garry Williams <garry@zvolve.com>
0.748 ( 5.2 / 7.0) 10 "Alan J. Flavell" <flavell@mail.cern.ch>
0.737 ( 4.3 / 5.8) 7 Beable van Polasm <beable@my-deja.com>
Bottom 10 Posters by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.448 ( 5.6 / 12.5) 13 Brad Baxter <bmb@ginger.libs.uga.edu>
0.442 ( 6.9 / 15.7) 18 "Charles K. Clarkson" <c_clarkson@hotmail.com>
0.437 ( 0.9 / 2.1) 5 brian d foy <comdog@panix.com>
0.428 ( 1.6 / 3.7) 6 Michael Budash <mbudash@sonic.net>
0.418 ( 4.0 / 9.6) 6 Greg Bacon <gbacon@cs.uah.edu>
0.411 ( 13.1 / 31.9) 32 Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
0.368 ( 1.8 / 4.8) 6 "John W. Krahn" <krahnj@acm.org>
0.353 ( 1.8 / 5.1) 7 Christopher Burke <craznar@hotmail.com>
0.319 ( 1.4 / 4.4) 6 Tony Curtis <tony_curtis32@yahoo.com>
0.205 ( 1.5 / 7.5) 5 Craig Manley <c.manley@chello.nl>
46 posters (13%) had at least five posts.
Top 10 Threads by Number of Posts
=================================
Posts Subject
----- -------
42 Difficult Split Question
27 PROPOSAL: Graphics::ColorNames
20 chop and chomp
19 Perl in UNIX
18 How can I detect if program is run by cron?
13 perl irc channel
13 Regexp to match Web urls?
12 Specifying the length of regular expression
12 Whats wrong with this????
12 SMTP server
These threads accounted for 18.7% of all articles.
Top 10 Threads by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Subject
-------------------------- ----- -------
94.5 ( 37.0/ 54.3/ 36.9) 42 Difficult Split Question
62.2 ( 32.5/ 27.8/ 19.7) 27 PROPOSAL: Graphics::ColorNames
44.5 ( 10.0/ 33.3/ 12.2) 9 (OFF TOPIC) Re: This is driving me nuts and I need a guru
42.5 ( 11.2/ 29.3/ 24.0) 13 Regexp to match Web urls?
36.2 ( 11.0/ 24.5/ 14.9) 12 Specifying the length of regular expression
35.1 ( 14.6/ 18.8/ 11.9) 19 Perl in UNIX
30.9 ( 14.1/ 15.0/ 8.7) 18 How can I detect if program is run by cron?
29.1 ( 17.7/ 10.9/ 6.6) 20 chop and chomp
28.3 ( 9.6/ 18.5/ 15.1) 12 Whats wrong with this????
25.1 ( 10.1/ 14.4/ 5.6) 11 Need help creating a simple class.
These threads accounted for 22.8% of the total volume.
Top 10 Threads by OCR (minimum of five posts)
==============================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.845 ( 10.2/ 12.1) 11 calling other executables from a perl script
0.819 ( 24.0/ 29.3) 13 Regexp to match Web urls?
0.817 ( 15.1/ 18.5) 12 Whats wrong with this????
0.815 ( 5.0/ 6.2) 5 Any way to modify a script while executing it?
0.801 ( 6.1/ 7.6) 6 Disabling debugging support in Perl?
0.759 ( 1.5/ 2.0) 5 What's wrong with this script?
0.743 ( 5.8/ 7.8) 10 question about arrays
0.731 ( 6.0/ 8.2) 5 Well, looks like ANOTHER bug in perl-5.6.0
0.720 ( 1.5/ 2.1) 6 removing carriage return from a string
0.712 ( 6.7/ 9.4) 7 Reg Ex Help Pls
Bottom 10 Threads by OCR (minimum of five posts)
=================================================
(kb) (kb)
OCR orig / body Posts Subject
----- -------------- ----- -------
0.482 ( 5.1 / 10.5) 6 How is @INC populated
0.463 ( 4.5 / 9.6) 8 splice question
0.450 ( 2.7 / 6.1) 5 knifflige perl probleme ...
0.446 ( 1.4 / 3.1) 5 Storing an array as Attribute of object.
0.437 ( 2.7 / 6.2) 6 Is this taint example correct?
0.427 ( 5.2 / 12.2) 6 regex help needed
0.408 ( 3.1 / 7.5) 13 perl irc channel
0.386 ( 5.6 / 14.4) 11 Need help creating a simple class.
0.365 ( 12.2 / 33.3) 9 (OFF TOPIC) Re: This is driving me nuts and I need a guru
0.364 ( 1.2 / 3.2) 7 file size
67 threads (25%) had at least five posts.
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
39 comp.lang.perl.modules
9 gnu.emacs.help
9 comp.lang.tcl
9 alt.perl
7 comp.lang.perl
5 comp.programming
5 comp.mail.misc
4 comp.lang.python
3 comp.unix.shell
2 comp.unix.solaris
Top 10 Crossposters
===================
Articles Address
-------- -------
10 "TeKno" <TeKno@supportinfo.com>
7 abigail@foad.org
6 Robert Rothenburg <wlkngowl@unix.asb.com>
5 Brad Baxter <bmb@ginger.libs.uga.edu>
4 Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
4 Frederic BONNET <fredericbonnet@free.fr>
4 Logan Shaw <logan@cs.utexas.edu>
3 Kai =?iso-8859-1?q?Gro=DFjohann?= <Kai.Grossjohann@CS.Uni-Dortmund.DE>
3 "Markus Elfring" <ELF@Messer.de>
3 nobull@mail.com
------------------------------
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 358
**************************************