[21702] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3906 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 3 00:05:45 2002

Date: Wed, 2 Oct 2002 21:05:11 -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, 2 Oct 2002     Volume: 10 Number: 3906

Today's topics:
        can't pass a variable in argument <Crackhead@mensa.org>
    Re: can't pass a variable in argument <Crackhead@mensa.org>
    Re: cat * | perl, then interactive STDIN <3b533a81314e4@heavyk.org>
    Re: Downloading from a www server: Problem <spam@thecouch.homeip.net>
        Entering a list with <STDIN> in DOS <jeremiahtu@yahoo.com>
    Re: Entering a list with <STDIN> in DOS <wksmith@optonline.net>
    Re: Floating point question <REMOVEsdnCAPS@comcast.net>
        Help w map & its iterator plse <penny1482@attbi.com>
    Re: Help w map & its iterator plse <wksmith@optonline.net>
    Re: Help w map & its iterator plse (Tad McClellan)
    Re: Mac OS X and Perl 6 <bobx@linuxmail.org>
        OLE Module and setting a Boolean value <tomowen@starband.net>
    Re: Open File problem (kazchan)
    Re: Open File problem (kazchan)
    Re: Perl Tutor Wanted - Mtn View, CA (Tad McClellan)
    Re: Perl Tutor Wanted - Mtn View, CA (Tad McClellan)
        Printing text to a file <Crackhead@mensa.org>
    Re: Script stops working when DBI added. Why? (Chop Wood)
    Re: Speed optimization (with code) <heather710101@yahoo.com>
        Tricky question on calling a shell from a perl script <zeus_riposta@yahoo.com>
    Re: Tricky question on calling a shell from a perl scri <zeus_riposta@yahoo.com>
        want reverse substr gary.hodgesREMOVE@cires.colorado.edu
    Re: want reverse substr gary.hodgesREMOVE@cires.colorado.edu
    Re: want reverse substr (Tad McClellan)
    Re: Which one is more efficient regarding constant scal <VES@VES.NET>
    Re: Which one is more efficient regarding constant scal <pinyaj@rpi.edu>
    Re: why does where matter? <REMOVEsdnCAPS@comcast.net>
    Re: why does where matter? <jurgenex@hotmail.com>
        || versus OR <bobx@linuxmail.org>
    Re: || versus OR <brittedg@student.gvsu.edu>
    Re: || versus OR <krahnj@acm.org>
    Re: || versus OR <bobx@linuxmail.org>
    Re: || versus OR <s_grazzini@hotmail.com>
    Re: || versus OR <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 03 Oct 2002 02:11:45 GMT
From: Crackpot <Crackhead@mensa.org>
Subject: can't pass a variable in argument
Message-Id: <Xns929BC34376FD6Crackheadmensaorg@204.127.68.17>

Hello,
I'm trying to access an excel spreadsheet which I do succesfuly using 

use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3;                       # die on errors...
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
    || Win32::OLE->new('Excel.Application', 'Quit');

now I'm trying to get data from all cells in Columns B,C,F. So I tried to 
write a while loop that would go down the rows after retrieving data from 
right cell. first cells would B2:C2:F2 then, B3:C3:F etc...
here's my code,

open new;
my $Book = $Excel->Workbooks->Open("C:\\test.xls"); #open Excel file
	my $Sheet = $Book->Worksheets(1);        #select worksheet number 1

my $filename;
my $row=2;
my $id;
  while($row<20)
    {	
	$filename = $Sheet->Range("B$row")->{'VALUE'}; # initialize 
filename

        $id    = $Sheet->Range("C$row")->{'VALUE'};#initialize ID
			$row++;
    } 

	$Book->Close;

So now I'm trying to figure out how to pass variables here but I keep 
getting errors. Can anyone help?

Thanks


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

Date: Thu, 03 Oct 2002 03:11:39 GMT
From: Crackpot <Crackhead@mensa.org>
Subject: Re: can't pass a variable in argument
Message-Id: <Xns929BCD6BF5B76Crackheadmensaorg@204.127.68.17>

I'm sorry group. I am an idiot. I figured it out myself.




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

Date: Thu, 03 Oct 2002 01:23:12 GMT
From: Keith Resar <3b533a81314e4@heavyk.org>
Subject: Re: cat * | perl, then interactive STDIN
Message-Id: <4_Mm9.89751$q42.3017763@bin3.nnrp.aus1.giganews.com>

In article <GhLm9.32749$YI.6533655@twister.nyc.rr.com>, Steve Grazzini wrote:
> 
> I don't know the portable solution, but on Unix:
> 
>   open STDIN, '/dev/tty' or die "open /dev/tty : $!";

That did it.

Keith Resar.


-- 


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

Date: Thu, 03 Oct 2002 00:18:32 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: Downloading from a www server: Problem
Message-Id: <3D9BC518.9090708@thecouch.homeip.net>



develop@gistenson.com wrote:
> Gregory,
> 
> I don't see how a form and submit can help. Please explain. I've been 
> developing web sites since 1996, so I must be dense.
> 
> Thanks
> Dan

Hello Dan

LWP is (usually) for perl programs to download files from remote machines.

This does not seem to be your case. You want to SEND the file to the 
remote machine.  Apache+Perl make this quite convenient for you since 
all the tcp/ip/protocol is already taken care of.. All you have to do is 
tell the client what the type of the content you're sending it is, then 
the content. and presto !

This is untested.. but should work. It could be summarized to 1 line, 
but I prefer the extra sanity :

-------- cut here --------
#!/usr/bin/perl

use strict;
use vars qw($filename);
use CGI::Carp qw(fatalsToBrowser);

$filename = "/home/privatecontent/filename.zip";

&sendfile();

sub sendfile() {
	local(*FH);
	open (FH, $filename) || die "Error: Failed to open local file: $!\n";
	print "Content-type: application/octet-stream\n\n";
	binmode(STDOUT);
	while (<FH>) {
		print;
		}
	close (FH);
	}
-------- cut here --------

Best of luck.


> 
> Gregory Toomey <nobody@nowhere.com> wrote:
> 
> 
> : develop@gistenson.com wrote in message ...
> :>Tab and Alan,
> :>
> :>I'll try again.
> :>
> :>I'm developing a web site, not client-side software. The web site needs to
> :>transfer files from it to the client.
> :>
> :>Alan, you're solution, using an anchor, is fine for downloading one file,
> :>but I'm interested in a shopping cart application: A user, via his
> :>browser, selects the items he wants to buy by clicking on a picture of
> :>each item he intends to buy. This causes the item to be added to his
> :>shopping cart. When the user has picked all of the items he wants to buy,
> :>he clicks on a link, call it:
> :>
> :><a href="checkout.cgi">checkout</a>
> :>
> :>The script checkout.cgi is the script of interest here and needs to do the
> :>following:
> :>1. Initiate the credit card processing (No help needed here.)
> :>2. Download to the user all of the purchased items. (The items are all
> :>binary files.)
> :>
> :>The LWP documentation appears to say that LWP's purpose is at the machine
> :>at the "receiveing" end of a file transfer. (ie. get, getprint and
> :>getstore.) Am I wrong? I need something like putstore.
> :>
> :>I'm looking for guidance with the second of the above two "checkout"
> :>steps.
> :>
> :>Thanks,
> :>Dan
> :>
> 
> : You need a standard cgi form and a submit button.
> 
> : gtoomey
> 
> 



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

Date: Thu, 03 Oct 2002 01:56:44 GMT
From: "tu" <jeremiahtu@yahoo.com>
Subject: Entering a list with <STDIN> in DOS
Message-Id: <wtNm9.81441$jG2.4445746@bgtnsc05-news.ops.worldnet.att.net>

Hi,
I am going through the exercises in the book "Learning Perl".  An number of
exercise problems ask to write a program that reads a list of numbers (on
separate lines) into an array variable.

I know all I need to write in Perl is
print "Enter the list you want to print.";
@ArrayName = <STDIN>;
print @ArrayName;

My problem is when I run the script.  I get prompted to enter the list, but
I don't know how to enter it in DOS.  I have tried entering list of numbers
with a <return> after each number, and end with a CTRL-D.  All it does is
print a dimond after the stuffs I entered.  I tried ending it with CTRL-Z,
and it doesn't seem to work either.

Please help.  -tt




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

Date: Wed, 2 Oct 2002 22:38:26 -0400
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Entering a list with <STDIN> in DOS
Message-Id: <m5Om9.65401$9d3.2631262@news4.srv.hcvlny.cv.net>


"tu" <jeremiahtu@yahoo.com> wrote in message
news:wtNm9.81441$jG2.4445746@bgtnsc05-news.ops.worldnet.att.net...
> Hi,
> I am going through the exercises in the book "Learning Perl".  An number
of
> exercise problems ask to write a program that reads a list of numbers (on
> separate lines) into an array variable.
>
> I know all I need to write in Perl is
> print "Enter the list you want to print.";
> @ArrayName = <STDIN>;
> print @ArrayName;
>
> My problem is when I run the script.  I get prompted to enter the list,
but
> I don't know how to enter it in DOS.  I have tried entering list of
numbers
> with a <return> after each number, and end with a CTRL-D.  All it does is
> print a dimond after the stuffs I entered.  I tried ending it with CTRL-Z,
> and it doesn't seem to work either.
>
> Please help.  -tt
>
>

CTRL-Z works for me using the dos window from Windows ME.  CTRL-Z must be on
a line by itself.

Bill





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

Date: Thu, 03 Oct 2002 02:04:10 GMT
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Floating point question
Message-Id: <Xns929BE0C829BFCsdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"J" <A@B> wrote in news:uplu00hgqm2t17@corp.supernews.com:

> 
> "Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message
> news:Xns929AD3B8FDBA0sdn.comcast@216.166.71.239...
>> "J" <<A@B>> wrote in news:upjooeq5n8egf0@corp.supernews.com:
>>
>> That's really really silly.
> 
> Ok, it may seems silly.
> 
> I work on a large system written in delphi. It complies fairly fast,
> but the procedure I am running takes quite a bit of time to run since
> it processes lots of data.
> Occasionally, I will try out new ideas in perl along with writing
> pseudocode, this
> helps me think about what I am doing before I start hacking on a unit
> with 1,000
> lines of code. If the perl script turns out to be extremely efficient
> I sometimes use the
> activeX scripting component to execute the script.
> 
> Also, I am not a perl guru, so seeing how certain algorithms work in
> perl is a good way to learn the language.

I apologize for my flip one-line answer. :-)

What I really meant was something like "working with odd boundary cases 
in one language (eg, your floating-point issue) and expecting the answer 
to carry over into other languages is really really silly".

Not sure if that's what you were expecting or not, but that's how it 
seemed to me at the time.  Using one language to do quick and dirty 
prototyping of algorithms is quite a reasonable thing to do.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPZul+2PeouIeTNHoEQIDLACeMdMKDn5oslmxJOxUf613vp22+iAAoMoa
cIV8baLcue9dwJbHSdUB06kw
=nZkf
-----END PGP SIGNATURE-----


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

Date: Thu, 03 Oct 2002 01:50:34 GMT
From: "Dick Penny" <penny1482@attbi.com>
Subject: Help w map & its iterator plse
Message-Id: <KnNm9.17310$dp1.47208@rwcrnsc52.ops.asp.att.net>

Here I go again, 3rd time in one day, you guys put up with a lot. Thanks.

I've successfully transformed an array of strings (actually from a file but
not illustrated here) into an array of arrays containing strings(numbers)
which I can access as a 2D matrix. Now I am trying to insert decimal points
into all numbers whose string reprensation is 6 digits. My hang up (I think)
is that I don't know how to use the 1st iterator $_ which is a ref to an
annon array as input to a map.

Code follows, I desire @numbrs2 to be same size, shape, type, as @numbrs BUT
with decimal points inserted into 6 digit strings, effectively scaling the
data.

Can this all be done with a chain of maps?

_______ trial code, runs, but bad results
use strict;
use warnings;
use Data::Dumper;
my @lines = (
   'SPH 083000  111200  111300  111100  111280   503   959',
   'SPH 084000  111250  111380  111200  111370   354   115',
   'SPH 084500  111350  111390  111050  111100   353   747' );
my @numbrs = map{[/\d+/g]} @lines;
my @numbrs2 =();
print "numbrs are\n", Dumper @numbrs;
foreach (@numbrs)
{  @numbrs2 = map{[$_ =~ s/(\d{4})(\d{2})/$1\.$2/g]} @$_ }
print "numbrs2 are\n", Dumper @numbrs2;

-- --------
Dick Penny




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

Date: Wed, 2 Oct 2002 23:28:26 -0400
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Help w map & its iterator plse
Message-Id: <9QOm9.66006$9d3.2659717@news4.srv.hcvlny.cv.net>


"Dick Penny" <penny1482@attbi.com> wrote in message
news:KnNm9.17310$dp1.47208@rwcrnsc52.ops.asp.att.net...
> Here I go again, 3rd time in one day, you guys put up with a lot. Thanks.
>
> I've successfully transformed an array of strings (actually from a file
but
> not illustrated here) into an array of arrays containing strings(numbers)
> which I can access as a 2D matrix. Now I am trying to insert decimal
points
> into all numbers whose string reprensation is 6 digits. My hang up (I
think)
> is that I don't know how to use the 1st iterator $_ which is a ref to an
> annon array as input to a map.
>
> Code follows, I desire @numbrs2 to be same size, shape, type, as @numbrs
BUT
> with decimal points inserted into 6 digit strings, effectively scaling the
> data.
>
> Can this all be done with a chain of maps?
>
> _______ trial code, runs, but bad results
> use strict;
> use warnings;
> use Data::Dumper;
> my @lines = (
>    'SPH 083000  111200  111300  111100  111280   503   959',
>    'SPH 084000  111250  111380  111200  111370   354   115',
>    'SPH 084500  111350  111390  111050  111100   353   747' );
> my @numbrs = map{[/\d+/g]} @lines;
> my @numbrs2 =();
> print "numbrs are\n", Dumper @numbrs;
> foreach (@numbrs)
> {  @numbrs2 = map{[$_ =~ s/(\d{4})(\d{2})/$1\.$2/g]} @$_ }

    { push @numbrs2, [map {s/(\d{4})(\d{2})/$1\.$2/;$_} @$_]; }

> print "numbrs2 are\n", Dumper @numbrs2;
>
> -- --------
> Dick Penny
>
>

I suggested a minimal change to your code.  This also changes the array
@numbrs.  I added ';$_' to the map block to get it to return the change
rather than the status.
the push is needed to store each reference as it is made.

The foreach loop could be replaced with an outer map.
The change to @numbrs could be prevented by assigning $_ to a temp variable
in the map block.  Make the substitution to the temp and then return it.

Good Luck
Bill




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

Date: Thu, 03 Oct 2002 04:02:06 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help w map & its iterator plse
Message-Id: <slrnapng74.5f3.tadmc@magna.augustmail.com>

Dick Penny <penny1482@attbi.com> wrote:

> which I can access as a 2D matrix. Now I am trying to insert decimal points
> into all numbers whose string reprensation is 6 digits. My hang up (I think)
> is that I don't know how to use the 1st iterator $_ which is a ref to an
> annon array as input to a map.


No, you are dereferencing $_ just fine.


> Code follows, I desire @numbrs2 to be same size, shape, type, as @numbrs BUT
> with decimal points inserted into 6 digit strings, 


It will insert decimal points in any string of _at least_ 6 digits.

You need some anchors in your pattern.


> effectively scaling the
> data.
> 
> Can this all be done with a chain of maps?


Yes.


> _______ trial code, runs, but bad results
> use strict;
> use warnings;
> use Data::Dumper;
> my @lines = (
>    'SPH 083000  111200  111300  111100  111280   503   959',
>    'SPH 084000  111250  111380  111200  111370   354   115',
>    'SPH 084500  111350  111390  111050  111100   353   747' );
> my @numbrs = map{[/\d+/g]} @lines;
> my @numbrs2 =();
> print "numbrs are\n", Dumper @numbrs;
> foreach (@numbrs)
> {  @numbrs2 = map{[$_ =~ s/(\d{4})(\d{2})/$1\.$2/g]} @$_ }


   { push @numbrs2, [ map{ s/^(\d{4})(\d{2})$/$1\.$2/g; $_} @$_ ] }


You are looping once for each array ref, so you want to
push an array ref each time:

   { push @numbrs2, [ ] }

Then you need to populate the array ref with the transformed strings.

With:

   { push @numbrs2, [ map{ s/^(\d{4})(\d{2})$/$1\.$2/g } @$_ ] }

The mapped values will be the value returned by s/// in list
context, which are not very interesting.

You need to mention $_ last in the map block so its value will be
the value of the block, and hence passed on by the map.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 03 Oct 2002 01:23:08 GMT
From: "Bob X" <bobx@linuxmail.org>
Subject: Re: Mac OS X and Perl 6
Message-Id: <0_Mm9.17516$Lg2.4824292@news2.news.adelphia.net>

"Da Witch" <heather710101@yahoo.com> wrote in message
news:aneu30$g62$1@reader1.panix.com...
>
> In O'Reilly's page on the Mac OS X Conference (url below), it says
> that "[a]lmost all of the Perl 6 core team has switched to Mac OS X."
> I was quite surprised by that statement (is it even true???).  Somehow
> I thought that Perl was a lot more committed to Linux than that.  I
> guess I was mistaken...  As a die-hard fan of Linux, or rather, of the
> idea of a non-proprietary operating system, I'm rather bummed by these
> news.
>
> h
>
> http://conferences.oreillynet.com/pub/w/19/invite.html
>
>
Cool! Since I am going to OSX myself.  : )




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

Date: Thu, 03 Oct 2002 01:51:55 GMT
From: "Tom Owen" <tomowen@starband.net>
Subject: OLE Module and setting a Boolean value
Message-Id: <lpNm9.599$rR1.214262872@twister2.starband.net>

I am able to use OLE module without any difficulty except for setting
boolean properties. When I need to update a property that is boolean I get
an OLE err that says type mismatch. I have tried every combination possible:
1. $objCube->Reports->{'AllowDrillThrough'} => Variant(VT_BSTR,'-1');
2. $objCube->Reports->{'AllowDrillThrough'} => $vtTrue; (earlier in the code
is my $vtTrue =1 or my $vtTure=-1;)
3. $objCube->Reports->{'AllowDrillThrough'} => 1;
4. $objCube->Reports->{'AllowDrillThrough'} => -1;
5. $objCube->Reports->{'AllowDrillThrough'} => ( 1=1);

if not syntax error, then type mismatch. 1 should be true, while 0 false. I
have
use Win32::OLE::Variant;
use Win32::OLE qw(in with);

It is my understanding that Variant should handle the translation from
integer (1) to Boolean. But cannot set the property 'AllowDrillThrough' to
true.

I am using ActivePerl 5.6.1 on WinNT machine.

Any ideas?

Much appreciated




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

Date: 2 Oct 2002 18:31:19 -0700
From: kazchan@curio-city.com (kazchan)
Subject: Re: Open File problem
Message-Id: <3baaab4f.0210021731.2e9bdc09@posting.google.com>

$id is generated by a simple put method form.  When someone submit a
form with the specific numbers, the form should be mailed to the
address specified in the data file.  Making a change from $exit to
$next does not do anything different.



"Newbie" <mike_constant@yahoo.com> wrote in message news:<anftam$dqgqk$1@ID-161864.news.dfncis.de>...
> "kazchan" <kazchan@curio-city.com> wrote in message
> news:3baaab4f.0210021444.5daeb7ae@posting.google.com...
> > I am trying make people put number to send an E-mail.  It works when
> > the data file has only one line, but it does not work when it has two
> > or more lines.
> >
> >
> > Here is part of problem:
> >
> > open(FILEHANDLE,"<address.dat") or &error("Could not open
> > address.dat");
> > while($line = <FILEHANDLE>)
> > {
> > $line =~ s/\n//g;
> > ($member,$mailto) = split(/::/, $line);
> > if ($id ne $member)
> > {
> > close FILEHANDLE;
> > &error('No valid member found.');
> > exit;
> > }
> > }
> >
> > The data file is something like this:
> >
> > This works fine
> > 1033444038::user@mail.com
> >
> > But this does not work
> > 1033444038::user@mail.com
> > 1027847623::user@hotmail.com
> >
> >
> > I guess the command does work correctly.
> > $line =~ s/\n//g;
> >
> > Please help.
> 
> How is $id generated?  Also, should it be a "next" instead of "exit"?


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

Date: 2 Oct 2002 18:59:55 -0700
From: kazchan@curio-city.com (kazchan)
Subject: Re: Open File problem
Message-Id: <3baaab4f.0210021759.44636b02@posting.google.com>

I forgot to put one thing.  When I put the data file below, it still
works if the id number is 1033444038.  So, this means it recognizes
the only first line of the data.

> But this does not work
> 1033444038::user@mail.com
> 1027847623::user@hotmail.com




kazchan@curio-city.com (kazchan) wrote in message news:<3baaab4f.0210021444.5daeb7ae@posting.google.com>...
> I am trying make people put number to send an E-mail.  It works when
> the data file has only one line, but it does not work when it has two
> or more lines.
> 
> 
> Here is part of problem:
> 
> open(FILEHANDLE,"<address.dat") or &error("Could not open
> address.dat");
> while($line = <FILEHANDLE>)
> {
> $line =~ s/\n//g;
> ($member,$mailto) = split(/::/, $line);
> if ($id ne $member)
> {
> close FILEHANDLE;
> &error('No valid member found.');
> exit;
> }
> }
> 
> The data file is something like this:
> 
> This works fine
> 1033444038::user@mail.com
> 
> But this does not work
> 1033444038::user@mail.com
> 1027847623::user@hotmail.com
> 
> 
> I guess the command does work correctly.
> $line =~ s/\n//g;
> 
> Please help.


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

Date: Thu, 03 Oct 2002 01:25:30 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl Tutor Wanted - Mtn View, CA
Message-Id: <slrnapn6f9.4d2.tadmc@magna.augustmail.com>

Dick Penny <penny1482@attbi.com> wrote:

> For me clpm is either 100% success or 100% failure


So you get half your problems solved for free.  

That's a pretty good deal.


For the other half:

Have you tried Perl Monks yet?

   www.perlmonks.com


If you are a beginner, there is also a mailing list just for that:

   http://lists.perl.org/showlist.cgi?name=beginners


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 03 Oct 2002 01:25:31 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl Tutor Wanted - Mtn View, CA
Message-Id: <slrnapn6ua.4d2.tadmc@magna.augustmail.com>

Dick Penny <penny1482@attbi.com> wrote:

> IMHO perldoc sucks unless you know what Q to ask it


I agree. I never actually _use_ the perldoc program, though
I seem to cite it with the same frequency as drawing breath :-)

(I lied there. I do use perldoc for seeing _module_ documentation)

perldoc is a not-so-hot search tool though.

I find out where the *.pod files got installed and grep away
to my heart's content.

If faced with information overload from too many hits, I make
indexes and then grep the indexes. eg:

   grep ^=head perlfaq[0-9].pod >faq.indexed

Putting an Initial Cap on your search term is also a handy trick,
finds it in titles and at the beginning of sentences.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 03 Oct 2002 03:44:05 GMT
From: Crackpot <Crackhead@mensa.org>
Subject: Printing text to a file
Message-Id: <Xns929BD2EB75E32Crackheadmensaorg@204.127.68.17>

Hello,
I have a file that I create and I want to put text on it. However my text 
has tons of quotations and special characters. How do I print a block of 
text with special characters in Perl?
Thanks


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

Date: 2 Oct 2002 18:39:49 -0700
From: chopwood@resumemail.com (Chop Wood)
Subject: Re: Script stops working when DBI added. Why?
Message-Id: <38f25324.0210021739.484c2c32@posting.google.com>

"ColdCathoid" <me@me.com> wrote in message news:<anf9q2$d3001$1@ID-158028.news.dfncis.de>...
> "William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
> news:anf89h$hin$1@nntp9.atl.mindspring.net...
> > "ColdCathoid" <me@me.com> wrote in message
> > news:anf5mt$dn8k5$1@ID-158028.news.dfncis.de...
> > >
> > > "Helgi Briem" <helgi@decode.is> wrote in message
> > > news:3d9b14db.2013682432@news.cis.dfn.de...
> > > > On Wed, 2 Oct 2002 08:37:00 -0600, "ColdCathoid" <me@me.com>
> > > > wrote:
>  <snip>
> > > >
> > > > Then set up a web server and Perl on your workstation and
> > > > test it there before uploading. Easy enough.
> > >
> > > Well, no it's not that easy. At work I am limited as to what I can
>  install
> > > on my workstation.
> > >
> >
> > Really? WADR, it appears you are arguing too strongly for your
>  limitations,
> > instead of seeking a way to overcome them.
> >
> > It appears you are running Windows at both locations. Why not download and
> > install IndigoPerl, available free from www.indigostar.org. You'd then
>  have
> > a local test environment, where you'd be able to debug your scripts before
> > uploading to your ISP.
> 
> Yes I suppose I am. I did not intend to come off as strong as I did and I do
> apoligise. It's just some people make generaliztions without knowing my
> situation.
> 
> You are correct, I am running Windows both at home and at work. I am in the
> process of setting up a linux server at home. Hopefully soon I will have
> perl running there. But until then I must work with the situation I am
> given. I will check out IndigoPerl for sure! BTW it seems to be
> www.indigostar.com =) Thank you very much for a very helpful response.

From Chop Wood: I really don't belong here at all, but thought someone
might take pity on me. [Such a PC ignoramous I can't figure out how
Microsoft "Community Newsgroups" are supposed to work] Just a question
re Text Pad...hoping it works the same for Windows as it does for
Linux.

I have Windows ME. I downloaded a Spanish doc into Text Pad probably 6
mo ago now, and I believe Text Pad switched to Spanish mode at that
time. I need to get it back into English but haven't a clue how to do
it.


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

Date: Thu, 3 Oct 2002 01:58:00 +0000 (UTC)
From: Da Witch <heather710101@yahoo.com>
Subject: Re: Speed optimization (with code)
Message-Id: <ang878$1ti$1@reader1.panix.com>

In <20021002115938.260$I5@newsreader.com> ctcgag@hotmail.com writes:

>You could use DProf, but you'd have to break main down into
>reasonable subroutines (which you should do anyway).

I had more subs, but I found that when I inlined them, the running
time dropped by about 40%.

>What is this?  Is it some kind of Fisher's exact test?

Exactly.

>p.s. caching the slice @nameslist[1..$#nameslist]  will get you ~15%
>faster.

Do you mean

  my @temp = @nameslist[1..$#nameslist];
  for(@temp) {
    ...

instead of

  for(@nameslist[1..$#nameslist]) {
    ...

?

Thanks!

h



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

Date: Wed, 02 Oct 2002 19:51:59 -0700
From: Zeus <zeus_riposta@yahoo.com>
Subject: Tricky question on calling a shell from a perl script
Message-Id: <3D9BB0CF.155D1340@yahoo.com>

Hi,

I'm trying to call a shell script from a perl script which should run a
few programs and then exit back to the perl script.

For example, perl script P invokes shell script S to run programs A, B &
C. Then the unix equivalent of what I'm trying to achieve is:
cat << EOF | S
A
B
C
EOF

In the above example, A, B & C will be executed within shell S and on
completion S exits back to the parent shell.

I'd like to know whether this can be achieved in perl.

Thanks,

Zeus.




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

Date: Wed, 02 Oct 2002 20:04:13 -0700
From: Zeus <zeus_riposta@yahoo.com>
Subject: Re: Tricky question on calling a shell from a perl script
Message-Id: <3D9BB3AD.2804C034@yahoo.com>

A correction: In the example below, S is a shell while A, B and C are shell
scripts. Please forgive me for not phrasing the question correctly.

Zeus.

Zeus wrote:

> Hi,
>
> I'm trying to call a shell script from a perl script which should run a
> few programs and then exit back to the perl script.
>
> For example, perl script P invokes shell script S to run programs A, B &
> C. Then the unix equivalent of what I'm trying to achieve is:
> cat << EOF | S
> A
> B
> C
> EOF
>
> In the above example, A, B & C will be executed within shell S and on
> completion S exits back to the parent shell.
>
> I'd like to know whether this can be achieved in perl.
>
> Thanks,
>
> Zeus.



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

Date: Thu, 3 Oct 2002 02:48:13 +0000 (UTC)
From: gary.hodgesREMOVE@cires.colorado.edu
Subject: want reverse substr
Message-Id: <angb5d$9ki$1@news.nems.noaa.gov>

OK, bad subject.  I want to accomplish the following.

$file = "1234-01";

I want to search from the end until I find a \D 
Something like this only backwards

while ($file !~ /^\D) {
  $file = substr($file,1);
}

Which exits with a value of $file of -01 .   In this example the result is
the same, but it is what I want to do.

Gary


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

Date: Thu, 3 Oct 2002 03:00:31 +0000 (UTC)
From: gary.hodgesREMOVE@cires.colorado.edu
Subject: Re: want reverse substr
Message-Id: <angbsf$a1g$1@news.nems.noaa.gov>

OK, it looks like reverse will get me where I'm going.

GH

gary.hodgesREMOVE@cires.colorado.edu wrote:
: OK, bad subject.  I want to accomplish the following.

: $file = "1234-01";

: I want to search from the end until I find a \D 
: Something like this only backwards

: while ($file !~ /^\D) {
:   $file = substr($file,1);
: }

: Which exits with a value of $file of -01 .   In this example the result is
: the same, but it is what I want to do.

: Gary


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

Date: Thu, 03 Oct 2002 04:02:05 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: want reverse substr
Message-Id: <slrnapndom.5bn.tadmc@magna.augustmail.com>

gary.hodgesREMOVE@cires.colorado.edu <gary.hodgesREMOVE@cires.colorado.edu> wrote:

> I want to search from the end until I find a \D 


Take advantage of greedy matching:

   $file =~ s/.*(\D)/$1/;
or
   $file =~ s/.*(?=\D)//;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 03 Oct 2002 02:27:43 GMT
From: Vespasian <VES@VES.NET>
Subject: Re: Which one is more efficient regarding constant scalars?
Message-Id: <cqqbPeluoO4WWW8IJ7BQcU=azU2T@4ax.com>

On 2 Oct 2002 07:02:47 GMT, "Tassilo v. Parseval"
<Tassilo.Parseval@post.rwth-aachen.de> wrote:

>Also sprach Vespasian:
>
>> Which of the following is more time/memory efficient or are they the
>> same?
>> 
>> 1) 
>> use constant PI => 3.14; 
>> 
>> or,
>> 
>> 2) 
>> *PI = \3.14;
>
>The difference is negligible. But then, those two statements are not
>equivalent. The first creates an inlined subroutine:
>
>    sub PI () { 3.14 }
>
>while the second assigns 3.14 to the scalar slot of the typeglob *PI.
>That -being a scalar - has the advantage of interpolating nicely in
>strings:
>
>    print "PI is $PI";
>
>But it's not really a constant since it's value can be altered.
>
>By the way, you could write the first also with a typeglob:
>
>    BEGIN { *PI = sub () { 3.14 } }
>
>That needs to be in a begin block because the prototype requires compile
>time.
>
>Tassilo


 print "PI is $PI";
 but it nor really a constant since it's value can be altered.

*PI = \3.14 
makes  $PI read-only.



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

Date: Wed, 2 Oct 2002 22:38:02 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: Which one is more efficient regarding constant scalars?
Message-Id: <Pine.A41.3.96.1021002223726.33186A-100000@cortez.sss.rpi.edu>

On Thu, 3 Oct 2002, Vespasian wrote:

>*PI = \3.14 
>makes  $PI read-only.

But not *PI, so I can say

  *PI = \3.14;
  *PI = \3;

-- 
Jeff "japhy" Pinyan      RPI Acacia Brother #734      2002 Acacia Senior Dean
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Thu, 03 Oct 2002 02:13:42 GMT
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: why does where matter?
Message-Id: <Xns929BE2654FFC5sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"~greg" <gm@magpage.com> wrote in news:ane09h$61j$0@216.155.33.35:

> use strict;
> 
> my $Test1 = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]];
> 
> sub PrintArray
> {
>   my $a = shift;
>   my $a_ = eval $a;
 ...
> }
 ...
> 
> PrintArray( '$Test1' );
> PrintArray( '$Test2' );
 
I have to ask, why on earth are you passing variables in by name, and using 
an eval on them?  I can't think of a sane reason for doing so.  All you're 
doing is making your program slow and bug-prone.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPZuoNmPeouIeTNHoEQLGpQCg1EHR3dpE/yMjIqs7vysQfyD1FO8AoI/v
YSqXC9FjaBJuBOOw4+wi5rTF
=TEQx
-----END PGP SIGNATURE-----


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

Date: Wed, 2 Oct 2002 19:21:59 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: why does where matter?
Message-Id: <3d9ba9c7$1@news.microsoft.com>

~greg wrote:
> This subroutine pretty-prints the contents of 2-dim arrays.
> It's output is intended to replace a calculated array with a static
> definition.
>
> .
> example:
>    PrintArray( '$Test' );
>
> where $Test is a reference to a 2-dim array.

I guess this is a very odd usage of symbolic references. Please see the FAQ
about why they are evil. Why don't you just pass the variable $Test to your
function?
    PrintArray $Test;
If you want the name of the variable, too, then just use a second parameter,
one for the data, the second for the name:
    PrintArray $Test, '$Test';

Having said that I would suggest to use Data::Dumper instead of your
home-cooked solution.
Data::Dumper provides this functionality already.

jue




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

Date: Thu, 03 Oct 2002 01:24:46 GMT
From: "Bob X" <bobx@linuxmail.org>
Subject: || versus OR
Message-Id: <y%Mm9.17519$Lg2.4824543@news2.news.adelphia.net>

Is there any real difference between the two operators? The only thing I
usually see is a statement such as "...the lower precedence OR". Is there a
case where it would matter or is it purely a style choice?

Bob




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

Date: Wed, 02 Oct 2002 21:34:36 -0400
From: David Britten <brittedg@student.gvsu.edu>
Subject: Re: || versus OR
Message-Id: <B9C116EC.550C%brittedg@student.gvsu.edu>

On 10/2/02 9:24 PM, in article
y%Mm9.17519$Lg2.4824543@news2.news.adelphia.net, "Bob X"
<bobx@linuxmail.org> wrote:

> Is there any real difference between the two operators? The only thing I
> usually see is a statement such as "...the lower precedence OR". Is there a
> case where it would matter or is it purely a style choice?
> 
> Bob

Here's the relevant portion of the precedence table from O'Reilly's Perl
Pocket Reference. The operators would be evaluated from top to bottom.

&&
||
 ..  ...
?:
=   +=  -=  etc.
,   =>
list operators (whatever that's supposed to mean)
not
and
or
xor


So the difference is fairly minimal. You'll only notice a difference when
dealing with those operators that fall between the symbolic and English
versions in terms of precedence.


-David Britten



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

Date: Thu, 03 Oct 2002 01:41:21 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: || versus OR
Message-Id: <3D9BA01D.60E81D3B@acm.org>

Bob X wrote:
> 
> Is there any real difference between the two operators? The only thing I
> usually see is a statement such as "...the lower precedence OR". Is there a
> case where it would matter or is it purely a style choice?

In a list context || has higher precedence than the comma operator while
or has lower precence so yes it does matter.  :-)


John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 03 Oct 2002 01:49:15 GMT
From: "Bob X" <bobx@linuxmail.org>
Subject: Re: || versus OR
Message-Id: <vmNm9.17551$Lg2.4829564@news2.news.adelphia.net>

"John W. Krahn" <krahnj@acm.org> wrote in message
news:3D9BA01D.60E81D3B@acm.org...
> Bob X wrote:
<snip>
> In a list context || has higher precedence than the comma operator while
> or has lower precence so yes it does matter.  :-)
>
>
> John

Can you give me a very short lesson as to how it matters in a list context?

Bob




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

Date: Thu, 03 Oct 2002 01:51:12 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: || versus OR
Message-Id: <koNm9.33169$YI.6656492@twister.nyc.rr.com>

Bob X <bobx@linuxmail.org> wrote:
> Is there any real difference between the two operators? The only
> thing I usually see is a statement such as "...the lower precedence
> OR". Is there a case where it would matter or is it purely a style
> choice?
> 

  open FOO, 'foo'  || die $!;

Seems to happen fairly often...

-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'


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

Date: Wed, 2 Oct 2002 19:13:32 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: || versus OR
Message-Id: <3d9ba7cc$1@news.microsoft.com>

Bob X wrote:
> Is there any real difference between the two operators? The only
> thing I usually see is a statement such as "...the lower precedence
> OR". Is there a case where it would matter or is it purely a style
> choice?

Oh, it does matter quite a bit. Typical example (square brackets added to
illustrate precedences):

    [open F, 'foo.bar'] or [die "Can't open foo.bar because $!\n"];
versus
    open F, ['foo.bar' || die "Can't open foo.bar because $!\n"];

Which one do you want?

jue




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 3906
***************************************


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