[17081] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4493 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 2 14:11:51 2000

Date: Mon, 2 Oct 2000 11:10:21 -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: <970510221-v9-i4493@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 2 Oct 2000     Volume: 9 Number: 4493

Today's topics:
        perl as a browser malatov@my-deja.com
    Re: perl as a browser <amonotod@netscape.net>
        Perl4-036 compile error in eval.c (Long T. Nguyen)
    Re: Perl4-036 compile error in eval.c (Chris Fedde)
        PL/SQL from a CGI Script ?? foxskin@my-deja.com
    Re: PL/SQL from a CGI Script ?? <newsposter@cthulhu.demon.nl>
    Re: PL/SQL from a CGI Script ?? rereidy@my-deja.com
    Re: PL/SQL from a CGI Script ?? <jgoldst@my-deja.com>
        Please critique this code <jcook@strobedata.com>
    Re: question about regular expressions (shock, horror.. <stephen@bcl.com>
    Re: Questions about space-saving techniques (James Weisberg)
    Re: Regex comparing street addresses <bmb@ginger.libs.uga.edu>
    Re: Regex comparing street addresses <godzilla@stomp.stomp.tokyo>
    Re: Regex comparing street addresses <amonotod@netscape.net>
        Reverse by paragraphs - NOT! ollie_spencer@my-deja.com
    Re: Reverse by paragraphs - NOT! (NP)
    Re: Reverse by paragraphs - NOT! <amonotod@netscape.net>
    Re: Reverse by paragraphs - NOT! <godzilla@stomp.stomp.tokyo>
        Running script as root <adalessandro@odione.com>
    Re: Running script as root <amonotod@netscape.net>
    Re: Running script as root <philipg@atl.mediaone.net>
        Search and Destroy rathmore@tierceron.com
    Re: Search and Destroy wrathmolten@my-deja.com
    Re: Search and Destroy (Clay Irving)
    Re: Search and Destroy (Clay Irving)
    Re: Strange behaviour with @{...} <moell@ID-PRO.de>
    Re: Strange behaviour with @{...} <mauldin@netstorm.net>
    Re: What's wrong with this regex? nobull@mail.com
    Re: why it's called a "hash" (and a whole lot more) (Ilya Zakharevich)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 02 Oct 2000 17:24:16 GMT
From: malatov@my-deja.com
Subject: perl as a browser
Message-Id: <8ragbk$tlj$1@nnrp1.deja.com>

I am attmepting to enable cookies in my perl script, as if it were a
browser. I would like to script to "auto-accept" cookies from sites. Is
this possible? And if so, how can I do this?



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


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

Date: Mon, 02 Oct 2000 17:29:04 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: perl as a browser
Message-Id: <8ragkk$tqo$1@nnrp1.deja.com>

In article <8ragbk$tlj$1@nnrp1.deja.com>,
  malatov@my-deja.com wrote:
> I am attmepting to enable cookies in my perl script, as if it were a
> browser. I would like to script to "auto-accept" cookies from sites.
Is
> this possible? And if so, how can I do this?
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

Hey, you're using Deja to post, why not try using it to search?

http://www.deja.com/dnquery.xp?ST=QS&DBS=2&groups=comp.lang.perl.misc&QR
Y=cookies&svcclass=dncurrent

HTH,
amonotod

--
    `\|||/                     amonotod@
      (@@)                     netscape.net
  ooO_(_)_Ooo________________________________
  _____|_____|_____|_____|_____|_____|_____|_____|


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


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

Date: 2 Oct 2000 17:40:22 GMT
From: dragon@monet.artisan.calpoly.edu (Long T. Nguyen)
Subject: Perl4-036 compile error in eval.c
Message-Id: <8raha6$17p$1@cscnews.csc.calpoly.edu>


In attempt to compile perl4.036 for an old in-house perl application here
one of the error during the make. Can somebody help me. The perl was 
compiled successfully in HP-UX 10.20 but failed to compile in HP-UX 11.00

Here is the errors in HP-UX: cc
-------------------------------
`sh  cflags eval.o` eval.c
          CCCMD =  cc -c  -O
cc: "eval.c", line 2924: error 1527: Incompatible types in cast: Must
cast from scalar to scalar or to void type.
cc: "eval.c", line 2927: error 1527: Incompatible types in cast: Must
cast from scalar to scalar or to void type.
*** Error exit code 1

Stop.

Thanks

regards,
long
--
Long Nguyen - email: dragon@polymail.calpoly.edu  --  CALPOLY University
URL=http://www.calpoly.edu/~dragon                --  San Luis Obispo, CA 93407
voice: 805-756-1550 * fax: 805-756-5535           --  Building 14, Room 111



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

Date: Mon, 02 Oct 2000 17:41:47 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: Perl4-036 compile error in eval.c
Message-Id: <vN3C5.72$D4.174846976@news.frii.net>

In article <8raha6$17p$1@cscnews.csc.calpoly.edu>,
Long T. Nguyen <dragon@monet.artisan.calpoly.edu> wrote:
>
>In attempt to compile perl4.036 for an old in-house perl application here
>one of the error during the make. Can somebody help me. The perl was 
>compiled successfully in HP-UX 10.20 but failed to compile in HP-UX 11.00
>
>Here is the errors in HP-UX: cc
>-------------------------------
>`sh  cflags eval.o` eval.c
>          CCCMD =  cc -c  -O
>cc: "eval.c", line 2924: error 1527: Incompatible types in cast: Must
>cast from scalar to scalar or to void type.
>cc: "eval.c", line 2927: error 1527: Incompatible types in cast: Must
>cast from scalar to scalar or to void type.
>*** Error exit code 1
>
>Stop.
>

Three approaches come to mind.

    1) Fix the casts in the source file and see if perl passes it's
	self test

    2) Move the hierarchies from the 10.20 system to the 11.00
	system then see if they run.

    3) Upgrade to the recent release of Perl and see if the script runs
	then fix as needed. 

Also, I seem to remember that the HP users group maintained a set of pre-compiled
binaries for various HP operating systems.  Maybe there is something there
that might serve?  I'm not very clear on this point though. The last time
that I was responsible for an HP system version 9.3 was all the rage.

chris
-- 
    This space intentionally left blank


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

Date: Mon, 02 Oct 2000 15:14:31 GMT
From: foxskin@my-deja.com
Subject: PL/SQL from a CGI Script ??
Message-Id: <8ra8og$mgc$1@nnrp1.deja.com>

Hello,

I want to call a PL/SQL script which is stored in an Oracle Database
directly from my HTML or from a perl script.

I know this is possible with the Oracle Webserver. One I have
configured him right, I can just call the PL/SQL from my HTML and it
works.

Now I want to get it working with another webserver.

Does anyone know if this is possible, and if it is.. How ??

Hope you can help me, Thanks in advance.


Arthur


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


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

Date: 2 Oct 2000 15:53:39 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: PL/SQL from a CGI Script ??
Message-Id: <8rab23$k5r$1@internal-news.uu.net>

foxskin@my-deja.com wrote:

> I want to call a PL/SQL script which is stored in an Oracle Database
> directly from my HTML or from a perl script.

> I know this is possible with the Oracle Webserver. One I have
> configured him right, I can just call the PL/SQL from my HTML and it
> works.

> Now I want to get it working with another webserver.

> Does anyone know if this is possible, and if it is.. How ??

  Install DBI and DBD::Oracle, and read the documentation that comes
with it.

Erik



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

Date: Mon, 02 Oct 2000 15:45:42 GMT
From: rereidy@my-deja.com
Subject: Re: PL/SQL from a CGI Script ??
Message-Id: <8raaj4$o6q$1@nnrp1.deja.com>

Arthur,

Look at the POD for DBD::Oracle.  It has examples on how to call a
PL/SQL stored procedure from Perl.

Ron Reidy
Oracle DBA

In article <8ra8og$mgc$1@nnrp1.deja.com>,
  foxskin@my-deja.com wrote:
> Hello,
>
> I want to call a PL/SQL script which is stored in an Oracle Database
> directly from my HTML or from a perl script.
>
> I know this is possible with the Oracle Webserver. One I have
> configured him right, I can just call the PL/SQL from my HTML and it
> works.
>
> Now I want to get it working with another webserver.
>
> Does anyone know if this is possible, and if it is.. How ??
>
> Hope you can help me, Thanks in advance.
>
> Arthur
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


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


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

Date: Mon, 02 Oct 2000 17:28:30 GMT
From: JL Goldstein <jgoldst@my-deja.com>
Subject: Re: PL/SQL from a CGI Script ??
Message-Id: <8ragji$tq1$1@nnrp1.deja.com>

In article <8ra8og$mgc$1@nnrp1.deja.com>,
  foxskin@my-deja.com wrote:

> I want to call a PL/SQL script which is stored in an Oracle Database
> directly from my HTML or from a perl script.

This is how I do it in a non-CGI Perl script:

	system $ORACLE_HOME/bin/sqlplus / @pathtoSQLscript

It may or may not be the correct approach, but it works for me.


--
"Bother," said Pooh, as Satan laid his soul to waste.


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


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

Date: Mon, 02 Oct 2000 08:15:27 -0700
From: Jim Cook <jcook@strobedata.com>
Subject: Please critique this code
Message-Id: <39D8A68F.C802E2A2@strobedata.com>


I know I'm really asking for it here. Please try to be helpful instead
of bashing.

The program below takes a text file and generates random text based on
the frequency of the letters found in the text file. My goal here was to
make pronouncable random text. 

I start with a string from the file of N length (specified as input to
the program) and start generating.

I am sure that my method of removing trouble-making characters is, well,
terrible. What's the right way to do it? Is there a better way to take a
string ABCD and append E and drop A? ABCD -> BCDE?

The algorithm is as follows:

 .) Read the file into a scaler and remove troublesome characters.
 .) Pick a random starting location and keep the N characters starting
there.
 .) Pick a random character from the set of characters which follow my
current string. (Print it.)
 .) My new current string loses the first character and gains the random
character.

One thing I did to speed things up is to record the "set of characters
which follow" in a has, so if I get the same N sequence again, I won't
have to do a search for the characters again.

Also, if somehow I ended up with a string that didn't have any following
characters, I started the sequence over. I think this could only happen
if I got to the end of the file.

I translated "." to "#" so I could print periods without them messing up
my search.

This is not a professional program, so lots of commenting and a clean
user interface wasn't something that I worried about. I know well enough
what to do for that part. Just the structure and actual code.

Ok, I'm listening. I'd love to be educated.

#############################################
#! perl -w
use strict;

my $File = shift || die "Need a filename";
my $Depth = shift || die "Need a depth";

print "Opening file ";
open (IN, $_ = $File) || die "$_: $!";
print "\nReading file ";
my $Text = join("", <IN>);
print length($Text) . "\nCleaning EOL ";
$Text =~ tr/\r\n/  /;
$Text =~ tr/./#/;
print length($Text) . "\nCleaning meta characters ";
$Text =~ s/[^A-Za-z\'\,\s#]//g;
print length($Text) . "\nCleaning doubled spaces ";
$Text =~ s/\s\s+/ /g while $Text =~ /\s\s+/;
print length($Text) . "\n";
close IN;

my $Running = substr($Text, rand(length($Text)) - 100, $Depth);
print "\n";
print $Running;
my %Found;

my $i = 0;

while (1) {
    while (!(defined $Found{$Running})) {
        my $matches = join("", ($Text =~ /$Running(.)/g));
        if ($matches eq "") {
            print "\n\n";
            $Running = substr($Text, rand(length($Text)) - 100, $Depth);
        }
        else {
            $Found{$Running} = $matches;
        }
    }

    my $newletter = substr($Found{$Running},
rand(length($Found{$Running})), 1);

    $Running = substr($Running, 1, $Depth - 1) . $newletter;

    $newletter = ".\n\n" if $newletter eq "#";
    print $newletter;
}



--
jcook@strobedata.com  Live Honourably    4/1 - 4/3 + 4/5 - 4/7 + . . .
2000 Tuesdays: Feb/last 4/4 6/6 8/8/ 10/10 12/12 9/5 5/9 7/11 11/7 3/14
Strobe Data Inc. home page   http://www.strobedata.com
My home page    O-           http://jcook.net


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

Date: Mon, 02 Oct 2000 11:22:43 +0100
From: Steve Howe <stephen@bcl.com>
Subject: Re: question about regular expressions (shock, horror.. )
Message-Id: <zWHYOYPelheAKf6kkNQNGQfstrLS@4ax.com>

This humble wanderer of the perl language libraries remains, once
more, in your debt, kind learned people.

Thank you sincerely.

Steve Howe


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

Date: Mon, 02 Oct 2000 17:17:00 GMT
From: chadbour@wwa.com (James Weisberg)
Subject: Re: Questions about space-saving techniques
Message-Id: <gq3C5.8233$l35.169397@iad-read.news.verio.net>

In article <B53B5.13337$td5.2361678@news1.rdc2.pa.home.com>,
Ben Kennedy <bkennedy@hmsonline.com> wrote:
>"James Weisberg" <chadbour@wwa.com> wrote in message
>news:usKA5.5654$l35.133134@iad-read.news.verio.net...
>>    And it's one I've been wrestling with for a while. As I said in my
>> original post, I'm using MLDBM to do multidimensional ties. And because
>> of the way MLDBM works, it's a bit finicky FETCHing records out of the
>> database. In fact, given a $date and an $object, it FETCHes *all*
>> records (i.e. all intervals) associated with that date and object. I
>> cannot control that part (and you can see the MLDBM man page for more
>> if interested).
>
>I'm not sure on the details of the serialization, but I have a feeling that
>by accessing under a $date and $object key (via $DB{$data}{$object}), what
>happens is somethings like
>
>$ref = $DB{$data};
>
>$intervals = $ref->{$object};
>
>I don't know if its possible to get to $intervals without having the whole
>thing deserialized at some point, bringing into scope data about $object's
>you don't care about.  Though it may only be long enough to store the
>correct $intervals reference, and let the rest fade out of scope, I don't
>know.  I don't even know if it matters or not, just more stuff to think
>about.  

	Well I can tell you that there is a vast difference in FETCH time
with the various serializers and that I have put some print statements
into MLDBM.pm to see when it is making FETCH calls. It does one FETCH
per object (for all intervals) and as far as I know, unless I ask for
an object, it doesn't FETCH it. Therefore, I am not FETCHing data about
objects I don't care about. I am FETCHing all intervals (records) for
every object I care about however. That's okay in reality, as most 
requests want all or most of those intervals anyway. It's also okay in
theory because if I ever turn this into some database server, I'd like
to keep so many days of data resident in memory and know that *all* 
records for those days are in memory and not just some subset. A priori,
I don't even know what the subset should be; so in some ways it's just
much simpler to say that if a FETCH is done on an object for a specific
date, then *all* records for that object were FETCHed. And if a request
only needs a subset of those records, then so be it. 

>But have you considered moving to a true DBMS?  That would solve a
>lot of problems.  

	Well, I've considered it, yes. True, it might solve some problems,
but then again, it introduces a "problem" of learning all that stuff
from scratch. I like the idea of tying a database to a Perl hash and
just being done with it so I can get on to manipulating this data the
Perl-way, without resorting to any DB-specific functions. I never 
really wanted to be a database programmer anyway! Here, the database
serves only as a depository for raw information that can be fetched
and massaged in Perl. 

>Something like MySQL seems well suited for this kind of
>thing.  Once you get past the overhead of setting it up, learning some SQL
>syntax, and installing DBI, it becomes very easy to maintain and query.  Not
>to mention there is a lot of personal satisfaction getting the whole thing
>running smoothly.

	Assuming you get that far. Meanwhile, you got a lot of personal grief!
See, what's true of my DB-application is that I don't need anything more
elaborate than FETCH and STORE and so the only db-type functions I needed
to write were read_db() and write_db(). For some completeness I also wrote
a print_db() for debugging purposes. Any of those functions can be rewritten
if the db mechanism changes without changing any of the functions that then
use that information. Once that information sits in a Perl hash structure,
I can sort and search it using basic Perl code. That's one of the reasons 
I also loaded up all the data into one structure so I could clearly draw
a distinction between reading the database with read_db() and then doing
something to that data after the record is read. As I started this topic
inquiring about memory-saving techniques, it still seems to me that this
was a good strategy to adopt without going down the MySQL route.



-- 
World's Greatest Living Poster


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

Date: Mon, 2 Oct 2000 11:16:18 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Regex comparing street addresses
Message-Id: <Pine.A41.4.21.0010021114350.14510-100000@ginger.libs.uga.edu>

On Mon, 2 Oct 2000, Godzilla! wrote:
> Screw off Flavell. You have a well earned and long documented
> history for being amongst the worst of trolls within USENET
> and, you daily spend hours spreading discontent and hatred
> every chance you get. I am not interested in playing your 
> ignorant hateful troll game. Go to Hades you sociopath.
> 
> 
> Godzilla!

s/Flavell/Godzilla!/;


Brad



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

Date: Mon, 02 Oct 2000 08:47:09 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regex comparing street addresses
Message-Id: <39D8ADFD.DBAD748C@stomp.stomp.tokyo>

Brad Baxter wrote:
 
> Godzilla! wrote:

> > Screw off Flavell. You have a well earned and long documented
> > history for being amongst the worst of trolls within USENET
> > and, you daily spend hours spreading discontent and hatred
> > every chance you get. I am not interested in playing your
> > ignorant hateful troll game. Go to Hades you sociopath.

> s/Flavell/Godzilla!/;

 
Sancho, my armor! Sancho, old friend, my lance!
Our Good Ol' Boys Club is besieged by terrifying truth!
Rosinante bear my burden well during my call to rise,
my call to fight a battle of righting the unrighteous! 
Hi Ho Rosinante! Up, up and away!


Cervantes Godzilla!


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

Date: Mon, 02 Oct 2000 16:50:16 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: Regex comparing street addresses
Message-Id: <8raec5$rkk$1@nnrp1.deja.com>

In article <39D8ADFD.DBAD748C@stomp.stomp.tokyo>,
  "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> Sancho, my armor! Sancho, old friend, my lance!
> Our Good Ol' Boys Club is besieged by terrifying truth!
> Rosinante bear my burden well during my call to rise,
> my call to fight a battle of righting the unrighteous!
> Hi Ho Rosinante! Up, up and away!
>

How fitting that you assume the role of a recognized (fictional) madman,
a person whose view of reality is kilted (perhaps tilted would be more
appropriate?) to the point of apparent derangement.  Coincidence?  I
think not.

amonotod

--
    `\|||/                     amonotod@
      (@@)                     netscape.net
  ooO_(_)_Ooo________________________________
  _____|_____|_____|_____|_____|_____|_____|_____|


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


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

Date: Mon, 02 Oct 2000 16:07:05 GMT
From: ollie_spencer@my-deja.com
Subject: Reverse by paragraphs - NOT!
Message-Id: <8rabr2$pa4$1@nnrp1.deja.com>

Hi- Another tale of woe.

I am trying to process a file that has the following description:
It has a report header on each page. The data that follows the header
consists of paragraphs of data entered sequentially from a
manufacturing process(processing sector, when entered, data acquired,
etc.). There's no blank lines in a paragraph, but each paragraph is
terminated by a blank line. It's complicated by the fact that the file
is "upside-down", with the most recent paragraph at the top, the first
paragraph at the bottom.

I successfully read-in the file, trash the header(after extracting some
data), then discard certain irrelevant paragraphs, saving the keepers
in array @OF. For convenience, I would then like to reverse the file so
the initial paragraph is at the top, the most recent at the bottom. I
seem unable to get the reversing procedure (from the Perl Cookbook) to
work - the whole file is reversed line by line, not paragraph by
paragraph. I include the code below. Where am I going wrong?

====Beginning of code snippet

open INFILE or die "Couldn't open $INFILE... Exiting\n";
open OUTFILE or die "Couldn't open $OUTFILE... Exiting\n";

#------------------------------------------------------------------
# Set up $Technology and $Product so they are usable as flags
#------------------------------------------------------------------
undef $Technology;
undef $Product;

#------------------------------------------------------------------
# Go through <INFILE> a line at a time...
#------------------------------------------------------------------
while(<INFILE>){
#    chomp();
    if (/\(GTLT\)/ ... /-{40}/){
	if (defined($Technology)){
	    next;
	}else{
	    if (/^\s+PRODUCT\.\.(\S+)\s+\w(.{34}?)/){
		($Product, $Technology)=($1, $2);
		push @OF, "Product=$Product Technology=$Technology\n";
		next;
	    }
	}
    }
#------------------------------------------------------------------
# This stuff gets saved to @OF
#------------------------------------------------------------------
    if (/ MOVE OUT/ ... /^$/){
	push @OF, "="x120 if / MOVE OUT/;
	push @OF,$_;

    }

    if (/LOG AN EVENT/ ... /^$/){
	{
	    push @OF, $_;
	    last if(/^$/);
	}
    }
}
#-------------------------------------------------------------------
# To this point the GTLT file is read-in, headers removed.
# and the result saved in array @OF.
# Now try to reverse the file by paragraphs into array @ROF.
# per the Perl Cookbook------
#-------------------------------------------------------------------

{
local $/ = '';
@ROF=reverse @OF;
}

for $line( @ROF){print "$line\n";};


==== End of code snippet

The last line is the only print in the code.

Thanks in advance!

ollie spencer


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


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

Date: Mon, 02 Oct 2000 16:50:57 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: Reverse by paragraphs - NOT!
Message-Id: <R13C5.54588$A4.1708512@news1.giganews.com>

[PLEASE DO NOT CC ME AS A FOLLOWUP TO NEWSGROUP POSTINGS.]

ollie_spencer@my-deja.com wrote:
: 
: I am trying to process a file that has the following description:
: It has a report header on each page. The data that follows the header
: consists of paragraphs of data entered sequentially from a

Why not try this as a starting point?

#!/usr/bin/perl -w

die("usage: $0 <infile>")
    if $#ARGV == -1;

# for "paragraphs"
$/ = '';

# $para[0] will be your header
# $para[$#para] will be the last paragraph
my @para;

# $r_para[$#r_para] will be your header
# $r_para[0] will be the last paragraph
my @_para;

while(<>) {
    push(@para, $_);
}

# reverse the paragraph order.
@r_para = reverse @para;

print("Header:\n$para[0]\n");
print("Last Paragraph:\n$para[$#para]\n\n");

print("Header is now:\n$r_para[$#r_para]\n\n");
print("First Paragraph is now:\n$r_para[0]\n");

-- 
Nate II


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

Date: Mon, 02 Oct 2000 17:23:31 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: Reverse by paragraphs - NOT!
Message-Id: <8raga8$tl4$1@nnrp1.deja.com>

In article <8rabr2$pa4$1@nnrp1.deja.com>,
  ollie_spencer@my-deja.com wrote:
<snip>
> in array @OF. For convenience, I would then like to reverse the file
> so the initial paragraph is at the top, the most recent at the bottom.
> I seem unable to get the reversing procedure (from the Perl Cookbook)
> to work - the whole file is reversed line by line, not paragraph by
> paragraph. I include the code below. Where am I going wrong?
<snip>
> #------------------------------------------------------------------
> # Go through <INFILE> a line at a time...
> #------------------------------------------------------------------
> while(<INFILE>){
<snip>

I think that says it all....

You might try something like:
<PSUEDOCODE>
$article = (<FILE>);
@paras = split(/\n\n/, $article);
foreach (@paras) {
  while($_) {
</PSUEDOCODE>

HTH,
amonotod

--
    `\|||/                     amonotod@
      (@@)                     netscape.net
  ooO_(_)_Ooo________________________________
  _____|_____|_____|_____|_____|_____|_____|_____|


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


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

Date: Mon, 02 Oct 2000 10:43:09 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Reverse by paragraphs - NOT!
Message-Id: <39D8C92D.B00B5F70@stomp.stomp.tokyo>

ollie_spencer wrote:

(snippage)

> ...terminated by a blank line. It's complicated by the fact that the file
> is "upside-down", with the most recent paragraph at the top, the first
> paragraph at the bottom.
 
> ... - the whole file is reversed line by line, not paragraph by
> paragraph. I include the code below. Where am I going wrong?


There are two undocumented functions in Perl
which meet your needs quite well per your
given parameters. Taking out the garbage
is man's job, traditionally.

use slurp (schizoid);
use while (schizoid);


Godzilla!
--
Androids And More
  http://la.znet.com/~callgirl/android.html


TEST SCRIPT:
____________


#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";


## use slurp (schizoid);

local ($/) = "©";

open (TEST, "test.txt");
$data = <TEST>;
close (TEST);

print "Boss, this is your input:\n\n$data\n\n";

print "Boss, this is my output:\n\n";

@Array = split (/\n\n/, $data);
@Array = reverse (@Array);

foreach $element (@Array)
 { print "$element\n\n"; }



## use while (schizoid);

print "\n___\n\n\n\nBoss, this is your input:\n\n";

open (TEST, "test.txt");

local ($/) = "®";

while (<TEST>)
 {
  print $_;

  $_ =~ s/\n\n/¦/g;

  $data = $_;
  
  close (TEST);
 }

@Array = split (/¦/, $data);
@Array = reverse (@Array);

print "\n\nBoss, this is my output:\n\n";

foreach $line (@Array)
 { print "$line\n\n"; }

exit;



PRINTED RESULTS:
________________


Boss, this is your input:

This is the first paragraph which is appear
as the last paragraph after processing.

This is the second paragraph which is to appear
as the third paragraph after processing.

This is the third paragraph which is to appear
as the second paragraph after processing.

This is the last paragraph which is to appear
as the first paragraph after processing.



Boss, this is my output:

This is the last paragraph which is to appear
as the first paragraph after processing.

This is the third paragraph which is to appear
as the second paragraph after processing.

This is the second paragraph which is to appear
as the third paragraph after processing.

This is the first paragraph which is appear
as the last paragraph after processing.


___



Boss, this is your input:

This is the first paragraph which is appear
as the last paragraph after processing.

This is the second paragraph which is to appear
as the third paragraph after processing.

This is the third paragraph which is to appear
as the second paragraph after processing.

This is the last paragraph which is to appear
as the first paragraph after processing.



Boss, this is my output:

This is the last paragraph which is to appear
as the first paragraph after processing.

This is the third paragraph which is to appear
as the second paragraph after processing.

This is the second paragraph which is to appear
as the third paragraph after processing.

This is the first paragraph which is appear
as the last paragraph after processing.


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

Date: Mon, 2 Oct 2000 11:49:46 -0400
From: "Arthur Dalessandro" <adalessandro@odione.com>
Subject: Running script as root
Message-Id: <sthbkvri3o7t1d@corp.supernews.com>

I have a script that does certain commands that require them to be run as
root, however, I need non-root users to call the script.  Is there an easy
way to accomplish this?






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

Date: Mon, 02 Oct 2000 16:55:48 GMT
From: amonotod <amonotod@netscape.net>
Subject: Re: Running script as root
Message-Id: <8raemf$s19$1@nnrp1.deja.com>

In article <sthbkvri3o7t1d@corp.supernews.com>,
  "Arthur Dalessandro" <adalessandro@odione.com> wrote:
> I have a script that does certain commands that require them to be run
> as root, however, I need non-root users to call the script.  Is there
> an easy way to accomplish this?

1) Unless you have thoroughly and completely audited your script for
security risks, you shouldn't do this.

2) This is not a Perl question, it is an OS question.  You really should
go to a newsgroup appropriate to your OS.

Having said that, try:

%> man chmod

amonotod

--
    `\|||/                     amonotod@
      (@@)                     netscape.net
  ooO_(_)_Ooo________________________________
  _____|_____|_____|_____|_____|_____|_____|_____|


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


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

Date: Mon, 02 Oct 2000 17:28:20 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: Running script as root
Message-Id: <UA3C5.9777$jJ4.2380013@typhoon.southeast.rr.com>

amonotod <amonotod@netscape.net> wrote in message
news:8raemf$s19$1@nnrp1.deja.com...
> In article <sthbkvri3o7t1d@corp.supernews.com>,
>   "Arthur Dalessandro" <adalessandro@odione.com> wrote:
> > I have a script that does certain commands that require them to be run
> > as root, however, I need non-root users to call the script.  Is there
> > an easy way to accomplish this?
>
> 1) Unless you have thoroughly and completely audited your script for
> security risks, you shouldn't do this.
>
> 2) This is not a Perl question, it is an OS question.  You really should
> go to a newsgroup appropriate to your OS.
>
> Having said that, try:
>
> %> man chmod

Look for setuid.  One problem you may face is that many operating systems
only allow binary executables to be setuid, so Perl and shell scripts are
out.  If you're unlucky and yours is one of these *nixes, you may try the
experimental perl compiler "perlcc" to turn your script into a binary.

Another possible way is to use sudo.  You can find it on Freshmeat.net.

hth,
p




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

Date: Mon, 02 Oct 2000 16:13:17 GMT
From: rathmore@tierceron.com
Subject: Search and Destroy
Message-Id: <8rac6k$pn9$1@nnrp1.deja.com>

Here's the code I'll be asking questions about:

@sourcefile = $ftp->ls('/some_directory/');
# Need some code here between these two lines!
$numOrderFiles = @sourcefile; # Holds the number of files found in
previous line

What I'm doing is reading from a remote directory and putting all the
file names into the array @sourcefile. I then assign the number of
files found into the $numOrderFiles.

That's works great, but what I really want to know is all the files in
the directory that end with the ".txt" file extension. If the file
doesn't end with ".txt" then I don't want it assigned to the
@sourcefile array.

I'm stumped on how to do that.

Thanks!
Rathmore


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


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

Date: Mon, 02 Oct 2000 16:15:20 GMT
From: wrathmolten@my-deja.com
Subject: Re: Search and Destroy
Message-Id: <8racaf$pqd$1@nnrp1.deja.com>

Also, forgot to ask this previously...

How would I go about moving all the files in said directory that are
older than 7 days to an archive directory?

Thanks again!


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


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

Date: 2 Oct 2000 16:38:40 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Search and Destroy
Message-Id: <slrn8thegf.2fn.clay@panix2.panix.com>

On Mon, 02 Oct 2000 16:15:20 GMT, wrathmolten@my-deja.com 
<wrathmolten@my-deja.com> wrote:

>How would I go about moving all the files in said directory that are
>older than 7 days to an archive directory?

File::Find 
File::Copy

-- 
Clay Irving <clay@panix.com>
I was going to tape some records onto a cassette, but I got the wires
backwards.  I erased all of the records.  When I returned them to my friend, he
said, "Hey, these records are all blank."  - Steven Wright 


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

Date: 2 Oct 2000 16:48:34 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Search and Destroy
Message-Id: <slrn8thf31.2fn.clay@panix2.panix.com>

On Mon, 02 Oct 2000 16:13:17 GMT, rathmore@tierceron.com 
<rathmore@tierceron.com> wrote:

>Here's the code I'll be asking questions about:
>
>@sourcefile = $ftp->ls('/some_directory/');
># Need some code here between these two lines!
>$numOrderFiles = @sourcefile; # Holds the number of files found in
>previous line
>
>What I'm doing is reading from a remote directory and putting all the
>file names into the array @sourcefile. I then assign the number of
>files found into the $numOrderFiles.
>
>That's works great, but what I really want to know is all the files in
>the directory that end with the ".txt" file extension. If the file
>doesn't end with ".txt" then I don't want it assigned to the
>@sourcefile array.

First, you'll need to use "dir" instead of "ls":

       ls ( [ DIR ] )
           Get a directory listing of DIR, or the current
           directory.

           In an array context, returns a list of lines returned
           from the server. In a scalar context, returns a
           reference to a list.

       dir ( [ DIR ] )
           Get a directory listing of DIR, or the current
           directory in long format.

           In an array context, returns a list of lines returned
           from the server. In a scalar context, returns a
           reference to a list.

You should be able to find all files ending with ".txt" and (following 
up to the next question you posted) the last modification date.

-- 
Clay Irving <clay@panix.com>
He who desires, but acts not, breeds pestilence. 
- William Blake 


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

Date: Mon, 02 Oct 2000 18:02:52 +0200
From: Volker Moell <moell@ID-PRO.de>
Subject: Re: Strange behaviour with @{...}
Message-Id: <39D8B1AC.AFDE2497@ID-PRO.de>

Jim Mauldin wrote:
> 
> This behavior is expected, not strange.  The construct @{$a} (which
> could be stated as @$a in this context) is not an operator.  It is an
> anonymous array whose referenece is contained in $a.  Merely using @{$a}
> in a statement causes the reference to spring into existence, even if
> the array is empty (Perl tries to be helpful).

Thanks for your quick answer. But isn't it a little bit inconsequent,
that 
  foreach (@$a) {};
shows this behaviour, but not
  my @b = @$a;
?

    -volker

-- 
Volker Moell <moell@ID-PRO.de> (Products & Developement)
* ID-PRO Deutschland GmbH * Am Hofgarten 20 * D-53113 Bonn
* Tel. +49 (0) 2 28-4 21 54-0 * Fax -3 59
* http://open-for-the-better.com


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

Date: Mon, 02 Oct 2000 17:06:27 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Strange behaviour with @{...}
Message-Id: <39D8C052.3906D91@netstorm.net>

Volker Moell wrote:
> 
> Jim Mauldin wrote:
> >
> > This behavior is expected, not strange.  The construct @{$a} (which
> > could be stated as @$a in this context) is not an operator.  It is an
> > anonymous array whose referenece is contained in $a.  Merely using @{$a}
> > in a statement causes the reference to spring into existence, even if
> > the array is empty (Perl tries to be helpful).
> 
> Thanks for your quick answer. But isn't it a little bit inconsequent,
> that
>   foreach (@$a) {};
> shows this behaviour, but not
>   my @b = @$a;
> ?

I can't give you a definitive answer, but consider this:  if you reverse
the assignment:
@$a = my @b;
then suddenly $a contains an array reference.  "Programming Perl" 3rd
edition says that in an assignment:

   The right operand can be any expression you like, but the left
operand
   must be a valid lvalue (which, when translated to English, means a 
   valid storage location like a variable, or a location in an array).

So perl won't force the right hand side (RHS) to be defined, but will
cause the LHS to be defined if possible.

Other people in clpm may be able to elaborate.

HTH,

-- Jim


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

Date: 02 Oct 2000 18:40:03 +0100
From: nobull@mail.com
Subject: Re: What's wrong with this regex?
Message-Id: <u966nbgn0s.fsf@wcl-l.bham.ac.uk>

"Ivo Swartjes" <i.m.t.swartjes@wmw.utwente.nl> writes:

> Hi guys,
> 
> I'm trying to strip a filename from a path+filename, and am trying to do it
> like this ($filename is the path+filename):
> 
> $filename =~ /\\(.+?)$/;
> 
> I then try to put the part between ( ) in a new variable:
> 
> $lastpart = $1;
> 
> But it won't work, it matches the whole $filename, or so it seems.
> 
> What am I doing wrong?

Misunderstanding minimal matching operators.  Regular expressions
_always_ match as early as possible.  The minimal matching qualifier
only cause the shortest match to be chosen amongst candidates starting
at the first possible start position.

($lastpart) = $filename =~ /.*\\(.+)$/;

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 1 Oct 2000 21:59:21 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: why it's called a "hash" (and a whole lot more)
Message-Id: <8r8c3p$m0q$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Jeff Pinyan 
<japhy@pobox.com>],
who wrote in article <Pine.GSO.4.21.0009301830000.12979-100000@crusoe.crusoe.net>:
> 
>        The hash algorithm is defined in the `PERL_HASH(hash, key,
>        klen)' macro:
> 
>            hash = 0;
>            while (klen--)
>                hash = (hash * 33) + *key++;

This is the calculation of the hash...

>            hash = hash + (hash >> 5);                  /* after 5.6 */

This is just an optimization: precalculate how this number is going to
be translated to a bucket number.

> Once a hash value has been determined for a key, this value is taken,
> modulus some number.

So before 5.005_52 hash->bucket translation was

	     hash & 0b11111

(for 32-bucket hash), after this it became

	     (hash + (hash >> 5)) & 0b11111

(BTW, this + is a misprint.  I wanted it to be |, but it was late, and
my fingers slipped...  With | it is a one-to-one mapping - so gives
less surprises in the "quality of hashing" arguments.)

Here is how I want to change it.  Why hash | (hash >> 5) is performed?
To increase "randomness" of low-order bits (those bits which are used
for actual bucket number!)  Let increase randomness of high-order bits
instead:

            hash |= (hash << 5);
            hash |= (hash << 11);
            hash |= (hash << 29);

(I did not do any testing to check whether these numbers are indeed
"optimal".)  Probably it is more optimal to change | to + and write it as

	    hash = hash * (1+(1<<5)) * (1+(1<<11)) * (1+(1<<29))

(And on 64-bit machines we need an extra step as well...)

Now translate hash to bucket as

    bucket = hash >> 27;

(for a 32-bucket hash on a 32-bit machine).  Why this may have any
advantages?  So far none.

But:

  x) modify the new-key-insertion code to insert the HEK (sic!) not at
     the start of the chain, but in the order of hash-values/strings;

  x) modify the hash splitting code to preserve the order when
     splitting (this will *simplify* this code and will make it
     quickier);

  x) modify the hash lookup code to take into account that hash values
     are ordered (may speed up access to a non-existing key in a
     conjested buckets 2 times);

What we got?  A minor slowdown of creation of a new hash value; a
moderate speedup of the access to non-existing key, and

  *a reproducible ordering of the results of each()/keys()/values()*

(Why?  Because the mapping hash-value==>buckets is nondecreasing!)

The last change may be a major speedup in coding some algorithms.
Anyone wanting to code it?

Ilya


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

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


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