[15486] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2896 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 28 18:06:33 2000

Date: Fri, 28 Apr 2000 15:05:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <956959519-v9-i2896@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 28 Apr 2000     Volume: 9 Number: 2896

Today's topics:
    Re: [REGEXP] Extremely important please read! (Bart Lateur)
    Re: A job for Perl? and What? (Steve)
    Re: A job for Perl? and What? <lr@hpl.hp.com>
    Re: A job for Perl? and What? peliknish@my-deja.com
    Re: A job for Perl? and What? (Tad McClellan)
    Re: A script to make the output of "perldoc -f ..." mor <iltzu@sci.invalid>
    Re: A script to make the output of "perldoc -f ..." mor (Bart Lateur)
    Re: capture perl -cw from perl (Brandon Metcalf)
    Re: capture perl -cw from perl (Brandon Metcalf)
    Re: capture perl -cw from perl swaroop_g@my-deja.com
    Re: capture perl -cw from perl <mjcarman@home.com>
    Re: capture perl -cw from perl (Tad McClellan)
        Co <care227@attglobal.net>
    Re: Co <tony_curtis32@yahoo.com>
    Re: Co <care227@attglobal.net>
    Re: Co <lauren_smith13@hotmail.com>
    Re: Co <sariq@texas.net>
    Re: Co <lr@hpl.hp.com>
    Re: Co <lauren_smith13@hotmail.com>
    Re: Co <lr@hpl.hp.com>
    Re: Co <sariq@texas.net>
    Re: control-backslash in a literal string <jrw32982@my-deja.com>
        DBD::CSV Can't Find Text::CSV_XS <grichard@uci.edu>
        do function <ppi@searchy.net>
    Re: do function <lr@hpl.hp.com>
    Re: do function jlamport@calarts.edu
    Re: do function <lr@hpl.hp.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 28 Apr 2000 18:20:05 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: [REGEXP] Extremely important please read!
Message-Id: <3909d647.768345@news.skynet.be>

Charles Henry wrote:

>> > That is from your point of view, which you are untitled to.
>>                                                  ^^
>> Interesting Freudian slip? ;-)
>
>That is to say?

	ENtitled

-- 
	Bart.


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

Date: 28 Apr 2000 20:42:26 GMT
From: sjlen@ndirect.co.uk (Steve)
Subject: Re: A job for Perl? and What?
Message-Id: <slrn8gjpu1.ete.sjlen@zero-pps.localdomain>

On Fri, 28 Apr 2000 16:32:16 GMT, peliknish@my-deja.com wrote:
>Hello,
>Currenly I know javascript and HTML but am totally ignorant about perl,
>cgi and anything serverside. I want to learn enough perl and whatever
>else is necessary to do the following  (see below).  My questions are
>1. What else, if anything, *is* necessary?  2. Is it realistic to think
>I could learn enough to do this in a week if I studied it full time?
>3.  Are there big pieces of code out there I could adapt for this
>purpose without having to learn much at all?  (I’d like to learn but I
>don’t have much time at the moment.)
>
>So here’s what I want to do.  A word game I’ve written in javascript on
>a web page requires an array of 100 words.  I want this array of 100 to
>be freshly drawn at random from a list I have of about 100,000 english
>words (currently in a .txt file with words separated by carriage
>returns) to be kept (in whatever form) on the server.

Create a file on the disk, in your script check the contents of the file
with the system date, if the file and system date are different then
write over the file with the new date and go on to pick 100 new words which
you'll put into a file for use throughout today, (make sure all users get the
same word list). Tom's advice on chosing random words should get you started.

open (THETIMELINE, "/usr/lastdatewritten")
        || die "Can't open file lastdatewritten $!";

while(<THETIMELINE>)
    {
      chomp;
      $dateinfile = $_;
    }

close (THETIMELINE, "/usr/lastdatewritten")
        || die "Can't close file lastdatewritten $!";

$onedayatatime = (scalar localtime);

@whatdayisit = split /\s/, $onedayatatime;

$justfortoday="$whatdayisit[0] $whatdayisit[1] $whatdayisit[2] $whatdayisit[4]" 

if($justfortoday != $dateinfile)
  {
    open (THETIMELINE, ">/usr/lastdatewritten")
        || die "Can't open file lastdatewritten $!";
    
    print THETIMELINE, $justfortoday;

    close (THETIMELINE, "/usr/lastdatewritten")
        || die "Can't close file lastdatewritten $!";

    therandwordthing();

  } 
   
sub therandwordthing
    {

     ## Tom's random word stuff goes here. 

    }


I havn't tested this so it will need considerable tweaking, but you get
the idea.

-- 
Cheers
Steve              email mailto:sjlen@ndirect.co.uk

%HAV-A-NICEDAY Error not enough coffee  0 pps. 

web http://www.ndirect.co.uk/~sjlen/

or  http://start.at/zero-pps

  7:54pm  up 1 day, 21:55,  4 users,  load average: 1.00, 1.00, 1.00


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

Date: Fri, 28 Apr 2000 12:57:10 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: A job for Perl? and What?
Message-Id: <MPG.13738cef64de948998a9ab@nntp.hpl.hp.com>

In article <slrn8gjpu1.ete.sjlen@zero-pps.localdomain> on 28 Apr 2000 
20:42:26 GMT, Steve <sjlen@ndirect.co.uk> says...

 ...

> $justfortoday="$whatdayisit[0] $whatdayisit[1] $whatdayisit[2] $whatdayisit[4]" 
> 
> if($justfortoday != $dateinfile)

 ...

> I havn't tested this so it will need considerable tweaking, but you get
> the idea.

It sure will.  :-)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 28 Apr 2000 20:59:29 GMT
From: peliknish@my-deja.com
Subject: Re: A job for Perl? and What?
Message-Id: <8ecu38$ol8$1@nnrp1.deja.com>

Thanks a bunch Steve and Tom.  I don't totally understand what's going
on but having these relevant examples will make going through tutorials
much more effective I think.  There's still one step I'm completely
baffled about and that's the final one.  Maybe it's there and I don't
understand it, but how do we ("we" gives you a sense that this is a
group project--we're all in this together, fighting for what is right)
get the file that Tom's code produces onto the page?  That is, how do
we produce an html file like...

<html>
<head>
<script language=javascript>
var todaysArray = new Array(CONTENT OF TOM'S FILE, each word quoted and
separated by commas)
   //or just
var todaysGiant100WordListString =  CONTENT OF TOM'S FILE in the form
of one long string, words separated by spaces or whatever, which can
later be converted into a javascript array (That part I know how to
do.).

Uh-oh.  Theres not a limit on the length of strings in javascript is
there?  I'll have to look into that.


Anyway, I'm not lazy.  I'm an efficient learner.
TA and TIA,
kurt
pelicans at hotmail dot etc


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 28 Apr 2000 15:59:25 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: A job for Perl? and What?
Message-Id: <slrn8gjrct.37k.tadmc@magna.metronet.com>

On Fri, 28 Apr 2000 16:32:16 GMT, peliknish@my-deja.com <peliknish@my-deja.com> wrote:

>I want to learn enough perl and whatever
>else is necessary to do the following  (see below).  My questions are
>1. What else, if anything, *is* necessary?  


You will need to learn a bit about CGI too, but that
is off-topic for this newsgroup (you can use just about
any programming language for writing CGI programs).

See    comp.infosystems.www.authoring.cgi   for CGI questions.



But there are Perl FAQs that mention CGI:

   "Where can I learn about CGI or Web programming in Perl?"

   "My CGI script runs from the command line but not the browser."

   "How can I get better error messages from a CGI program?"

   "How do I make sure users can't enter values into a form that 
    cause my CGI script to do bad things?"

   "How do I decode a CGI form?"


Some of those include URLs of other FAQs to have a look at.


>2. Is it realistic to think
>I could learn enough to do this in a week if I studied it full time?


Yes.


>3.  Are there big pieces of code out there I could adapt for this
>purpose without having to learn much at all?  (I’d like to learn but I
>don’t have much time at the moment.)


Yes.

The CGI.pm module will handle many things that you need done.


>So here’s what I want to do.  A word game I’ve written in javascript on
>a web page requires an array of 100 words.  I want this array of 100 to
>be freshly drawn at random from a list I have of about 100,000 english
>words (currently in a .txt file with words separated by carriage
>returns) to be kept (in whatever form) on the server.


The "perldoc" program (part of the perl distribution) can look
up Frequently Asked Questions for you:

   perldoc -q random

   "How do I select a random line from a file?"


>I'd appreciate any answers to the above questions and/or broad outlines
>for how you would go about setting up such a thing.  Or, what the hell,
>specific outlines, or, just go ahead and write the whole thing for me
>and do my taxes and sweep the yard and fertilize the hydrangea and
>defrost my refrigerator.


Thank you so much for not asking us to do Windows    :-)


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 28 Apr 2000 18:08:04 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: A script to make the output of "perldoc -f ..." more readable.
Message-Id: <956945253.23648@itz.pp.sci.fi>

In article <m1og6vxizh.fsf@halfdome.holdit.com>, Randal L. Schwartz wrote:
>>>>>> "Francis" == Francis Litterio <franl-removethis@world.omitthis.std.com> writes:
>Francis> This script arranges to feed the output of "perldoc -f ..." through
>Francis> pod2man to make it more readable.
>
>you don't like 
>        perldoc -t -f FUNCNAME
>That's what I use.  Lot less work. :)

$ perldoc -f my 
=item my EXPR

A C<my()> declares the listed variables to be local (lexically) to the
enclosing block, file, or C<eval()>.  If
more than one value is listed, the list must be placed in parentheses.  See
L<perlsub/"Private Variables via my()"> for details.

$ perldoc -t -f my
$ perldoc -t my
No documentation found for "my".

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Fri, 28 Apr 2000 18:24:02 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: A script to make the output of "perldoc -f ..." more readable.
Message-Id: <390ad684.829971@news.skynet.be>

Ilmari Karonen wrote:

>
>$ perldoc -f my 
>=item my EXPR
>
>A C<my()> declares the listed variables to be local (lexically) to the
 ...

Allow me to consider this a bug. Why on earth would "perldoc module"
have to format the docs, and "perldoc -f function" not?

-- 
	Bart.


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

Date: 28 Apr 2000 18:10:06 GMT
From: bmetcalf@baynetworks.com (Brandon Metcalf)
Subject: Re: capture perl -cw from perl
Message-Id: <8eck5u$k9d$2@spinner.corpeast.baynetworks.com>

aqumsieh@hyperchip.com writes:

 > 
 > "Asmara" <akubi_98@yahoo.com> writes:
 > 
 > > Hi there!
 > > 
 > > I am having some trouble with capturing a command output.
 > > 
 > > If I do:
 > >     $cmd = `ls`;
 > > 
 > > I get the command output. But if I try:
 > >     $cmd = `perl -cw foo.pl`;
 > > 
 > > I can't get anything!!! How come? What can I do to capture the
 > > output of the perl debugger?
 > 
 > Why are you using the -c switch? This switch asks Perl to check the
 > syntax of the script only, without executing it. From perlrun:

Maybe the OP wants to check the syntax of a command before executing
it.  I've never done this, but maybe that's what he had in mind.

Brandon


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

Date: 28 Apr 2000 18:10:06 GMT
From: bmetcalf@baynetworks.com (Brandon Metcalf)
Subject: Re: capture perl -cw from perl
Message-Id: <8eck5u$k9d$1@spinner.corpeast.baynetworks.com>

akubi_98@yahoo.com writes:

 > I am having some trouble with capturing a command output.
 > 
 > If I do:
 >     $cmd = `ls`;
 > 
 > I get the command output. But if I try:
 >     $cmd = `perl -cw foo.pl`;
 > 
 > I can't get anything!!! How come? What can I do to capture the output of the
 > perl debugger?
 > (I don't want to write the output to a file 'perl -cw foo.pl > file.txt')
 > 
 > I even tried: $cmd = `perl -cw foo.pl > echo`; and it doesn't work ...

Works for me.

lovett (bmetcalf_91) tmp $ cat jj
#!/bin/perl

$cmd = `perl -cw jj`;

print $cmd;
lovett (bmetcalf_91) tmp $ ./jj
jj syntax OK
lovett (bmetcalf_91) tmp $ 

Brandon


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

Date: Fri, 28 Apr 2000 18:25:02 GMT
From: swaroop_g@my-deja.com
Subject: Re: capture perl -cw from perl
Message-Id: <8ecl1b$e1r$1@nnrp1.deja.com>



try $cmd = `perl -cw foo.pl 2>&1`


In article <8ecfh7$h9o$1@wrath.news.nacamar.de>,
  "Asmara" <akubi_98@yahoo.com> wrote:
> Hi there!
>
> I am having some trouble with capturing a command output.
>
> If I do:
>     $cmd = `ls`;
>
> I get the command output. But if I try:
>     $cmd = `perl -cw foo.pl`;
>
> I can't get anything!!! How come? What can I do to capture the output
of the
> perl debugger?
> (I don't want to write the output to a file 'perl -cw foo.pl >
file.txt')
>
> I even tried: $cmd = `perl -cw foo.pl > echo`; and it doesn't work ...
>
> Manri
>
>

--

the future is happening   - me


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 28 Apr 2000 12:48:47 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: capture perl -cw from perl
Message-Id: <3909CEFF.3D6B0A90@home.com>

Asmara wrote:
> 
> I am having some trouble with capturing a command output.
> 
> [...] if I try:
>     $cmd = `perl -cw foo.pl`;
> 
> I can't get anything!!!

That syntax looks fine, so the problem must be elsewhere. Show us a few
lines from your script where the problem occurs.

-mjc


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

Date: Fri, 28 Apr 2000 16:31:58 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: capture perl -cw from perl
Message-Id: <slrn8gjt9u.37k.tadmc@magna.metronet.com>

On Fri, 28 Apr 2000 18:51:31 +0200, Asmara <akubi_98@yahoo.com> wrote:

>I am having some trouble with capturing a command output.
>
>If I do:
>    $cmd = `ls`;
>
>I get the command output. But if I try:
>    $cmd = `perl -cw foo.pl`;
>
>I can't get anything!!! How come? 


Because that is what it is supposed to do.

The docs even say that it is supposed to do that.

Backticks (qx) is documented in the perlop.pod man page:

   "The collected standard output of the
    command is returned; standard error is unaffected."


>What can I do to capture the output of the
>perl debugger?


I don't know what that question is doing here, you are not
using the perl debugger...

The perl debugger is invoked with the "-d" switch.

I'll assume that you instead meant "How can I capture the
output from 'perl -cw'".


Warnings (and errors) are output on STDERR.


So you need to capture STDERR from an external command:

   Perl FAQ, part 8:

      "How can I capture STDERR from an external command?"


Short answer: use shell redirection to merge STDERR with STDOUT


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 28 Apr 2000 14:10:19 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Co
Message-Id: <3909D40B.B68C0502@attglobal.net>

OK, I have a quick question about getting the count of an array
reference, as contrasted to a normal array.

Im used to doing something like:

for ($i = 0; $i <=$#array; $i++){

        do stuff with each element here

}

But I have a reference that im using, and not the actual
array.  My question.  How would I get the last number, using
the method above, of a reference?  is it like this:

for ($i = 0; $i <=$$#array; $i++){}

or is there some other syntax?

I checked the archives via Deja and re-read the perlref documents,
but didn't find the information.  Any help would be appreciated.


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

Date: 28 Apr 2000 13:17:43 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Co
Message-Id: <87k8hit7i0.fsf@shleppie.uh.edu>

>> On Fri, 28 Apr 2000 14:10:19 -0400,
>> Drew Simonis <care227@attglobal.net> said:

> for ($i = 0; $i <=$#array; $i++){
>         do stuff with each element here
> }

> But I have a reference that im using, and not the actual
> array.  My question.  How would I get the last number,
> using the method above, of a reference?  is it like
> this:

> for ($i = 0; $i <=$$#array; $i++){}

$#array gives the last index of 'array'.

So for a reference you'd just need:

    @data = (1, 2, 3, 4, 5, 6);

    $ref = \@data;

    $count = $#data;
    print "$count\n";

    $count = $#$ref;
    print "$count\n";

Also: are you sure you need to iterate over the indices
like this?  It has a certain "C" flavour to it.  A map or
foreach might be more perlish, but it depends on what
you're doing.


hth
t


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

Date: Fri, 28 Apr 2000 14:30:05 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Co
Message-Id: <3909D8AD.37BAB757@attglobal.net>



Tony Curtis wrote:
> 
>     $count = $#$ref;
>     print "$count\n";
> 
> Also: are you sure you need to iterate over the indices
> like this?  It has a certain "C" flavour to it.  A map or
> foreach might be more perlish, but it depends on what
> you're doing.
> 

I look at the subject and think I got distracted.  Co?
Anyway, what Im doing with this is printing the array 
out to a text file line by line, kinda like this:

for ($i = 0; $i <= $#$ref; $i++){

print DATA $ref->[$i] . "blah blah blah \n";

}

Is there an easier way?


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

Date: Fri, 28 Apr 2000 11:21:10 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Co
Message-Id: <8eckrn$k57$1@brokaw.wa.com>


Drew Simonis <care227@attglobal.net> wrote in message
news:3909D40B.B68C0502@attglobal.net...
> OK, I have a quick question about getting the count of an array
> reference, as contrasted to a normal array.
>
> Im used to doing something like:
>
> for ($i = 0; $i <=$#array; $i++){
>
>         do stuff with each element here
>
> }

The usual method of iterating through a list is with the 'foreach'
statement.

foreach $item (@array) { # do something with $item }

If you have a reference to the array:

foreach $item (@$arrayref) { ... }

> But I have a reference that im using, and not the actual
> array.  My question.  How would I get the last number, using
> the method above, of a reference?  is it like this:
>
> for ($i = 0; $i <=$$#array; $i++){}
>
> or is there some other syntax?

You could simplify that line to

for ($i = 0; $i < @$array; $i++) {...}

But I think the foreach method is cleaner and much more Perlish.

perldoc -f foreach
perldoc -f for

Lauren




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

Date: Fri, 28 Apr 2000 13:47:32 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Co
Message-Id: <3909DCC4.4BF56026@texas.net>

Drew Simonis wrote:
> 
> I look at the subject and think I got distracted.  Co?
> Anyway, what Im doing with this is printing the array
> out to a text file line by line, kinda like this:
> 
> for ($i = 0; $i <= $#$ref; $i++){
> 
> print DATA $ref->[$i] . "blah blah blah \n";
> 
> }
> 
> Is there an easier way?

Easier?  Well, at least more Perlish...

for (@$ref) {

     print DATA "${_}blah blah blah \n";
}

or, if you need the index for a reason, 

for (0..$#$ref) {

     print DATA "$ref->[$i]blah blah blah \n";
}

- Tom


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

Date: Fri, 28 Apr 2000 11:42:40 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Co
Message-Id: <MPG.13737b7ccf270a2e98a9a5@nntp.hpl.hp.com>

[What did you have in mind for a Subject?  'Co' just doesn't convey 
much.  :-]

In article <3909D40B.B68C0502@attglobal.net> on Fri, 28 Apr 2000 
14:10:19 -0400, Drew Simonis <care227@attglobal.net> says...
> OK, I have a quick question about getting the count of an array
> reference, as contrasted to a normal array.

 ...

> for ($i = 0; $i <=$$#array; $i++){}
> 
> or is there some other syntax?

Oh, so close!

It is $#$array_ref .  (But I would say '$i < @$array_ref' in any case.)

There was a long thread here just last week, I think, about a lot of 
variations on that including braces to delimit complex references:

    $#{$foo[$bar]}

But offhand I don't know where this is explicitly shown.  The simple 
$#array syntax is defined in perldata, but I find nothing in perlref or 
perlreftut.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 28 Apr 2000 11:46:55 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Co
Message-Id: <8ecma4$k0s$1@brokaw.wa.com>


Drew Simonis <care227@attglobal.net> wrote in message
news:3909D8AD.37BAB757@attglobal.net...
>
> I look at the subject and think I got distracted.  Co?
> Anyway, what Im doing with this is printing the array
> out to a text file line by line, kinda like this:
>
> for ($i = 0; $i <= $#$ref; $i++){
>
> print DATA $ref->[$i] . "blah blah blah \n";
>
> }
>
> Is there an easier way?

Yep.

for (@$ref) {
   print DATA $_."blah blah blah \n";
}


:-)
Lauren




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

Date: Fri, 28 Apr 2000 11:53:41 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Co
Message-Id: <MPG.13737e123512cd6598a9a7@nntp.hpl.hp.com>

In article <3909D8AD.37BAB757@attglobal.net> on Fri, 28 Apr 2000 
14:30:05 -0400, Drew Simonis <care227@attglobal.net> says...

 ...

> Anyway, what Im doing with this is printing the array 
> out to a text file line by line, kinda like this:
> 
> for ($i = 0; $i <= $#$ref; $i++){
> 
> print DATA $ref->[$i] . "blah blah blah \n";
> 
> }
> 
> Is there an easier way?

  print DATA map $_ . "blah blah blah \n" => @$ref;

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 28 Apr 2000 16:17:53 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Co
Message-Id: <390A0001.7C3529B8@texas.net>

Tom Briles wrote:
> 
> Drew Simonis wrote:
> >
> > I look at the subject and think I got distracted.  Co?
> > Anyway, what Im doing with this is printing the array
> > out to a text file line by line, kinda like this:
> >
> > for ($i = 0; $i <= $#$ref; $i++){
> >
> > print DATA $ref->[$i] . "blah blah blah \n";
> >
> > }
> >
> > Is there an easier way?
> 
> Easier?  Well, at least more Perlish...
> 
> for (@$ref) {
> 
>      print DATA "${_}blah blah blah \n";
> }
> 
> or, if you need the index for a reason,
> 
> for (0..$#$ref) {
> 
>      print DATA "$ref->[$i]blah blah blah \n";

Ack!  Someone kindly berate me for not cutting-and-pasting. 

     print DATA "$ref->[$_]blah blah blah \n";

> }

For completeness (and in addition to Larry Rosler's map approach), the
above can be written as:

print DATA "${_}blah blah blah \n" for @$ref;

and

print DATA "$ref->[$_]blah blah blah \n" for 0..$#$ref;

if you have Perl version >= 5.005.

My excuse for not offering these approaches to begin with is that most
of the machines I use have 5.004 installed, and I have no control over
any upgrades.

- Tom


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

Date: Fri, 28 Apr 2000 19:15:25 GMT
From: John Wiersba <jrw32982@my-deja.com>
Subject: Re: control-backslash in a literal string
Message-Id: <8ecnvt$hgq$1@nnrp1.deja.com>

Thanks, Tom.

In article
<Pine.GSO.4.10.10004280929320.21722-100000@user2.teleport.com>,
  Tom Phoenix <rootbeer@redcat.com> wrote:
> On Fri, 28 Apr 2000, John Wiersba wrote:
>
> > How do I specify ^\ (control-backslash), using \c notation?
>
> You can't; use a different notation.
>
> There was a long, long, looooong discussion of this on the p5p list
last
> November. Look for the "[ID 19991118.014]" messages here, if you want
to
> re-live the pain. :-)
>
>
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1999-11/thrd9.htm
l
>
> Cheers!
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>
>

--
John Wiersba


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 28 Apr 2000 11:35:50 -0700
From: "Gabe" <grichard@uci.edu>
Subject: DBD::CSV Can't Find Text::CSV_XS
Message-Id: <8ecls9$flq$1@news.service.uci.edu>

I've been tring to install DBD::CSV and I keep getting the message:

Checking for DBI, 1.00 or later ... ok
Checking for Text::CSV_XS, 0.16 or later ...
You don't have installed the Text::CSV_XS package, version 0.16 or later.

But the program is lying to me. I installed version .2, and when I got the
error message I tried version .18. Anyone know the problem or how I can find
out the problem?

Gabe




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

Date: Fri, 28 Apr 2000 20:24:12 +0200
From: Penpal International <ppi@searchy.net>
Subject: do function
Message-Id: <3909D74C.327B5850@searchy.net>

I have a little question concerning about the function 'do'.
I know it will execute the script you had given to it. 

Now I have a file. It's containing 1 line with %execute% On that place I
want to execute the script with do like this:

foreach $line(@file) {
	$line =~ s/%execute%/do 'script.pl'/g;
	print $line;
}

But I know this won't work, but it makes the idea of mine distinct.
How can I do this.


-- 
Penpal International
http://ppi.searchy.net/
ppi@searchy.net


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

Date: Fri, 28 Apr 2000 12:05:13 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: do function
Message-Id: <MPG.137380c157f5467b98a9a8@nntp.hpl.hp.com>

In article <3909D74C.327B5850@searchy.net> on Fri, 28 Apr 2000 20:24:12 
+0200, Penpal International <ppi@searchy.net> says...
> I have a little question concerning about the function 'do'.
> I know it will execute the script you had given to it. 
> 
> Now I have a file. It's containing 1 line with %execute% On that place I
> want to execute the script with do like this:
> 
> foreach $line(@file) {
> 	$line =~ s/%execute%/do 'script.pl'/g;
> 	print $line;
> }
> 
> But I know this won't work, but it makes the idea of mine distinct.
> How can I do this.

If you add the /e modifier, the program will execute 'script.pl' and 
substitute for %execute% the value of the last expression evaluated in 
it.  The /g modifier means it will do it again for each '%execute' in 
$line, which is unlikely to be what you want.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 28 Apr 2000 19:29:13 GMT
From: jlamport@calarts.edu
Subject: Re: do function
Message-Id: <8ecopk$iga$1@nnrp1.deja.com>

In article <3909D74C.327B5850@searchy.net>,
  Penpal International <ppi@searchy.net> wrote:
> I have a little question concerning about the function 'do'.
> I know it will execute the script you had given to it.
>
> Now I have a file. It's containing 1 line with %execute% On that place I
> want to execute the script with do like this:
>
> foreach $line(@file) {
> 	$line =~ s/%execute%/do 'script.pl'/g;
> 	print $line;
> }
>
> But I know this won't work, but it makes the idea of mine distinct.
> How can I do this.

If I understand you correctly, it *will* work with just a few extra
keystrokes.  Change the second line to:

 	$line =~ s/\%execute\%/do 'script.pl'/ge;

the e switch causes the right side of the s/// operator to be evaluated
as an expression rather than as a string.  So every instance of %execute%
will cause your script to do 'script.pl', and the string %execute% will
be replaced by whatever the return value of do 'script.pl' is...

See the "Regexp Quote-Like Operators" section of the perlop manpage for
more info.

(Also notice that you need to escape the %'s on the left side of the s///
operator: otherwise Perl will try to interpolate hashes called %execute
and %/ rather than doing what you want.  Hopefully you're running this
with 'use strict' in effect -- so the compiler would have warned you
about that.)

-jason


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 28 Apr 2000 12:58:52 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: do function
Message-Id: <MPG.13738d5b1afaefe798a9ac@nntp.hpl.hp.com>

In article <8ecopk$iga$1@nnrp1.deja.com> on Fri, 28 Apr 2000 19:29:13 
GMT, jlamport@calarts.edu <jlamport@calarts.edu> says...

 ...

> (Also notice that you need to escape the %'s on the left side of the s///
> operator: otherwise Perl will try to interpolate hashes called %execute
> and %/ rather than doing what you want.  Hopefully you're running this
> with 'use strict' in effect -- so the compiler would have warned you
> about that.)

Err, no.  Hashes don't interpolate.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 2896
**************************************


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