[30481] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1724 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 16 18:09:42 2008

Date: Wed, 16 Jul 2008 15:09:10 -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           Wed, 16 Jul 2008     Volume: 11 Number: 1724

Today's topics:
        C linked lists in Perl <cartercc@gmail.com>
    Re: C linked lists in Perl <uri@stemsystems.com>
    Re: C linked lists in Perl xhoster@gmail.com
    Re: C linked lists in Perl <jurgenex@hotmail.com>
    Re: C linked lists in Perl (Jens Thoms Toerring)
    Re: C linked lists in Perl <ben@morrow.me.uk>
    Re: C linked lists in Perl xhoster@gmail.com
    Re: FAQ 1.12 What's the difference between "perl" and " <etc@gmail.com>
    Re: FAQ 1.12 What's the difference between "perl" and " <jdhog@gmail.com>
        How to identify a 32 or 64 bit OS? <g4173c@motorola.com>
    Re: How to identify a 32 or 64 bit OS? <fawaka@gmail.com>
        Regular Expression Problem <Kryten68@googlemail.com>
    Re: Regular Expression Problem <daveb@addr.invalid>
    Re: Regular Expression Problem <fawaka@gmail.com>
    Re: reliability problem with Finance::QuoteHist::Yahoo <r.ted.byers@gmail.com>
    Re: reliability problem with Finance::QuoteHist::Yahoo <brian.d.foy@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 16 Jul 2008 13:11:24 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: C linked lists in Perl
Message-Id: <8bd59750-feb2-455d-8b1a-868dfb2b0c80@m44g2000hsc.googlegroups.com>

I guess like almost everybody, I like to discuss (argue) the merits of
different technologies. In my world, the big two are Java and
ColdFusion. Recently, we had someone with a background in embedded
systems who has been advocating C. The conversation goes something
like this:

him - Does Perl have linked lists?
me - No.
him - Therefore, C is better than Perl because it has linked lists.
me - But Perl has other data structures that are easier to use than
linked lists.
him - So what? Perl still doesn't have linked lists.

I've never studied linked lists and certainly never coded one (in C or
anything else) but it aroused my curiosity. So after searching on
c.l.p.m. and online, I decided to see if I couldn't do a linked list
in Perl. My first  thought is to do something like this:

%linked_list{$key} = { prev => $linked_list{$prev_key}{prev},
                                   value => $value,
                                   next => $linked_list{$next_key}
{next}  };

I know that most people will think I'm an absolute moron for thinking
about this (and they likely would be right), but CAN you do a linked
list in Perl (never mind that you would never want to), and if so, how
would you go about it?

My motive is to say to my C friend, "Nya, nya, nya."

Thanks, CC.


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

Date: Wed, 16 Jul 2008 20:43:27 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: C linked lists in Perl
Message-Id: <x7lk017e6n.fsf@mail.sysarch.com>

>>>>> "c" == cartercc  <cartercc@gmail.com> writes:

  c> I guess like almost everybody, I like to discuss (argue) the merits of
  c> different technologies. In my world, the big two are Java and
  c> ColdFusion. Recently, we had someone with a background in embedded
  c> systems who has been advocating C. The conversation goes something
  c> like this:

  c> him - Does Perl have linked lists?
  c> me - No.
  c> him - Therefore, C is better than Perl because it has linked lists.
  c> me - But Perl has other data structures that are easier to use than
  c> linked lists.
  c> him - So what? Perl still doesn't have linked lists.


your cow-orker is an idiot. and i say that from 20 years of deep c
experience (and more with assemblers and other langs) and 15 years of
perl. he is a total idiot. linked lists are NOT in c. in fact they
aren't in ANY language. linked lists are a general data structure built
upon various language constructs. you can make them from a single large
allocated array (use indexes for links and manage your own ram) or from
malloced buffers and hard pointers as in c, or in perl with references
(which are better and safer than pointers).

  c> I've never studied linked lists and certainly never coded one (in C or
  c> anything else) but it aroused my curiosity. So after searching on
  c> c.l.p.m. and online, I decided to see if I couldn't do a linked list
  c> in Perl. My first  thought is to do something like this:

  c> %linked_list{$key} = { prev => $linked_list{$prev_key}{prev},
  c>                                    value => $value,
  c>                                    next => $linked_list{$next_key}
  c> {next}  };

that is one way. i mentioned the large array with indexes and that is
another (i effectively did that for a large data tree in perl4 which
didn't have references).

  c> My motive is to say to my C friend, "Nya, nya, nya."

and give him the finger from me. he is nuts if he keeps making that
claim. as i said above no lang HAS linked lists and ALL langs can build
them if they have even basic large array support.

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: 16 Jul 2008 20:46:21 GMT
From: xhoster@gmail.com
Subject: Re: C linked lists in Perl
Message-Id: <20080716164624.300$8B@newsreader.com>

cartercc <cartercc@gmail.com> wrote:
> I guess like almost everybody, I like to discuss (argue) the merits of
> different technologies. In my world, the big two are Java and
> ColdFusion. Recently, we had someone with a background in embedded
> systems who has been advocating C. The conversation goes something
> like this:
>
> him - Does Perl have linked lists?
> me - No.
> him - Therefore, C is better than Perl because it has linked lists.

Unless this is a huge gap in my C knowledge, which is entirely possible,
C doesn't have linked lists.  C has pointers, which can be used to
implement linked lists.  Perl has references, which can be used to
implement linked lists.

> me - But Perl has other data structures that are easier to use than
> linked lists.
> him - So what? Perl still doesn't have linked lists.

You know what they say about arguing with a pig?

> I've never studied linked lists and certainly never coded one (in C or
> anything else) but it aroused my curiosity. So after searching on
> c.l.p.m. and online, I decided to see if I couldn't do a linked list
> in Perl. My first  thought is to do something like this:

see perldoc -q linked for some ideas.

>
> %linked_list{$key} = { prev => $linked_list{$prev_key}{prev},
>                                    value => $value,
>                                    next => $linked_list{$next_key}
> {next}  };


What is this supposed to do?  (Once the %linked_list{ syntax error is
fixed). That is, what is the state of the linked_list supposed to be just
before and just after this code executes?  It seems like node $key is going
to point to previous and next, but previous and next don't point back to
it.  It is hard to see how that is correct.

> I know that most people will think I'm an absolute moron for thinking
> about this (and they likely would be right), but CAN you do a linked
> list in Perl (never mind that you would never want to), and if so, how
> would you go about it?

How I would go about would depend on why I wanted to do it, which I
wouldn't. You could just translate C code to perl, making the syntax
changes needed to change structs to hashes.  It would be horrible memory
inefficient, because a lot of small hashes have too much overhead.  So you
could use parallel hashes %value, %next, and (if doubly-linked) %previous.

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: Wed, 16 Jul 2008 21:06:45 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: C linked lists in Perl
Message-Id: <80ns74dcv0g44a1vq4mtsgml25h3m76lsk@4ax.com>

cartercc <cartercc@gmail.com> wrote:
>I guess like almost everybody, I like to discuss (argue) the merits of
>different technologies. In my world, the big two are Java and
>ColdFusion. Recently, we had someone with a background in embedded
>systems who has been advocating C. The conversation goes something
>like this:
>
>him - Does Perl have linked lists?
>me - No.
>him - Therefore, C is better than Perl because it has linked lists.

Mr. Him is mistaken: C does not have linked lists. It may have
primitives which allow a programmer to create a data structure that
behaves like a linked list. But there is no data type "linked list" in
C.

>me - But Perl has other data structures that are easier to use than
>linked lists.
>him - So what? Perl still doesn't have linked lists.

But Perl has primitives which allow a programmer to create a data
structure that behaves like a linked list. 

>in Perl. My first  thought is to do something like this:
>
>%linked_list{$key} = { prev => $linked_list{$prev_key}{prev},
>                                   value => $value,
>                                   next => $linked_list{$next_key}
>{next}  };

I suppose that may work somehow. 

But why not just use references where in C you would use pointers? Then
a single element would have a reference to the previous and the next
element plus a reference to the data section of this element. 

>I know that most people will think I'm an absolute moron for thinking
>about this (and they likely would be right), but CAN you do a linked
>list in Perl (never mind that you would never want to), and if so, how

Why wouldn't you want to? It's a totally valid request and if the nature
of a problem involves a sequential data structure with frequent add and
remove operations then a linked list should be much faster than doing
those operations on a large array. 

>would you go about it?

Just use Perl references instead of C pointers. The rest is virtually
identical excpet that you as a programmer don't have to worry about
memory management as in C. perl takes care of that for you.

jue


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

Date: 16 Jul 2008 21:15:34 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: C linked lists in Perl
Message-Id: <6e76nmF5n46kU1@mid.uni-berlin.de>

cartercc <cartercc@gmail.com> wrote:
> I guess like almost everybody, I like to discuss (argue) the merits of
> different technologies. In my world, the big two are Java and
> ColdFusion. Recently, we had someone with a background in embedded
> systems who has been advocating C. The conversation goes something
> like this:

> him - Does Perl have linked lists?
> me - No.
> him - Therefore, C is better than Perl because it has linked lists.
> me - But Perl has other data structures that are easier to use than
> linked lists.
> him - So what? Perl still doesn't have linked lists.

As I see it it's actually the other way round. C doesn't
"have" linked lists, i.e. there aren't any built-in fea-
tures in the C language especially made for linked lists.
On the other hand in Perl normal arrays can do what makes
linked lists in C so attractive: you can remove and insert
elements at arbitrary places. So, if your collegue says
that C "has" linked lists then you could very well argue
that that's not true and instead Perl "has" linked lists,
just going by a different name, arrays.

In Perl, you don't have to do any book-keeping for getting
the pointers pointing into the right places. And you don't
have to write any special functions for insertion, deleting,
appending etc. Everything can be done with the functions for
dealing with arrays (push/pop/shift/unshift/splice etc.) In-
stead of explicitely iterating over a linked list you can
use map and grep to write things in a single line of code
for which you would need dozends of lines in C with a linked
list. Actually, you mostly need linked lists in C because
those functionalities aren't available.

But if he insists on what he calls linked lists even then
he isn't right. You can create data structures that are
exactly like traditional linked lists in Perl as easily
as you can do it in C. If you do in C

struct node {
     Payload_T     data
     struct node * next;
};

and then create objects of this type ('strcut node') you can
do in Perl exactly the same

my %elem = ( payload => $date,
             next    => \%some_other_elem );

In C you then would e.g. iterate over the linked list with

for ( l = &list_head; l; l = l->next )
     /* do something here for each elements playload l->data */ ;

while in Perl you could do it with

for ( my $l = \%list_head; $l; $l = $l->{ next } )
     # do something here for each elements payload $l->{ payload }
     ;

Not too much of a difference, is there?

See also 'perldoc perlfaq4' and look for "How do I handle
linked lists?".

Being more a C than a Perl programmer I just can say that in C
I use linked lists all of the time. But in nearly ten years of
dabbling with Perl from time to time I never ever had to resort
to using a traditional kind of linked list...

                           Regards, Jens
-- 
  \   Jens Thoms Toerring  ___      jt@toerring.de
   \__________________________      http://toerring.de


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

Date: Wed, 16 Jul 2008 22:13:51 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: C linked lists in Perl
Message-Id: <ft42l5-t512.ln1@osiris.mauzo.dyndns.org>


Quoth cartercc <cartercc@gmail.com>:
> I guess like almost everybody, I like to discuss (argue) the merits of
> different technologies. In my world, the big two are Java and
> ColdFusion. Recently, we had someone with a background in embedded
> systems who has been advocating C. The conversation goes something
> like this:
> 
> him - Does Perl have linked lists?
> me - No.
> him - Therefore, C is better than Perl because it has linked lists.
> me - But Perl has other data structures that are easier to use than
> linked lists.
> him - So what? Perl still doesn't have linked lists.
> 
> I've never studied linked lists and certainly never coded one (in C or
> anything else) but it aroused my curiosity. So after searching on
> c.l.p.m. and online, I decided to see if I couldn't do a linked list
> in Perl. My first  thought is to do something like this:
> 
> %linked_list{$key} = { prev => $linked_list{$prev_key}{prev},
>                                    value => $value,
>                                    next => $linked_list{$next_key}
> {next}  };

That isn't even valid Perl... more importantly, I don't really
understand what you are trying to do here. A hash full of

    { prev => KEY, next => KEY, value => VALUE }

structures would be one way to do this (using the keys of your master
hash as a substitute for C pointers), but Perl already has a
pointer-substitute: references. The advantage of using references to
otherwise-unreferenced data structures is that when you drop the ref
they will be freed automatically. With your scheme you'd have to
manually delete the entry from the hash.

> I know that most people will think I'm an absolute moron for thinking
> about this (and they likely would be right), but CAN you do a linked
> list in Perl (never mind that you would never want to), and if so, how
> would you go about it?

The simplest implementation of a singly-linked list (as such) in Perl
would be something like (completely untested)

    package LinkedList;

    sub new { return bless [$_[1], undef], $_[0] }

    sub get { return $_[0][0] }

    sub set { $_[0][0] = $_[1] }

    sub next { return $_[0][1] }

    sub insert { 
        my ($self, $value) = @_;
        my $next = $self->next;
        $self->[1] = bless [$value, $next], ref $self;
    }

    sub remove_next {
        my ($self) = @_;
        $self->[1] = $self->next->next;
    }

which you could use like

    my $ll = LinkedList->new(1);

    $ll->insert(2);
    $ll->insert(3);
    $ll->remove_next;
    $ll->insert(4);
    $ll->set(5);

    $\ = "\n";

    # notice how a C-ish structure lends itself to C-ish for loops
    for (my $lp = $ll; $lp->next; $lp = $lp->next) {
        print $lp->get;
    }

which would print

    5
    4
    2

Extending this to a doubly-linked list is trivial for anyone who's ever
written C :). Of course, the most common use of linked lists in C is to
compensate for the fact C arrays don't auto-extend; for these cases, a
Perl array is much more useful, and much faster. However, the
generalisations of linked lists (trees and such, and more general
iterators) are very much useful, and used, in Perl.

Ben

-- 
I have two words that are going to make all your troubles go away.
"Miniature". "Golf".
                                                         [ben@morrow.me.uk]


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

Date: 16 Jul 2008 21:34:03 GMT
From: xhoster@gmail.com
Subject: Re: C linked lists in Perl
Message-Id: <20080716173406.245$NG@newsreader.com>

Jürgen Exner <jurgenex@hotmail.com> wrote:
>
> >I know that most people will think I'm an absolute moron for thinking
> >about this (and they likely would be right), but CAN you do a linked
> >list in Perl (never mind that you would never want to), and if so, how
>
> Why wouldn't you want to? It's a totally valid request and if the nature
> of a problem involves a sequential data structure with frequent add and
> remove operations then a linked list should be much faster than doing
> those operations on a large array.

Maybe, but I'm having a hard time thinking up a real problem that would
benefit in this way.  As long as the add and remove operations are happing
at or near the ends of the list, you would be hard pressed to implement
linked lists in Perl that are faster than perl's splice on a large array.
If you are doing a bunch of adds and removes from the middle of the list,
then splicing a big array would be more problematic.  But with linked
lists, getting to the middle is usually a performance problem in the first
place.

Maybe something where you have two super-imposed data structures.  Like a
cache where you can instantly jump to any node via hash-key, but then
move that node in a LRU linked-list that threads the nodes.

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: Wed, 16 Jul 2008 14:10:30 -0700
From: "Gordon Corbin Etly" <etc@gmail.com>
Subject: Re: FAQ 1.12 What's the difference between "perl" and "Perl"?
Message-Id: <6e76e8F5mepvU1@mid.individual.net>

Ted Zlatanov wrote:
> On Wed, 16 Jul 2008 09:17:40 -0700 "Gordon Corbin Etly" wrote:

> > You at least tried to form a coherent argument, but you failed to
> > prove why it shouldn't be acceptable to write "PERL" just like you
> > can compress other meanings and expansions.

> Right, nor do I care to prove it. It's irrelevant, as I've explained.

Then you concede that this view against "PERL" is indeed a weak on? If 
is wasn't, then there shouldn't be any problem proving it.


> Please look up "shibboleth."

I am quite familiar with the term. Here is the jist of it:

[ http://dictionary.reference.com/search?q=shibboleth ]
" a peculiarity of pronunciation, behavior, mode of dress, etc.,
" that distinguishes a particular class or set of persons


But to use something as a shibboleth (as a say to distinguish "a 
particular class or set of persons") is a very poor measuring stick. 
It's akin to database queries for a table without unique keys. This is 
the point I'm stressing.


--
Gordon C. Etly
Email: perl -e "print q{}.reverse(q{moc.liamg@ylte.nodrog})" 




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

Date: Wed, 16 Jul 2008 14:19:41 -0700
From: "Gordon Corbin Etly" <jdhog@gmail.com>
Subject: Re: FAQ 1.12 What's the difference between "perl" and "Perl"?
Message-Id: <6e76veF5om2cU1@mid.individual.net>

Charlton Wilbur wrote:
>>>>>> "GCE" == Gordon Corbin Etly <cor@gmail.com> writes:

> > Then why suppose this notion that people typing "PERL" is some
> > how inferior. It is little more than a stereotype, and there
> > are several people that push this and essentially tell the
> > person they are replying that "this is how to write it, conform
> > or else". It's this which I believe is just wrong. I have no
> > problems _what_ _so_ _ever_ with correcting people who are
> > doing something wrong. However, typing "PERL" is not a mistake
> > in and of itself; it's a perfectly valid compression and
> > telling random people it is wrong is misleading at best,
> > deceptive at worst.

> I'm not telling you it's *wrong*, for the record.

Fair enough.


> I'm telling you that using it makes you look like someone who's
> inexperienced with Perl,

But, *why*? What *real* connection is there between writing "PERL" and 
being inexperienced? This to me is like writing "SELECT person FROM 
people WHERE person.intelligence < 3 AND person.hasWrittenPERL = 1;" I 
would consider that a poor way to formulate such a statement, as it's 
based entirely on an assumption that is easily wrong (that one cannot be 
intelligent and freethinking and choose to write "Perl" however they 
wish.


> like someone who's never read the FAQ, or

Why is it, again and again, you people seem to mistake the purpose of an 
FAQ; they exist to be guidelines. They were never intended to be 
regarded as a biblical document.


> who's too stubborn to conform to common usage.

IMHO, it takes a strong mind to realize you don't have to conform to 
every single thing a pseudo society says is right or wrong. Those who do 
a little more than sheep.


> These are the three reasons that people commonly use PERL.
> Inexperience, ignorance, intransigence.

This is nothing short of a stereotype. This is no different than saying 
all Mexican's are lazy, wear huge hats, and eat nothing but tacos and 
burritos.


> You may be a brilliant programmer, the best software developer ever,
> but if you use PERL on a resume, in a cover letter, or in an online
> forum, the safe bet is that you're one of the three.  It's not worth
> wasting time to figure out that you're just a free thinker.

shibboleth:
[ http://dictionary.reference.com/search?q=shibboleth ]
" 3. a common saying or belief with little
"    current meaning or truth.


--
Gordon C. Etly
Email: perl -e "print q{}.reverse(q{moc.liamg@ylte.nodrog})" 




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

Date: Wed, 16 Jul 2008 12:25:00 -0700 (PDT)
From: T <g4173c@motorola.com>
Subject: How to identify a 32 or 64 bit OS?
Message-Id: <23bee253-cd16-494a-af99-1ac25364a16d@k13g2000hse.googlegroups.com>

Greetings:

How could I identify if the OS is 32 bit or 64 bit? I need to find a
way to do this that will work on Windows as well as Linux. Thus even
if the processor is 64, you might be running just Windows XP or is it
running Windows XP 64? Same would be true for Linux, although I think
I can use "uname -a" for that. Yes/No?

Thanks in Advance!
   Tom


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

Date: Wed, 16 Jul 2008 21:46:38 +0200
From: Leon Timmermans <fawaka@gmail.com>
Subject: Re: How to identify a 32 or 64 bit OS?
Message-Id: <89438$487e501e$89e0e08f$2685@news1.tudelft.nl>

On Wed, 16 Jul 2008 12:25:00 -0700, T wrote:

> Greetings:
> 
> How could I identify if the OS is 32 bit or 64 bit? I need to find a way
> to do this that will work on Windows as well as Linux. Thus even if the
> processor is 64, you might be running just Windows XP or is it running
> Windows XP 64? Same would be true for Linux, although I think I can use
> "uname -a" for that. Yes/No?
> 
> Thanks in Advance!
>    Tom

I don't know of any portable way to check if the OS is 64, but there is a 
way to check if Perl is compiled with 64bit support.

use Config;
print "64\n" if $Config{use64bitall};

Leon Timmermans


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

Date: Wed, 16 Jul 2008 12:02:36 -0700 (PDT)
From: Kryten <Kryten68@googlemail.com>
Subject: Regular Expression Problem
Message-Id: <c0a150ee-cddd-4714-ae58-b04241eccc98@x35g2000hsb.googlegroups.com>

Hi,
I'd be grateful for assistance with a regular expression problem I
have.

My texttakes the format of:-

aaabbbcccorangesbananashhhjjjapples
qqqqyy333366sssssorangesbananasuuu555449

What I want is to match bananas but only when immediately preceded by
oranges.
So ggggggggeeeeeeeorangestbananasrrrrr would not match. Neither would
ffffiiiiiiiiiiiqa2332332orangebananasjjj33yyttti

is this positive lookbehind? Or am I getting my regex terms mixed up?

Thanks

Stuart



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

Date: Wed, 16 Jul 2008 21:11:11 +0200
From: Dave B <daveb@addr.invalid>
Subject: Re: Regular Expression Problem
Message-Id: <g5lgtc$l2o$1@registered.motzarella.org>

Kryten wrote:

> Hi,
> I'd be grateful for assistance with a regular expression problem I
> have.
> 
> My texttakes the format of:-
> 
> aaabbbcccorangesbananashhhjjjapples
> qqqqyy333366sssssorangesbananasuuu555449
> 
> What I want is to match bananas but only when immediately preceded by
> oranges.
> So ggggggggeeeeeeeorangestbananasrrrrr would not match. Neither would
> ffffiiiiiiiiiiiqa2332332orangebananasjjj33yyttti
> 
> is this positive lookbehind? Or am I getting my regex terms mixed up?

Yes, you need something like

/(?<=oranges)bananas/

(tweak as needed)

-- 
D.


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

Date: Wed, 16 Jul 2008 21:15:02 +0200
From: Leon Timmermans <fawaka@gmail.com>
Subject: Re: Regular Expression Problem
Message-Id: <d5788$487e48b6$89e0e08f$2685@news1.tudelft.nl>

On Wed, 16 Jul 2008 12:02:36 -0700, Kryten wrote:

> Hi,
> I'd be grateful for assistance with a regular expression problem I have.
> 
> My texttakes the format of:-
> 
> aaabbbcccorangesbananashhhjjjapples
> qqqqyy333366sssssorangesbananasuuu555449
> 
> What I want is to match bananas but only when immediately preceded by
> oranges.
> So ggggggggeeeeeeeorangestbananasrrrrr would not match. Neither would
> ffffiiiiiiiiiiiqa2332332orangebananasjjj33yyttti
> 
> is this positive lookbehind? Or am I getting my regex terms mixed up?
> 

In case of positive lookbehind you first search for bananas, and then you 
look back to see if it is preceded by orange. You could use that here, 
but I don't think that that approach is necessary. A simple 
/orangebananas/ would do fine too. Unless mismatching 'orange' is very 
expensive and frequent, I wouldn't recommend using using lookbehinds.

Leon Timmermans


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

Date: Wed, 16 Jul 2008 12:39:32 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: reliability problem with Finance::QuoteHist::Yahoo
Message-Id: <10a4f8a6-453d-46f0-9c92-a7e9339dfc1a@b1g2000hsg.googlegroups.com>

On Jul 16, 7:45=A0am, Ted Byers <r.ted.by...@gmail.com> wrote:
> Hi Peter,
>
> On Jul 16, 5:38=A0am, Peter Scott <Pe...@PSDT.com> wrote:> On Fri, 11 Jul=
 2008 21:53:53 -0700, Ted wrote:
> > > I have been able to get this package to work sometimes. =A0However,
> > > invariably it fails on me part way through my script, after
> > > downloading data for from one to four ticker symbols. =A0The error is=
:
>
> > > Can't use an undefined value as an ARRAY reference at C:/Perl/site/li=
b/
> > > Finance/QuoteHist/Generic.pm line 863.
>
> > Line 863 of the current version of that module does not attempt an arra=
y
> > dereference. =A0Consider upgrading.
>
A little more info...

Adding the following (to the appended script - slightly modified from
that shown above):

BEGIN { $SIG{__DIE__} =3D sub { require Carp; Carp::confess(@_) } }

Provides the following additional output:

Can't use an undefined value as an ARRAY reference at C:/Perl/site/lib/
Finance/QuoteHist/Generic.pm line 863.
 at k:/MarketData/TickerSymbolsTest2.pl line 8
	main::__ANON__('Can\'t use an undefined value as an ARRAY reference
at C:/Per...') called at C:/Perl/site/lib/Finance/QuoteHist/Generic.pm
line 863
=09
Finance::QuoteHist::Generic::lineup('Finance::QuoteHist::Yahoo=3DHASH(0x1a3=
09a8)')
called at C:/Perl/site/lib/Finance/QuoteHist/Generic.pm line 422
	Finance::QuoteHist::Generic::__ANON__() called at C:/Perl/site/lib/
Finance/QuoteHist/Generic.pm line 142
=09
Finance::QuoteHist::Generic::dividends('Finance::QuoteHist::Yahoo=3DHASH(0x=
1a309a8)')
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.  Is there a way to query yahoo to find out the
inception date of a given ticker?  If I had that, and provided it as
the start date, maybe that would clear things up to where this could
be useful.

Thanks

Ted
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3Dnew little
script=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
use Finance::TickerSymbols;
use Finance::QuoteHist::Yahoo;
use IO::File;
use Date::Manip;

$|=3D1;

BEGIN { $SIG{__DIE__} =3D sub { require Carp; Carp::confess(@_) } }

Date_Init("TZ=3DEST5EDT");
my $date =3D ParseDate('today');
$date =3D Date_PrevWorkDay($date,1);

my $fname1;
my $fname2;
my $fname3;

for my $industry ( industries_list()) {
  print "\n\n$industry\n";
  mkdir "$industry";
  for my $symbol ( industry_list( $industry ) ) {
    print "$symbol\n\n";
    mkdir "$industry\\$symbol";
    $fname1 =3D "$industry\\$symbol\\values.csv";
    $fname2 =3D "$industry\\$symbol\\splits.csv";
    $fname3 =3D "$industry\\$symbol\\dividends.csv";
    $fh1 =3D new IO::File "> $fname1";
    $fh2 =3D new IO::File "> $fname2";
    $fh3 =3D new IO::File "> $fname3";
print "flag 1\n";
    $q =3D new Finance::QuoteHist::Yahoo
      (
       symbols    =3D> "$symbol",
       end_date   =3D> $date
      );
print "flag 2\t";
    # Values
    foreach $row ($q->quotes()) {
print "flag 2a\t";
      if (defined $row ) {
        ($symbol, $date, $open, $high, $low, $close, $volume) =3D @$row;
        print $fh1 "$symbol, $date, $open, $high, $low, $close, $volume
\n";
print "flag 2b\n";
      } else {
	print "No data for $symbol\n";
	next;
      }
    }
print "flag 3\t";
    $fh1->close();
    foreach $row ($q->splits()) {
      if (defined $row ) {
        ($symbol, $date, $post, $pre) =3D @$row;
        print $fh2 "$symbol, $date, $post, $pre\n";
      } else {
	print "No splits data for $symbol\n";
	next;
      }
    }
print "flag 4\n";
    $fh2->close();
    foreach $row ($q->dividends()) {
      if (defined $row ) {
        ($symbol, $date, $dividend) =3D @$row;
        print $fh3 "$symbol, $date, $dividend\n";
      } else {
	print "No dividend data for $symbol\n";
	next;
      }
    }
    $fh3->close();
print "flag 5\n";
  }
}



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

Date: Wed, 16 Jul 2008 14:52:06 -0500
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: reliability problem with Finance::QuoteHist::Yahoo
Message-Id: <160720081452063067%brian.d.foy@gmail.com>

In article
<f7d07b56-bd0b-40d3-9518-a4c01261ac99@e53g2000hsa.googlegroups.com>,
Ted Byers <r.ted.byers@gmail.com> wrote:

> I have often used data source modules to provide simulated data for my
> models, but I don't really want to try to simulate such data at this
> time (unless there is a library that facilitates creationg of
> multifractal brownian motion, 

I think you're over thinking it.

Grab a bunch of historical data however you like. Add any special cases
you like. Write a module to return records at the unit test level.

The simulation is just fetching records, not creating data.


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

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


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