[22253] in Perl-Users-Digest
Perl-Users Digest, Issue: 4474 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 28 00:06:01 2003
Date: Mon, 27 Jan 2003 21:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 27 Jan 2003 Volume: 10 Number: 4474
Today's topics:
Re: byte array in perl, how? pack, unpack? java to perl <goldbb2@earthlink.net>
Edit a perl script and run the modified one from the co (Jim Carter)
Re: Edit a perl script and run the modified one from th <jurgenex@hotmail.com>
Email address RE <mbear@uq.net.au>
Re: Email address RE (Alan Barclay)
Re: Entering backslashed values into variables when rea <hal@thresholddigital.com>
Re: Entering backslashed values into variables when rea (Tony L. Svanstrom)
Re: Entering backslashed values into variables when rea (Tad McClellan)
GetOptions - Can you get the order of the options? <ekulis@apple.com>
Re: GetOptions - Can you get the order of the options? <skuo@mtwhitney.nsc.com>
Re: More random then other random ctcgag@hotmail.com
Re: More random then other random <bwalton@rochester.rr.com>
Re: Netscape 4.x on Mac-Pc Window Resize Problem (Tad McClellan)
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
Re: Q: Shopping Cart Software (RKR)
Re: Question about 64bit Integers in Perl <IHATESPAMdportz@mts.net>
Re: Question about 64bit Integers in Perl <penny1482@attbi.com>
Re: Question about 64bit Integers in Perl (Sisyphus)
Re: Regex: optional word boundary (Amittai Aviram)
Re: Regex: optional word boundary (Amittai Aviram)
Re: Regular Expression Question <gregs@trawna.com>
Re: Regular Expression Question (Tad McClellan)
Re: Regular Expression Question <krahnj@acm.org>
Re: What is the maximum record length for DBM entries? <goldbb2@earthlink.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 28 Jan 2003 00:00:44 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: byte array in perl, how? pack, unpack? java to perl
Message-Id: <3E360E7C.A31A818E@earthlink.net>
vientoloco wrote:
[snip]
> public static byte[] fromHex(String hex) {
sub fromHex($) {
pack 'H*', $_[0];
}
[snip]
> public static String toHex(byte[] b) {
sub toHex($) {
unpack 'H*', $_[0];
}
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: 27 Jan 2003 17:12:53 -0800
From: carterave@yahoo.com (Jim Carter)
Subject: Edit a perl script and run the modified one from the command line..
Message-Id: <9c2a26b6.0301271712.49ffb9e8@posting.google.com>
Hi all,
I have file, called test.pl and a part of the whole code is follows:
----------------------------------------------
system "copy C:\\Test\\links3.cgi C:\\Test2";
system "ren C:\\Test2\\links3.cgi linkTest3.cgi";
--------------------------------------------------
Now I want to update the number 3 with 4 and execute the modified file
from the command line. The modified test.pl must be
-----------------------------------------
system "copy C:\\Test\\links4.cgi C:\\Test2";
system "ren C:\\Test2\\links4.cgi linkTest4.cgi";
-------------------------------------------------
The command I know is (windows 2000)
C:\perl -e "s/3/4/g;" test.pl
and it doesn't work. Do any of you modify the the above piece of line?
Thanks,
JC
------------------------------
Date: Tue, 28 Jan 2003 01:38:44 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Edit a perl script and run the modified one from the command line..
Message-Id: <EalZ9.4952$P64.1118@nwrddc02.gnilink.net>
Jim Carter wrote:
> Hi all,
>
> I have file, called test.pl and a part of the whole code is follows:
> ----------------------------------------------
> system "copy C:\\Test\\links3.cgi C:\\Test2";
Why not
use File::Copy;
copy 'C:/Test/links3.cgi', 'C:/Test2';
> system "ren C:\\Test2\\links3.cgi linkTest3.cgi";
Why not
rename 'C:/Test2/links3.cgi', 'linkTest3.cgi';
> --------------------------------------------------
>
> Now I want to update the number 3 with 4 and execute the modified file
> from the command line. The modified test.pl must be
> -----------------------------------------
> system "copy C:\\Test\\links4.cgi C:\\Test2";
> system "ren C:\\Test2\\links4.cgi linkTest4.cgi";
> -------------------------------------------------
So you don't want to update number 3 with number 4 but actually you want to
replace the digit 3 with the digit 4.
> The command I know is (windows 2000)
> C:\perl -e "s/3/4/g;" test.pl
>
> and it doesn't work.
Please define "doesn't work".
> Do any of you modify the the above piece of line?
Well, that is just a single line of code. You are not reading anyting into
your single-line program, you are not writing anything. All you are doing is
to replace a 3 with a 4 in the value of the variable $_ (which happens to be
undef because you never assigned anything to it).
You may want to check 'perldoc perlrun', in particular the -n and maybe
the -p options.
jue
------------------------------
Date: Tue, 28 Jan 2003 10:21:26 +1000
From: Matthew Braid <mbear@uq.net.au>
Subject: Email address RE
Message-Id: <b14ie7$84$1@bunyip.cc.uq.edu.au>
Hi all,
I've been looking for a package to retrieve a valid email address from a
string and have had little luck (Mail::Address was a little
disappointing - given the string "fleeble" it thinks the email address
is "fleeble" rather than ''. Useful)
Anyway, after looking at how some other people had done it I came up
with the function at the end of this message. Note that it will return
'' if there is no address in the string.
Just in case - does anyone know of a package somewhere that does the
same (better?) I can't use Mail::Address because I'm scanning not only
for the address, but to know there _is_ an address there (which is why
Mail::Address fails me - if its just going to return something random if
there is no address, I'm back to using an RE to validate it anyway).
MB
sub get_email {
my ($string, $lead) = @_;
# Get the first email address from the string
# If lead is true, there can be nothing but whitespace before it
my $start = ($lead ? qr/^\s*/ : qr/(?:^|\s/));
my $aliasre = qr/[\w\-\+\.]+/; # the alias - alphanums, underscores,
-, + and .
my $n = qr/[a-zA-Z0-9]/; # 'Normal' characters - alphanums
# Dash and Underscores in domain can follow each other, but can't have
multiples
# of the same in a row - ie -_ ok, but -- or __ not.
my $d = qr/\-(?=_|$n)/; # 'Dash' characters
my $u = qr/_(?=\-|$n)/; # 'Underscore' characters
# A section of a domain name - must start/end with a normal
my $sectre = qr/$n|(?:$n(?:$n|$d|$u)*$n)/;
# The domain - any number of sections, each followed by a . and ends with
# a TLD - which, thanks to such useful extensions as info, museum etc
can't
# be tied down to hard - its just a sequence of alphas.
my $domainre = qr/(?:$sectre\.)+[a-zA-Z]+/; # The domain
$string =~ /$start($aliasre\@$domainre)(?:\s|\n|\z)/;
return $1;
}
------------------------------
Date: 28 Jan 2003 01:43:12 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: Email address RE
Message-Id: <1043718192.977292@elaine.furryape.com>
In article <b14ie7$84$1@bunyip.cc.uq.edu.au>,
Matthew Braid <mbear@uq.net.au> wrote:
>Hi all,
>
>I've been looking for a package to retrieve a valid email address from a
>string and have had little luck (Mail::Address was a little
>disappointing - given the string "fleeble" it thinks the email address
>is "fleeble" rather than ''. Useful)
Why the sarcasm? fleeble is a perfectly valid email address.
------------------------------
Date: Tue, 28 Jan 2003 00:51:36 GMT
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Re: Entering backslashed values into variables when read in from files
Message-Id: <sukZ9.58338$VU6.45795@rwcrnsc52.ops.asp.att.net>
Tad McClellan wrote:
> Hal Vaughan <hal@thresholddigital.com> wrote:
>
>> I'm not even sure what man or perldoc page to read for this. I'd
>> appreciate at least a pointer in the right direction.
>
>
> I doubt that it is covered in perl's docs, because it is so fundamental.
>
> In the first or second week of a first programming class, the
> difference between what is code and what is data is taught.
Well, considering I'm self-taught, that might explain a lot. I'd love to
take classes, but I'm a little tied up in running my business. With the
current contracts I have, my income will be stable within the next year or
two, when I'll be making enough to live off of (actually, I'll be making
more in a month than I used to make in a year as a teacher). If I sound
snotty, it's because, even though I appreciate the help, I think one snotty
attitude deserves another.
>
> It appears that you do not understand the difference. I'll try
> and help you with that.
You don't teach, do you? As I said, I appreciate the help, but I certainly
wouldn't recommend you work in a position where people skills are required.
>
<snip>
> Stuff you input from a file is "data".
>
> Data is not subject to interpretation like "code" is.
That one sentence, above, would have answered all my questions, without all
the need for extra comments. Thanks for the bit of useful information
interspersed with the self-important comments and put-downs.
<snip>
>> How can I read a line like this:
>>
>> set lf \012
>>
>> in from a file and translate that to a control code within the program?
>
>
> You will need to supply the interpretation of what '\012' means yourself.
>
> First, convert the octal number to decimal:
>
> perldoc -f oct
>
> Then convert the decimal number to the corresponding character:
>
> perldoc -f chr
>
>
> Assuming that the string (data) you've input is in the $_ variable:
>
> s/\\(\d{3})/ chr oct $1 /ge;
>
Thank you for he assistance. That last little bit is a big help. If I can
ever be helpful to you (like teaching people skills or interpersonal
communication without being condesencing), please let me know.
Hal
------------------------------
Date: Tue, 28 Jan 2003 03:53:50 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Entering backslashed values into variables when read in from files
Message-Id: <1fphbuc.1mejtm65mptygN%tony@svanstrom.com>
Hal Vaughan <hal@thresholddigital.com> wrote:
> Tad McClellan wrote:
> > It appears that you do not understand the difference. I'll try
> > and help you with that.
>
> You don't teach, do you? As I said, I appreciate the help, but I certainly
> wouldn't recommend you work in a position where people skills are required.
This is c.l.p.m, we don't do "people skills", we do perl... =)
Seriously, though, you might want to go easy on the "thou hast an
attitude me doth not like"; the same people that you want to reply to
your questions are the same ones that use huge killfiles just to keep
the noice down... and whatever you do, do not meddle in the affairs of
perlwizards, for they are subtle and quick to anger (and you are crunchy
and taste good with ketchup).
--
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #
perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'
------------------------------
Date: Mon, 27 Jan 2003 22:09:50 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Entering backslashed values into variables when read in from files
Message-Id: <slrnb3c0ke.3c7.tadmc@magna.augustmail.com>
Hal Vaughan <hal@thresholddigital.com> wrote:
> Tad McClellan wrote:
>> Hal Vaughan <hal@thresholddigital.com> wrote:
>>
>>> I'm not even sure what man or perldoc page to read for this. I'd
>>> appreciate at least a pointer in the right direction.
>>
>>
>> I doubt that it is covered in perl's docs, because it is so fundamental.
>>
>> In the first or second week of a first programming class, the
>> difference between what is code and what is data is taught.
>
> Well, considering I'm self-taught, that might explain a lot.
It is reasonable to expect that you will miss basic things then.
You shouldn't get all huffy when the expected happens.
You hit upon a learning opportunity. I showed you something
that you did not know.
> even though I appreciate the help,
I am having a difficult time believing you there.
> I think one snotty
> attitude deserves another.
I am sorry that you interpreted my followup that way.
>> It appears that you do not understand the difference. I'll try
>> and help you with that.
>
> You don't teach, do you?
As a matter of fact I do. I've made my living teaching Perl for
the last three years. Programming in some other language is a
prerequisite though, so I don't have a polished approach to
teaching the CS fundamentals, my students already have those.
>> Stuff you input from a file is "data".
>>
>> Data is not subject to interpretation like "code" is.
>
> That one sentence, above, would have answered all my questions, without all
> the need for extra comments. Thanks for the bit of useful information
> interspersed with the self-important comments and put-downs.
As a teacher, you must surely realize that you never know what it
is that will make it click, so you try lots of different things to
get the point across. I certainly can't tell when you've "gotten it"
in a forum like Usenet. I can't see the look of recognition of your
face after the first try and stop. So I keep trying in case one of
the later ones is "the one".
I cannot see what in my post was a put-down. Please point it out
to me so that I can avoid it in the future.
[snip some other trys]
>> Assuming that the string (data) you've input is in the $_ variable:
>>
>> s/\\(\d{3})/ chr oct $1 /ge;
>>
>
> Thank you for he assistance.
You have a peculiar way of showing gratitude then.
> That last little bit is a big help.
It will not be happening a fourth time.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 27 Jan 2003 17:34:09 -0800
From: Ed Kulis <ekulis@apple.com>
Subject: GetOptions - Can you get the order of the options?
Message-Id: <BA5B1E11.5868%ekulis@apple.com>
Hi,
While using GetOptions, there a way to tell in what order the options
occured in the @ARGV variable?
I don't want to require an order I just what to know what it is.
GetOptions will accept the shortest non-ambigious abbreviation so just
grepping for the option in @ARGV won't do.
-ed
------------------------------
Date: Mon, 27 Jan 2003 18:20:42 -0800
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: GetOptions - Can you get the order of the options?
Message-Id: <Pine.GSO.4.21.0301271815350.8207-100000@mtwhitney.nsc.com>
On Mon, 27 Jan 2003, Ed Kulis wrote:
> Hi,
>
> While using GetOptions, there a way to tell in what order the options
> occured in the @ARGV variable?
>
> I don't want to require an order I just what to know what it is.
>
> GetOptions will accept the shortest non-ambigious abbreviation so just
> grepping for the option in @ARGV won't do.
>
> -ed
Make a copy of @ARGV before calling GetOptions. You can "expand" the
abbreviated option switches yourself:
#! /usr/local/bin/perl
use strict;
use warnings;
use Getopt::Long;
my ($one, $two, $three);
my @orig_argv = @ARGV;
my %opt_hash = (
'one=i' => \$one,
'two=i' => \$two,
'three=i' => \$three,
);
GetOptions(
%opt_hash
);
print "Input order (possibly abbreviated option
switches) : @orig_argv\n\n";
print "Input order:\n";
for my $argv (@orig_argv) {
next unless ($argv =~ /^-/);
my @switch = grep /^$argv/, map { /^(.*)[=:!+]/; "-$1" } keys
(%opt_hash);
if (@switch == 1) {
print "@switch\n";
} else {
print "ambiguous option: $argv\n";
}
}
$one ||= 1;
$two ||= 2;
$three ||= 3;
print "ONE: $one, TWO: $two, THREE: $three\n";
--
Hope this helps,
Steven
------------------------------
Date: 28 Jan 2003 01:45:38 GMT
From: ctcgag@hotmail.com
Subject: Re: More random then other random
Message-Id: <20030127204538.401$q3@newsreader.com>
"ColdCathoids" <mememe@meme.com> wrote:
>
> I thought about this for awhile and devised a ghetto way of doing it. I
> would create a table that contains one column. There would be the number
> 10 entered 10 times, 9 entered 9 times, and so on. I would then randomly
> grab a row from this table. Then based on that select all the ads with
> the corresponding rating and get a random one from those. I know this
> will work but it seems plain ugly to me.
This will work correctly only if there about the same number of adds with
each rating. If you are going to do that, then you can forgo the table (or
a 55 element array in perl) by using the mathematical formula
sum 1..n = n*(n+1)/2, then solving the quadratic, leading to:
$rating = ceiling ((-1+sqrt(1+8*(rand(55)+1)))/2)
where 55 is for n=max_rating=10, for other n use n*(n+1)/2 instead of 55.
(it wouldn't surprise me if the sqrt and ceiling make this slower than
the array look up, at least for n=10.)
Again, this depends on the assumption that each rating class is equally
populous.
It seems the main things you must consider are:
How big will this table get?
How fast do you want the answers?
Do you plan on reading the entire table (or a large part of it) into
memory?
If yes, do you plan on doing this read every time you need a random
add?
If yes, Wow!
If no, how do you plan on keeping the data fresh?
If no, how do you plan on getting a randomly chosen row from Mysql?
Depending on the answers, this can be anywhere from trivial to
surprisingly difficult.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Tue, 28 Jan 2003 03:46:43 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: More random then other random
Message-Id: <3E35FCE9.6020101@rochester.rr.com>
ctcgag@hotmail.com wrote:
> "ColdCathoids" <mememe@meme.com> wrote:
...
> $rating = ceiling ((-1+sqrt(1+8*(rand(55)+1)))/2)
...
> Xho
Hmmmm...where does ceiling come from? It's not a Perl function, unless
it is a function from some module. Thanks!
--
Bob Walton
------------------------------
Date: Mon, 27 Jan 2003 15:23:02 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Netscape 4.x on Mac-Pc Window Resize Problem
Message-Id: <slrnb3b8pm.2hi.tadmc@magna.augustmail.com>
Minh V. Tran <minh26@hotmail.com> wrote:
> I post this
> problem with a hope you JavaScript experts can help me out on this matter.
You are in the wrong newsgroup dude.
The javascript experts are in the javascript newsgroups:
comp.lang.java.javascript
comp.lang.javascript
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 27 Jan 2003 21:08:04 -0600
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.3 $)
Message-Id: <xMWcndMwM_KJaaijXTWcoA@august.net>
Outline
Before posting to comp.lang.perl.misc
Must
- Check the Perl Frequently Asked Questions (FAQ)
- Check the other standard Perl docs (*.pod)
Really Really Should
- Lurk for a while before posting
- Search a Usenet archive
If You Like
- Check Other Resources
Posting to comp.lang.perl.misc
Is there a better place to ask your question?
- Question should be about Perl, not about the application area
How to participate (post) in the clpmisc community
- Carefully choose the contents of your Subject header
- Use an effective followup style
- Speak Perl rather than English, when possible
- Ask perl to help you
- Do not re-type Perl code
- Provide enough information
- Do not provide too much information
- Do not post binaries, HTML, or MIME
Social faux pas to avoid
- Asking a Frequently Asked Question
- Asking a question easily answered by a cursory doc search
- Asking for emailed answers
- Beware of saying "doesn't work"
- Sending a "stealth" Cc copy
Be extra cautious when you get upset
- Count to ten before composing a followup when you are upset
- Count to ten after composing and before posting when you are upset
-----------------------------------------------------------------
Posting Guidelines for comp.lang.perl.misc ($Revision: 1.3 $)
This newsgroup, commonly called clpmisc, is a technical newsgroup
intended to be used for discussion of Perl related issues (except job
postings), whether it be comments or questions.
As you would expect, clpmisc discussions are usually very technical in
nature and there are conventions for conduct in technical newsgroups
going somewhat beyond those in non-technical newsgroups.
This article describes things that you should, and should not, do to
increase your chances of getting an answer to your Perl question. It is
available in POD, HTML and plain text formats at:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
For more information about netiquette in general, see the "Netiquette
Guidelines" at:
http://andrew2.andrew.cmu.edu/rfc/rfc1855.html
A note to newsgroup "regulars":
Do not use these guidelines as a "license to flame" or other
meanness. It is possible that a poster is unaware of things
discussed here. Give them the benefit of the doubt, and just
help them learn how to post, rather than assume
A note about technical terms used here:
In this document, we use words like "must" and "should" as
they're used in technical conversation (such as you will
encounter in this newsgroup). When we say that you *must* do
something, we mean that if you don't do that something, then
it's unlikely that you will benefit much from this group.
We're not bossing you around; we're making the point without
lots of words.
Do *NOT* send email to the maintainer of these guidelines. It will be
discarded unread. The guidelines belong to the newsgroup so all
discussion should appear in the newsgroup. I am just the secretary that
writes down the consensus of the group.
Before posting to comp.lang.perl.misc
Must
This section describes things that you *must* do before posting to
clpmisc, in order to maximize your chances of getting meaningful replies
to your inquiry and to avoid getting flamed for being lazy and trying to
have others do your work.
The perl distribution includes documentation that is copied to your hard
drive when you install perl. Also installed is a program for looking
things up in that (and other) documentation named 'perldoc'.
You should either find out where the docs got installed on your system,
or use perldoc to find them for you. Type "perldoc perldoc" to learn how
to use perldoc itself. Type "perldoc perl" to start reading Perl's
standard documentation.
Check the Perl Frequently Asked Questions (FAQ)
Checking the FAQ before posting is required in Big 8 newsgroups in
general, there is nothing clpmisc-specific about this requirement.
You are expected to do this in nearly all newsgroups.
You can use the "-q" switch with perldoc to do a word search of the
questions in the Perl FAQs.
Check the other standard Perl docs (*.pod)
The perl distribution comes with much more documentation than is
available for most other newsgroups, so in clpmisc you should also
see if you can find an answer in the other (non-FAQ) standard docs
before posting.
It is *not* required, or even expected, that you actually *read* all of
Perl's standard docs, only that you spend a few minutes searching them
before posting.
Try doing a word-search in the standard docs for some words/phrases
taken from your problem statement or from your very carefully worded
"Subject:" header.
Really Really Should
This section describes things that you *really should* do before posting
to clpmisc.
Lurk for a while before posting
This is very important and expected in all newsgroups. Lurking means
to monitor a newsgroup for a period to become familiar with local
customs. Each newsgroup has specific customs and rituals. Knowing
these before you participate will help avoid embarrassing social
situations. Consider yourself to be a foreigner at first!
Search a Usenet archive
There are tens of thousands of Perl programmers. It is very likely
that your question has already been asked (and answered). See if you
can find where it has already been answered.
One such searchable archive is:
http://groups.google.com/advanced_group_search
If You Like
This section describes things that you *can* do before posting to
clpmisc.
Check Other Resources
You may want to check in books or on web sites to see if you can
find the answer to your question.
But you need to consider the source of such information: there are a
lot of very poor Perl books and web sites, and several good ones
too, of course.
Posting to comp.lang.perl.misc
There can be 200 messages in clpmisc in a single day. Nobody is going to
read every article. They must decide somehow which articles they are
going to read, and which they will skip.
Your post is in competition with 199 other posts. You need to "win"
before a person who can help you will even read your question.
These sections describe how you can help keep your article from being
one of the "skipped" ones.
Is there a better place to ask your question?
Question should be about Perl, not about the application area
It can be difficult to separate out where your problem really is,
but you should make a conscious effort to post to the most
applicable newsgroup. That is, after all, where you are the most
likely to find the people who know how to answer your question.
Being able to "partition" a problem is an essential skill for
effectively troubleshooting programming problems. If you don't get
that right, you end up looking for answers in the wrong places.
It should be understood that you may not know that the root of your
problem is not Perl-related (the two most frequent ones are CGI and
Operating System related), so off-topic postings will happen from
time to time. Be gracious when someone helps you find a better place
to ask your question by pointing you to a more applicable newsgroup.
How to participate (post) in the clpmisc community
Carefully choose the contents of your Subject header
You have 40 precious characters of Subject to win out and be one of
the posts that gets read. Don't waste them. Take care while
composing them, they are the key that opens the door to getting an
answer.
Spend them indicating what aspect of Perl others will find if they
should decide to read your article.
Do not spend them indicating "experience level" (guru, newbie...).
Do not spend them pleading (please read, urgent, help!...).
Do not spend them on non-Subjects (Perl question, one-word
Subject...)
For more information on choosing a Subject see "Choosing Good
Subject Lines":
http://www.perl.com/CPAN-local/authors/Dean_Roehrich/subjects.post
Part of the beauty of newsgroup dynamics, is that you can contribute
to the community with your very first post! If your choice of
Subject leads a fellow Perler to find the thread you are starting,
then even asking a question helps us all.
Use an effective followup style
When composing a followup, quote only enough text to establish the
context for the comments that you will add. Always indicate who
wrote the quoted material. Never quote an entire article. Never
quote a .signature (unless that is what you are commenting on).
Intersperse your comments *following* each section of quoted text to
which they relate. Unappreciated followup styles are referred to as
"Jeopardy" (because the answer comes before the question), or
"TOFU".
Reversing the chronology of the dialog makes it much harder to
understand (some folks won't even read it if written in that style).
For more information on quoting style, see:
http://web.presby.edu/~nnqadmin/nnq/nquote.html
Speak Perl rather than English, when possible
Perl is much more precise than natural language. Saying it in Perl
instead will avoid misunderstanding your question or problem.
Do not say: I have variable with "foo\tbar" in it.
Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
or I have $var = <DATA> (and show the data line).
Ask perl to help you
You can ask perl itself to help you find common programming mistakes
by doing two things: enable warnings (perldoc warnings) and enable
"strict"ures (perldoc strict).
You should not bother the hundreds/thousands of readers of the
newsgroup without first seeing if a machine can help you find your
problem. It is demeaning to be asked to do the work of a machine. It
will annoy the readers of your article.
You can look up any of the messages that perl might issue to find
out what the message means and how to resolve the potential mistake
(perldoc perldiag). If you would like perl to look them up for you,
you can put "use diagnostics;" near the top of your program.
Do not re-type Perl code
Use copy/paste or your editor's "import" function rather than
attempting to type in your code. If you make a typo you will get
followups about your typos instead of about the question you are
trying to get answered.
Provide enough information
If you do the things in this item, you will have an Extremely Good
chance of getting people to try and help you with your problem!
These features are a really big bonus toward your question winning
out over all of the other posts that you are competing with.
First make a short (less than 20-30 lines) and *complete* program
that illustrates the problem you are having. People should be able
to run your program by copy/pasting the code from your article. (You
will find that doing this step very often reveals your problem
directly. Leading to an answer much more quickly and reliably than
posting to Usenet.)
Describe *precisely* the input to your program. Also provide example
input data for your program. If you need to show file input, use the
__DATA__ token (perldata.pod) to provide the file contents inside of
your Perl program.
Show the output (including the verbatim text of any messages) of
your program.
Describe how you want the output to be different from what you are
getting.
If you have no idea at all of how to code up your situation, be sure
to at least describe the 2 things that you *do* know: input and
desired output.
Do not provide too much information
Do not just post your entire program for debugging. Most especially
do not post someone *else's* entire program.
Do not post binaries, HTML, or MIME
clpmisc is a text only newsgroup. If you have images or binaries
that explain your question, put them in a publically accessible
place (like a Web server) and provide a pointer to that location. If
you include code, cut and paste it directly in the message body.
Don't attach anything to the message. Don't post vcards or HTML.
Many people (and even some Usenet servers) will automatically filter
out such messages. Many people will not be able to easily read your
post. Plain text is something everyone can read.
Social faux pas to avoid
The first two below are symptoms of lots of FAQ asking here in clpmisc.
It happens so often that folks will assume that it is happening yet
again. If you have looked but not found, or found but didn't understand
the docs, say so in your article.
Asking a Frequently Asked Question
It should be understood that you may have missed the applicable FAQ
when you checked, which is not a big deal. But if the Frequently
Asked Question is worded similar to your question, folks will assume
that you did not look at all. Don't become indignant at pointers to
the FAQ, particularly if it solves your problem.
Asking a question easily answered by a cursory doc search
If folks think you have not even tried the obvious step of reading
the docs applicable to your problem, they are likely to become
annoyed.
If you are flamed for not checking when you *did* check, then just
shrug it off (and take the answer that you got).
Asking for emailed answers
Emailed answers benefit one person. Posted answers benefit the
entire community. If folks can take the time to answer your
question, then you can take the time to go get the answer in the
same place where you asked the question.
It is OK to ask for a *copy* of the answer to be emailed, but many
will ignore such requests anyway. If you munge your address, you
should never expect (or ask) to get email in response to a Usenet
post.
Ask the question here, get the answer here (maybe).
Beware of saying "doesn't work"
This is a "red flag" phrase. If you find yourself writing that,
pause and see if you can't describe what is not working without
saying "doesn't work". That is, describe how it is not what you
want.
Sending a "stealth" Cc copy
A "stealth Cc" is when you both email and post a reply without
indicating *in the body* that you are doing so.
Be extra cautious when you get upset
Count to ten before composing a followup when you are upset
This is recommended in all Usenet newsgroups. Here in clpmisc, most
flaming sub-threads are not about any feature of Perl at all! They
are most often for what was seen as a breach of netiquette. If you
have lurked for a bit, then you will know what is expected and won't
make such posts in the first place.
But if you get upset, wait a while before writing your followup. I
recommend waiting at least 30 minutes.
Count to ten after composing and before posting when you are upset
After you have written your followup, wait *another* 30 minutes
before committing yourself by posting it. You cannot take it back
once it has been said.
AUTHOR
Tad McClellan <tadmc@augustmail.com> and many others on the
comp.lang.perl.misc newsgroup.
------------------------------
Date: 27 Jan 2003 17:06:56 -0800
From: rkroehl@pingnet.com (RKR)
Subject: Re: Q: Shopping Cart Software
Message-Id: <7f065d71.0301271706.c0ce185@posting.google.com>
I recently released a free JSP shopping cart based upon the perl
shopping cart CommerceSQL. It uses MySQL and most any JSP web server
(Tomcat, Netscape, JRun, etc).
http://jcommercesql.com
------------------------------
Date: Mon, 27 Jan 2003 17:20:54 -0600
From: "Doug" <IHATESPAMdportz@mts.net>
Subject: Re: Question about 64bit Integers in Perl
Message-Id: <o9jZ9.31482$7_.128644@news1.mts.net>
I was refering to a 2^64 (1.844+E19) interger
We want to poll our routers and return the Byte traffic as a 64 bit interger
I think what you are saying is that Perl can handle this type of 64bit
interger.
"Abigail" <abigail@abigail.nl> wrote in message
news:slrnb3base.pj6.abigail@alexandra.abigail.nl...
> doug (doug.portz@mts.mb.ca) wrote on MMMCDXXXVI September MCMXCIII in
> <URL:news:bff1479d.0301270904.13bcb2fa@posting.google.com>:
> \\ Hi,
> \\
> \\ let me say right off the bat, I know nothing about Perl.... but I do
> \\ have a question I am hoping someone can answer.
> \\
> \\ We currently have a Perl program that manages an SNMPT application.
> \\ we wantto change from 32 bit to 64 bit integers - which we can do
> \\ pretty easy. but I have heard that getting perl to accept a 64bit
> \\ integer may be difficult.
> \\
> \\ Can someone confirm with me whether it is easy to change a Perl
> \\ program to accept a 64 bit integer, if so are there limitations?
>
>
> What do you mean by "accept a 64 bit integer"? Perl compiled with
> 64 bit integer support handles 64 bit integers just fine.
>
>
>
> Abigail
> --
> BEGIN {$^H {q} = sub {pop and pop and print pop}; $^H = 2**4.2**12}
> "Just "; "another "; "Perl "; "Hacker\n";
------------------------------
Date: Tue, 28 Jan 2003 03:47:43 GMT
From: "Dick Penny" <penny1482@attbi.com>
Subject: Re: Question about 64bit Integers in Perl
Message-Id: <B2nZ9.59667$eM6.119142@rwcrnsc51.ops.asp.att.net>
She was/is, BUT only if the Perl interpreter was compiled to accept a 64 bit
integer. You must check with the 'particular' inplementation of Perl you are
using or thinking of using.
Dick Penny
"Doug" <IHATESPAMdportz@mts.net> wrote in message
news:o9jZ9.31482$7_.128644@news1.mts.net...
> I was refering to a 2^64 (1.844+E19) interger
>
> We want to poll our routers and return the Byte traffic as a 64 bit
interger
>
> I think what you are saying is that Perl can handle this type of 64bit
> interger.
>
> "Abigail" <abigail@abigail.nl> wrote in message
> news:slrnb3base.pj6.abigail@alexandra.abigail.nl...
> > doug (doug.portz@mts.mb.ca) wrote on MMMCDXXXVI September MCMXCIII in
> > <URL:news:bff1479d.0301270904.13bcb2fa@posting.google.com>:
> > \\ Hi,
> > \\
> > \\ let me say right off the bat, I know nothing about Perl.... but I do
> > \\ have a question I am hoping someone can answer.
> > \\
> > \\ We currently have a Perl program that manages an SNMPT application.
> > \\ we wantto change from 32 bit to 64 bit integers - which we can do
> > \\ pretty easy. but I have heard that getting perl to accept a 64bit
> > \\ integer may be difficult.
> > \\
> > \\ Can someone confirm with me whether it is easy to change a Perl
> > \\ program to accept a 64 bit integer, if so are there limitations?
> >
> >
> > What do you mean by "accept a 64 bit integer"? Perl compiled with
> > 64 bit integer support handles 64 bit integers just fine.
> >
> >
> >
> > Abigail
> > --
> > BEGIN {$^H {q} = sub {pop and pop and print pop}; $^H = 2**4.2**12}
> > "Just "; "another "; "Perl "; "Hacker\n";
>
>
------------------------------
Date: 27 Jan 2003 20:03:36 -0800
From: kalinabears@hdc.com.au (Sisyphus)
Subject: Re: Question about 64bit Integers in Perl
Message-Id: <e615828f.0301272003.1a7e0368@posting.google.com>
"Doug" <IHATESPAMdportz@mts.net> wrote in message news:<o9jZ9.31482$7_.128644@news1.mts.net>...
> I was refering to a 2^64 (1.844+E19) interger
>
> We want to poll our routers and return the Byte traffic as a 64 bit interger
>
> I think what you are saying is that Perl can handle this type of 64bit
> interger.
>
Yes, perl can handle integers of any size, but unless perl has been
compiled with 64-bit integer support, then you'll need to 'use
Math::BigInt;' to handle integers bigger than 53 bits.
Try:
my $x = 2 ** 63 + 25;
my $y = 2 ** 63 + 30;
if($x == $y) {print "64 bits not supported"}
else {print "64 bits supported"}
See what that tells you.
Then try:
use Math::BigInt;
my $two = Math::BigInt->new(2);
my $x = $two ** 63 + 25;
my $y = $two ** 63 + 30;
if($x == $y) {print "64 bits not supported"}
else {print "64 bits supported"}
Better news ..... hopefully :-)
Cheers,
Rob
------------------------------
Date: 27 Jan 2003 15:07:36 -0800
From: amittai@amittai.com (Amittai Aviram)
Subject: Re: Regex: optional word boundary
Message-Id: <ebcb341d.0301271507.cbc16e2@posting.google.com>
tiltonj@erols.com (Jay Tilton) wrote in message news:<3e2e1864.419854151@news.erols.com>...
> "Amittai Aviram" <amittai@amittai.com> wrote:
>
> If you can take a Perl regex and make it work in [Language X], nobody
> has to know. Understand, though, that readers of that list may simply
> not know the answer, and they would appreciate an exploration of regex
> syntax. If you get something working, contribute to the community by
> sharing the solution with them.
>
> Chances are that it will drop right into place, but not always.
> Readers only tend to get grumpy when they build a spiffy Perl regex
> for somebody, then that person comes back with "That doesn't work in
> [Language X]. Fix it!" :)
Just want to say -- again -- it does work, _and_ I learned some more
in the process, so thank you twice over.
> : I didn't know that the ?: conditional syntax worked in Perl
>
> There may be some confusion there. The (?:pattern) thing is not the
> same as the ternary ?: operator. (?:pattern) is the same as (pattern)
> except it does not capture a substring--it's for grouping
> subexpressions when capturing is unnecessary or undesirable.
Yeah, I did some more reading and realized that I had made this gaff.
Sorry about that and thanks for clearing it up for any other readers
who might be misled.
Amittai
------------------------------
Date: 27 Jan 2003 15:11:54 -0800
From: amittai@amittai.com (Amittai Aviram)
Subject: Re: Regex: optional word boundary
Message-Id: <ebcb341d.0301271511.271a26e9@posting.google.com>
genericax@hotmail.com (Sara) wrote in message news:<776e0325.0301221324.43604b48@posting.google.com>...
> "Amittai Aviram" <amittai@amittai.com> wrote in message news:<b0ksdj$r073c$1@ID-124651.news.dfncis.de>...
> > \bfan(mail | base)?
> You pretty much got it, but it looks like you added a ' ' in the
> alternative clause. You can't "pretty it up" with spaces dude- they
> are strictly interpreted inside the /'s. So your example would match
> "fanmail " but not "fanmail,". It would also match " fan base" but not
> " fanbase ". As I said you ALMOST had it.
D'oh! I can't believe I did that! I admit, it can get a little
confusing going between program coding, where you do want to pretty
things up, and regular expressions, where you do _not_ -- sometimes
the habits get transferred, especially when you are posting in public
and want things to look good! :-) Sorry -- and thanks for posting the
caution to the public.
Amittai
------------------------------
Date: Mon, 27 Jan 2003 23:43:19 GMT
From: Greg Schmidt <gregs@trawna.com>
Subject: Re: Regular Expression Question
Message-Id: <ptgb3vshtskft8bidr8t46dpufr5h02mfe@4ax.com>
On Mon, 27 Jan 2003 22:25:12 GMT, "John W. Krahn" <krahnj@acm.org>
wrote:
>SteveW wrote:
>>
>> I've been looking at example 9.15 in Dave Roth's "Win32 Perl
>> Scripting: The Administrator's Handbook" and I've got a question. He
>> uses a regular expression
>>
>> my( $Regex ) = ( $Name =~ m#[$^\\/*?{}\[\]]+# );
>>
>> that is described as "If a process name is passed in, all processes
>> matching the name are terminated. If the name contains wildcards such
>> as * and ?, it is used as a regular expression." (p. 342)
>>
>> When I try using this routine, passing in a process name, I get the
>> following error:
>> "Use of uninitialized value in concatenation (.) or string"
>>
>> Can anyone explain to me what this regular expression is doing,
>
>Yes, the regular expression is a character class matching one or more
>(this is redundant as matching only one will accomplish the same thing)
>of either '$' or '^' or '\' or '/' or '*' or '?' or '{' or '}' or '[' or
>']'. If one of these characters is found in $Name then $Regex is
>assigned 1 (true) or if not then $Regex is assigned 0 (false).
From man perlop:
When there are no parentheses in the pattern, the return value is the
list (1) for success. With or without parentheses, an empty list is
returned upon failure.
So, if one of these characters is found in $Name, then $Regex is
assigned 1 (true) or if not then ($Regex) is assigned the empty list,
which means $Regex is assigned undef, which will evaluate to 0 (false)
in scalar context.
>> and why I get an error when I pass in a process name?
>
>The error message is from some other line in the program as there is no
>concatenation involved in the line you provided.
The error is likely coming from a concatenation of $Regex with
something, agreed that it is on another line. Try:
my( $Regex ) = ( $Name =~ m#[$^\\/*?{}\[\]]+# || 0 );
to assign the value 0 to $Regex instead of undef.
--
Greg Schmidt (gregs@trawna.com)
Trawna Publications (http://www.trawna.com/)
Fiction Into Film List (http://fictionintofilm.trawna.com/)
Seven Wonders of the Web (http://7ww.trawna.com/)
------------------------------
Date: Mon, 27 Jan 2003 18:23:28 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regular Expression Question
Message-Id: <slrnb3bjc0.2t2.tadmc@magna.augustmail.com>
Greg Schmidt <gregs@trawna.com> wrote:
> On Mon, 27 Jan 2003 22:25:12 GMT, "John W. Krahn" <krahnj@acm.org>
> wrote:
>>SteveW wrote:
>>>
>>> my( $Regex ) = ( $Name =~ m#[$^\\/*?{}\[\]]+# );
>>> "Use of uninitialized value in concatenation (.) or string"
> So, if one of these characters is found in $Name, then $Regex is
> assigned 1 (true) or if not then ($Regex) is assigned the empty list,
> which means $Regex is assigned undef, which will evaluate to 0 (false)
> in scalar context.
undef evaluates to zero in a _numeric_ scalar context.
It evaluates to the empty string in a string scalar context
(such as with concatenation).
>>The error message is from some other line in the program
Right.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 28 Jan 2003 03:55:24 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Regular Expression Question
Message-Id: <3E35FEC4.52AEC8E2@acm.org>
Greg Schmidt wrote:
>
> The error is likely coming from a concatenation of $Regex with
> something, agreed that it is on another line. Try:
> my( $Regex ) = ( $Name =~ m#[$^\\/*?{}\[\]]+# || 0 );
> to assign the value 0 to $Regex instead of undef.
Better to just remove the parenthesis and it will work correctly.
my $Regex = $Name =~ m#[$^\\/*?{}\[\]]#;
Or you could use the transliteration operator which _will_ put 0 in
$Regex if no characters are found.
my $Regex = $Name =~ tr'$^\/*?{}[]'';
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 28 Jan 2003 00:15:54 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: What is the maximum record length for DBM entries?
Message-Id: <3E36120A.70148D5E@earthlink.net>
"Litalien, Robert [SKY:7Q23:EXCH]" wrote:
>
> I have a question about DBM files.
What kind of 'DBM' files?
ODBM_File? NDBM_File? SDBM_File? GDBM_File? DB_File?
> I've been looking at Perl documentation on the web and cannot find any
> length limits for a value assigned to a DBM key (not the length of the
> key itself but its value).
You must be looking in the wrong place, cause I found it.
perldoc AnyDBM_File
The max sizes for key+value, for the *DB*_File modules I cited above,
are, respectively, 1k, 4k, 1k, unlimited, unlimited. And that 1k for
SDBM_File can be changed by reconfiguring it and recompiling it.
> I have a small DB of about 15 entries (keys) but their value can be
> significant.
>
> Would someone know the length limits of such an entry?
In addition to the perl docs, you could get the sources of those modules
(the sources of the C library parts of them) and read them.
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
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 4474
***************************************