[22808] in Perl-Users-Digest
Perl-Users Digest, Issue: 5029 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 23 06:06:03 2003
Date: Fri, 23 May 2003 03:05:07 -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 Fri, 23 May 2003 Volume: 10 Number: 5029
Today's topics:
Re: awstats ignores HostAliases if using %virtualname <cat@no-spam.com>
Re: calling an exe file <islaw@adexec.com>
Re: calling an exe file <islaw@adexec.com>
Re: calling an exe file <islaw@adexec.com>
Re: calling an exe file <islaw@adexec.com>
Re: Copying all files in a directory (Helgi Briem)
Re: day of week <cat@no-spam.com>
Re: extract pattern <ericw@nospam.ku.edu>
Re: help me with these guts <foobear@nospam.net>
Re: Info files? <nobody@noplace.com>
Lookahead: find empty line(s) or $ <MartinSchweikert@gmx.de>
o conf urllist <waty@powerup.com.au>
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
Re: Problem with Addition - doesn't interpret as a numb <krahnj@acm.org>
Re: Problem with Addition - doesn't interpret as a numb <bigj@kamelfreund.de>
reading javascript arrays <wenjoh26@EMAIL.pct.edu>
Re: reading javascript arrays <allanon@hotmail.com>
Re: Regexp Multiple Matching Problem (david)
Re: Scalar String concatination not working <subs.nntp.wfitzgerald@crtman.com>
Re: Strange output from three arrays defined in one sta <somebody@foobar.xxx>
Re: While loops and arrays <islaw@adexec.com>
Re: Win32::OLE (Graham Smith)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 23 May 2003 18:53:19 +1000
From: Cat <cat@no-spam.com>
Subject: Re: awstats ignores HostAliases if using %virtualname
Message-Id: <3ECDE17F.E721523D@no-spam.com>
gooze wrote:
>
> Now my question: Does somebody know awstats?
>
http://awstats.sourceforge.net/
Or maybe try posting to alt.unix.wizards
good luck
------------------------------
Date: Fri, 23 May 2003 04:32:31 GMT
From: "Islaw" <islaw@adexec.com>
Subject: Re: calling an exe file
Message-Id: <zvhza.112$af7.13159609@newssvr15.news.prodigy.com>
Bernard El-Hagin wrote:
> Islaw wrote:
>
>> w i l l wrote:
>>> On Tue, 20 May 2003 23:19:52 GMT, "Anthony" <johnsmith@yahoo.com>
>>> wrote:
>>>
>>>> hi
>>>>
>>>>
>>>> Am still a newie to perl
>>>> How do i run an exe. Is there a command.
>>>>
>>>> once the script is finished running
>>>> i need to alert an application that files are waiting in c:\test.
>>>> The application has an exe test.exe and will pick the waiting
>>>> files in c:\test. How do i call the test.exe
>>>>
>>>>
>>>> tony
>>>>
>>>
>>> system('c:/test/test.exe');
>>
>>
>> Or if the output is needed to be captured:
>>
>> my $out = `c:/test/text.exe 2>&1
>
>
>
> Closing the quote will help substantially.
>
>
> :-)
Indeed, thanks for pointing that out. Even dumb mistakes can lesser
experienced the wrong idea sometimes. I shall watch that ;-p
--
Islaw
------------------------------
Date: Fri, 23 May 2003 04:35:55 GMT
From: "Islaw" <islaw@adexec.com>
Subject: Re: calling an exe file
Message-Id: <Lyhza.114$6l7.13517087@newssvr15.news.prodigy.com>
Islaw wrote:
> Allanon wrote:
>> "Islaw" <islaw@adexec.com> wrote in message
>> news:bhFya.4663$YS4.3391@newssvr17.news.prodigy.com...
>> [..]
>>> Or if the output is needed to be captured:
>>>
>>> my $out = `c:/test/text.exe 2>&1`
>>
>> That's useful to know :)
>>
>> Can you explain what the "2>&1" bit actually means/does char-by-char.
>>
>> Thanks
>> Allanon
>
> In a nutshell, it ensures all output is caputured (STDOUT and STDERR.)
>
> Can even be used to redirect both of those STDs (no wise cracks) to a
> file:
>
> `c:/test/text.exe 2>&1 > out.txt`;
And see Thomas' post for a good description too!
--
Islaw
------------------------------
Date: Fri, 23 May 2003 04:38:55 GMT
From: "Islaw" <islaw@adexec.com>
Subject: Re: calling an exe file
Message-Id: <zBhza.116$Uj7.13446323@newssvr15.news.prodigy.com>
Allanon wrote:
> "Thomas Kratz" <ThomasKratz@REMOVEwebCAPS.de> wrote in message
> news:3ecbc2ab.0@juno.wiesbaden.netsurf.de...
>>
>> "Allanon" <allanon@hotmail.com> wrote...
>>> "Islaw" <islaw@adexec.com> wrote in message
>>> news:bhFya.4663$YS4.3391@newssvr17.news.prodigy.com...
>>> [..]
>>>> Or if the output is needed to be captured:
>>>>
>>>> `c:/test/text.exe 2>&1`
>>>
>>> That's useful to know :)
>>>
>>> Can you explain what the "2>&1" bit actually means/does
>>> char-by-char.
>>
>> Unix shells (*and* the cmd shell under win32) treat numbers in
>> connection
> with piping or redirection symbols as descriptors for stdin(0),
> stdout(1) and stderr(2).
>>
>> The above means "redirect what's sent to stderr to the same place
>> where
> stdout is sent". And by capturing the output with backticks you will
> get both stdout and stderr from running test.exe.
>
> I see.. kind-of (goes off to find out what backticks are ;)
>
> Thanks
>
> Allanon
In Perl (and I believe in general, unix-wise) `` are used for running na
external application much like system(), whereas you can snag the output to
a variable:
my $out = `c:/test/text.exe 2>&1`;
Of course this can be done with system as well, just send the output to a
file and read it in Perl.
--
Islaw
------------------------------
Date: Fri, 23 May 2003 04:44:31 GMT
From: "Islaw" <islaw@adexec.com>
Subject: Re: calling an exe file
Message-Id: <PGhza.118$nq7.13832411@newssvr15.news.prodigy.com>
Eric J. Roode wrote:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> "Islaw" <islaw@adexec.com> wrote in news:bhFya.4663$YS4.3391
> @newssvr17.news.prodigy.com:
>
>> Or if the output is needed to be captured:
>>
>> my $out = `c:/test/text.exe 2>&1
>
> Somehow I expect that "2>&1" won't work under Windows.
While I normally use Perl under Linux, I have a version on windows (XP-Pro)
(activestate) and thus was able to do a test:
> perl -e "print \"hello\n\";" 2>&1 > test.out
Wrote everything to the file just fine.
> perl --help 2>&1 > test.out
That too.
NT based systems seem to be fine with it, not sure about 9x boxes though.
--
Islaw
------------------------------
Date: Fri, 23 May 2003 09:02:26 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Copying all files in a directory
Message-Id: <3ecde330.3694257581@news.cis.dfn.de>
On Thu, 22 May 2003 22:12:44 +0000 (UTC), mjd@plover.com
(Mark Jason Dominus) wrote:
>In article <3eccd69d.3625496618@news.cis.dfn.de>,
>Helgi Briem <helgi@decode.is> wrote:
>>Well, as our occasionally resident guru, Mark Jason Dominus,
>>once said:
>>
>>"#11901 You can't just make s**t up and expect the computer
>>to know what you mean, R******!"
>
>I did not. I said
>
>#11901 You can't just make shit up and expect the computer
> to know what you mean, Retardo!
>
>If you find the words 'shit' and 'Retardo' too offensive to utter,
>then perhaps you should not be quoting my offensive remark.
>
What can I say? I'm squeamish.
I apologise for misrepresenting you.
--
Regards, Helgi Briem
helgi DOT briem AT decode DOT is
------------------------------
Date: Fri, 23 May 2003 19:35:41 +1000
From: Cat <cat@no-spam.com>
Subject: Re: day of week
Message-Id: <3ECDEB6D.554A9D55@no-spam.com>
Garry Williams wrote:
>
> my $then = timelocal 0, 0, 0, $da, $mm - 1, $yr + 2000;
>
??? Year is the number of years since 1900, therefore shouldn't it be
my $then = timelocal 0, 0, 0, $da, $mm - 1, $yr + 100;
Because $yr is two digits (eg 03).
$yr + 100 = 103
therefore
year = 1900 + 103 = 2003
------------------------------
Date: Fri, 23 May 2003 04:30:47 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: Re: extract pattern
Message-Id: <pan.2003.05.22.23.27.33.868185.10673@nospam.ku.edu>
On Thu, 22 May 2003 21:09:47 -0500, Sara wrote:
> vaidehi_30@yahoo.com (vaidehi) wrote in message
> news:<b20ff12f.0305221456.7e72faa2@posting.google.com>...
>> I have got strings like this one:
>> 1: 196.37.75.158:1024 - 10.10.1.12:79 (a2b) 6> 6<
>> (complete)
> * or lots of others?
if it always has spaces in the same places:
$result = join(" ",(split(/\s+/, $string)[1..3]);
use list context and range addressing
(and make it a little more clear what you mean than a hairy regex)
to break the data down into finer bits, just use /:|\s+/ or whatever and
maybe save to an array
--Eric
------------------------------
Date: Fri, 23 May 2003 04:21:44 GMT
From: <foobear@nospam.net>
Subject: Re: help me with these guts
Message-Id: <slhza.110$m53.13016@petpeeve.ziplink.net>
Sara <genericax@hotmail.com> wrote:
>> if ($source == NULL) {
> better written
> unless ($source)
> Not sure exactly what you're trying to do, but on the surface it looks
> like you're a c-programmer who is trying to make his Perl look as much
> like c as you can. I'm not saying that's necessarily a bad thing, but
This is XS code.
perldoc perlxs
------------------------------
Date: Fri, 23 May 2003 04:02:24 GMT
From: "Gregory Toomey" <nobody@noplace.com>
Subject: Re: Info files?
Message-Id: <01c320e1$bc0b6660$fd498a90@gmtoomey>
Mike Ballard <dont_w@nt_spam.org> wrote in article
<m2of1u8jk8.fsf@west_f1.net>...
>
> Hi -
>
> Anyone know where (or if) I can get Info files for the latest Perl?
>
http://perldoc.com/ ??
gtoomey
------------------------------
Date: 23 May 2003 09:36:19 GMT
From: Martin Schweikert <MartinSchweikert@gmx.de>
Subject: Lookahead: find empty line(s) or $
Message-Id: <Xns9384760E2D847MartinSchweikertgmxd@130.133.1.4>
Hi!
I would like to find empty lines or '$' characters in a lookahead
expression. Finding empty lines or a '$' character in separate
expressions is easy:
(?=\n{2,}) finds one or more empty lines
(?=\$) finds a '$' character
This works so far.
But now I want to say: "find one or more empty line or a '$' character"
in one statement.
I tried variants of
(?=[\n{2,}\$]) '$' is found correctly, but introducing the []
causes \n{2,} to match a single \n instead of 2 or more.
(?=\n{2,})(?=\$) finds nothing at all; the expression (?=)(?=) I have
seen in some example code does not work for me, it seems.
(?=\n{2,}|\$) finds the empty line, but not the '$' character
((?=\n{2,})|(?=\$)) same as previous
In case that the content matters, I'm using this piece of code:
----------
use strict;
undef $/;
open (TEXT, 'foo.txt');
while (<TEXT>) {
while ( /\$(\d+)\/(\d+)\$(.*?)(<expression wanted>)/gs ) {
print "$1-$2: $3\n";
}
}
----------
The input looks like
----------
asdasdf
$1/11$ aaa aaaaaaaa aaa a aaaaaaaa aa $1/12$ bbbbbbb bb bbbbbbb b bbb bb
$1/13$ cccccc ccccc cc c
ccccccccc cc $1/14$ dddddddd dddddd dddd
dddddddd ddddd
----------
What I would like to see is:
----------
1-11: aaa aaaaaaaa aaa a aaaaaaaa aa
1-12: bbbbbbb bb bbbbbbb b bbb bb
1-13: cccccc ccccc cc c ccccccccc cc
1-14: dddddddd dddddd dddddddddddd ddddd
----------
Help!
Regards,
Martin
--
http://www.martin-schweikert.de
------------------------------
Date: Fri, 23 May 2003 08:42:50 GMT
From: "Alan Watson" <waty@powerup.com.au>
Subject: o conf urllist
Message-Id: <ealza.1983$iv4.22195@news-server.bigpond.net.au>
I can't seem to reset the default ftp site in CPAN. Can anyone tell me how?
I think the command is something like:
o conf urllist
Thanks,
Alan
------------------------------
Date: Fri, 23 May 2003 02:24:53 -0500
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.4 $)
Message-Id: <Dgudne5DBLFYUVCjXTWcqQ@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.4 $)
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.cpan.org/authors/id/D/DM/DMR/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: Fri, 23 May 2003 05:47:28 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Problem with Addition - doesn't interpret as a number?
Message-Id: <3ECDB5DD.2084B879@acm.org>
Bob Walton wrote:
>
> You don't say what your OS is, or to what device your output is being
> sent. My guess is that $array[13] contains one or more leading
> non-printing control characters which are both preventing the string
> from being interpreted as a number and also are not showing up on your
> output. You could try removing any such characters, perhaps with
> something like:
>
> $array[13]=~y/\000-\037//d;
>
> prior to your prints and see if the behavior changes.
This looks better and might even work better. :-)
$array[13] =~ y/0-9.-//cd;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 23 May 2003 05:51:03 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Problem with Addition - doesn't interpret as a number?
Message-Id: <pan.2003.05.23.03.48.07.143938@kamelfreund.de>
John W. Krahn wrote at Fri, 23 May 2003 05:47:28 +0000:
>> You don't say what your OS is, or to what device your output is being
>> sent. My guess is that $array[13] contains one or more leading
>> non-printing control characters which are both preventing the string
>> from being interpreted as a number and also are not showing up on your
>> output. You could try removing any such characters, perhaps with
>> something like:
>>
>> $array[13]=~y/\000-\037//d;
>>
>> prior to your prints and see if the behavior changes.
>
> This looks better and might even work better. :-)
>
> $array[13] =~ y/0-9.-//cd;
Talking about readability, I would add
$array[13] =~ s/[[:cntrl:]]//g;
Greetings,
Janek
------------------------------
Date: 23 May 2003 00:41:02 -0500
From: "darthtampon" <wenjoh26@EMAIL.pct.edu>
Subject: reading javascript arrays
Message-Id: <3ecdb46e$1_2@corp-news.newsgroups.com>
i have tried everything. All the books i have dont help either. can somebody
give me an example of perl code reading a javascript array.
------------------------------
Date: Fri, 23 May 2003 10:34:24 +0100
From: "Allanon" <allanon@hotmail.com>
Subject: Re: reading javascript arrays
Message-Id: <bakpv1$m8i@newton.cc.rl.ac.uk>
"darthtampon" <wenjoh26@EMAIL.pct.edu> wrote in message
news:3ecdb46e$1_2@corp-news.newsgroups.com...
>
> i have tried everything. All the books i have dont help either. can
somebody
> give me an example of perl code reading a javascript array.
Pass the array to Perl via the query string.
Eg:
function summonCGI()
{
var myArray = new Array(1,2,3,4,5,6,7,8,9);
var myString = myArray.join(','); // convert array to string
eval('document.location.href = "/cgi-bin/myperlscript.cgi?' + myString
+ '"');
}
<a href="javascript:summonCGI()">Click here</a>
Then, in myperlscript.cgi:
myString = @ARGV[0];
myArray = split /,/, myString; # convert string back to array
Allanon
------------------------------
Date: 23 May 2003 01:20:36 -0700
From: dwlepage@yahoo.com (david)
Subject: Re: Regexp Multiple Matching Problem
Message-Id: <b09a22ae.0305230020.2e113643@posting.google.com>
jonasb@alum.rpi.edu (Big Brother) wrote in message news:<79c1dbe1.0305211051.687aebe6@posting.google.com>...
> Hi -
>
> I am writing a script that parses through a file line by line to
> search for IP addresses (it's to make syslog files available in HTML
> with the IPs highlighted). I've got the code working for the first IP
> on each line, but it never goes on to match if there is a second IP on
> the line. So I have...
> if($_=~/IPmatchingregexp/)
> {
> do stuff
> }
>
> I tried replacing the if with a while, but it seems to go into an
> infinite loop. Can anyone help me on how do basically do a:
> foreach(matched regexp)? I want to run the "do stuff" code for each IP
> on the line, not just the first.
>
> Thanks!
> B
I may be dense, but if you post some sample data that would be much more helpful.
------------------------------
Date: Fri, 23 May 2003 04:22:27 GMT
From: "Warrick FitzGerald" <subs.nntp.wfitzgerald@crtman.com>
Subject: Re: Scalar String concatination not working
Message-Id: <7mhza.5332$Pz3.4247879@news4.srv.hcvlny.cv.net>
>
> "42\r" =~ /(.*)/; # $1="42\r"
> print $1."\n"; # print 42
> print $1."zz\n"; # print 42 then overwrite it with zz
>
> Does that explain what you are seeing?
Thanks Brian, you are a STAR :)
You were correct. Sorry everyone else, I will provide a better example
next time. I could not provide the real URL in this example as the
domain resolves to a private IP Address.
Thanks
Warrick
------------------------------
Date: Thu, 22 May 2003 23:15:39 -0700
From: who me? <somebody@foobar.xxx>
Subject: Re: Strange output from three arrays defined in one statement. Can anyone explain?
Message-Id: <d0frcvg06ffh9apm3p9k7i4jkokdms75hp@4ax.com>
Thank you,Chad and Abigail. I should have caught that myself.
------------------------------
Date: Fri, 23 May 2003 04:28:29 GMT
From: "Islaw" <islaw@adexec.com>
Subject: Re: While loops and arrays
Message-Id: <Nrhza.110$7i7.13331599@newssvr15.news.prodigy.com>
Thomas Kratz wrote:
> "Andres Monroy-Hernandez" <andres@monroy.com> schrieb im Newsbeitrag
> news:3591b31a.0305202017.7320289e@posting.google.com...
>> One way to do it (remember TMTOWTDI) is to create a temporary array
>> for every cycle of the while loop. After each cycle, append the
>> temporary array to the global array @data.
>>
>> It would be something like:
>>
>> use strict;
>> my @data;
>> while(<FILE>){
>> my @tmp = split /,/;
>> push(@tmp, @data);
>
> Surely you mean:
>
> push(@data, @tmp);
>
> Or using and array of arrays as others have suggested:
>
> push(@data, \@tmp);
Yes, if memory serves, the former just tacks the elements in @tmp to the end
of @data resulting in one big array in the form of @data.
The latter woudl seem the logical choice for keeping a row context (as you
noted.)
>> }
>>
>> print "@data";
>>
>> This will print all the elements captured by the while loop.
>>
>> By the way, always work with "use strict" enabled.
>
> And test code before you post it ;-)
To the OP: You may want to see my other post in this tread for some tested
code (5.6.1)
--
Islaw
------------------------------
Date: 22 May 2003 23:44:51 -0700
From: grehom@ntlworld.com (Graham Smith)
Subject: Re: Win32::OLE
Message-Id: <98eb7f13.0305222244.7a456921@posting.google.com>
Thanks Brian the VT_BYREF|VT_R8 worked perfectly, in fact when I
looked up the VT_BYREF in the Win32::OLE::Variant documentation there
was an example for getting x & y coordinates from a Corel Draw OLE
Server :o , I should have read everything in the documentation before
pestering everyone.
Brian McCauley <nobull@mail.com> wrote in message news:<u9u1bmzu69.fsf@wcl-l.bham.ac.uk>...
> grehom@ntlworld.com (Graham Smith) writes:
>
> > I am trying to use OLE to automate plotting points in DesignCAD to
> > save laboriously typing in each coordinate and have got stuck
> > translating the following bit of Visual Basic
> >
> > DcPts.GetUserPoint X, Y, Z
> >
> > I have tried the following:
> >
> > my $x = Variant(VT_R8, 0.0);
> > my $y = Variant(VT_R8, 0.0);
> > my $z = Variant(VT_R8, 0.0);
> >
> > $DcPts->GetUserPoint($x, $y, $z)
> > or die( "Unable to get user point ", Win32::OLE->LastError() );
> > print "x=$x, y=$y, z=$z\n";
> >
>
> Since you are trying to get values back you need VT_BYREF in there.
>
> > The problem is when the code runs it returns the following error:
> >
> > C:\perlSrcs\DesignCad>perl -w draw_points_rel.pl u 5 r 5 d 5 l 5
> > Win32::OLE(0.1603) error 0x80020005: "Type mismatch"
> > in METHOD/PROPERTYGET "GetUserPoint" argument 1 at
> > draw_points_rel.pl line 91
> >
> > The OLE Browser documents the function as follows:
> >
> > Function GetUserPoint(dX As Double, dY As Double, dZ As Double) As
> > Boolean Member of DesignCAD.CmdPoints
>
> Well double should ve VT_R8 alright, so try VT_BYREF|VT_R8
>
> Note I have an unpolished module that simplifies the
> Win32::OLE::Variant interface:.
>
> $DcPts->GetUserPoint(ByRef([VT_R8], my($x, $y, $z) = (0,0,0)));
> # $x, $y, $z are now plain numbers not Win32::OLE::Variant
>
> -------------------
> package Local::Win32::OLE::Varients;
> use strict;
> use warnings;
> use Carp;
>
> use Win32::OLE::Variant;
>
> require Exporter;
> our(@ISA) = qw(Exporter);
> our(@EXPORT) = qw(ByRef Variants);
>
> # We can't subclass Win32::OLE::Variant so we must hook into its
> # destructor
>
> my $oDESTROY = \&Win32::OLE::Variant::DESTROY;
> my %tie;
>
> sub ByRef {
> unshift @_ => [ VT_DISPATCH ]
> unless ref $_[0] eq 'ARRAY';
> unshift @_ => VT_BYREF;
> &_variants;
> }
>
> sub Variants {
> unshift @_ => 0;
> &_variants;
> }
>
> sub _variants {
> my $byref = shift;
> my $types = shift;
> my @result;
> for my $arg ( \ (@_) ) {
> my $type = $types->[0] | $byref;
> my $variant = Variant( $type, $$arg);
> $tie{overload::StrVal $variant} = $arg
> if $type & $byref;
> push @result => $variant;
> shift @$types if @$types > 1;
> }
> unless (wantarray) {
> croak((caller 0)[3] . "() in scalar context with multiple arguments")
> if @result > 1;
> return $result[0];
> }
> @result;
> };
>
> no warnings 'redefine';
>
> *Win32::OLE::Variant::DESTROY = sub {
> if ( my $var = delete $tie{overload::StrVal $_[0]} ) {
> $$var = $_[0]->Value;
> }
> &$oDESTROY;
> };
>
> 1;
------------------------------
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 5029
***************************************