[15654] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3067 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 16 18:15:54 2000

Date: Tue, 16 May 2000 15:15:29 -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: <958515329-v9-i3067@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 16 May 2000     Volume: 9 Number: 3067

Today's topics:
    Re: Is my Perl 5.005_03 Compiler broken? <webqueen@my-deja.com>
    Re: Java/Perl lingo (Elaine -HFB- Ashton)
        Link Extractor <samay1NOsaSPAM@hotmail.com.invalid>
    Re: Link Extractor (Tad McClellan)
    Re: neo: require doesn't work <rootbeer@redcat.com>
    Re: perl & apache conf <michael.holzer@attglobal.net>
    Re: Perl and binary files <lr@hpl.hp.com>
    Re: Perl vs ActivePerl <rootbeer@redcat.com>
        Problem or normal?? <skfreeman@my-deja.com>
    Re: Problem or normal?? (Tad McClellan)
    Re: Problem or normal?? <andrew.mcguire@walgreens.com>
        Processing All Files in a Directory: Sorting? (Cory Phillips)
    Re: Processing All Files in a Directory: Sorting? (Tad McClellan)
    Re: Processing All Files in a Directory: Sorting? (Neil Kandalgaonkar)
        Protecting Source Code? <spectralmedia@home.com>
    Re: Protecting Source Code? (Abigail)
    Re: Protecting Source Code? <lr@hpl.hp.com>
    Re: Protecting Source Code? (Tad McClellan)
    Re: Protecting Source Code? <andrew.mcguire@walgreens.com>
    Re: Queastion about CGI.pm sticky values <trw@freewwweb.com>
    Re: Reading and Writing to a file [OT & long] <andrew.mcguire@walgreens.com>
        regexp %%CODE%% multi-line sub in template <dwoods@ucalgary.ca>
    Re: regexp %%CODE%% multi-line sub in template (Abigail)
    Re: regexp %%CODE%% multi-line sub in template (Tad McClellan)
    Re: regexp %%CODE%% multi-line sub in template <dwoods@ucalgary.ca>
    Re: regexp %%CODE%% multi-line sub in template (Abigail)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 16 May 2000 19:33:04 GMT
From: webqueen, queen of the web <webqueen@my-deja.com>
Subject: Re: Is my Perl 5.005_03 Compiler broken?
Message-Id: <8fs7pg$sa3$1@nnrp1.deja.com>

Hi Tom:

No- the only change I made was to add in the () around the expression,
and the previous expression was properly terminated with ;

Besides, if the line above WAS missing a ; then then the

     if defined ($s{$_})

should have been terminated with it's own ; to end the statement above.
It wasn't, and no errors were produced from that either.


This compiler is misbehaving I believe.. And misbehaving in a very bad
way, as the missing ()'s were very difficult to find (in the middle of
the 600-odd lines of code), with no compiler warning or even
an informative run-time message.

I appreciate the possible cause of this problem, but I don't that's it.
I wish it was that easy this time. Any other ideas I promise to look at
very closely; this is discerting. I want a stable, behaving compiler.


Thanks & regards,
-WQ








What I don't understand is, if I read my Programming Perl correctly (pp
532), the expression MUST be surrounded by ()'s, so this should have
generated a syntax error in the <if> production.



In article
<Pine.GSO.4.10.10005160902410.25459-100000@user2.teleport.com>,
  Tom Phoenix <rootbeer@redcat.com> wrote:
> On Tue, 16 May 2000, it was written:
>
> > I had a bug in my code:
> >
> >    if defined ($s{$_})
> >     {print "<tr><td><input type=checkbox name=$_
checked>$sta{id}</td>".
> >            "<td>$sta{name}</td></tr>"}
> >
> > where I'd left the ()'s from around the
> >
> >     if (expression).
> >
> >
> >   *********************************************************
> >     perl -cw mysource
> >
> > said no problem- syntax OK (huh???)
>
> Just because the syntax is okay, that doesn't mean that it's the
syntax is
> doing what you want. Just like in any language, computer or otherwise.
The
> syntax may be correct, but the result may not be correctly glorked.
>
> I'd guess that the if looked like it was modifying something previous
-
> which had a missing semicolon, perhaps?
>
> Cheers!
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>
>

--
Time is nature's way of preventing everything from happening at once.


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


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

Date: 16 May 2000 18:49:37 GMT
From: elaine@chaos.wustl.edu (Elaine -HFB- Ashton)
Subject: Re: Java/Perl lingo
Message-Id: <slrn8i35ur.364.elaine@chaos.wustl.edu>

In article <8fr4me$jm9$1@nnrp1.deja.com>, stbruno@my-deja.com wrote:
>Does anyone know if this is still available as part of Perl5.6 and if there's
>any documentation?

Yes and Yes.

http://search.cpan.org/search?dist=perl

e.


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

Date: Tue, 16 May 2000 11:55:40 -0700
From: Samay <samay1NOsaSPAM@hotmail.com.invalid>
Subject: Link Extractor
Message-Id: <015f3d35.ba387e1a@usw-ex0104-087.remarq.com>

Hi, I would like to extract the link recursively from webpages
which are located on the server to which I have telnet access
to..

My Perl Question is that how to I do it without using LWP
modules as I cannot install any modules on it..


Thanks
Samay

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Tue, 16 May 2000 15:29:18 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Link Extractor
Message-Id: <slrn8i38ce.4sq.tadmc@magna.metronet.com>

On Tue, 16 May 2000 11:55:40 -0700, Samay <samay1NOsaSPAM@hotmail.com.invalid> wrote:

>My Perl Question is that how to I do it without using LWP
>modules as I cannot install any modules on it..
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^


Why not?


Perl FAQ, part 8:

   "How do I keep my own module/library directory?"


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


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

Date: Tue, 16 May 2000 11:07:25 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: neo: require doesn't work
Message-Id: <Pine.GSO.4.10.10005161103130.25459-100000@user2.teleport.com>

On Tue, 16 May 2000 ninuzzo@my-deja.com wrote:

> I have a subroutine read_input to parse out CGI query strings.

Use the CGI module instead. 

> This returns an associative array which contains the pairs (name,value).

The CGI module will allow you to have multiple values with the same name,
which can't hurt and might help.

> It is fine, but every time i have to paste its code into the script.

You wouldn't have to, if you use the CGI module.

> To avoid this i decided to put read_input in a separate file
> (read_input.pl), and i added this line in a script:
> 
> require 'read_input.pl';

Ah, so you read the docs for 'require' in the perlfunc manpage?

> but it doesn't work, i get this error:
> 
> read-input.pl did not return a true value at ./test.pl line 3.

No, that's not the error from that line of code. You didn't
copy-and-paste, you retyped something. I can tell because one has an
underscore and the other has a hyphen. 

Of course, if you had read the entry for 'require' in the perlfunc
manpage, you'd have seen the problem and how to fix it.

Did you look for that error message in the perldiag manpage? Will you
check next time? :-)

Oh, and did I mention the CGI module? :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 16 May 2000 23:30:43 +0200
From: "Michael Holzer" <michael.holzer@attglobal.net>
Subject: Re: perl & apache conf
Message-Id: <3921bf6b_3@news3.prserv.net>


Ian wrote in message <8fr8tk$clh$1@news6.svr.pol.co.uk>...
|I have changed the shebang line as you suggested, I'm using Win98 so I have
|changed it as below. The error log is still reading:-
|
|[Tue May 16 11:42:29 2000] [error] [client 127.0.0.1] (2)No such file or
|directory: couldn't spawn child process: c:/program files/apache
|group/apache/cgi-bin/p20_5.pl
|
|
|#!c:\progra~1\apache~1\apache\cgi-bin\p20_5.pl
|

Maybe i didn't write this clear enough, you don't write the path of your
script,
but the path where perl.exe is. What happened is that you told apache that
the interpreter of your perl script is
c:/program files/apache group/apache/cgi-bin/p20_5.pl
which is positively not the programm to interpret your script, but the
script
to be interpreted.

ys Michael




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

Date: Tue, 16 May 2000 11:40:03 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl and binary files
Message-Id: <MPG.138b35e08df9fc8c98aa88@nntp.hpl.hp.com>

In article <8fr83i$f8c$1@pegasus.tiscalinet.it> on Tue, 16 May 2000 
12:32:43 +0200, Davide Locci <dlocci@tiscali.it> says...
> I would like to know why Perl for WIN32S doesn't allow to copy a binary file
> using the following script?
> 
>  open (INPUT, "anag.dat");
>  open (OUTPUT, ">anag.tmp");

How do you know that those opens succeeded?  Always test!

   open INPUT,  'anag.dat'  or die "Couldn't open anag.dat. $!\n";
   open OUTPUT, '>anag.tmp' or die "Couldn't open anag.tmp. $!\n";

Now you need to spcify binary data-handling for each stream:

   binmode INPUT;
   binmode OUTPUT;

>  while (<INPUT>) {
>       print OUTPUT;
>  }

It is silly to use 'line-at-a-time' I/O on a file that has no 'lines'.

   print OUTPUT while read INPUT, $_, 8192; # Or choose your own size.

>  close (OUTPUT);
>  close (INPUT);
> 
> 
> I need to use this script because i have to pars the byinary string in the
> file.
> How can i solve this problem?

I don't see where you are capturing the string in order to parse it.

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


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

Date: Tue, 16 May 2000 11:09:17 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl vs ActivePerl
Message-Id: <Pine.GSO.4.10.10005161107490.25459-100000@user2.teleport.com>

On Tue, 16 May 2000, Saddek Rehal wrote:

> > > I discovered now that if I put my program hdate.exe at the root directory
> > > and change the line $hdateprg = "/apache/ActivePerl/bin/hdate.exe"; to
> > > $hdateprg = "/hdate.exe";    than my script works correctly, Why???
> >
> > Perhaps because you're using the correct path to that program rather than
> > the incorrect one? Cheers!

> I don't think så. I have hdate.exe in both directories and the path
> are used correctly.

So, you're saying that it's in both /hdate.exe and in
/apache/ActivePerl/bin/hdate.exe? Well, there may be something else wrong
with your program, of course. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 16 May 2000 19:03:05 GMT
From: Stan Freeman <skfreeman@my-deja.com>
Subject: Problem or normal??
Message-Id: <8fs60u$q7h$1@nnrp1.deja.com>

I've run across a problem that I don't recall ever seeing before.
Perhaps its just that I haven't tried to do exactly this same thing.
Anyway, the following script simply reads in an array of filenames and
calls a subroutine to process each file.  (I've taken out all but the
basics.)

As it is written, after each call of the subroutine, my array shrinks
by one, until after all 3 calls, the array becomes empty.  If I take
the while loop out of the subroutine, the array remains intact.  ??
I'd like for the array to remain.

What am I missing??
Thanks.
===================================================================

use strict;
my $file;
my @filearray = ("file1","file2","file3");

print "filearray is @filearray\n";
foreach (@filearray) {
	$file = $_;
	print "file is $file\n";
	&READXVALUES;
};

exit;



sub READXVALUES {

	open  (INFILE, "< $file.txt");

	while ( <INFILE> ) {       # if I take this while loop out the
array is preserved

	};   #  End while

	close (INFILE);
	print "AFTER filearray is @filearray\n";
};



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


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

Date: Tue, 16 May 2000 15:27:01 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Problem or normal??
Message-Id: <slrn8i3885.4sq.tadmc@magna.metronet.com>

On Tue, 16 May 2000 19:03:05 GMT, Stan Freeman <skfreeman@my-deja.com> wrote:

>Anyway, the following script simply reads in an array of filenames and
>calls a subroutine to process each file.  (I've taken out all but the
>basics.)


But it seems likely that some part of that non-basic stuff
is where the problem is...


>As it is written, after each call of the subroutine, my array shrinks
>by one, until after all 3 calls, the array becomes empty.  If I take
>the while loop out of the subroutine, the array remains intact.  ??
>I'd like for the array to remain.
>
>What am I missing??



>use strict;
>my $file;


You should not use global variables to communicate with
a subroutine. You should pass arguments to the subroutine instead.


>my @filearray = ("file1","file2","file3");
>
>print "filearray is @filearray\n";
>foreach (@filearray) {
>	$file = $_;
>	print "file is $file\n";
>	&READXVALUES;


ALL UPPER CASE is yucky.

   read_X_values( $_ );  # don't need to copy values around either


>
>sub READXVALUES {

   my($file) = @_;


>	open  (INFILE, "< $file.txt");

You should always, yes *always*, check the return value from open():

   open  (INFILE, "< $file.txt") || die "could not open '$file.txt'  $!";


>	while ( <INFILE> ) {       # if I take this while loop out the
>array is preserved
>
>	};   #  End while
>
>	close (INFILE);
>	print "AFTER filearray is @filearray\n";
>};


The code shown looks fine (well, not so fine really, but nothing
that explains changing array contents).

You have removed some important part.

Try giving us a real, complete, and short program that we can
run to see the behavior you describe.


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


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

Date: Tue, 16 May 2000 16:50:02 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: Problem or normal??
Message-Id: <3921C28A.3117DF65@walgreens.com>

Tad McClellan wrote:
> 
> On Tue, 16 May 2000 19:03:05 GMT, Stan Freeman <skfreeman@my-deja.com> wrote:
> 
> >Anyway, the following script simply reads in an array of filenames and
> >calls a subroutine to process each file.  (I've taken out all but the
> >basics.)

[ snip of code and reply ]

> You have removed some important part.

I don't think he did.

> Try giving us a real, complete, and short program that we can
> run to see the behavior you describe.

Well I am not the OP, but I rewrote his script, and find it
a bit perl-plexing myself. :-)

#!/usr/bin/perl -w

use strict;
my @filelist = ( 'file1', 'file2', 'file3' );

print "filelist is @filelist\n";

for (@filelist) {
    print "file is $_\n";
    &read_x_values("$_");
}

print "Afterwards, filelist is @filelist\n";

sub read_x_values {
    my $file = shift;
    open INFILE, "$file.txt"
        or die "Can't open $file.txt: $!\n";
    print while <INFILE>;
    close INFILE;
}

__END__

If you comment out the 'print while <INFILE>;' it works
just fine.  There is something here that I too am missing. :-)

Regards,

anm
-- 
/*-------------------------------------------------------.
| Andrew N. McGuire                                      |
| andrew.mcguire@walgreens.com                           |
`-------------------------------------------------------*/


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

Date: Tue, 16 May 2000 20:00:56 GMT
From: cory-p@usa.net (Cory Phillips)
Subject: Processing All Files in a Directory: Sorting?
Message-Id: <3921a847.23795808@news.jsc.nasa.gov>

I have a script that reads the file names from a directory.  Is there
some way to sort my directory list?  Do I have to load the files in an
array and sort them myself.

My sample code.

opendir(DIR, $dirPath) or die "Can't opendir $dirPath: $!\n";

while(defined($file = readdir(DIR))) {
   $modTime = (stat("$dirPath/$file"))[9]; # Get modification time.
   print "$file \t\t" . localtime($modTime) . "\n";
}

closedir(DIR);

Cory Phillips


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

Date: Tue, 16 May 2000 15:53:09 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Processing All Files in a Directory: Sorting?
Message-Id: <slrn8i39p5.4uq.tadmc@magna.metronet.com>

On Tue, 16 May 2000 20:00:56 GMT, Cory Phillips <cory-p@usa.net> wrote:

>I have a script that reads the file names from a directory.  Is there
>some way to sort my directory list?  


The same way that you sort any other list.


>Do I have to load the files in an
>array 


No, you can sort a list, it does not need to be an array.


>and sort them myself.


I dunno what that means.


>while(defined($file = readdir(DIR))) {


   foreach my $file ( sort readdir(DIR)) {


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


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

Date: 16 May 2000 21:15:02 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: Processing All Files in a Directory: Sorting?
Message-Id: <8fsdom$8kv$1@newsflash.concordia.ca>

In article <3921a847.23795808@news.jsc.nasa.gov>,
Cory Phillips <cory-p@usa.net> wrote:
>I have a script that reads the file names from a directory.  Is there
>some way to sort my directory list?  Do I have to load the files in an
>array and sort them myself.

If you use opendir, etc., you'll have to sort it yourself.
 
The other options are a bit wasteful and possibly more dangerous:

open DIR, "ls $mydir |" or die $!;
while (<DIR>) {
   ...
}
close DIR;

ls sorts asciibetically by default, and has other sorting options too.

Requires extra caution to make sure that $mydir doesn't contain nasty 
commands, perhaps supplied by a malicious user. Tainting helps: see man 
perlsec.



-- 
Neil Kandalgaonkar
neil@brevity.org


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

Date: Tue, 16 May 2000 19:11:58 GMT
From: "James" <spectralmedia@home.com>
Subject: Protecting Source Code?
Message-Id: <24hU4.66606$fF5.2310884@news1.rdc1.il.home.com>

Anyone know any good techniques for protecting your perl code?




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

Date: 16 May 2000 19:51:49 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Protecting Source Code?
Message-Id: <slrn8i39ml.k11.abigail@ucan.foad.org>

On Tue, 16 May 2000 19:11:58 GMT, James <spectralmedia@home.com> wrote:
++ Anyone know any good techniques for protecting your perl code?


    $ chmod 000 program.pl


Abigail


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

Date: Tue, 16 May 2000 13:09:50 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Protecting Source Code?
Message-Id: <MPG.138b4aee3718496498aa89@nntp.hpl.hp.com>

In article <slrn8i39ml.k11.abigail@ucan.foad.org> on 16 May 2000 
19:51:49 GMT, Abigail <abigail@foad.org> says...
> On Tue, 16 May 2000 19:11:58 GMT, James <spectralmedia@home.com> wrote:
> ++ Anyone know any good techniques for protecting your perl code?
> 
>     $ chmod 000 program.pl

No, no, no.  The permissions need to be 200.  I need to write the damned 
thing, don't I?

To the original poster:  You may find some insight in perlfaq3: "How can 
I hide the source for my Perl program?"

The short answer might be, "Hire a good lawyer!"

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


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

Date: Tue, 16 May 2000 15:19:27 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Protecting Source Code?
Message-Id: <slrn8i37pv.4sq.tadmc@magna.metronet.com>

On Tue, 16 May 2000 19:11:58 GMT, James <spectralmedia@home.com> wrote:

>Anyone know any good techniques for protecting your perl code?
                                     ^^^^^^^

"Protect" perl code from _what_?



1) Release it under a license

2) Make an off-line backup and then delete it

3) Change permissions to all zeros

4) Rewrite it in a language with opaque binaries, but it
   still won't be protected.

5) type:

   perldoc -q hide



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


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

Date: Tue, 16 May 2000 15:22:48 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: Protecting Source Code?
Message-Id: <3921AE18.6D2B07C7@walgreens.com>

James wrote:
> 
> Anyone know any good techniques for protecting your perl code?

Lock it up in Fort Knox?  Delete it? ;^)

perldoc -q source

Cheers,

anm
-- 
/*-------------------------------------------------------.
| Andrew N. McGuire                                      |
| andrew.mcguire@walgreens.com                           |
`-------------------------------------------------------*/


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

Date: Tue, 16 May 2000 15:08:21 -0400
From: "Todd W" <trw@freewwweb.com>
Subject: Re: Queastion about CGI.pm sticky values
Message-Id: <8fs5sf$8vh$1@news.smartworld.net>


jamalone@earthlink.net wrote in message
<39209dab.794692@news.earthlink.net>...
>How is it possible to make variables retrieved from CGI.pm not sticky?
>I am going to go and get the book tomorrow but I can't find any online
>docs on it right now.

I belive this would be correct as it is what I use:

$query->delete('foo');
or because I like to use the function oriented interface:
use CGI qw/:standard/;
Delete('foo');
you just have to remember to do it in the right place in your code.....


print popup_menu(-name=>'color',
    -values=>['red','green','blue','chartreuse'],
    -default=>'red');
Delete('color');

will leave the popup sticky because its printed before the Delete(), but

Delete('color');
print popup_menu(-name=>'color',
    -values=>['red','green','blue','chartreuse'],
    -default=>'red');

will force the popup_menu function to respect the default setting.
hope this helps.





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

Date: Tue, 16 May 2000 15:12:53 -0500
From: "Andrew N. McGuire" <andrew.mcguire@walgreens.com>
Subject: Re: Reading and Writing to a file [OT & long]
Message-Id: <3921ABC5.E21B1C01@walgreens.com>

Xah wrote:

[ snip ]

> In the art of flame war, it's passe to pick on people's spellings. Why?
> Because the wise understands that an invigorating argument is one that hits
> each other's spots, not going for the cheap shots. You grasps my meaning,
> and hit me back with reason. I grasp your reason, and kick you with
> rationality. That is dialectics. And when exquisitely articulated, it's
> rhetoric, delighting a wide audience on the side.

Pedantry.  I find it funny that you accuse LR and UG of
showcasing bloated english.

Well personally, I think that the 'art of the flame war' is
childish.  I can't say I have never been sucked into them
before. Actually I have, and into a pretty bad one I must
say...  The reason for that particular flame war is because
one of the individuals in that group, which I had never
even thought about subscribing to, kept sending me what I thought
was offensive material.  I found out who he and his cohorts
were and told them, hoping they would stop... They didn't,
and I got sucked into some silly flame war on netiquette,
with a bunch of racist fools.

I was angered, and got into a flame war with them, hoping
to show them I was right.  Well, I wasn't, I made an ass out
of myself, and owe an apology to damn near all of Usenet for
my silly behaviour.   I will never make that mistake again.
( One good reason for killfiles by the way ).  I will have
an argument with someone, but I will not 'flame' anymore,
I draw a distiction.

> > [ aside to Xah: lists can have duplicate elements, sets can't,
> > by definition ]
> 
> Does it subtract any meaning from that paragraph i wrote? (and do you think
> i don't know that?) Argue with people's head, not their mouth. 


I do not understand what you mean by that last sentence, you make
an ostentatious show of words, to the near brink of obfuscation,
yet you expect people to argue with you, not your words.. Well
in Usenet, your words ARE a description of you.  I fail to see
your distinction.

To point, as one of the primary concerns in sorting is efficiency, it
does matter.. Also, a set can directly contain other sets, while Perl
lists
can't directly contain other lists, only references to lists.
This matters as well, to the best of my knowledge.. I will however
bow to any correction on this matter.  Overall though, Perl lists,
and mathematical sets, do not equate.

> Focus on what
> they mean, not their accents. Poems are for apprehension, not chanting. In
> Godzilla's terms: "reading comprehension".

I would not liken ALL of Godzilla's postings to poetry, some yes,
but even still, this is not a peotry group... Perl poetry, perhaps..
Also, I would like to ask, what other purpose is there for reading?
Enjoyment you say?  It is kind of hard to enjoy a book if you
do not comprehend it.

> Godzilla's problem, is largely the same problem i face when dealing with
> Perl peddlers. Ideas fly over their heads, but they bog you down with petty
> details and artless slobber.

'Petty' details can make a big difference, as in leaving
of a petty ';'..  It is the difference between a functional program
and a defunct one.

> The Perl mongers and unix weenies, think that
> their stupid naming of programs and pathetic syntax makes them giant poets.

I am a Perl monger, not officially (but I am thinking of joining
my local group) and a UNIX weenie, I do not however claim to be 
a poet, nor have I ever.

> I see pubescent laddies playing with their peckers for the first time.

If that is what you are into... ;^)

> The perl folks with their beads of little eyes, cannot see beyond their
> perl-perl-land.

Quite the opposite, I am a UNIX weenie too.

Regards,

anm
-- 
/*-------------------------------------------------------.
| Andrew N. McGuire                                      |
| andrew.mcguire@walgreens.com                           |
`-------------------------------------------------------*/


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

Date: Tue, 16 May 2000 13:53:13 -0600
From: Dan Woods <dwoods@ucalgary.ca>
Subject: regexp %%CODE%% multi-line sub in template
Message-Id: <3921A729.C868DA5@ucalgary.ca>

I am trying to use a template file and replace a section within a
multi-line file with different text.  The template file contains
%%CUT_BEGIN%% and (later on) %%CUT_END%%.
I tried using s///gm and this won't work unless _BEGIN & _END are on
the same line. When I tried using m///gm, I got a scalar error.
The text inside the (.*) is what I want to ignore and also remove
the tags.  What did I miss in my code below ?
Thanks...Dan.
---------------------------------------
$text = "Long file with multiple lines with embedded template tags";
$replace = "CUT";
$output = "text to replace with";
 ...
  elsif ($replace =~ s/(\w+)_BEGIN$/$1/) {
    # allow 0/1 spaces around tag
    $text =~
s/%%\s?${replace}_BEGIN\s?%%(.*)%%\s?${replace}_END\s?%%/$output/gmi;
  }


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

Date: 16 May 2000 20:07:22 GMT
From: abigail@foad.org (Abigail)
Subject: Re: regexp %%CODE%% multi-line sub in template
Message-Id: <slrn8i3ajq.k11.abigail@ucan.foad.org>

On Tue, 16 May 2000 13:53:13 -0600, Dan Woods <dwoods@ucalgary.ca> wrote:
++ I am trying to use a template file and replace a section within a
++ multi-line file with different text.  The template file contains
++ %%CUT_BEGIN%% and (later on) %%CUT_END%%.
++ I tried using s///gm and this won't work unless _BEGIN & _END are on
++ the same line. When I tried using m///gm, I got a scalar error.
++ The text inside the (.*) is what I want to ignore and also remove
++ the tags.  What did I miss in my code below ?

A ``.'' in a regex doesn't match a newline, unless you use the /s option.
And since you don't use ^ or $, there's no need for the /m.



Abigail


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

Date: Tue, 16 May 2000 15:49:58 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: regexp %%CODE%% multi-line sub in template
Message-Id: <slrn8i39j6.4uq.tadmc@magna.metronet.com>

On Tue, 16 May 2000 13:53:13 -0600, Dan Woods <dwoods@ucalgary.ca> wrote:
>I am trying to use a template file and replace a section within a
>multi-line file with different text.  The template file contains
>%%CUT_BEGIN%% and (later on) %%CUT_END%%.

>I tried using s///gm and this won't work unless _BEGIN & _END are on
>the same line. 


It will work if you use the correct options.

We cannot fix your s///gm code because you did not show
it to us.

Show it to us.


>When I tried using m///gm, I got a scalar error.
                                  ^^^^^^^^^^^^^^

What on Earth is that?

Please do not paraphrase error/warning messages, give the actual
message text (and look up the message in perldiag.pod *before*
posting, you might find out how to fix the problem there).


>The text inside the (.*) is what I want to ignore and also remove
>the tags.  What did I miss in my code below ?
>Thanks...Dan.
>---------------------------------------
>$text = "Long file with multiple lines with embedded template tags";


That does NOT have multiple lines.

That does NOT have embedded template tags.

*This* has both of those things:

my $text = 'before
more before
%%CUT_BEGIN%%
cut me
cut me too
%%CUT_END%%
after
';


>$replace = "CUT";
 ^^^^^^^^
 ^^^^^^^^
>$output = "text to replace with";
>...
>  elsif ($replace =~ s/(\w+)_BEGIN$/$1/) {
          ^^^^^^^^
          ^^^^^^^^

I don't know what you are trying to do there.

$replace has 3 characters in it.

Your pattern requires a minimum of 7 characters.

The pattern can never match.

Your pattern also matches "_BEGIN" only at the end of a line.
Aren't there some %% characters between "_BEGIN" and the
end of line?

And if $replace _did_ happen to contain "CUT_BEGIN" you want
it to contain only "CUT" after the s///


What is it that you are trying to do with that elsif code there?


>    # allow 0/1 spaces around tag
>    $text =~
>s/%%\s?${replace}_BEGIN\s?%%(.*)%%\s?${replace}_END\s?%%/$output/gmi;


s///m only affects anchors ( ^ and $ ). You don't have any anchors
in that pattern. What is the 'm' option there for?

You need s///s if you want dot to match newline.


Since you have s///i, I guess that

   %%cUt_BeGiN%%

is an allowable marker?

Don't just try options at random. Find out what they do, and use
them if you _need_ them.


-----------------------
#!/usr/bin/perl -w
use strict;

my $text = 'before
more before
%%CUT_BEGIN%%
cut me
cut me too
%%CUT_END%%
after
';

my $replace = 'CUT';
my $output = 'text to replace with';

$text =~ s/%%\s?${replace}_BEGIN\s?%%(.*?)%%\s?${replace}_END\s?%%/$output/s;

print $text;
-----------------------

output:

before
more before
text to replace with
after


It works for me.


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


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

Date: Tue, 16 May 2000 15:19:51 -0600
From: Dan Woods <dwoods@ucalgary.ca>
Subject: Re: regexp %%CODE%% multi-line sub in template
Message-Id: <3921BB77.A64A72D8@ucalgary.ca>

Tad,

> >I tried using s///gm and this won't work unless _BEGIN & _END are on
> >the same line.
> It will work if you use the correct options.

Code was at the bottom.

> >$text = "Long file with multiple lines with embedded template tags";
> That does NOT have multiple lines.
> That does NOT have embedded template tags.

You took my code example to literally (initial settings), while
I was only providing pseudo-code.

Anyways, both you and abigail provided what I needed, which was to
use /s option with my s/// substitution.

I obviously got it confused (misunderstood) with the /m option.
And then you can s///s, s///m, m///s, m///m ... sheesh !
Now back to coding...

Thanks for the help...Dan.


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

Date: 16 May 2000 21:48:40 GMT
From: abigail@foad.org (Abigail)
Subject: Re: regexp %%CODE%% multi-line sub in template
Message-Id: <slrn8i3gho.k11.abigail@ucan.foad.org>

On Tue, 16 May 2000 15:19:51 -0600, Dan Woods <dwoods@ucalgary.ca> wrote:
++ 
++ I obviously got it confused (misunderstood) with the /m option.
++ And then you can s///s, s///m, m///s, m///m ... sheesh !

Eh, m///s and m///m won't do what you think they do. Perhaps you meant
m//s and m//m.


Abigail


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

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


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