[7304] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 929 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 27 04:17:22 1997

Date: Wed, 27 Aug 97 01:11:12 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 27 Aug 1997     Volume: 8 Number: 929

Today's topics:
     Re: 'abandon' hope (was: Re: Need help: how to exit a s (Damian Conway)
     Re: 'abandon' hope (was: Re: Need help: how to exit a s <seay@absyss.fr>
     [Q] Awk's "s in A" Hash Test In Perl? <monty@primenet.com>
     Re: [Q] Awk's "s in A" Hash Test In Perl? (Eric Bohlman)
     Re: A Complex Regex Needed <seay@absyss.fr>
     Calling URL inside PERL (Lennie Jarratt)
     Re: cardinality of an array given a reference <tom@mitra.phys.uit.no>
     Re: CAT in PERL <seay@absyss.fr>
     Re: command line parameter -e yields different results? (Eric Bohlman)
     Re: date & time calculations (Scott  Wimer)
     Re: Fork problem (Josh Purinton)
     Re: Function Call (Charles DeRykus)
     Re: guestbook: new entry at top && fast (Eric Bohlman)
     How to Check if a file has been required <achoy@us.oracle.com>
     Re: HTTP Requests with PERL <rael@zx81.dnai.com>
     Re: importing comma deliniated - I'm stuck! (Josh Purinton)
     Re: Need advice on data storage and retrieval m.king@praxa.com.au
     Re: Need help: how to exit a subroutine if a test insid <merlyn@stonehenge.com>
     Ok, everybody laugh at me ;) <jwood@esus.cs.montana.edu>
     Re: Ok, everybody laugh at me ;) <jwood@esus.cs.montana.edu>
     Perl 5 for Win95 churley@gte.net
     Re: perl cgi and mastercard <rael@zx81.dnai.com>
     Re: Perl Regular Expression has a bug? <rael@zx81.dnai.com>
     Re: perl rtf conversion script? <rael@zx81.dnai.com>
     Re: perl rtf conversion script? m.king@praxa.com.au
     Re: Reading a text file from an URL (Michael Fuhr)
     Re: Reading a text file from an URL (Jim Michael)
     Re: Reading a text file from an URL (Eric Bohlman)
     Re: RegExp Win95/NT4.0 ? <Marc_Filthaut@HP.com>
     Re: Scanning Large File <seay@absyss.fr>
     Re: Scrambling using tr <stuartc@ind.tansu.com.au>
     Re: Suppressing a specific Perl warning (Terry Michael Fletcher - PCD ~)
     Using NT registry functions to get performance data (Jerry Britton)
     Re: When to use "use strict" (Scott  Wimer)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 27 Aug 1997 01:37:32 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: 'abandon' hope (was: Re: Need help: how to exit a sub)
Message-Id: <5u00cs$6iv$1@towncrier.cc.monash.edu.au>

Tom Phoenix <rootbeer@teleport.com> writes:

>On Tue, 26 Aug 1997, Benjamin Sugars wrote:

>> I often find myself writing constructs like
>> 
>> open(FILE, $file) or do {
>>     warn "couldn't open $file: $!\n";
>>     return;
>> };
>> 
>> It would save some typing - and also provide some syntactic closure -
>> if I could write something like
>> 
>> open(FILE, $file) or 
>>     abandon "couldn't open $file: $!\n";
>> 
>> What do you think?

You can get pretty close with:

	open(FILE, $file) or
		return !warn "couldn't open $file: $!\n";

>Seriously, the ability to make the sub abandon which would exit out of the
>caller's subroutine might be more useful, since it's more generalized than
>a new abandon built-in. Hmmm....

How about extending the "magic goto" a little:

	sub abandon
	{
		warn shift;
		goto &return;		# PROPOSED NEW goto MAGIC
	}

The logic is that "magic goto" replaces the call to its enclosing
subroutine with a call to the goto's argument. If you replace a call
to "abandon" with a call to "return" that ought to cause the
subroutine that originally called "abandon" to immediately return. :-)

Damian

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  who: Damian Conway                 email: damian@cs.monash.edu.au
where: Computer Science Dept.          web: http://www.cs.monash.edu.au/~damian
       Monash University             quote: "The best form of self-defence is
       Clayton 3168, Australia               not being there in the first place"


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

Date: Wed, 27 Aug 1997 10:01:29 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: 'abandon' hope (was: Re: Need help: how to exit a sub)
Message-Id: <3403DED9.1602ADA@absyss.fr>

Damian Conway wrote:
> 
> How about extending the "magic goto" a little:
> 
>         sub abandon
>         {
>                 warn shift;
>                 goto &return;           # PROPOSED NEW goto MAGIC
>         }

return isn't a function, it is an operator.  The way to have done that
would be to call &abandon() with the third form of GOTO (goto a
fuction).

- doug


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

Date: 26 Aug 1997 23:16:01 -0700
From: Jim Monty <monty@primenet.com>
Subject: [Q] Awk's "s in A" Hash Test In Perl?
Message-Id: <5u0gn1$ehp@nntp02.primenet.com>

I'm an awk programmer learning Perl. What is the equivalent in Perl
of awk's "subscript in array" expression for testing the existence
of a _subscript_ (NOT an element!) in an associative array?

For example, in awk, one might say

    secretword = name in words ? words[name] : "groucho"

-- 
Jim Monty
monty@primenet.com
Tempe, Arizona USA


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

Date: Wed, 27 Aug 1997 07:12:29 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: [Q] Awk's "s in A" Hash Test In Perl?
Message-Id: <ebohlmanEFK9Ct.Huv@netcom.com>

Jim Monty (monty@primenet.com) wrote:
: I'm an awk programmer learning Perl. What is the equivalent in Perl
: of awk's "subscript in array" expression for testing the existence
: of a _subscript_ (NOT an element!) in an associative array?

: For example, in awk, one might say

:     secretword = name in words ? words[name] : "groucho"

TMTOWTDI, but "defined($words{$name})" should do it.



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

Date: Wed, 27 Aug 1997 09:49:14 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: A Complex Regex Needed
Message-Id: <3403DBFA.7760B6D5@absyss.fr>

Christopher Stetson wrote:
> 
> Hi All,
> 
> I am trying to write a match-oriented regex that is taking a tab
> delimited set of fields as the target operand and trying to match it
> with a regex that is looking at various fields for a matchs.
> 
> E.G.:
> 
> Fields   | Movie Name    Actor Name    Director Name     Category
> Record 1 | Big        \t Tom Hanks  \t Penny Marshall \t Comedy
> 
> The regex needs to look for "Big" and "Penny" in the exact fields and no
> others and the regex should do it in one fell swoop (no splitting).

Why "no splitting"?  Has split tormented you in the past and you have
now black listed it?

my ($film, $director) = ( split(/\t/, $record) )[0,2];

But since you want a RE, that would be

$record =~ m/([^\t]+)\t+[^\t]+\t+([^\t]+);
my ($film, $director) = $1, $3;

- doug


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

Date: Wed, 27 Aug 1997 06:50:34 GMT
From: lbj_ccsi@atl.mindspring.com (Lennie Jarratt)
Subject: Calling URL inside PERL
Message-Id: <5u0ikh$nif@camel4.mindspring.com>

I am trying to have Perl call another URL and exit after some
processing.  I am using IIS under Windows NT and full Perl.  I needed
to read and write to a file.  Using 

   print "Location: $URL"

just prints the line on my current page.  What do I need?  How do I do
this?

Thanks,

Lennie 



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

Date: 27 Aug 1997 09:54:06 +0200
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: cardinality of an array given a reference
Message-Id: <nqohgcccb8h.fsf@mitra.phys.uit.no>


For those just joining us, the heart of this thread is how and why

perl -le '$a=[1..100];print $#{@$a}'

works.

Tom Phoenix <rootbeer@teleport.com> writes:
> [ To those reading along at home: Notice that @$a seems to be
> automatically dereferenced here. Odd, isn't it? ]

Now, before terminology gets out of hand here, let me share with you
some words from the mouth of the camel (p.245)

"To *reference* a variable, in the terminology of this chapter, is to
create a hard reference to the thingy underlying the variable. [...]
To *dereference* this scalar value is to use it to refer back to the
original thingy, as you must do when reading or writing to the
thingy."

So, since the $#{ ARRAYREF } expects a *reference* to an array, but is
passed a *dereferenced* array reference (@$a), what is happening seems
to be an implicit *referencing.* (that is, the @$a is treated as if it
were \@$a.  Please note that this notation is exactly equivalent to $a
when $a referers to an array.)

> > It's most probably an undocumentet feature. (I haven't gone through
> > perlref with a fine-toothed comb yet.)  If you want my opinion, it's
> > also a misfeature. 

> Really? I don't know yet whether I like it or not. What do you have
> against it? :-) 

It's so counterintuitive considering how all other referencing/
dereferencing operators behave.  Backslashing something creates a
reference, (references whatever it prefixes) while prefixing with a $
(for scalars, including elements of arrays or hashes), an @ or a %
dereferences it.  The same way that @{ ARRAYREF } won't accept a
dereferenced array reference,

perl -wle '$a=[1..10];print @{@$a}'	# prints nothing,

The following shouldn't work either (but do)

perl -wle '$a=[1..10];print ${@$a}[5]'	# prints 6
perl -wle '$a=[1..10];print $#{@$a}'	# prints 9

The same thing goes for passing actual arrays:

perl -wle '@a=(1..10);print @{@a}'	# prints nothing
perl -wle '@a=(1..10);print ${@a}[5]'	# prints 6
perl -wle '@a=(1..10);print $#{@a}'	# prints 9

A second (and perhaps more compelling) argument: If somebody is
passing a dereferenced <something> to an operator expecting a
<something> it probably indicates a programmer error or a deeper
misunderstanding of what is happening.

IMHO, all of the above examples should give the error message:
Not an ARRAY reference at -e line 1.

As for HASH references, the same thing goes:
perl -wle '$a={1..10};print %{$a}'	# prints 91012345678
perl -wle '$a={1..10};print %{%$a}'	# prints nothing
perl -wle '$a={1..10};print ${%$a}{5}'	# prints 6

As for curious error messages, try this:
perl -wle '$a={1..10};print $#{%$a}'
Can't use an undefined value as an ARRAY reference at -e line 1.

It may not be the obvious ARRAY reference, but it's not undefined
either, or is it?  Can somebody explain?

> Tom Phoenix           http://www.teleport.com/~rootbeer/

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: Wed, 27 Aug 1997 09:28:04 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: CAT in PERL
Message-Id: <3403D704.50116104@absyss.fr>

John Grimm wrote:
> 
> How could I translate the following sentence:
> cat $1 | tee /dev/port102
> except /dev/port102 will be SEND in the program.  Or how could I just
> send the contents of a file using print?

I don't understand the question.  But I do want to point out that you
are guilty of a useless "cat" before Randal does.

If you mean "how do I take copy a file to both STDOUT and a socket (that
is what send works with), you could do something like

while ( !eof(INPUT) )
	{
	read(INPUT, $buffer, 4096);
	print STDOUT $buffer;
	# IO::Socket is way cool
	$socket->send($buffer, '');
	}

This slings data in 4k chunks, so it is a bit faster than line oriented
I/O.

- doug


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

Date: Wed, 27 Aug 1997 01:27:48 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: command line parameter -e yields different results?
Message-Id: <ebohlmanEFJtEC.B51@netcom.com>

John Erickson (jderick@mail.utexas.edu) wrote:
: Using Perl 5.003_07 under WindowsNT

[snip]

: perl -w -i.bak -p -e "s!SRC=\"([^\"]+)\"!SRC=\"\./images/$1\"!g;"
: myfile.htm

: and the result is no change in the myfile.htm file.

: When I move the switch to a file

: rel.pl
: --
: s!SRC=\"([^\"]+)\"!SRC=\"\./images/$1\"!g;
: --
: and then run the script using:

: perl -w -i.bak -p rel.pl myfile.htm

: it successfully fixes all the tags.

: Is there any reason why the first method didn't work?  It seems to me
: that it should be identical.

The reason is that the Windows command interpreter doesn't know that 
putting a backslash before a quote is supposed to suppress its normal 
meaning.  Therefore some of the quotes aren't being passed to the 
interpreter.  The command interpreter doesn't treat backslashes as 
"escape" characters because of their use as path separators.



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

Date: Wed, 27 Aug 1997 05:51:50 GMT
From: scottw@cgibuilder.com (Scott  Wimer)
Subject: Re: date & time calculations
Message-Id: <3403bfbe.179528942@news.earthlink.net>

Hi,

Use thetime() function to calculate the current time in seconds.  Then
to find the date N days from today, do the following:
@future_date=localtime( time+( $N*( 24*60*60 ) ) );

@future_date now contains the date info for the day $N days from the
current day.

regards,
scottwimer



[ Author Cc:ed ]
On Mon, 25 Aug 1997 09:31:21 -0400, Chandra Kandiakounder
<chandrak@ml.com> wrote:

>Hi,
>
>	Is there any perl library which is useful for date and time
>calculation. For example, like given a date the perl routines should 
>be able to give date, which is 'x' number of days from the given date..
>I welcome any suggestions.
>
>-Chandrakanth
>-- 
>==============================================================================
>
>The woods are lovely dark and deep
>But I have promises to keep
>Miles to go before I sleep
>Miles to go before I sleep.

Scott Wimer
"Life's too short to write shell scripts." - Me!


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

Date: 26 Aug 1997 18:13:03 -0700
From: joshp@silmaril.com (Josh Purinton)
Subject: Re: Fork problem
Message-Id: <5tvuuv$6d8$1@shell3.ba.best.com>

[ posted and mailed ]

The one and only  <kchadha@hotmail.com> writes:

> Now the problem is that while executing the subroutine, the program
> prints out "abc" and then prints it out again after the message
> "process completed" has been issued.

fork() copies the process's memory space, including stdio buffers. Put

	$| = 1;

at the beginning of your program to turn off buffering on stdout.

--Josh

-- 
Josh Purinton <joshp@silmaril.com>
	
That which can be said to deceive
	can also be said to enchant. -- Plato




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

Date: Wed, 27 Aug 1997 01:47:54 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Function Call
Message-Id: <EFJuBx.Au6@bcstec.ca.boeing.com>

In article <01bca744$ac337740$4003420a@uc518.infogrames.fr>,
UC 518 <ejammes@infogrames.fr> wrote:
 > Hello,
 > 
 > I'd like to call in a script perl a function which is in another script. I
 > do *NOT* want do use a 'require', because the name of the function I want
 > to call is already used in my script. I also cannot change the name of this
 > function for quite complex reasons.
 > 
 > So, I'd like to call this function precising the name of the script where
 > it is located.
 > 
 > The solution is probably simple, but I could not be able to find it.
 > 
 > thanks in advance.
 > 
 > MANU.

You may be giving up too quickly on require if the other script's 
function is already scoped by a unique package keyword, e.g.,


    package Other_script;
    ...
    sub same_function { ...
        ...
    } 

Then, you can just do this to invoke the function from
the other script like this:

    require  "/path/to/Other_script.pl";
    &Other_script::same_function();

(Of course, this assumes the other file returns a true value
 so the  "require"  will work)


Another case:

If the package of the function in the other script is 
the same as the package containing the script in the
current script, you could possibly just envelop the
current local function in its own package,  e.g.

    require  "/path/to/Other_script.pl";
    package This_script;
        sub same_function {
            ...
        }
    package main;
            ...
    &same_function();       # call require'd func 
    ...
    &This_script;;same_function();   # call local one 



And if the other script's function has no explicit package, 
you can just force the function into a unique package in the 
currently running script, e.g.,

    package Other_script; 
       require "path/to/Other_script.pl";
    package main;
        ...
        &same_function(); 
        ...
        &Other_script::same_function();
        ...


So, there's several possibilities to avoid namespace collisions 
with require. 


HTH,
--
Charles DeRykus
ced@carios2.ca.knock_it_off.boeing.com


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

Date: Wed, 27 Aug 1997 07:07:51 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: guestbook: new entry at top && fast
Message-Id: <ebohlmanEFK953.HL4@netcom.com>

Siegfried Reker (s.reker@cray.ping.de) wrote:
: I'm just creating a guestbook using cgi/perl. I want new entries to
: appear at the top of the guestbook. Thus opening the file in append
: mode does not work. So by now, I create a temporary file, write the
: new entry into it, append the old guestbook entries and finally move/
: rename the temporary file to replace the old guestbook. As the
: guestbook grows this gets increasingly time consuming. Is there a
: better way?

How about writing new entries to the end of the file as they're made 
(using append mode), and massaging the file's data when you need to print 
it out (this assumes that you're using a script to display the entries 
rather than writing the entries directly to an HTML file as they're 
made)?  The display script can simply slurp up the entire file into an 
array and then output the entries in reverse order (this will be much 
easier if you come up with a standard entry separator in your data file).


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

Date: Tue, 26 Aug 1997 18:05:38 -0700
From: Allen Choy <achoy@us.oracle.com>
Subject: How to Check if a file has been required
Message-Id: <34037D62.2D66E59D@us.oracle.com>

Hi.

Is there a way to verify if a file has been 'require'd or 'use'd?

thanks in advance,

Allen



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

Date: 26 Aug 1997 21:46:37 -0700
From: Rael Dornfest <rael@zx81.dnai.com>
Subject: Re: HTTP Requests with PERL
Message-Id: <8767ssb5ci.fsf@zx81.dnai.com>


Thomas Whang <thomas@netpart.com> writes:

> I have a peculiar problem when doing HTTP requests with Perl.  If
> anybody can give me a clue, that would be greatly appreciated.  I am
> writing a "crawler", a search program to collect urls from search
> engines depending on the keywords given.  Everything seems to work fine
> when you tell it to list < 100 listings per page.  When you list more
> than that, it semms to lose info.  As shown below.  

You didn't include any Perl source here to take a look at.

If not already doing so, you should make use of the libwww-perl (LWP)
module, available at a CPAN mirror near you (http://www.perl.com/CPAN/).

Rael

---------------------------------------------------------------------------
/Rael Dornfest/                    <title>Vice President & Webmaven</title>
                              %company = (DNAI => 'Direct Network Access');
print <<ADDRESS;
2039 Shattuck Avenue, Suite 206                           To: rael@dnai.com
Berkeley, CA 94704                                 atdt 888 321 3624 (DNAI)
ADDRESS                           <a href="http://www.dnai.com">Website</a>





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

Date: 26 Aug 1997 18:01:26 -0700
From: joshp@silmaril.com (Josh Purinton)
Subject: Re: importing comma deliniated - I'm stuck!
Message-Id: <5tvu96$1to$1@shell3.ba.best.com>

[ posted and mailed ]

The one and only Shane <zatezalo.2@osu.edu> writes:
> I'm trying to read-in data from a comma deliniated file.
>
> The problem is that any variable that does NOT have quotes around it
> screws the program up.  And in the real database, there are quite a
> few of these.  There are also entries that will be blank (notices
> the 6666",, from the first entry in the text file).

Text::ParseWords does everything you want:

use Text::ParseWords;
while(<COMMA_DELIMITED_FILE>) {
	my @fields = quotewords(",", 0, $_);
	...
}

--Josh

-- 
Josh Purinton <joshp@silmaril.com>
	
The difference between theory and practice is usually larger in
practice than in theory.  -- Peter Salus




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

Date: Wed, 27 Aug 1997 04:36:50 GMT
From: m.king@praxa.com.au
Subject: Re: Need advice on data storage and retrieval
Message-Id: <3403aecf.515191345@news.ozemail.com.au>

On Sun, 24 Aug 1997 14:03:05 +0100, random <mbosley@shore.net> wrote:

>Ok, here's the question.  I am writing a web based game and the back end
>is in perl.  Up until now, I have been using basic delimited text files
>to store and retrieve the data.  I have found that most of the
>programming I am doing is retrieving/storing the data to those files. 
>It would be wonderous if I could get some alternatives to using the
>delimited text files (faster IS better! :)
>
>A sample entry would look something like this (delimited by ::):
>
>Draegonya::troop::Infantry::0::1800::4.4::11::0.55::22::11::::22::1::112::1::1::900::1.1::0.5::::2::1::::5.5::1::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::0::1::1::250::::::0.666666666666667::A/G::0.166666666666667::0.5::0.166666666666667::::2::1::0::0::0::::::0::N/A::0::0::0::::0::0::0::0::0::::::0::N/A::0::0::0::::0::0::0::0::0::::::0::N/A::0::0::0::::0::0::0::0::0::::::0::N/A::0::0::0::::0::0::0::0::0::::::0::N/A::0::0::0::::0::0::2950::5.5::10.5::19.5::9.83333333333333::::14.5::1::112::::::::737500::1652000::0::0
>
>*But* each database is different.  Each player has 6 separate db's to
>hold their info.  Some are 5 entries, and one is 248 entries.
>
>I was recently toying with packing and unpacking the info (which could
>actually be quite nice).  Also, I was toying with the idea of using
>mSQL.  The problem I can forsee is that the game is written to run on
>anything that Perl is ported to (hopefully...) so I will need something
>that can be used crossplatform (mainly on Unix variants and WIN32.)

Yes, data storage is a common problem, and databases are a bit too
regular for irregular data, which yours certainly seems to be.

I have solved this problem for myself by storing data in a .pl file.
When I need the data again, I simply require the file, and hey presto,
everything is there just as I saved it, and I did not need to unpack
the data.

Here is an example of my data file :-

#!/usr/local/bin/perl
# This is a generated file, please do not edit it
%mydata = (	
		"UserID",	"Mike",
		"Score",	"20",
		"Comment",	"Do you get the idea ?",
	};
1;		# Keeps perl happy

Basically all of this (persistent) data is kept in an associative
array called $mydata. I have a simple piece of code to write out the
contents of the array, and I can store whatever I like in it.

My code references values like this :-

$myarray{"UserID"} = "New Value";

Hope this helps

Mike


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

Date: 26 Aug 1997 23:02:01 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Benjamin Sugars <bsugars@sunpub.com>
Subject: Re: Need help: how to exit a subroutine if a test inside fails?
Message-Id: <8cu3gcupt2.fsf@gadget.cscaper.com>

>>>>> "Benjamin" == Benjamin Sugars <bsugars@sunpub.com> writes:

Benjamin> Has anyone ever felt the need for a function that prints something to
Benjamin> STDERR and then immediately does a return()?  I often find myself
Benjamin> writing constructs like

Benjamin> open(FILE, $file) or do {
Benjamin>     warn "couldn't open $file: $!\n";
Benjamin>     return;
Benjamin> };

Benjamin> It would save some typing - and also provide some syntactic closure -
Benjamin> if I could write something like

Benjamin> open(FILE, $file) or 
Benjamin>     abandon "couldn't open $file: $!\n";

Benjamin> What do you think?

I think you can already write

	open FILE, $file or
		(warn "whatever!"), return;

Or any of a dozen such variations.

What else do you need that might already be easy to do? :-)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 370 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Tue, 26 Aug 1997 19:59:53 -0600
From: "Jason Wood" <jwood@esus.cs.montana.edu>
Subject: Ok, everybody laugh at me ;)
Message-Id: <5u01pq$dk4@netra.montana.edu>

 Here is a little (umm big) routine to convert $$money$$ into its correct
form..

sub format_money

 my $number = @_[0];
 ($before,$after) = split (/\./, $number);
 if ($after < 100) {
  if ($after < 10) { $after = $after . "0"; }
  if ("1" . $after < 100) { $after = "00"; }
 }
 else {
  while ($after > 100) {
   $after /= 10;
   ($after,$leftover) = split (/\./, $after);
  }
  while ($leftover >10) {
   $leftover /=10;
   ($leftover,$blah) = split (/\./, $leftover);
  }
  if ($leftover >4) { $after++; }
  if ($after == 100)

   $after = "00";
   $before++;
  }
 }
 return "$before.$after";
}


laugh it up, actually, a better way to do this would be helpful
I couldn't find any round functions to use, although I know they are there..
I've know Perl for less than a year, so I haven't learned the shortcuts..
Thanks, later





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

Date: Tue, 26 Aug 1997 20:36:07 -0600
From: "Jason Wood" <jwood@esus.cs.montana.edu>
Subject: Re: Ok, everybody laugh at me ;)
Message-Id: <5u03tn$e65@netra.montana.edu>

Found a little bug in my routine ;)

>sub format_money
>
> my $number = @_[0];
> ($before,$after) = split (/\./, $number);
> if ($after < 100) {
>  if ($after < 10) { $after = $after . "0"; }
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   if (($after < 10) and ( not substr($after,0,1) == "0")) { $after = $after
 . "0"; }





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

Date: 27 Aug 1997 03:18:17 GMT
From: churley@gte.net
Subject: Perl 5 for Win95
Message-Id: <5u069p$jqo$1@gte1.gte.net>

I am new to the world of Perl, infact am trying to teach myself the
language, and am trying to install the Perl compiler on my computer.
I have downloaded both the 5.03 and 5.04 versions.  5.03 in the form
of a .exe file and 5.04 as a tar.gz file.  My problem is configuring
it to work with my system.  I am trying to execute the examples as the
appear in O'Reilly's Learning Perl nutshell book.

I understand that these were written for a UNIX system, which I do not
have access to and I will be uploading my scripts to an NT server.

If anyone can help me set this  up and get started please e-mail me:

churley@gte.net

Thank you for any help and please bear with me as I try to learn....I
doubt this will be my last posting hahahaha...

Thanks,
Chris Hurley


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

Date: 26 Aug 1997 21:31:56 -0700
From: Rael Dornfest <rael@zx81.dnai.com>
Subject: Re: perl cgi and mastercard
Message-Id: <877md8b60z.fsf@zx81.dnai.com>


> | Would you know where I could obtain a pre-written Perl CGI script for 
> | handling www order forms with Visa and Mastercrd fields.

Take a look at "CC Verifier" at:

http://www.worldwidemart.com/scripts/ccver.shtml

Hope this helps!

Rael

---------------------------------------------------------------------------
/Rael Dornfest/                    <title>Vice President & Webmaven</title>
                              %company = (DNAI => 'Direct Network Access');
print <<ADDRESS;
2039 Shattuck Avenue, Suite 206                           To: rael@dnai.com
Berkeley, CA 94704                                 atdt 888 321 3624 (DNAI)
ADDRESS                           <a href="http://www.dnai.com">Website</a>





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

Date: 26 Aug 1997 21:59:41 -0700
From: Rael Dornfest <rael@zx81.dnai.com>
Subject: Re: Perl Regular Expression has a bug?
Message-Id: <874t8cb4qq.fsf@zx81.dnai.com>


> #!/usr/bin/perl
> $date = localtime();
> print "$date\n";
> if($date = ~/(..):(..):(..)/)
> {
>  print "Now \$date = $date\n";
>  print "Time: $1:$2:$3\n";
> } 

Or (if you are using Perl5) you could make things easier on yourself 
and use the Time module thusly:

#!/usr/local/bin/perl

use Time::localtime;

$now = localtime;

print "Time: ", join(/:/, $date->hour, $date->min, $date->sec), "\n";

Rael

---------------------------------------------------------------------------
/Rael Dornfest/                    <title>Vice President & Webmaven</title>
                              %company = (DNAI => 'Direct Network Access');
print <<ADDRESS;
2039 Shattuck Avenue, Suite 206                           To: rael@dnai.com
Berkeley, CA 94704                                 atdt 888 321 3624 (DNAI)
ADDRESS                           <a href="http://www.dnai.com">Website</a>





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

Date: 26 Aug 1997 21:15:42 -0700
From: Rael Dornfest <rael@zx81.dnai.com>
Subject: Re: perl rtf conversion script?
Message-Id: <8790xob6s1.fsf@zx81.dnai.com>


Hampton Keathley <hamptonk@ods.com> writes:

> Does anyone know where I can find a perl script that will convert rtf
> files to html?

SDF - Simple Document Format
A freely available documentation system designed and developed by Ian
Clatworthy, with help from many others. Based on a simple, readable
markup language, SDF generates high quality output in multiple
formats, all derived from a single document source. Supported output
formats include HTML, PostScript, PDF, man pages, POD, LaTeX, MIF,
RTF, Windows help and plain text.

Point your Web browser at:

http://www.mincom.com/mtr/sdf/

For info on converting RTF to SDF (before outputting to HTML),
take a look at:

http://www.mincom.com/mtr/sdf/paper/sdfintro.html#Converting documents to SDF

Just one way to do it ;-)

Rael

---------------------------------------------------------------------------
/Rael Dornfest/                    <title>Vice President & Webmaven</title>
                              %company = (DNAI => 'Direct Network Access');
print <<ADDRESS;
2039 Shattuck Avenue, Suite 206                           To: rael@dnai.com
Berkeley, CA 94704                                 atdt 888 321 3624 (DNAI)
ADDRESS                           <a href="http://www.dnai.com">Website</a>





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

Date: Wed, 27 Aug 1997 04:35:45 GMT
From: m.king@praxa.com.au
Subject: Re: perl rtf conversion script?
Message-Id: <3403ae7f.515111691@news.ozemail.com.au>

On Wed, 20 Aug 1997 09:52:51 -0500, Hampton Keathley
<hamptonk@ods.com> wrote:

>Does anyone know where I can find a perl script that will convert rtf
>files to html?
>
>Thanks,
>
>Hampton
>

That sure would be nice - I would like to know about it too !

Word can do this already in its own fasion...

Mike


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

Date: 26 Aug 1997 19:08:26 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Reading a text file from an URL
Message-Id: <5tvuma$n66@flatland.dimensional.com>

bob@cafemedia.com (Bob Maillet) writes:

> Has anyone been able to read the text from an external source (URL) and
> write it to a buffer within perl?  
>
> Any help or direction would be appreciated.

Check out the LWP modules, part of libwww.  You can find this and
other useful modules on the Comprehensive Perl Archive Network (CPAN):

    http://www.perl.com/CPAN/CPAN.html

Hope this helps.
-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: Wed, 27 Aug 1997 01:08:04 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Reading a text file from an URL
Message-Id: <genepoolEFJsHG.I67@netcom.com>

Bob Maillet (bob@cafemedia.com) wrote:
: Has anyone been able to read the text from an external source (URL) and
: write it to a buffer within perl?  

Sorry, this is the one thing you can't do with Perl. ha ha just kidding 
:-) Check out the LWP module. 

Cheers and deja vu,

Jim



: Any help or direction would be appreciated.

: Bob

: -- 
: To get random signatures put text files into a folder called 3Random Signatures2 into your Preferences folder.


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

Date: Wed, 27 Aug 1997 01:34:23 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Reading a text file from an URL
Message-Id: <ebohlmanEFJtpB.BFJ@netcom.com>

Bob Maillet (bob@cafemedia.com) wrote:
: Has anyone been able to read the text from an external source (URL) and
: write it to a buffer within perl?  

Yes.

: Any help or direction would be appreciated.

Use LWP::Simple;

my $url="http://www.perl.com/";
my $buf=get $url;

HTH



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

Date: Wed, 27 Aug 1997 09:01:43 +0200
From: Marc Filthaut <Marc_Filthaut@HP.com>
Subject: Re: RegExp Win95/NT4.0 ?
Message-Id: <3403D0D7.DD7@HP.com>

Terry Michael Fletcher - PCD ~ wrote:
> 
> Marc Filthaut (Marc_Filthaut@HP.com) so eloquently and verbosely pontificated:

:-))

> the big difference is in the newline character, which would be a cntl-M

I know

 
> are you trying to match a newline?

Yes I try

> are you using /^anchors like this$/ ?

Yes for example if($_ =~ /(\015\012)$/) { ... } or
if($_ =~ /(\cM)$/) { ... } 

Under Unix it works fine but not under Windows95. But when I chop the
last character, the return is \cM, or \n\r, or \015\012

-- 
___________________________________________________________________
Marc Filthaut                      Hewlett-Packard GmbH
SW Delivery Support Engineering    Berliner Str. 111       _/
                                   40880 Ratingen         _/
Phone  : +49-2102-90-6505          Germany               _/_/_/ _/_/_/
Telnet : 705-6505                                       _/  _/ _/  _/
Fax    : +49-2102-90-6885                              _/  _/ _/_/_/
                                                            _/
eMail  : Marc_Filthaut@HP.com                              _/
_____________________________________________________________________


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

Date: Wed, 27 Aug 1997 09:16:54 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Scanning Large File
Message-Id: <3403D466.183A6FA5@absyss.fr>

Stephen Hill wrote:
> 
> Is there a way to scan a large file without reading the entire file into
> memory.
> 
> I have a file which is about 30meg, I want to be able to do a simple
> search on the data. My system doesn't have enough memory to handle this.
> Is there a way to read one line of the file into memory at a time?

The <> operator (as in "$var = <FILE>;") just reads a single line.  That
is a pretty basic concept, you can find the details in the docs.

- doug


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

Date: 27 Aug 1997 12:10:53 +1000
From: Stuart Cooper <stuartc@ind.tansu.com.au>
Subject: Re: Scrambling using tr
Message-Id: <yeo67sse5oy.fsf@kudu.ind.tansu.com.au>

jmastYers@pcocd2.intel.com (Justin Masters - remove "Y" to reply) writes:

> I have a script I'm writing, but with a "shortcut" to be used only for 
> analysis, and not to be abused by users.  
> 
> I would like to put in a short message to people using this option
> that an upcoming operation will be bypassed.
> 
> What's an easy method of "scrambling" a message to get past the casual
> searchers of the text which they may see displayed going by on the screen?
> 
> I tried using tr/a-z/Z-A/g, but it doesn't like (presumably) the "backwards
> range" of Z-A. 
> 
> Any ideas?
> 
> -- 
> --------------------------------------------------------------------------
>    Justin Masters   (Sr. Cad Engineer - Design Automation)  PH: 916-356-6735
>    Intel Corp. FM5-94                                      FAX: 916 356-7874
>    1900 Prairie City Rd, Folsom, CA 95630          jmastYers@pcocd2.intel.com

Any ideas? 

Yeah- 1) get your organisation to stop (pro|per)secuting Randal Schwartz. 
      2) ask the Intel guy who prosecuted Randal; he's a *real* expert.
         He unlearned Perl in 40 days!

Cheers,
stuartc!@intel.com

Stuart Cooper
stuartc@ind.tansu.com.au


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

Date: 27 Aug 1997 00:37:29 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: Suppressing a specific Perl warning
Message-Id: <5tvss9$7hm$1@news.fm.intel.com>

Greg Ward (greg@bic.mni.mcgill.ca) so eloquently and verbosely pontificated:
> 
> That warning should only pop up if Perl is interpreting your
> binary-with-underscores string as a number.  Seems to me that treating
> 101100101101111 as a decimal number, whether it has underscores or not,
> is the wrong thing to do.  So where are you putting your binary strings
> in a numeric context?  Remove the numericity of that use, and the
> warnings should disappear.

if i had the choice, i would not have picked the binary format to be the
same as the decimal.  it is a backward compatibility issue that i have no
control over :(  its not me putting them in numeric context, its an end
user.

luckily, it looks like the $SIG{__WARN__} routine should be able to do the
trick!  never really looked into that one before.

-- 
#!/usr/intel/bin/perl -w
$_=<<'/\<<$_; :-) \' ^/<\'<>/\'$!=0/\'/<&@_';@"=(qw; P ;,q*e*,qq,r,,q;l;);
^[^a-i*#,k-z@&]u[s,*]t$ ^[]/$%a!&]*not*\(anything\)*here*$ ^p[$_r%,.]i*nt$
[^hi]?[]MOM!#]$ #  tfletche@pcocd2.intel.com  # ^h*[^b$d-j%/,l-z(]\{3\}er$
/\<<$_; :-) ' ^/<'<>/'$!=0/'/<&@_
for(split){map{s;print;join"",@";eg;chop;print}q& &.qx;look -r '$_';}# TMF



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

Date: Wed, 27 Aug 1997 06:59:28 GMT
From: ywamadam@xs4all.nl (Jerry Britton)
Subject: Using NT registry functions to get performance data
Message-Id: <5u0j8g$gqd$1@news2.xs4all.nl>

Anyone got a working program to access the NT performance data using the 
WIN32::Registry package?


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

Date: Wed, 27 Aug 1997 05:59:45 GMT
From: scottw@cgibuilder.com (Scott  Wimer)
Subject: Re: When to use "use strict"
Message-Id: <3403c0fd.179848296@news.earthlink.net>

Randal,
How are the my() variables stored internally?  I understand the
mechanism used to grab package variables, but am not enough of a C
programmer to understand the storage mechanism for the my() values.
My assumption was that the my variables were in stored internally in
list format, and would therefore be much faster than haveing to do the
hash calculations, if you did not have an enormous number of my()'d
variables in each block.

How far off is my understanding of the internals? :)

As to `use strict': I turn it on for script development and while I'm
working on fine tuning stuff, but after that, I turn it off.  That way
I don't pay the small performance penalty when the code is in
production.

regards,
scottwimer

[ Author Cc:ed ]
On 26 Aug 1997 07:13:33 -0700, Randal Schwartz <merlyn@stonehenge.com>
wrote:

>>>>>> "Josh" == Josh Purinton <joshp@silmaril.com> writes:
>
>>> Should I use Package identifiers and fully qualify variable names?
>
>Josh> Either that or use the 'vars' module described above.
>
>Actually, I'd recommend neither of those.  Use lexical variables when
>possible.  They're faster to access, and trivial to declare (my $foo =
>"initial value";).  Use package variables (fully qualified or
>use-var'ed) only when others outside the current file need to access
>the variable.
>
>print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
>## legal fund: $20,990.69 collected, $186,159.85 spent; just 371 more days
>## before I go to *prison* for 90 days; email fund@stonehenge.com for details
>
>-- 
>Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
>Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
>Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
>Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
>Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me

Scott Wimer
"Life's too short to write shell scripts." - Me!


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 929
*************************************

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