[30485] in Perl-Users-Digest
Perl-Users Digest, Issue: 1728 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 17 14:09:55 2008
Date: Thu, 17 Jul 2008 11:09:17 -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 Thu, 17 Jul 2008 Volume: 11 Number: 1728
Today's topics:
Re: C linked lists in Perl <tzz@lifelogs.com>
Re: C linked lists in Perl <uri@stemsystems.com>
Re: comma quoted lists question <tzz@lifelogs.com>
Re: comma quoted lists question <ben@morrow.me.uk>
Re: comma quoted lists question <tzz@lifelogs.com>
Re: FAQ 1.12 What's the difference between "perl" and " <tzz@lifelogs.com>
Re: FAQ 1.12 What's the difference between "perl" and " <dave.s.doyle@gmail.com>
get process name from process id <a@a.com>
Re: get process name from process id <tzz@lifelogs.com>
Re: get process name from process id <joost@zeekat.nl>
Re: How to ensure I'm doing lwp with https correctly? volantecho@gmail.com
Re: How to identify a 32 or 64 bit OS? <tzz@lifelogs.com>
Re: How to identify a 32 or 64 bit OS? <fawaka@gmail.com>
Re: How to identify a 32 or 64 bit OS? <ben@morrow.me.uk>
Re: How to identify a 32 or 64 bit OS? <tzz@lifelogs.com>
Re: How to identify a 32 or 64 bit OS? <tzz@lifelogs.com>
Re: How to identify a 32 or 64 bit OS? <g4173c@motorola.com>
Re: Question in Perl Arrays xhoster@gmail.com
Re: Question in Perl Arrays <spamtrap@dot-app.org>
Re: Question in Perl Arrays <spamtrap@dot-app.org>
Re: Question in Perl Arrays <fawaka@gmail.com>
Re: Question in Perl Arrays <ben@morrow.me.uk>
Re: Question in Perl Arrays <uri@stemsystems.com>
Re: Regular Expression Problem <ben@morrow.me.uk>
Re: Regular Expression Problem <daveb@addr.invalid>
Re: reliability problem with Finance::QuoteHist::Yahoo <r.ted.byers@gmail.com>
Re: remove previous lines of a log file <sivarajesh.jarugula@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 17 Jul 2008 10:03:15 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: C linked lists in Perl
Message-Id: <86sku8r1sc.fsf@lifelogs.com>
On Wed, 16 Jul 2008 20:43:27 GMT Uri Guttman <uri@stemsystems.com> wrote:
UG> as i said above no lang HAS linked lists
Java has them as part of the standard java.util libraries that come with
the standard JRE.
Lisp pretty much is all about linked lists, they are built into
everything.
I'm sure there are others.
Ted
------------------------------
Date: Thu, 17 Jul 2008 17:26:58 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: C linked lists in Perl
Message-Id: <x7zlogqv4t.fsf@mail.sysarch.com>
>>>>> "TZ" == Ted Zlatanov <tzz@lifelogs.com> writes:
TZ> On Wed, 16 Jul 2008 20:43:27 GMT Uri Guttman <uri@stemsystems.com> wrote:
UG> as i said above no lang HAS linked lists
TZ> Java has them as part of the standard java.util libraries that come with
TZ> the standard JRE.
i wouldn't call that part of the lang. but some would.
TZ> Lisp pretty much is all about linked lists, they are built into
TZ> everything.
sure but other than car and cdr (great names! and i know why) and dotted
pair, it doesn't have any builtin support for linked lists. you still
need to work at making them with primitives. i have made linked list
libs in c on more than one project and it is the same in lisp at that
level. the problem with built in linked lists is the data. in c you need
custom structures to hold a link and data or an opaque pointer to the
data off a generic link structure. in lisp you need to do the same
(actually make a tree) if you want more than a atom value at each link
node. that is why linked lists are taught as a data structure and
algorithm and hopefully independent of the language used. as i said
earlier, any large array can be used as the basis for a linked list
structure with no outside data. once you understand that algorithm and
such, all other versions are just variants.
and i want to kill the cow-orker who said perl has no linked lists. or
better, make him code in cobol for 10 years!
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Thu, 17 Jul 2008 09:54:41 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: comma quoted lists question
Message-Id: <86wsjkr26m.fsf@lifelogs.com>
On Thu, 17 Jul 2008 05:27:38 -0700 (PDT) cartercc <cartercc@gmail.com> wrote:
c> Yes, I am learning. I intend to add this weapon to my arsenal in the
c> next week or so. I have recently done the same for PDF and have
c> discovered anew the truth of Clark's law that 'Any sufficiently
c> advanced technology is indistinguishable from magic.'
If you're running on Windows, you can use the ActiveState distribution
and its OLE support (I don't know if that's available in any other
Windows distributions of Perl) to open any Excel-supported file
(including 2007), read or modify it, then save the results back.
Ted
------------------------------
Date: Thu, 17 Jul 2008 17:50:30 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: comma quoted lists question
Message-Id: <mr94l5-hja.ln1@osiris.mauzo.dyndns.org>
Quoth Ted Zlatanov <tzz@lifelogs.com>:
>
> If you're running on Windows, you can use the ActiveState distribution
> and its OLE support (I don't know if that's available in any other
> Windows distributions of Perl)
You could check :). http://cpantesters.perl.org/show/Win32-OLE.html has
lots of PASSes from people using Strawberry Perl and people using
Cygwin.
Ben
--
Joy and Woe are woven fine,
A Clothing for the Soul divine William Blake
Under every grief and pine 'Auguries of Innocence'
Runs a joy with silken twine. ben@morrow.me.uk
------------------------------
Date: Thu, 17 Jul 2008 12:34:42 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: comma quoted lists question
Message-Id: <86k5fkpg7h.fsf@lifelogs.com>
On Thu, 17 Jul 2008 17:50:30 +0100 Ben Morrow <ben@morrow.me.uk> wrote:
BM> Quoth Ted Zlatanov <tzz@lifelogs.com>:
>>
>> If you're running on Windows, you can use the ActiveState distribution
>> and its OLE support (I don't know if that's available in any other
>> Windows distributions of Perl)
BM> You could check :). http://cpantesters.perl.org/show/Win32-OLE.html has
BM> lots of PASSes from people using Strawberry Perl and people using
BM> Cygwin.
I didn't think of that way to check, thanks!
Ted
------------------------------
Date: Thu, 17 Jul 2008 09:23:59 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: FAQ 1.12 What's the difference between "perl" and "Perl"?
Message-Id: <86lk00si68.fsf@lifelogs.com>
On Wed, 16 Jul 2008 14:10:30 -0700 "Gordon Corbin Etly" <etc@gmail.com> wrote:
GCE> Ted Zlatanov wrote:
>> Right, nor do I care to prove it. It's irrelevant, as I've explained.
GCE> Then you concede that this view against "PERL" is indeed a weak on? If
GCE> is wasn't, then there shouldn't be any problem proving it.
I previously mentioned that debating this point with you is like
arm-wrestling a coconut; you can choose to interpret that comment in
several ways and that's intentional. I just don't want to argue to
point with you, so please stop inferring the validity of your position
from that.
GCE> [ http://dictionary.reference.com/search?q=shibboleth ]
GCE> " a peculiarity of pronunciation, behavior, mode of dress, etc.,
GCE> " that distinguishes a particular class or set of persons
GCE> But to use something as a shibboleth (as a say to distinguish "a
GCE> particular class or set of persons") is a very poor measuring stick.
GCE> It's akin to database queries for a table without unique keys. This is
GCE> the point I'm stressing.
Your analogy is poor, but I know what you're trying to say and it's
irrelevant because (again) you are applying technical criteria to a
social problem. Understand that the shibboleth is a social qualifier,
not a technical one. Social qualifiers are organic and only have
meaning within the society that uses them. They may be technically
valid or not, and they may be logically consistent or not, but all of
that is irrelevant.
Ted
------------------------------
Date: Thu, 17 Jul 2008 08:17:48 -0700 (PDT)
From: meraxes <dave.s.doyle@gmail.com>
Subject: Re: FAQ 1.12 What's the difference between "perl" and "Perl"?
Message-Id: <e99ad471-0c72-4744-8a67-fb8c19ed1d04@x35g2000hsb.googlegroups.com>
Lovingly paraphrased from ST:TNG, Season 2 Ep 1 - "The Child"
Cast:
Dr. Kate Pulaski as... GCE
Lt. Cmdr. Data as..... Perl
GCE : PERL, look at this.
Perl : Perl.
GCE : What?
Perl : My name. It is spelled "Perl".
GCE : Oh?
Perl : You called me PERL.
GCE : [laughing] What's the difference?
Perl : One is my name. The other is not.
From the mouths of androids. ;)
------------------------------
Date: 17 Jul 2008 10:18:49 -0700
From: perlcoder <a@a.com>
Subject: get process name from process id
Message-Id: <g5nutp0m7d@drn.newsguy.com>
I need to know the name of the parent process.
using getppid function I can get the process id
of the parent process. How do I translate parent
pid to a name.
Is there a way to do it in in perl without invoking ps command.
thanks.
------------------------------
Date: Thu, 17 Jul 2008 12:33:06 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: get process name from process id
Message-Id: <86od4wpga5.fsf@lifelogs.com>
On 17 Jul 2008 10:18:49 -0700 perlcoder <a@a.com> wrote:
p> I need to know the name of the parent process.
p> using getppid function I can get the process id
p> of the parent process. How do I translate parent
p> pid to a name.
p> Is there a way to do it in in perl without invoking ps command.
Get Proc::ProcessTable from CPAN.
Ted
------------------------------
Date: Thu, 17 Jul 2008 19:31:43 +0200
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: get process name from process id
Message-Id: <877ibkv2m8.fsf@zeekat.nl>
perlcoder <a@a.com> writes:
> I need to know the name of the parent process.
> using getppid function I can get the process id
> of the parent process. How do I translate parent
> pid to a name.
>
> Is there a way to do it in in perl without invoking ps command.
From what I've been able to find in a few minutes of searching, you
can't do this portably on unix. using the output of `ps` may very well
be the "best" way to go about it, since ps is at least part of POSIX.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: Thu, 17 Jul 2008 08:45:10 -0700 (PDT)
From: volantecho@gmail.com
Subject: Re: How to ensure I'm doing lwp with https correctly?
Message-Id: <fb5f605f-55dc-4fa5-9d11-162d8be2a97c@34g2000hsf.googlegroups.com>
hi all..
i face the same problem...
i tried debugging..still couldnt find out the reason why...
i received 2 kind of response when execute the script few times:
response #1 (which i think successfully bind)
SSL_connect:before/connect initialization
SSL_connect:SSLv2/v3 write client hello A
SSL_connect:SSLv3 read server hello A
SSL_connect:SSLv3 read server certificate A
SSL_connect:SSLv3 read server done A
SSL_connect:SSLv3 write client key exchange A
SSL_connect:SSLv3 write change cipher spec A
SSL_connect:SSLv3 write finished A
SSL_connect:SSLv3 flush data
SSL_connect:SSLv3 read finished A
<show the page content> # $res->content
response #2 (failure)
500 Connect failed: connect: Connection refused; Connection refused #
$res->content
i think it can bind to the remote ssl client, just very unstable or i
used the wrong method to access..
does it cause the problem if client wrote their own ssl certificate
without registering?
appreciate your help!
------------------------------
Date: Thu, 17 Jul 2008 10:09:53 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How to identify a 32 or 64 bit OS?
Message-Id: <86lk00r1ha.fsf@lifelogs.com>
On Wed, 16 Jul 2008 12:25:00 -0700 (PDT) T <g4173c@motorola.com> wrote:
T> How could I identify if the OS is 32 bit or 64 bit? I need to find a
T> way to do this that will work on Windows as well as Linux. Thus even
T> if the processor is 64, you might be running just Windows XP or is it
T> running Windows XP 64? Same would be true for Linux, although I think
T> I can use "uname -a" for that. Yes/No?
Leon's suggestions is good, and you can also do
pack "q", 1;
If it fails, you don't have 64 bit support.
(I mention this because recently I argued that the "q" template should
not require 64-bit support, as it does now :)
Ted
------------------------------
Date: Thu, 17 Jul 2008 18:22:02 +0200
From: Leon Timmermans <fawaka@gmail.com>
Subject: Re: How to identify a 32 or 64 bit OS?
Message-Id: <2a950$487f71aa$89e0e08f$22247@news1.tudelft.nl>
On Thu, 17 Jul 2008 10:09:53 -0500, Ted Zlatanov wrote:
> On Wed, 16 Jul 2008 12:25:00 -0700 (PDT) T <g4173c@motorola.com> wrote:
>
>
> Leon's suggestions is good, and you can also do
>
> pack "q", 1;
>
> If it fails, you don't have 64 bit support.
>
> (I mention this because recently I argued that the "q" template should
> not require 64-bit support, as it does now :)
>
Yeah, I also don't understand why "q" can't work on 32bit platforms. Most
common 32 bit platforms support 64 bit integers these days. It has to be
possible to make some kind of hack to include this support. Math::Int64
seems to be able to do it, so I don't see why perl itself can't.
Leon Timmermans.
------------------------------
Date: Thu, 17 Jul 2008 18:05:40 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How to identify a 32 or 64 bit OS?
Message-Id: <4oa4l5-hja.ln1@osiris.mauzo.dyndns.org>
Quoth Leon Timmermans <fawaka@gmail.com>:
> On Thu, 17 Jul 2008 10:09:53 -0500, Ted Zlatanov wrote:
> > On Wed, 16 Jul 2008 12:25:00 -0700 (PDT) T <g4173c@motorola.com> wrote:
> >
> > Leon's suggestions is good, and you can also do
> >
> > pack "q", 1;
> >
> > If it fails, you don't have 64 bit support.
> >
> > (I mention this because recently I argued that the "q" template should
> > not require 64-bit support, as it does now :)
>
> Yeah, I also don't understand why "q" can't work on 32bit platforms. Most
> common 32 bit platforms support 64 bit integers these days. It has to be
> possible to make some kind of hack to include this support. Math::Int64
> seems to be able to do it, so I don't see why perl itself can't.
It can, you just need to build perl correctly:
~% uname -m
i386
~% sysctl hw.model
hw.model: Intel(R) Pentium(R) 4 CPU 1500MHz
~% perl -V:'(ptr|long|iv)size'
ivsize='8';
longsize='4';
ptrsize='4';
~% perl -le'print unpack "q", pack "q", 2**54'
18014398509481984
~% perl -v
This is perl, v5.8.8 built for i386-freebsd-64int
Ben
--
Although few may originate a policy, we are all able to judge it.
Pericles of Athens, c.430 B.C.
ben@morrow.me.uk
------------------------------
Date: Thu, 17 Jul 2008 12:35:19 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How to identify a 32 or 64 bit OS?
Message-Id: <86fxq8pg6g.fsf@lifelogs.com>
On Thu, 17 Jul 2008 18:22:02 +0200 Leon Timmermans <fawaka@gmail.com> wrote:
LT> On Thu, 17 Jul 2008 10:09:53 -0500, Ted Zlatanov wrote:
>> On Wed, 16 Jul 2008 12:25:00 -0700 (PDT) T <g4173c@motorola.com> wrote:
>>
>>
>> Leon's suggestions is good, and you can also do
>>
>> pack "q", 1;
>>
>> If it fails, you don't have 64 bit support.
>>
>> (I mention this because recently I argued that the "q" template should
>> not require 64-bit support, as it does now :)
>>
LT> Yeah, I also don't understand why "q" can't work on 32bit platforms. Most
LT> common 32 bit platforms support 64 bit integers these days. It has to be
LT> possible to make some kind of hack to include this support. Math::Int64
LT> seems to be able to do it, so I don't see why perl itself can't.
I asked on perl5-porters, let's see what they say.
Ted
------------------------------
Date: Thu, 17 Jul 2008 12:37:14 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How to identify a 32 or 64 bit OS?
Message-Id: <86bq0wpg39.fsf@lifelogs.com>
On Thu, 17 Jul 2008 18:05:40 +0100 Ben Morrow <ben@morrow.me.uk> wrote:
BM> Quoth Leon Timmermans <fawaka@gmail.com>:
>> On Thu, 17 Jul 2008 10:09:53 -0500, Ted Zlatanov wrote:
>> > On Wed, 16 Jul 2008 12:25:00 -0700 (PDT) T <g4173c@motorola.com> wrote:
>> >
>> > Leon's suggestions is good, and you can also do
>> >
>> > pack "q", 1;
>> >
>> > If it fails, you don't have 64 bit support.
>> >
>> > (I mention this because recently I argued that the "q" template should
>> > not require 64-bit support, as it does now :)
>>
>> Yeah, I also don't understand why "q" can't work on 32bit platforms. Most
>> common 32 bit platforms support 64 bit integers these days. It has to be
>> possible to make some kind of hack to include this support. Math::Int64
>> seems to be able to do it, so I don't see why perl itself can't.
BM> It can, you just need to build perl correctly:
Why should a 32-bit build be unable to construct or interpret a 64-bit
value? It's not particularly hard, after all, and it could take/return
a string or a bigint. I'll continue this in perl5-porters.
Ted
------------------------------
Date: Thu, 17 Jul 2008 10:41:00 -0700 (PDT)
From: T <g4173c@motorola.com>
Subject: Re: How to identify a 32 or 64 bit OS?
Message-Id: <f0f356df-17e1-4a8c-b4ae-a2089c3271a6@i76g2000hsf.googlegroups.com>
On Jul 17, 11:09=A0am, Ted Zlatanov <t...@lifelogs.com> wrote:
> On Wed, 16 Jul 2008 12:25:00 -0700 (PDT) T <g41...@motorola.com> wrote:
>
> T> How could I identify if the OS is 32 bit or 64 bit? I need to find a
> T> way to do this that will work on Windows as well as Linux. Thus even
> T> if the processor is 64, you might be running just Windows XP or is it
> T> running Windows XP 64? Same would be true for Linux, although I think
> T> I can use "uname -a" for that. Yes/No?
>
> Leon's suggestions is good, and you can also do
>
> pack "q", 1;
>
> If it fails, you don't have 64 bit support.
>
> (I mention this because recently I argued that the "q" template should
> not require 64-bit support, as it does now :)
>
> Ted
I thought that was it, however when I try that I get:
64 bit machine:
% test
Useless use of pack in void context at test line 4.
1
% perl -v
This is perl, v5.8.8 built for i686-linux-ld
On the 32 bit machine I get:
% test
Useless use of pack in void context at test line 4.
Invalid type 'q' in pack at test line 4.
% perl -v
This is perl, v5.8.8 built for i686-linux-ld
Copyright 1987-2006, Larry Wall
Thanks
Tom
------------------------------
Date: 17 Jul 2008 15:04:54 GMT
From: xhoster@gmail.com
Subject: Re: Question in Perl Arrays
Message-Id: <20080717110456.089$Xa@newsreader.com>
Yogi <yogeshkagrawal@gmail.com> wrote:
> On Jul 17, 2:46=A0pm, Mirco Wahab <wa...@chemie.uni-halle.de> wrote:
...
> >
> > Wrong. This is the flip-flop operator.
> > In scalar context with two constants,
> > it's matched against $.
> >
....
>
> Is there any simple document which explains how its working?
Probably not. It is complex, so a simple document would be misleading.
> I tried
> reading thru perldoc for .. operator, but am really confused between
> list and scalar contexts?
Can you clarify the nature of your confusion? Are you confused about how
.. behaves in each context, or how to determine which context it is in?
On the first point, I'm somewhat confused myself. I've never fully
understand what the flip-flop mode does, but I understand enough to avoid
accidentally using it, so my confusion is safely sequestered.
On the second point, that is not an issue specific to "..", but a general
Perl issue. In this case, it is intuitive to me that the subscript of
$x[] is in scalar and @x[] is in list, but if you want to discover that
by experimentation, you can make a tattler function:
sub tattle { warn "wantarray: ", wantarray };
And then replace the ".." construct with an invocation of tattle to see
what context your are in.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Thu, 17 Jul 2008 11:31:28 -0400
From: Sherman Pendley <spamtrap@dot-app.org>
Subject: Re: Question in Perl Arrays
Message-Id: <m163r4plwv.fsf@dot-app.org>
RedGrittyBrick <RedGrittyBrick@SpamWeary.foo> writes:
> C:\>perl -e "print scalar (0..3)"
> 1
>
> So 0..3 evaluates to 1 in a scalar context.
Huh? This is the first time in quite a while that Perl has managed to
surprise me. I would have expected the above to print 4 - the number
of elements in the list.
Why 1?
sherm--
--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Thu, 17 Jul 2008 11:33:40 -0400
From: Sherman Pendley <spamtrap@dot-app.org>
Subject: Re: Question in Perl Arrays
Message-Id: <m11w1splt7.fsf@dot-app.org>
Mirco Wahab <wahab@chemie.uni-halle.de> writes:
>> So 0..3 evaluates to 1 in a scalar context.
>> Therefore $a[0..3] is $a[1]
>> Presumably because array indexing uses a scalar index.
>
> Wrong. This is the flip-flop operator.
> In scalar context with two constants,
> it's matched against $.
D'oh! Never mind my question then. I should have read the whole thread
before responding.
It's rather embarrassing that I forgot about the range operator, after
having talked about it just a few days ago... That'll teach me to post
before I'm done with my first coffee of the day. :-(
sherm--
--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Thu, 17 Jul 2008 17:57:54 +0200
From: Leon Timmermans <fawaka@gmail.com>
Subject: Re: Question in Perl Arrays
Message-Id: <f3ef0$487f6c02$89e0e08f$22247@news1.tudelft.nl>
On Thu, 17 Jul 2008 11:31:28 -0400, Sherman Pendley wrote:
> RedGrittyBrick <RedGrittyBrick@SpamWeary.foo> writes:
>
>> C:\>perl -e "print scalar (0..3)"
>> 1
>>
>> So 0..3 evaluates to 1 in a scalar context.
>
> Huh? This is the first time in quite a while that Perl has managed to
> surprise me. I would have expected the above to print 4 - the number of
> elements in the list.
>
> Why 1?
>
> sherm--
Because in scalar context it doesn't produce a range, but a flip-flop. It
returns 1 if the current line number (in the variable $.) is equal to the
first number and continues to do so until the line number is equal to the
second number. This is a heritage from sed and awk.
Since he doesn't do any reading, $. == 0, so it returns 1.
Returning its length is a property of arrays, *not a general feature of
list* or functions or builtins returning lists. m//, s///, qw//, qx//,
reverse, split, splice, split, sort, times, unpack, readdir, stat,
caller, get*/set*, localtime, gmtime and possibly a few more don't do so
either. In fact, I think grep and map are the only builtins that mimic
the behavior of arrays.
Leon Timmermans
------------------------------
Date: Thu, 17 Jul 2008 17:58:06 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Question in Perl Arrays
Message-Id: <u9a4l5-hja.ln1@osiris.mauzo.dyndns.org>
Quoth xhoster@gmail.com:
>
> On the first point, I'm somewhat confused myself. I've never fully
> understand what the flip-flop mode does, but I understand enough to avoid
> accidentally using it, so my confusion is safely sequestered.
It's designed for use with -n. Something like
perl -ne'/foo/../bar/ and print'
will print all the lines from 'foo' to 'bar', and
perl -ne'3../STOP/ and print'
will print from the third line up to one containing 'STOP'. It is the
same as the ',' operator in sed(1) and awk(1) (specifically, .. is like
awk's and ... like sed's) and was put into Perl for the benefit of
people used to those utilities.
Ben
--
"Faith has you at a disadvantage, Buffy."
"'Cause I'm not crazy, or 'cause I don't kill people?"
"Both, actually."
[ben@morrow.me.uk]
------------------------------
Date: Thu, 17 Jul 2008 17:33:00 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Question in Perl Arrays
Message-Id: <x7vdz4quus.fsf@mail.sysarch.com>
>>>>> "BM" == Ben Morrow <ben@morrow.me.uk> writes:
BM> Quoth xhoster@gmail.com:
>>
>> On the first point, I'm somewhat confused myself. I've never fully
>> understand what the flip-flop mode does, but I understand enough to avoid
>> accidentally using it, so my confusion is safely sequestered.
BM> It's designed for use with -n. Something like
BM> perl -ne'/foo/../bar/ and print'
and i have used it before with while(<FH>) loops. it isn't dedicated to
-n.
the flip flop op is just a bistable value. it starts out as false (it
returns a false value) until the left side expression evaluates to
true. then it returns true until the right side expression evaluates to
true. the it reverts to false and testing the left side again.
so it keeps track of its state between its evaluations. that is why it
is called flip flop (after the single bit hardware memory cell that
remembers its state). bistable is also a good name as it is stable in
two ways, true and false and needs a trigger (one side or the other
evaluating to true at the right time.
note that .. only evaluates one side or the other based on its current
state.
and it is called range even in scalar context because a (the most?)
common use is to select a range of lines from a stream. it even has a
builtin test against $. if either side is a literal number.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Thu, 17 Jul 2008 15:25:48 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Regular Expression Problem
Message-Id: <cc14l5-qu3.ln1@osiris.mauzo.dyndns.org>
Quoth Dave B <daveb@addr.invalid>:
>
> Ok. In your first post you mentioned lookbehind, so I gave you an example.
> But as others have already said, you may be able to do what you want to
> without using lookaround, which is certainly more efficient.
> Also, if it turns out that you absolutely need lookbehind (seems unlikely),
> keep in mind that Perl (AFAIK) does not support variable-length lookbehind,
> so you can't say for instance
>
> /(?<=\d+)bananas/
>
> but again, you probably don't need lookbehind at all in your case.
With 5.10, or if you use Regexp::Keep, you can say
/\d+\Kbananas/
to get the most useful case of variable-length look-behind (at the
beginning of the match).
Ben
--
Many users now operate their own computers day in and day out on various
applications without ever writing a program. Indeed, many of these users
cannot write new programs for their machines...
-- F.P. Brooks, 'No Silver Bullet', 1987 [ben@morrow.me.uk]
------------------------------
Date: Thu, 17 Jul 2008 16:46:59 +0200
From: Dave B <daveb@addr.invalid>
Subject: Re: Regular Expression Problem
Message-Id: <g5nlqf$jkb$1@registered.motzarella.org>
Ben Morrow wrote:
>> so you can't say for instance
>>
>> /(?<=\d+)bananas/
>>
>> but again, you probably don't need lookbehind at all in your case.
>
> With 5.10, or if you use Regexp::Keep, you can say
>
> /\d+\Kbananas/
>
> to get the most useful case of variable-length look-behind (at the
> beginning of the match).
Ah thanks, I haven't looked into 5.10 yet, and I didn't know Regexp::Keep
either.
--
D.
------------------------------
Date: Thu, 17 Jul 2008 07:01:00 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: reliability problem with Finance::QuoteHist::Yahoo
Message-Id: <2f438bfc-3215-4960-91ed-ebe7e88867ed@e53g2000hsa.googlegroups.com>
On Jul 17, 6:42=A0am, Peter Scott <Pe...@PSDT.com> wrote:
> On Wed, 16 Jul 2008 12:39:32 -0700, Ted Byers wrote:
> > On Jul 16, 7:45=A0am, Ted Byers <r.ted.by...@gmail.com> wrote:
> >> > > Can't use an undefined value as an ARRAY reference at C:/Perl/site=
/lib/
> >> > > Finance/QuoteHist/Generic.pm line 863.
>
> >> > Line 863 of the current version of that module does not attempt an a=
rray
> >> > dereference. =A0Consider upgrading.
>
> > I am using version 1.11. =A0I know that is about a year old, but I
> > haven't found a more recent release. =A0Is there one?
>
> Then the line number is being misreported (very unusual for a run-time
> error):
>
> =A0 =A0859 =A0sub target_mode {
> =A0 =A0860 =A0 =A0my $self =3D shift;
> =A0 =A0861 =A0 =A0if (@_) {
> =A0 =A0862 =A0 =A0 =A0$self->{target_mode} =3D shift;
> =A0 =A0863 =A0 =A0}
> =A0 =A0864 =A0 =A0$self->{target_mode} || $self->default_target_mode;
> =A0 =A0865 =A0}
> =A0 =A0866
>
> Check your file.
>
> > Can't use an undefined value as an ARRAY reference at C:/Perl/site/lib/
> > Finance/QuoteHist/Generic.pm line 863.
> > =A0at k:/MarketData/TickerSymbolsTest2.pl line 8
> > =A0 =A0main::__ANON__('Can\'t use an undefined value as an ARRAY refere=
nce
> > at C:/Per...') called at C:/Perl/site/lib/Finance/QuoteHist/Generic.pm
> > line 863
>
> > Finance::QuoteHist::Generic::lineup('Finance::QuoteHist::Yahoo=3DHASH(0=
x1a309=ADa8)')
> > called at C:/Perl/site/lib/Finance/QuoteHist/Generic.pm line 422
>
> In my copy of this file, ->lineup() is called at line 437. =A0However, in
> version 1.10 (from backpan), not only is lineup() called from line 422,
> but:
>
> =A0 =A0860 =A0sub lineup {
> =A0 =A0861 =A0 =A0my $self =3D shift;
> =A0 =A0862 =A0 =A0$self->{lineup} =3D \@_ if @_;
> =A0 =A0863 =A0 =A0@{$self->{lineup}};
> =A0 =A0864 =A0}
>
> And there's the array deref right where perl said. =A0Therefore I am sure
> you have an outdated version, whatever you think its number is. =A0Upgrad=
e
> and rerun.
>
>
>
>
>
> > =A0 =A0Finance::QuoteHist::Generic::__ANON__() called at C:/Perl/site/l=
ib/
> > Finance/QuoteHist/Generic.pm line 142
>
> > Finance::QuoteHist::Generic::dividends('Finance::QuoteHist::Yahoo=3DHAS=
H(0x1a=AD309a8)')
> > called at k:/MarketData/TickerSymbolsTest2.pl line 62
>
> > Compilation exited abnormally with code 2 at Wed Jul 16 15:29:31
>
> > Does this make more sense?
>
> > The ticker it dies on is ACLO.OB.
>
> > NB: Computing yesterday's date from today's postponed the crash until
> > dividends() is called. =A0Is there a way to query yahoo to find out the
> > inception date of a given ticker?
>
> http://finance.yahoo.com/q/hp?s=3DACLO.OBfills in the inception date as t=
he
> start date. =A0I've not dealt with enough different symbols that I needed
> to automate fetching it. =A0I don't know if that's your problem though.
>
> --
> Peter Scotthttp://www.perlmedic.com/http://www.perldebugged.com/- Hide qu=
oted text -
>
> - Show quoted text -
You were right.
Activestate's PPM repository was out of date even though it said it
was providing version 1.11. Activestate's version was in fact 1.10.
I uninstalled it and installed from another repository (and verified
by looking in the files that I DID get version 1.11 this time), and
all problems went away.
I now have a couple other questions for you.
1) Do you compute adjusted closing prices yourself, or do you download
them from yahoo too? (If so, how?) Hmm, I just noticed the
documentation for label() mentions an 'adj' column. Does that mean
that if I change "($symbol, $date, $open, $high, $low, $close,
$volume) =3D @$row;" to "($symbol, $date, $open, $high, $low, $close,
$volume,$adj) =3D @$row;" I will get the adjusted prices too?
2) Finance::TickerSymbols seems to produce ticker symbols for which
Finance::QuoteHist::Yahoo doesn't seem to be able to get data. I
guess that is because it doesn't use all the sources or exchanges that
Finance::TickerSymbols uses. When I look at finance.yahoo, it seems
to list a large number of exchanges it gets data from. Is my guess
close to being correct? Is there a way to increase the percentage of
ticker symbols found by Finance::TickerSymbols that
Finance::QuoteHist::Yahoo can retrieve data for? And, out of
curiousity, is it possible to use it to find out whether or not a give
stock is traded on more than one exchange, and if so, get the data for
that stock from each exchange it is traded on (to test the efficient
markets theory - I want to see if the prices are the same on all the
exchanges a given stock is traded on)?
Thanks,
Ted
------------------------------
Date: Thu, 17 Jul 2008 09:25:44 -0700 (PDT)
From: rajesh <sivarajesh.jarugula@gmail.com>
Subject: Re: remove previous lines of a log file
Message-Id: <6c14e08e-86e5-46b8-8b57-b95cd06bbc23@x41g2000hsb.googlegroups.com>
On Jul 16, 5:44=A0am, j...@toerring.de (Jens Thoms Toerring) wrote:
> rajesh <sivarajesh.jarug...@gmail.com> wrote:
> > =A0 =A0 =A0 =A0I am unable to use this script. It gives the output file=
with
> > the lines until the keyword is found. after the first occurance of the
> > keyword, starting from there all lines are getting deleted.
> > I am adding code for your reference. I want to find out ENUMERR which
> > is there in the line no.11. my resultant output file should not have
> > line no: 9,10,11. Remaining all should be intact.
> > =A0endtask : collect_e_daita
> > =A0 =A0 3 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |
> > =A0 =A0 4 ncvlog: *W,LBLMAT (../_src/_hard/_vc/lcdport_vc/sv/
> > nec_lcdport_vc_etype_monitor.sv,1 =A0 =A0 =A068|24): Label/name mismatc=
h:
> > collect_e_data - collect_e_daita.
> > =A0 =A0 5 (`include file: ../_src/_hard/_vc/lcdport_vc/sv/
> > nec_lcdport_vc_etype_monitor.sv line =A0 =A0 =A0 168, `include file: ..=
/_src/
> > _hard/_vc/lcdport_vc/sv/nec_lcdport_vc_top.sv line 47, =A0 =A0 =A0 `inc=
lude
> > file: ../_src/_hard/_tb/_lcdbif_top.sv line 26, file: ../_src/_hard/
> > _tb/nec =A0 =A0 =A0_lcdbif_tb_top.sv line 39)
> > =A0 =A0 6 =A0 =A0 =A0apb_trans_cov.sample();
> > =A0 =A0 7 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |
> > =A0 =A0 8 ncvlog: *W,ECSSDM (./INCA_libs/irun.lnx86.06.20.nc/svpplib/h/
> > sivajar/lcdbif/_veri/_rando =A0 =A0 =A0m/_src/_hard/_uvc/apb_uvc/sv/
> > apb_uvc_master_monitor.sv,149|24): The 'sample' met =A0 =A0 =A0hod is c=
alled
> > upon a covergroup instance whose declaration has a default sampling
> > condit =A0 =A0 =A0ion associated with it.
> > =A0 =A0 9 =A0 =A0 `ovm_field_int =A0 (rd_wr, =A0 =A0 =A0 =A0OVM_ALL_ON)
> > =A0 =A010 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |
> > =A0 =A011 ncvlog: *W,ENUMERR (../_src/_hard/_uvc/apb_uvc/examples/../
> > examples/dummy_memconfig_ =A0 =A0 =A0types.sv,8|46): This assignment is=
a
> > violation of SystemVerilog strong typing rules for =A0 =A0 =A0 enumerat=
ion
> > datatypes.
> > =A0 =A012 =A0 =A0 `ovm_field_int =A0 (rdy_int, =A0 =A0 =A0 =A0OVM_ALL_O=
N)
>
> Did you try the corrected version (modulo the bug Leon Timmermans
> pointed out)? Here it is with hopefully everything cleaned up:
>
> -----8<------------------------------
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> open my $in, =A0'<', 'log' =A0 =A0 or die "Can't open log file.\n";
> open my $out, '>', 'log.new' or die "Can't open replacement file.\n";
>
> my @lines;
> $lines[ 0 ] =3D <$in>;
> $lines[ 1 ] =3D <$in>;
>
> while ( <$in> ) {
> =A0 =A0 if ( /ENUMERR/ ) {
> =A0 =A0 =A0 =A0 @lines =3D ( );
> =A0 =A0 =A0 =A0 last;
> =A0 =A0 }
> =A0 =A0 print $out shift @lines;
> =A0 =A0 push @lines, $_;
>
> }
>
> if ( @lines ) {
> =A0 =A0 print $out $_ for @lines;} else {
>
> =A0 =A0 while ( <$in> ) {
> =A0 =A0 =A0 =A0 print $out $_;
> =A0 =A0 }
>
> }
>
> rename 'log.new', 'log';
>
> -----8<------------------------------
>
> At least for your input file it deletes just the lines 9, 10 and
> 11, as you wanted to. But please note:
>
> a) if 'ENUMERR' does appear in the first two lines nothing happens
> =A0 =A0to that lines, your specifications did not cover the case, so I
> =A0 =A0have no idea what you want to happen then
> b) it does only remove the first instance 'ENUMERR' (and the two
> =A0 =A0lines before, you didn't tell what to do if it shows up a
> =A0 =A0second (or third etc.) time.
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 R=
egards, Jens
> --
> =A0 \ =A0 Jens Thoms Toerring =A0___ =A0 =A0 =A0j...@toerring.de
> =A0 =A0\__________________________ =A0 =A0 =A0http://toerring.de- Hide qu=
oted text -
>
> - Show quoted text -
Hi Jens,
Thanks for the Solution. It looks work fine. But What I
need is that it should happen through out the file where the keyword
occurs.
Thanks in Advance,
Rajesh
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 1728
***************************************