[30476] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1719 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 15 11:09:54 2008

Date: Tue, 15 Jul 2008 08: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           Tue, 15 Jul 2008     Volume: 11 Number: 1719

Today's topics:
        comma quoted lists question <cartercc@gmail.com>
    Re: comma quoted lists question <1usa@llenroc.ude.invalid>
    Re: comma quoted lists question <r.ted.byers@gmail.com>
    Re: comma quoted lists question xhoster@gmail.com
    Re: Does Perl 5.8.0 contain symbol Perl_sv_2pv? <benkasminbullock@gmail.com>
    Re: Does Perl 5.8.0 contain symbol Perl_sv_2pv? <sisyphus359@gmail.com>
    Re: Does Perl 5.8.0 contain symbol Perl_sv_2pv? <ben@morrow.me.uk>
        Fastest way to remove common substrings from a list of  <freesoft12@gmail.com>
    Re: Fastest way to remove common substrings from a list <wahab@chemie.uni-halle.de>
    Re: Fastest way to remove common substrings from a list <daveb@addr.invalid>
    Re: Fastest way to remove common substrings from a list <daveb@addr.invalid>
    Re: Fastest way to remove common substrings from a list <glennj@ncf.ca>
    Re: Generating fancy/pretty documents <cartercc@gmail.com>
    Re: installing perl modules on windows <ben@morrow.me.uk>
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@seesig.invalid
    Re: reliability problem with Finance::QuoteHist::Yahoo <r.ted.byers@gmail.com>
        use/require, and variables <nick@maproom.co.uk>
    Re: use/require, and variables <noreply@gunnar.cc>
    Re: use/require, and variables <glennj@ncf.ca>
    Re: use/require, and variables <noreply@gunnar.cc>
    Re: use/require, and variables <cmic@caramail.com>
    Re: use/require, and variables <nick@maproom.co.uk>
    Re: use/require, and variables <bmb@mail.libs.uga.edu>
    Re: use/require, and variables <ben@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 15 Jul 2008 06:09:10 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: comma quoted lists question
Message-Id: <ab3658b8-f57b-4277-a49d-92d44062d8fb@i76g2000hsf.googlegroups.com>

I create and deliver CSV files like this:
"12345","John","Q","Public","123 Main Street","Anywhere,
Alaska","800-555-1212"
I create this in my program as a seven element array. Users modify the
files, frequently using Excel, and return the files to me.

Sometimes I get the original format back.

Sometimes, Excel will mangle the file to this:
12345,John,Q,Public,123 Main Street,"Anywhere, Alaska",800-555-1212
My script will read this as an eight element array (splitting
"Anywhere, Alaska" on the comma).

Sometimes Excel will produce a tab delimited file like this:
12345 John Q Public 123 Main Street "Anywhere, Alaska" 800-555-1212
My script will read this as a two element array.

My users like to use Excel and I am not inclined to tell them they
can't, nor am I inclined to 'educate' them on making sure that Excel
doesn't change the file format. They honestly need the filtering and
sorting capabilities that Excel provides, as some of these files are
106 columns wide and thousands of rows deep. I have error checking in
place that rejects improperly formed files, which I define as
producing anything other than an X element array. However, this isn't
satisfactory, because I have the burden of reformatting the file.

Comments? Suggestions? Any module that automagically reformats files?
Will I have to write a reformatting script myself?

Thanks, CC.


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

Date: Tue, 15 Jul 2008 14:52:04 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: comma quoted lists question
Message-Id: <Xns9ADC6E8CBC43asu1cornelledu@127.0.0.1>

cartercc <cartercc@gmail.com> wrote in news:ab3658b8-f57b-4277-a49d-
92d44062d8fb@i76g2000hsf.googlegroups.com:

> I create and deliver CSV files like this:
> "12345","John","Q","Public","123 Main Street","Anywhere,
> Alaska","800-555-1212"
> I create this in my program as a seven element array. Users modify the
> files, frequently using Excel, and return the files to me.
> 
> Sometimes I get the original format back.
> 
> Sometimes, Excel will mangle the file to this:
> 12345,John,Q,Public,123 Main Street,"Anywhere, Alaska",800-555-1212
> My script will read this as an eight element array (splitting
> "Anywhere, Alaska" on the comma).

Use Text::CSV_XS instead of naively splitting on the comma.

> Sometimes Excel will produce a tab delimited file like this:
> 12345 John Q Public 123 Main Street "Anywhere, Alaska" 800-555-1212
> My script will read this as a two element array.

Again, use Text::CSV_XS bu specify the tab character as the separator 
instead of naively splitting on the comma.

> My users like to use Excel and I am not inclined to tell them they
> can't,

Why is this relevant?

> nor am I inclined to 'educate' them on making sure that Excel
> doesn't change the file format.

Changing from a comma to tab separated file requires explicit user 
action in Excel. So, you might want to tell them to save as CSV.

<snip>

Sinan


-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


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

Date: Tue, 15 Jul 2008 07:53:03 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: comma quoted lists question
Message-Id: <09edc90e-be8f-4a0d-9e73-39969a54bc17@z66g2000hsc.googlegroups.com>

On Jul 15, 9:09=A0am, cartercc <carte...@gmail.com> wrote:
> I create and deliver CSV files like this:
> "12345","John","Q","Public","123 Main Street","Anywhere,
> Alaska","=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0800-555-1212=A0=A0=A0=
=A0=A0=A0=A0"
> I create this in my program as a seven element array. Users modify the
> files, frequently using Excel, and return the files to me.
>
> Sometimes I get the original format back.
>
> Sometimes, Excel will mangle the file to this:
> 12345,John,Q,Public,123 Main Street,"Anywhere, Alaska",=A0=A0=A0=A0=A0=A0=
=A0=A0=A0=A0=A0=A0=A0=A0800-555-1212=A0=A0=A0=A0=A0=A0=A0
> My script will read this as an eight element array (splitting
> "Anywhere, Alaska" on the comma).
>
> Sometimes Excel will produce a tab delimited file like this:
> 12345 John Q Public 123 Main Street "Anywhere, Alaska" 800-555-1212
> My script will read this as a two element array.
>
> My users like to use Excel and I am not inclined to tell them they
> can't, nor am I inclined to 'educate' them on making sure that Excel
> doesn't change the file format. They honestly need the filtering and
> sorting capabilities that Excel provides, as some of these files are
> 106 columns wide and thousands of rows deep. I have error checking in
> place that rejects improperly formed files, which I define as
> producing anything other than an X element array. However, this isn't
> satisfactory, because I have the burden of reformatting the file.
>
> Comments? Suggestions? Any module that automagically reformats files?
> Will I have to write a reformatting script myself?
>
> Thanks, CC.

That you get multiple formats, such as optionally quoted fields or tab
delimited fields, suggests that user education in the use of Excel is
warranted.  Excel will only do what the users tell it to do, so the
problem is what your users are doing, not what Excel actually does.
But if you don't want to provide that education, you have no option
but to test for the format used yourself, or load the files into Excel
yourself, when you get them, and then re-export them in the format you
require.  To automagically handle this task in your script, regular
expressions are priceless.  You know what delimiters are possible, so
count each in turn, to see what had been used in the file you're
processing.  You can use a regular expression to escape delimiters,
such as commas, that appear within quotes.  Your options are
limitless.  You just have to pick one, and write code to do it.

You don't say what perl packages you use, but there are quite a number
(too many to list here) that make parsing delimited files easier.

HTH

Ted


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

Date: 15 Jul 2008 15:06:54 GMT
From: xhoster@gmail.com
Subject: Re: comma quoted lists question
Message-Id: <20080715110655.429$kY@newsreader.com>

cartercc <cartercc@gmail.com> wrote:
> I create and deliver CSV files like this:
> "12345","John","Q","Public","123 Main Street","Anywhere,
> Alaska","800-555-1212"
> I create this in my program as a seven element array. Users modify the
> files, frequently using Excel, and return the files to me.
>
> Sometimes I get the original format back.
>
> Sometimes, Excel will mangle the file to this:
> 12345,John,Q,Public,123 Main Street,"Anywhere, Alaska",800-555-1212
> My script will read this as an eight element array (splitting
> "Anywhere, Alaska" on the comma).

How do you avoid splitting that on that comma in the first case,
where all fields are quoted rather than just that one?  If it works
in the first case, it should work in the second case.  I'm guessing you
aren't using one of the standard modules for processing CSV?

>
> Sometimes Excel will produce a tab delimited file like this:
> 12345 John Q Public 123 Main Street "Anywhere, Alaska" 800-555-1212
> My script will read this as a two element array.

So then split on tabs instead when you see that the line has the right
number of tabs in it.

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: Tue, 15 Jul 2008 12:55:11 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: Does Perl 5.8.0 contain symbol Perl_sv_2pv?
Message-Id: <g5i6nf$d39$1@cgi-ml.accsnet.ne.jp>

On Mon, 14 Jul 2008 19:52:30 -0700, DirtyBear wrote:

> Why is Perl 5.8.0 so strange? How to resolve this problem?

Perhaps I'm making a stupid comment, because possibly you know that Perl 
is now on 5.10 and the 5.8 version of Perl is at version 5.8.8. I know 
that 5.8.0 had some bugs in it. If you want to build Perl from source, it 
might be a wise idea to build a more recent version.


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

Date: Tue, 15 Jul 2008 06:09:13 -0700 (PDT)
From: sisyphus <sisyphus359@gmail.com>
Subject: Re: Does Perl 5.8.0 contain symbol Perl_sv_2pv?
Message-Id: <da975fa3-5eda-41ae-8fdd-c0ad52cc87d3@k37g2000hsf.googlegroups.com>

On Jul 15, 12:52=A0pm, DirtyBear <zx.zhangxi...@gmail.com> wrote:
> Hi friends,
>
> Perl 5.8.0 seems a bit strange. I encounterred a trouble in my dynamic
> library which uses this symbol of Perl:
> ld.so.1: perl: fatal: relocation error: file /opt/mylib/libAPIPerl.so:
> symbol Perl_sv_2pv: referenced symbol not found
=2E
=2E
> Why is Perl 5.8.0 so strange? How to resolve this problem?
>

I find the same thing on Win32. Seems that Perl_sv_2pv was removed for
perl 5.8.0, and then reinstated for subsequent builds. (I don't know
why.)
If you need to have your code work on perl 5.8.0 then one way would be
to use something other than Perl_sv_2pv to do the job.

The perl 5.8.8 source file sv.h contains:

#define sv_2pv(sv, lp) sv_2pv_flags(sv, lp, SV_GMAGIC)

So you may just need to replace all of your "sv_2pv(sv, lp)" calls
with "sv_2pv_flags(sv, lp, SV_GMAGIC)". That's assuming that
sv_2pv_flags exists throughout the full range of perl versions that
you need to support. (I haven't checked to see whether that's the
case.)

Cheers,
Rob


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

Date: Tue, 15 Jul 2008 14:17:34 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Does Perl 5.8.0 contain symbol Perl_sv_2pv?
Message-Id: <ekkuk5-223.ln1@osiris.mauzo.dyndns.org>


Quoth DirtyBear <zx.zhangxiong@gmail.com>:
> 
> Perl 5.8.0 seems a bit strange. I encounterred a trouble in my dynamic
> library which uses this symbol of Perl:
> ld.so.1: perl: fatal: relocation error: file /opt/mylib/libAPIPerl.so:
> symbol Perl_sv_2pv: referenced symbol not found
> Killed
> 
<snip>
> But from perl5.6.1 to perl 5.8.8, I can find the reference in every
> release except 5.8.0.

From perl581delta:

| APIs obsoleted in Perl 5.8.0, like sv_2pv, sv_catpvn, sv_catsv,
| sv_setsv, are again available.

So it seems that removing these entry points, like a number of other
changes made in 5.8.0, was considered a bad idea and reverted for 5.8.1.
5.8.0 is well known to be quite buggy; it's a bad idea to use it. Unless
you have a strong reason not to, you should be using 5.8.8; otherwise,
use 5.8.1.

Ben

-- 
BEGIN{*(=sub{$,=*)=sub{print@_};local($#,$;,$/)=@_;for(keys%{ #ben@morrow.me.uk
$#}){/m/&&next;**=${$#}{$_};/(\w):/&&(&(($#.$_,$;.$+,$/),next);$/==\$*&&&)($;.$
_)}};*_=sub{for(@_){$|=(!$|||$_||&)(q) )));&((q:\:\::,q,,,\$_);$_&&&)("\n")}}}_
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $,


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

Date: Tue, 15 Jul 2008 06:02:38 -0700 (PDT)
From: "freesoft12@gmail.com" <freesoft12@gmail.com>
Subject: Fastest way to remove common substrings from a list of strings
Message-Id: <1d887445-3277-4e77-9251-d5e6eeaac143@k30g2000hse.googlegroups.com>

Hi,

Given a list containing various UNIX directory paths:

@list = qw(
/home/bart
/home/bart/foo
/usr/lib/
/home/bart/foo/xyz
/home/bart/foo/xyz/live.cpp )

I want to trim this list to contain:

@list = qw(
/usr/lib/
/home/bart/foo/xyz/live.cpp )

Is there a better way than this possibly n^2 algorithm below.

my @to_be_removed_indices = ();
for (my $index=0; $index < #list; ++$index) {
    my $current_item = $list[$index];
   ++$index;
   for (my $j = $index; $j < $#list; ++$j) {
      if ($current_item =~ m/$list[$j]/) {   # is the current item a
substring of another
         push (@to_be_removed_indices, $index); # schedule its removal
         last; # break
     }
}
# Remove matched items

Regards
John


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

Date: Tue, 15 Jul 2008 16:04:10 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Fastest way to remove common substrings from a list of strings
Message-Id: <g5iaoq$1ka1$1@nserver.hrz.tu-freiberg.de>

freesoft12@gmail.com wrote:
> Hi,
> 
> Given a list containing various UNIX directory paths:
> 
> @list = qw(
> /home/bart
> /home/bart/foo
> /usr/lib/
> /home/bart/foo/xyz
> /home/bart/foo/xyz/live.cpp )
> 
> I want to trim this list to contain:
> 
> @list = qw(
> /usr/lib/
> /home/bart/foo/xyz/live.cpp )
> 
> Is there a better way than this possibly n^2 algorithm below.

Still pseudo O(2), but much shorter:

    ...
    foreach my $k (@list) {
       $k = undef if grep defined && /^$k./, @list;
    }

    print join "\n", grep defined, @list;
    ...

Regards

M.



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

Date: Tue, 15 Jul 2008 16:47:17 +0200
From: Dave B <daveb@addr.invalid>
Subject: Re: Fastest way to remove common substrings from a list of strings
Message-Id: <g5idah$e47$1@registered.motzarella.org>

freesoft12@gmail.com wrote:
> Hi,
> 
> Given a list containing various UNIX directory paths:
> 
> @list = qw(
> /home/bart
> /home/bart/foo
> /usr/lib/
> /home/bart/foo/xyz
> /home/bart/foo/xyz/live.cpp )
> 
> I want to trim this list to contain:
> 
> @list = qw(
> /usr/lib/
> /home/bart/foo/xyz/live.cpp )
> 
> Is there a better way than this possibly n^2 algorithm below.
> 
> my @to_be_removed_indices = ();
> for (my $index=0; $index < #list; ++$index) {
>     my $current_item = $list[$index];
>    ++$index;
>    for (my $j = $index; $j < $#list; ++$j) {
>       if ($current_item =~ m/$list[$j]/) {   # is the current item a
> substring of another
>          push (@to_be_removed_indices, $index); # schedule its removal
>          last; # break
>      }
> }
> # Remove matched items

If your condition is "remove a string if it's a substring of another,
matching *at the beginning*", then the following code seems to work:

my @list = sort qw(
/home/bart
/home/bart/foo
/usr/lib/
/home/bart/foo/xyz
/home/bart/foo/xyz/live.cpp );

my $s=$list[0];
my @newlist;

for (@list, substr($list[-1],1)) {
  push(@newlist,$s) unless /$s/;
  $s=$_;
}

print "@newlist\n";

# now @newlist has the values that are not
# substring of anything else

I hope I understood the problem correctly.

-- 
D.


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

Date: Tue, 15 Jul 2008 17:02:10 +0200
From: Dave B <daveb@addr.invalid>
Subject: Re: Fastest way to remove common substrings from a list of strings
Message-Id: <g5ie6e$hqi$1@registered.motzarella.org>

Dave B wrote:

>   push(@newlist,$s) unless /$s/;

This is probably better and safer:

   push(@newlist,$s) unless /^\Q$s\E/;

-- 
D.


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

Date: 15 Jul 2008 15:04:45 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: Fastest way to remove common substrings from a list of strings
Message-Id: <slrng7pf4e.6vn.glennj@smeagol.ncf.ca>

At 2008-07-15 09:02AM, "freesoft12@gmail.com" wrote:
>  Hi,
>  
>  Given a list containing various UNIX directory paths:
>  
>  @list = qw(
>  /home/bart
>  /home/bart/foo
>  /usr/lib/
>  /home/bart/foo/xyz
>  /home/bart/foo/xyz/live.cpp )
>  
>  I want to trim this list to contain:
>  
>  @list = qw(
>  /usr/lib/
>  /home/bart/foo/xyz/live.cpp )

    my @uniq;
    my $prev = '';
    foreach my $dir (reverse sort @list) {
        unless ($prev =~ /^$dir/) {
            push @uniq, $dir;
            $prev = $dir;
        }
    }


-- 
Glenn Jackman
    Write a wise saying and your name will live forever. -- Anonymous


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

Date: Tue, 15 Jul 2008 06:29:27 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: Re: Generating fancy/pretty documents
Message-Id: <8891c9ed-0df4-465e-b49a-babe20d87f0f@l42g2000hsc.googlegroups.com>

On Jul 5, 9:52 am, Bernie Cosell <ber...@fantasyfarm.com> wrote:
> "pretty" PDF or ODF document directly?  I see there's a suite of modules
> PDF::API2 -- it looks pretty complicated....anyone used that?

I use PDF::API2 to generate hundreds of PDF files from one input file.
PDF::API2 is simple to use for text, images, and simple geographic
shapes, which meets my needs. If you email me privately, I'll send you
my script. Use c c c 3 1 8 0 7 @ y a h o o . c o m

CC


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

Date: Tue, 15 Jul 2008 14:23:26 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: installing perl modules on windows
Message-Id: <evkuk5-223.ln1@osiris.mauzo.dyndns.org>


Quoth gsa <hsggwk@gmail.com>:
> Hi all,
>          I am having to install the CGI module on a Windows XP machine
> and it is very frustrating. I read that I should use the PPM to
> install it, but the CGI module doesn't show up on the list of packages
> that PPM can install. So I tried installing manually by downloading
> the module and installing using nmake, dname, make.. none of which
> work. I get a message saying "nmake" is not a recognized command. I
> have installed perl modules on MACs a number of times and CPAN.pm
> works like a dream. This is very frustrating and I would appreciate
> any help in this regard. Thanks in advance for all your help.

perldoc perlwin32 tells you you can get nmake from
http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN‐US/nmake15.exe
 . If you want to use CPAN rather than PPM, I would strongly recommend
using Strawberry Perl rather than ActiveState: building XS modules with
ActiveState will require an installed copy of MSVC6 (the freely
available copies of MSVC7 and 8 will *not* work). ActiveState have
modified Config.pm so that it adjusts itself for gcc if it's in your
path, but IME it isn't completely reliable. Strawberry Perl, OTOH, is
bundled with the copy of gcc (and dmake, binutils, &c.) used to build
the binaries, so everything works as expected.

Ben

-- 
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk


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

Date: Tue, 15 Jul 2008 07:10:46 GMT
From: tadmc@seesig.invalid
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.8 $)
Message-Id: <W3Yek.16408$89.13984@nlpi069.nbdc.sbc.com>

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.8 $)
    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.

    The article at:

        http://www.catb.org/~esr/faqs/smart-questions.html

    describes how to get answers from technical people in general.

    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://www.rehabitation.com/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 that they do 
       know and are being the "bad kind" of Lazy.

    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
        "top-posting", "Jeopardy" (because the answer comes before the
        question), or "TOFU" (Text Over, Fullquote Under).

        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 and many others on the comp.lang.perl.misc newsgroup.

-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Tue, 15 Jul 2008 06:38:17 -0700 (PDT)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: reliability problem with Finance::QuoteHist::Yahoo
Message-Id: <139c6723-6a71-423c-9769-bbfc48fb2b89@d45g2000hsc.googlegroups.com>

On Jul 14, 6:23=A0pm, Jim Cochrane <allergic-to-s...@no-spam-
allowed.invalid> wrote:
> On 2008-07-14, smallpond <smallp...@juno.com> wrote:
>
>
>
>
>
> > 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/lib=
/
> >> Finance/QuoteHist/Generic.pm line 863.
>
> >> I have no information about how an undefined value is being passed
> >> deep into the code of a package I didn't write. =A0I took a quick look
> >> into Generic.pm and yahoo.pm, but found no enlightenment so far
> >> (there's a lot of code there).
>
> >> Sometimes it arises when quotes() is executed, and at other times, it
> >> occurs when dividends() is executed.
> >> ...
>
> > Without even looking at your code my guess is that Yahoo! is not partic=
ularly
> > pleased about providing an ad-sponsored service to web-scrapers. =A0Par=
t of the
> > reason that free services change their page format is to block people f=
rom
> > doing this. =A0Yahoo! changes their page format fairly frequently and I=
'm willing
> > to bet that their web programmers have access to CPAN. =A0If you need 7=
000 quotes
> > then its pretty clearly not for your personal portfolio. =A0Maybe time =
for your
> > company to invest in a quote service.
>
> If you have good software, configured to do intensive filtering, data
> for 7000 tradables can be easily managable for an individual trader.
> On the other hand, if an individual trader needs a reliable and accurate
> data feed for automated analysis, a free yahoo service is probably a
> poor choice.
>
> It sounds like the package in question is not as robust as it could be,
> allowing the user to encounter a run-time undefined value error instead
> of producing a good error message. =A0However, yahoo changing the server'=
s
> behavior or data format seems a likely initial cause of the problem.
>
> --- Hide quoted text -
>
> - Show quoted text -

This project is at its beginning, proof of concept, stage.   The plan
was to do an initial test using data from yahoo, and then proceed to
buying a datafeed from a commercial source.

We have had another project downloading a paltry 500 stocks daily for
about a year, without change or problem, but it doesn't get the data
for splits and dividends and it is written in PHP which I have never
used.  I'd thought, given the original programmer's tedious task of
manually finding new stocks to add to the download, and the
documentaton for these packages, rewriting in perl would be the path
of least pain.  But, it looks like I may have to write my own code to
do what this package does, so at least I can get a sensible error
message.

Cheers,

Ted


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

Date: Tue, 15 Jul 2008 10:48:27 +0100
From: Nick Wedd <nick@maproom.co.uk>
Subject: use/require, and variables
Message-Id: <xQ++ZoerJHfIFAEZ@maproom.demon.co.uk>

I have always found that putting "use strict" makes life easier for me.

But now, I am trying to use what C programmers call "#include".  I have 
a "main.pl" file, which needs to include another file where values are 
assigned to a variable.  I have tried all combinations of
   use "includedfile.pl"   or   require "includedfile.pl"
   declaring the variable (a hash) in the main file, or the included file
   declaring the variable  before or after the use/require statement
   declaring the variable as "my" or as "local"
but whatever I try, Perl complains about uninitialised or undeclared 
variables.

I have found that if I don't declare my hash at all, and use
'require "includedfile.pl"', it behaves as I want, the values assigned 
in the included file are usable in the main file.  Of course, failing to 
declare a variable means I can't use 'use strict'.

So, I would like to know what the recommended way is of declaring the 
kind of variable that you get when you just use one without declaring 
it.  This way, I would be able to have my #include working and still 
have "use strict" there to help me.

Nick
-- 
Nick Wedd    nick@maproom.co.uk


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

Date: Tue, 15 Jul 2008 12:05:26 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: use/require, and variables
Message-Id: <6e3b3gF51g4fU1@mid.individual.net>

Nick Wedd wrote:
> I have always found that putting "use strict" makes life easier for me.
> 
> But now, I am trying to use what C programmers call "#include".  I have 
> a "main.pl" file, which needs to include another file where values are 
> assigned to a variable.

It's not crystal clear what you mean - some code would have been nice - 
but...

> I have found that if I don't declare my hash at all, and use 
> 'require "includedfile.pl"', it behaves as I want, the values assigned 
> in the included file are usable in the main file.  Of course, failing to 
> declare a variable means I can't use 'use strict'.

I suppose you can declare the variable in main.pl with "our".

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 15 Jul 2008 10:53:50 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: use/require, and variables
Message-Id: <slrng7p0e0.6vn.glennj@smeagol.ncf.ca>

At 2008-07-15 05:48AM, "Nick Wedd" wrote:
>  I have always found that putting "use strict" makes life easier for me.
>  
>  But now, I am trying to use what C programmers call "#include".  I have 
>  a "main.pl" file, which needs to include another file where values are 

    do 'otherfile';

-- 
Glenn Jackman
    Write a wise saying and your name will live forever. -- Anonymous


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

Date: Tue, 15 Jul 2008 13:12:29 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: use/require, and variables
Message-Id: <6e3f18F5519tU1@mid.individual.net>

Glenn Jackman wrote:
> At 2008-07-15 05:48AM, "Nick Wedd" wrote:
>>  I have always found that putting "use strict" makes life easier for me.
>>  
>>  But now, I am trying to use what C programmers call "#include".  I have 
>>  a "main.pl" file, which needs to include another file where values are 
> 
>     do 'otherfile';

You need to declare the variable under strict 'vars' whether you do() or 
require() the file.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Tue, 15 Jul 2008 05:25:57 -0700 (PDT)
From: cmic <cmic@caramail.com>
Subject: Re: use/require, and variables
Message-Id: <b69cdd30-0a66-4a23-a17a-24b50091e822@y21g2000hsf.googlegroups.com>

On 15 juil, 11:48, Nick Wedd <n...@maproom.co.uk> wrote:
> I have always found that putting "use strict" makes life easier for me.
 ....snip
>
> So, I would like to know what the recommended way is of declaring the
> kind of variable that you get when you just use one without declaring
> it.  This way, I would be able to have my #include working and still
> have "use strict" there to help me.

Don't know if this is the "recommended way",
but you can do this way:

#!/usr/local/bin/perl
use warnings;
use strict;

use vars qw(%docs $style);
do "./variables.conf";

print $style, "\n";
print $docs{def}, "\n";
__END__

And the file variables.conf:
#
$style="free";
%docs=(abc => 111, def => 222);
#

though there might be other ways to do this.
Regards
--
michel marcon, sysadmin
>
> Nick
> --
> Nick Wedd    n...@maproom.co.uk



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

Date: Tue, 15 Jul 2008 13:29:17 +0100
From: Nick Wedd <nick@maproom.co.uk>
Subject: Re: use/require, and variables
Message-Id: <+xDtBzgdgJfIFAG4@maproom.demon.co.uk>

In message <6e3b3gF51g4fU1@mid.individual.net>, Gunnar Hjalmarsson
<noreply@gunnar.cc> writes
>Nick Wedd wrote:
>> I have always found that putting "use strict" makes life easier for me.
>>  But now, I am trying to use what C programmers call "#include".  I
>>have  a "main.pl" file, which needs to include another file where
>>values are  assigned to a variable.
>
>It's not crystal clear what you mean - some code would have been nice -
>but...

Ok.  main.pl says, among other things,
  require "freqs.pl";
  $w += @{$indfreq{"foo"}}[5];
and freqs.pl has many lines such as
  $indfreq{"foo"} = [ 0, 0, 0, 0, 19440, 68160, 54960, 8640 ];
  $indfreq{"bar"} = [ 0, 0, 0, 0, 14400, 67800, 59640, 9360 ];

>> I have found that if I don't declare my hash at all, and use
>>'require "includedfile.pl"', it behaves as I want, the values assigned
>>in the included file are usable in the main file.  Of course, failing
>>to  declare a variable means I can't use 'use strict'.
>
>I suppose you can declare the variable in main.pl with "our".

Thank you!  Using "our" works and is compatible with "use strict".  I
must look up what "our" does, it seems to be more recent than my
reference books.

Nick
-- 
Nick Wedd    nick@maproom.co.uk


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

Date: Tue, 15 Jul 2008 09:11:10 -0400
From: Brad Baxter <bmb@mail.libs.uga.edu>
Subject: Re: use/require, and variables
Message-Id: <%k1fk.1561$w93.1007@bignews4.bellsouth.net>

Nick Wedd wrote:
> I have found that if I don't declare my hash at all, and use
> 'require "includedfile.pl"', it behaves as I want, the values assigned 
> in the included file are usable in the main file.  Of course, failing to 
> declare a variable means I can't use 'use strict'.

Others have suggested 'use vars' and 'our', which answers your
question.  I wanted to comment a little bit about why.  If I
run this program:

   require 'qt.data';

   print "$_\n" for $bird, $fish, $worm;

   __END__
   contents of qt.data:
   ---
   $bird = 'canary';
   $fish = 'tuna';
   $worm = 'nematode';
   1;
   ---

it prints:

canary
tuna
nematode

without errors.  Note that neither the program nor the data
file have 'use strict'.  The reason this works is that perl
is simply allowing you to refer to those global variables
without explicit package names.

If I add 'use strict', I can still print the values if I
provide explicit package names:

   use strict;
   require 'qt.data';

   print "$_\n" for $main::bird, $main::fish, $main::worm;

prints the values without errors.

If I add 'use vars' or 'our', I can dispense with the explicit
package names:

   use strict;
   our( $bird, $fish, $worm );
   require 'qt.data';

   print "$_\n" for $bird, $fish, $worm;

The construct 'use vars' predates 'our' to do the same thing.

Be aware that this only works with global variables.  If the
data file were instead:

my $bird = 'canary';
my $fish = 'tuna';
my $worm = 'nematode';
1;

not even 'our' will let your program see those values.

I suggest that you use a configuration file module.

Cheers,

-- 
Brad


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

Date: Tue, 15 Jul 2008 14:26:05 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: use/require, and variables
Message-Id: <d4luk5-223.ln1@osiris.mauzo.dyndns.org>


Quoth Nick Wedd <nick@maproom.co.uk>:
> I have always found that putting "use strict" makes life easier for me.
> 
> But now, I am trying to use what C programmers call "#include".  I have 
> a "main.pl" file, which needs to include another file where values are 
> assigned to a variable.  I have tried all combinations of
>    use "includedfile.pl"   or   require "includedfile.pl"
>    declaring the variable (a hash) in the main file, or the included file
>    declaring the variable  before or after the use/require statement
>    declaring the variable as "my" or as "local"
> but whatever I try, Perl complains about uninitialised or undeclared 
> variables.

It is better to write a proper module you can 'use' which exports the
variables than to use 'require'. See perldoc perlnewmod and perldoc
Exporter.

Ben

-- 
Like all men in Babylon I have been a proconsul; like all, a slave ... During
one lunar year, I have been declared invisible; I shrieked and was not heard,
I stole my bread and was not decapitated.
~ ben@morrow.me.uk ~                   Jorge Luis Borges, 'The Babylon Lottery'


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

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


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