[30687] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1932 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 19 00:09:45 2008

Date: Sat, 18 Oct 2008 21:09:09 -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           Sat, 18 Oct 2008     Volume: 11 Number: 1932

Today's topics:
    Re: "Escape" in perl <tadmc@seesig.invalid>
    Re: "Escape" in perl <hjp-usenet2@hjp.at>
    Re: "Escape" in perl <tadmc@seesig.invalid>
    Re: "Escape" in perl <hjp-usenet2@hjp.at>
    Re: "Escape" in perl <whynot@pozharski.name>
    Re: "Escape" in perl <tadmc@seesig.invalid>
        DBI module: can't pass argument to "in (?)" clause <dn.perl@gmail.com>
    Re: DBI module: can't pass argument to "in (?)" clause <mgjv@tradingpost.com.au>
    Re: DBI module: can't pass argument to "in (?)" clause <bwalton@nospam.invalid>
    Re: Help: How to install a *.pm module <openlinuxsource@gmail.com>
    Re: Help: How to install a *.pm module <jurgenex@hotmail.com>
    Re: Help: How to install a *.pm module (fidokomik\)
    Re: Help: How to install a *.pm module <tadmc@seesig.invalid>
    Re: Help: How to install a *.pm module <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: Help: How to install a *.pm module (fidokomik\)
    Re: Help: How to install a *.pm module <whynot@pozharski.name>
    Re: Need help on AoH or array or any other think that m <jurgenex@hotmail.com>
        Procedural interface to mysql <usenet@larseighner.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 18 Oct 2008 07:58:16 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: "Escape" in perl
Message-Id: <slrngfjnb8.a65.tadmc@tadmc30.sbcglobal.net>

Bill H <bill@ts1000.us> wrote:


> I have been meaning to post a question / request about perldocs on
> here but keep forgeting. It would be immensely helpful to me, and no
> doubt others on here, to have a good description of how to get
> information out of perldocs.


I'll offer what help I can below.


> I have fumbled with the perldoc -f 


That looks in only one of the hundred-plus POD files (perlfunc.pod).

Searching less than 1% of the available information means you will
often miss what you are looking for.


> I was kinda suprised when I did a perldoc -f for and it came up
> with nothing on the for loop). 


That is because "control structures" are not "functions".

Perl's control structures are documented in perlsyn.pod.

    grep For all.heads

shows these 2 lines

    perlsyn.pod:=head2 For Loops
    perlsyn.pod:=head2 Foreach Loops

among its 50-some lines of output.


> Bill Hl > Bile oMost of the time I usually end up
> looking through a printed copy of all the docs (500+ double sided, 2
> up pages) that I had printed about 8 years ago.


Computers are much better at searching than using paper...


> I have never seen a simple "How do I
> find ?????? in perldoc?". 


I never actually use perldoc for searching the standard docs. I use grep(1).

I use perldoc for reading a module's docs fairly regularly though. I most
often use it only for getting the module's docs into a file though (so
that I can then grep it). eg:

   perldoc -u DBI >DBI.pod


> If this exists, it would be a great FAQ to
> have in the rotation, and possibly weighted so it shows up often. If
> it doesn't exist, maybe it should be written and placed in there.


Looks like it has been a couple of years since I last posted
my "Perl problem resolution checklist", so here it is again:




----------------------------------
Perl problem resolution checklist:
----------------------------------

1) check the Perl FAQs

   (word search with "perldoc -q". Or better, find where the
    *.pod's are on your system, and word search (grep) the
    entire contents of the files)

2) expand the above to _all_ of the standard *.pod files.

3) check a Usenet archive such as:

      http://groups.google.com/advanced_group_search

4) check books and websites (this step is optional)

5) write a Usenet article, but don't post it yet!

   5a) make a small and complete (including data) program that
       people can execute that shows your problem.

   5b) state how the program's output is not what you want. Describe
       what you want.

   5c) repeat steps 1-4 using search terms taken from your description
       of the problem or your Subject header (try some synonyms for
       the terms also)

6) Give up on a quick answer. Post to Usenet for a slow answer.

7) wait hours/days/forever for followups with answers rather than
   than the 5 or 10 minutes it would have taken if steps 1-3
   had worked.

8) Wonder at the quality of the answers given, rather than know
   it is a peer-reviewed, validated answer if steps 1-2 had worked.

9) Repeat steps 1-3 many times for many problems. You will seldom
   get past step 3, and even less often get past step 5a.

10) Now that you know so much, go *answer* some questions on Usenet  :-)


-----

To help with 1 and 2 above, I make "headlines" files to grep in,
because sometimes there is Too Much Information when grepping
the entire bodies:

   cd /an/INC/dir/pod/

   grep '^=' perlfaq[1-9].pod >faq.heads

   grep '^=' *.pod >all.heads



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


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

Date: Sat, 18 Oct 2008 19:46:20 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: "Escape" in perl
Message-Id: <slrngfk87e.7p0.hjp-usenet2@hrunkner.hjp.at>

On 2008-10-18 11:23, Bill H <bill@ts1000.us> wrote:
> I have fumbled with the perldoc -f and mostly found what I was looking
> for, and when I don't I post a question on here and 9 times out of 10
> someone will show me how I should have used perldoc (though as an
> aside, I was kinda suprised when I did a perldoc -f for and it came up
> with nothing on the for loop). Most of the time I usually end up
> looking through a printed copy of all the docs (500+ double sided, 2
> up pages) that I had printed about 8 years ago.

When I started to program Perl in earnest (in early 1995, so that must
have been 5.000), I started with "perldoc perl" ("man perl" actually, I
only found out about perldoc later) and read through all the documents
referenced from there. At the time that was a few hundred pages, so that
took only a few days. Today that would be quite a bit longer. I didn't
learn it by heart - just read through it to get a feeling for what the
language could do and how the documentation was laid out, so that later,
for any specific question I had a rough idea where to look (for example,
all the control structures are in "perldoc perlsyn", so that's where I
would look for information about the for loop).

The most important perldocs are imho:

 * perldoc Some::Module for information about Some::Module. Perl is
   CPAN, the rest is just syntactic sugar ;-).
 * perldoc perlre for information about regular expressions. There are 
   always some details about regexps which I don't quite remember, so 
   I use that frequently. 
 * perldoc perlfunc, or rather perldoc -f for info about builtin
   functions.
 * perldoc perlsyn, perlop and perldata for the language proper.
   (actually, these I days I mostly need them for usenet discussions :-))
 * perldoc perlrun for command line parameters
 * perldoc -q if I don't know where to look
 * perldoc perl if I still don't know where to look.

Usually I search first CPAN, then Google somewhere in between.
And of course there is http://perldoc.perl.org/ with a searchable
online version of all the perldocs for 5.10.0 and 5.8.8. I use that only
rarely, but I guess I should use it more often (if only because the
pages are better formatted than in a terminal window).

	hp


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

Date: Sat, 18 Oct 2008 14:23:16 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: "Escape" in perl
Message-Id: <slrngfkdt4.dvq.tadmc@tadmc30.sbcglobal.net>

Peter J. Holzer <hjp-usenet2@hjp.at> wrote:

> The most important perldocs are imho:
>
>  * perldoc Some::Module for information about Some::Module. Perl is
>    CPAN, the rest is just syntactic sugar ;-).
>  * perldoc perlre for information about regular expressions. There are 
>    always some details about regexps which I don't quite remember, so 
>    I use that frequently. 
>  * perldoc perlfunc, or rather perldoc -f for info about builtin
>    functions.
>  * perldoc perlsyn, perlop and perldata for the language proper.
>    (actually, these I days I mostly need them for usenet discussions :-))
>  * perldoc perlrun for command line parameters
>  * perldoc -q if I don't know where to look
>  * perldoc perl if I still don't know where to look.


Surely perlop.pod belongs in that list.


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


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

Date: Sat, 18 Oct 2008 22:02:11 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: "Escape" in perl
Message-Id: <slrngfkg65.c8s.hjp-usenet2@hrunkner.hjp.at>

On 2008-10-18 19:23, Tad J McClellan <tadmc@seesig.invalid> wrote:
> Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>> The most important perldocs are imho:
>>
>>  * perldoc Some::Module for information about Some::Module. Perl is
>>    CPAN, the rest is just syntactic sugar ;-).
>>  * perldoc perlre for information about regular expressions. There are 
>>    always some details about regexps which I don't quite remember, so 
>>    I use that frequently. 
>>  * perldoc perlfunc, or rather perldoc -f for info about builtin
>>    functions.
>>  * perldoc perlsyn, perlop and perldata for the language proper.
                       ^^^^^^
>>    (actually, these I days I mostly need them for usenet discussions :-))
>>  * perldoc perlrun for command line parameters
>>  * perldoc -q if I don't know where to look
>>  * perldoc perl if I still don't know where to look.
>
>
> Surely perlop.pod belongs in that list.

See above.

	hp


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

Date: Sun, 19 Oct 2008 00:11:38 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: "Escape" in perl
Message-Id: <slrngfkk8a.b0m.whynot@orphan.zombinet>

*SKIP*
> In this group there is usually 3 or more auto posts a day from the FAQ
> and they are on the majority very helpful, I have seen many
> duplicates, though, but I have never seen a simple "How do I find
> ?????? in perldoc?". If this exists, it would be a great FAQ to have
> in the rotation, and possibly weighted so it shows up often. If it
> doesn't exist, maybe it should be written and placed in there.

B<Perldoc::Search>?

It has a script inside, that provides quiet simple (down to dumb)
interface on all the *text* files in I<@INC> (I believe, didn't looked
inside).  It's too verbose for daily usage, but it does what its name
say.

-- 
Torvalds' goal for Linux is very simple: World Domination


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

Date: Sat, 18 Oct 2008 18:46:40 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: "Escape" in perl
Message-Id: <slrngfktb0.fpn.tadmc@tadmc30.sbcglobal.net>

Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
> On 2008-10-18 19:23, Tad J McClellan <tadmc@seesig.invalid> wrote:
>> Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
>>> The most important perldocs are imho:
>>>
>>>  * perldoc Some::Module for information about Some::Module. Perl is
>>>    CPAN, the rest is just syntactic sugar ;-).
>>>  * perldoc perlre for information about regular expressions. There are 
>>>    always some details about regexps which I don't quite remember, so 
>>>    I use that frequently. 
>>>  * perldoc perlfunc, or rather perldoc -f for info about builtin
>>>    functions.
>>>  * perldoc perlsyn, perlop and perldata for the language proper.
>                        ^^^^^^
>>>    (actually, these I days I mostly need them for usenet discussions :-))
>>>  * perldoc perlrun for command line parameters
>>>  * perldoc -q if I don't know where to look
>>>  * perldoc perl if I still don't know where to look.
>>
>>
>> Surely perlop.pod belongs in that list.
>
> See above.


See below:

  Doh!


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


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

Date: Sat, 18 Oct 2008 17:06:48 -0700 (PDT)
From: "dn.perl@gmail.com" <dn.perl@gmail.com>
Subject: DBI module: can't pass argument to "in (?)" clause
Message-Id: <d9fa147f-aa71-4e74-a13b-9a0ad1b55c3b@42g2000pry.googlegroups.com>


I have a table t1: State, Capital.
Entries are ('CA', 'Sacramento'),  ('MA', 'Boston') and  ('TX',
'Austin').

Here is a block which returns nothing :
my $my_list = " 'CA',  'MA' " ;
my $sth = $dbh->prepare("select capital from t1 where state in (?)");
$sth->execute($my_list) ;

If I replace it with the following, I get the expected results:
my $my_list = " 'CA',  'MA' " ;
my $sth = $dbh->prepare("select capital from t1 where state in
($my_list)");
$sth->execute() ;

What could be the problem?
Thanks in advance.



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

Date: Sun, 19 Oct 2008 11:49:42 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: DBI module: can't pass argument to "in (?)" clause
Message-Id: <670edg.4tj.ln@news.heliotrope.home>

On Sat, 18 Oct 2008 17:06:48 -0700 (PDT),
	dn.perl@gmail.com <dn.perl@gmail.com> wrote:
>
> I have a table t1: State, Capital.
> Entries are ('CA', 'Sacramento'),  ('MA', 'Boston') and  ('TX',
> 'Austin').
>
> Here is a block which returns nothing :
> my $my_list = " 'CA',  'MA' " ;
> my $sth = $dbh->prepare("select capital from t1 where state in (?)");
> $sth->execute($my_list) ;
>
> If I replace it with the following, I get the expected results:
> my $my_list = " 'CA',  'MA' " ;
> my $sth = $dbh->prepare("select capital from t1 where state in
> ($my_list)");
> $sth->execute() ;
>
> What could be the problem?


From the manual for DBI:

       Also, placeholders can only represent single scalar values.  For exam‐
       ple, the following statement won’t work as expected for more than one
       value:

         "SELECT name, age FROM people WHERE name IN (?)"    # wrong
         "SELECT name, age FROM people WHERE name IN (?,?)"  # two names



You could do something like:

my @states = qw/CA MA/;

my $sth = $dbh->prepare('select capital from t1 where state in (' .
    join(',', (?) x @states) . ')');

$sth->execute(@states);

I'm sure there are probably modules in the DBIx namespace somewhere that
have convenience methods for this.

Martien
-- 
                        | 
Martien Verbruggen      | Useful Statistic: 75% of the people make up
                        | 3/4 of the population.
                        | 


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

Date: Sat, 18 Oct 2008 21:24:40 -0400
From: Bob Walton <bwalton@nospam.invalid>
Subject: Re: DBI module: can't pass argument to "in (?)" clause
Message-Id: <48fa8c59$0$20318$9a6e19ea@unlimited.newshosting.com>

dn.perl@gmail.com wrote:
> I have a table t1: State, Capital.
> Entries are ('CA', 'Sacramento'),  ('MA', 'Boston') and  ('TX',
> 'Austin').
> 
> Here is a block which returns nothing :
> my $my_list = " 'CA',  'MA' " ;
> my $sth = $dbh->prepare("select capital from t1 where state in (?)");
> $sth->execute($my_list) ;

See the DBI docs section "Placeholders and Bind Values".  It discusses 
exactly the case you are attempting.  Basically, you need [untested]:

    ...where state in (?,?)");

and then a list of two values in the execute statement:

    $sth->execute('CA','MA');

I think the main reason for this is that the content-to-be of the 
placeholders is automatically quoted so one doesn't have to fuss around 
with all the SQL quoting rules -- but in a case like what you're doing, 
that gets in the way.

 ...
-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl


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

Date: Sun, 19 Oct 2008 00:28:00 +0800
From: Amy Lee <openlinuxsource@gmail.com>
Subject: Re: Help: How to install a *.pm module
Message-Id: <pan.2008.10.18.16.28.00.372714@gmail.com>

On Fri, 17 Oct 2008 20:09:05 -0500, Tad J McClellan wrote:

> Tim Greer <tim@burlyhost.com> wrote:
>> Henry Law wrote:
>>
>>> Tad J McClellan wrote:
>>>> Amy Lee <openlinuxsource@gmail.com> wrote:
>>>> 
>>>>> I download a module for BLAST parsing called "BPlite.pm", however I
>>>>> don't know how to install it.
>>>> 
>>>> 
>>>> Here is a radical idea: read the file in the distribution named
>>>> "INSTALL"!
>>> 
>>> And if the distribution doesn't have a file called that? (It doesn't).
>>> And if the "distribution" isn't a distribution but just a bare Perl
>>> module file?  (It is).
>>> 
>>  
>>
>> Isn't this a core module in BioPerl?
> 
> 
> That is what I downloaded before replying, so that I could
> ensure that it did have an "INSTALL" file.
Hi, thanks every one. I copy this module into
/usr/lib/perl5/site_perl/5.8.3 this directory then use this module
correctly.

Anyway, how can I know @INC contents?

Amy


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

Date: Sat, 18 Oct 2008 09:39:43 -0700
From: Jrgen Exner <jurgenex@hotmail.com>
Subject: Re: Help: How to install a *.pm module
Message-Id: <194kf4hbhm15dg79lp1odm3diavmtlia0p@4ax.com>

Amy Lee <openlinuxsource@gmail.com> wrote:

>Anyway, how can I know @INC contents?

What about just print()ing it?

jue


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

Date: Sat, 18 Oct 2008 18:37:42 +0200
From: "Petr Vileta \(fidokomik\)" <stoupa@practisoft.cz>
Subject: Re: Help: How to install a *.pm module
Message-Id: <gdd3pf$8fn$1@aioe.org>

Tad J McClellan wrote:
> Amy Lee <openlinuxsource@gmail.com> wrote:
> 
>> I download a module for BLAST parsing called "BPlite.pm", however I
>> don't know how to install it.
> 
> 
> Or maybe just try the standard way of installing modules:
> 
>   perldoc -q module
> 
>        How do I install a module from CPAN?
> 

Maybe will be good to add to FAQ some like:
"How do I install module to hosting server where it is not allowed?"
:-)

-- 
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail.
Send me your mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>



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

Date: Sat, 18 Oct 2008 14:21:32 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Help: How to install a *.pm module
Message-Id: <slrngfkdps.dvq.tadmc@tadmc30.sbcglobal.net>

Petr Vileta (fidokomik) <stoupa@practisoft.cz> wrote:
> Tad J McClellan wrote:
>> Amy Lee <openlinuxsource@gmail.com> wrote:
>> 
>>> I download a module for BLAST parsing called "BPlite.pm", however I
>>> don't know how to install it.
>> 
>> 
>> Or maybe just try the standard way of installing modules:
>> 
>>   perldoc -q module
>> 
>>        How do I install a module from CPAN?
>> 
>
> Maybe will be good to add to FAQ some like:
> "How do I install module to hosting server where it is not allowed?"


There is one:

   How do I keep my own module/library directory?


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


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

Date: Sat, 18 Oct 2008 14:45:08 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Help: How to install a *.pm module
Message-Id: <702qs5xn92.ln2@goaway.wombat.san-francisco.ca.us>

On 2008-10-18, Amy Lee <openlinuxsource@gmail.com> wrote:
>
> Anyway, how can I know @INC contents?

The same way you know the contents of any other variable.

print "@INC\n";

Do you know how to read the documentation for Perl?  It's quite
extensive.

--keith

-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information



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

Date: Sun, 19 Oct 2008 03:00:51 +0200
From: "Petr Vileta \(fidokomik\)" <stoupa@practisoft.cz>
Subject: Re: Help: How to install a *.pm module
Message-Id: <gde0sn$2n1$1@aioe.org>

Tad J McClellan wrote:
> Petr Vileta (fidokomik) <stoupa@practisoft.cz> wrote:
>> Maybe will be good to add to FAQ some like:
>> "How do I install module to hosting server where it is not allowed?"
> 
> 
> There is one:
> 
>   How do I keep my own module/library directory?

Oh sorry, I made a mistake.
-- 
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail.
Send me your mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>



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

Date: Sun, 19 Oct 2008 00:22:05 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Help: How to install a *.pm module
Message-Id: <slrngfkkru.b0m.whynot@orphan.zombinet>

On 2008-10-18, Amy Lee <openlinuxsource@gmail.com> wrote:
*SKIP*
> Hi, thanks every one. I copy this module into
> /usr/lib/perl5/site_perl/5.8.3 this directory then use this module
> correctly.

At first I wanted to bark "don't!  there're better places!".  But then,
just wondering, what's your distribution?  Never mind, please upgrade.

> Anyway, how can I know @INC contents?

C<perl -V> -- then look at last lines

-- 
Torvalds' goal for Linux is very simple: World Domination


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

Date: Sat, 18 Oct 2008 06:07:36 -0700
From: Jrgen Exner <jurgenex@hotmail.com>
Subject: Re: Need help on AoH or array or any other think that might help!
Message-Id: <4rnjf4dcpqotl4n8thoaemu3h35jf56fea@4ax.com>

"John W. Krahn" <someone@example.com> wrote:
>Jrgen Exner wrote:
>> perldoc -f split:
>> 	($customer, $category, undef, $price) = split ('|');
>
>The '|' character is special in a regular expresion.  If you want to 
>match a literal '|' character you have to escape it:

Ooops, you are right. 

jue


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

Date: Sun, 19 Oct 2008 03:07:17 +0000 (UTC)
From: Lars Eighner <usenet@larseighner.com>
Subject: Procedural interface to mysql
Message-Id: <slrngfl8if.1jgp.usenet@debranded.larseighner.com>

Is there a procedural interface to mysql?


-- 
        Lars Eighner <http://larseighner.com/> usenet@larseighner.com
                Q. What did Palin do that Obama could not do?
                        A. Got me to vote for Obama.


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

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


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