[12452] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6052 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 18 23:28:35 1999

Date: Fri, 18 Jun 99 20:00:21 -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           Fri, 18 Jun 1999     Volume: 8 Number: 6052

Today's topics:
        ******great new site guys!****** (IlIIIIIIII)
    Re: Afraid to ask about Y2K! <jamespc@qni.com>
    Re: Afraid to ask about Y2K! (Lee)
    Re: Afraid to ask about Y2K! (Lee)
    Re: Beginner program <unclelui@grin.net>
    Re: Beginner program <jeffp@crusoe.net>
    Re: Database Management Problem <rootbeer@redcat.com>
    Re: Hex to Decimal?? <whm10@amdahl.com>
    Re: HOWTO compare two arrays, an get the difference (Larry Rosler)
    Re: Is Perl4 Y2K compliant? <rootbeer@redcat.com>
    Re: JPEG height/width (Larry Rosler)
    Re: Match diff with '\s*' vs ' ' (Marcel Grunauer)
    Re: Neet Perl Obfucation Program (Lee)
    Re: odd autoincrement behavior ? (Lee)
        Perl and artificial intelligence. <xyf@inetnebr.com>
    Re: Perl scripts slows down servers? (Larry Rosler)
    Re: Perl scripts slows down servers? (Lee)
    Re: Perl scripts slows down servers? (Marcel Grunauer)
    Re: Perl Sockets <rootbeer@redcat.com>
    Re: s/\s/ /g does not work for me... why??!! <rootbeer@redcat.com>
        Scalar Names <troyknight@troyknight.eurobell.co.uk>
    Re: Scalar Names <rootbeer@redcat.com>
    Re: Scalar Names (Matthew Bafford)
    Re: Scalar Names (Marcel Grunauer)
    Re: Signature removal regex? (J. Moreno)
        Simple question <taswar@DONTSPAMcs.ualberta.ca>
    Re: Simple question <rootbeer@redcat.com>
    Re: sleeping vs stopping and restarting <rootbeer@redcat.com>
    Re: UNIX: ~name won't work on system() as expected <rick.delaney@home.com>
        Writing RTF with Perl NewtronBoy@aol.com
    Re: Writing RTF with Perl (Lee)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 19 Jun 1999 02:21:13 GMT
From: iliiiiiiii@aol.com (IlIIIIIIII)
Subject: ******great new site guys!******
Message-Id: <19990618222113.05377.00001419@ng38.aol.com>

check out:
http://devlib.cjb.net


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

Date: Fri, 18 Jun 1999 19:06:48 -0500
From: "Jim Connelley" <jamespc@qni.com>
Subject: Re: Afraid to ask about Y2K!
Message-Id: <7ken4g$279$1@scoop.suba.com>

http://drudgereport.com/matt1.htm

'nuf said.

--
Jim Connelley



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

Date: Fri, 18 Jun 1999 20:13:30 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <B39058EA96686CD12@0.0.0.0>

In article <7kejbe$bbf$1@brokaw.wa.com>,
jeromeo@atrieva.com (Jerome O'Neil) wrote:

>How do you feel about localtime() called in scalar context?

It's handy for timestamps and such, but it's not at the intermediate level
between localtime() and strftime() that I was talking about. 

I often want the results of localtime() in list context, with values munged
to months numbered from 1 to 12, etc. It's no biggie, but it's the sort of
thing that I generally expect to find available in Perl without having to
load a module or munge it myself.

Lee




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

Date: Fri, 18 Jun 1999 20:13:30 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <B39058EA96686CD2B@0.0.0.0>

In article <7keldd$7e7$1@fcnews.fc.hp.com>,
ada@fc.hp.com (Andrew Allen) wrote:

>Lee (rlb@intrinsix.ca) wrote:
>: In Perl, I *expect* to find the imaginary humantime() function. This is one
>: of the few times it has left me disappointed.
>
>Something other than POSIX::strftime?

I know (or suspect, I've never actually used any of them) that there are at
least three modules that give this functionality. But it seems such a
common need/desire that it shouldn't require a module. Or am I being a
silly git again?

Lee




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

Date: Fri, 18 Jun 1999 17:12:45 -0700
From: "Luis F. Salas" <unclelui@grin.net>
To: amirs@uclink4.berkeley.edu
Subject: Re: Beginner program
Message-Id: <376AE07D.6E60@grin.net>

> as being able to isolate just those two lines from the file, with a
> while loop and two if ($line =~ /pattern/) statements, but now I need
> to extract just the numbers out. Any ideas how?

make $line into an array (by using split)
then then pick whatever element of the array you want.
ejem:

file: maximum at 65        # $line = maximum at 65

@splitline = split(//,$line);      #$plitline[0] = maximum
     				   #$splitline[1]= at
     				   #$splitline[2]= 65

$max=$splitline[2];   #max = 65


(Double check the default for split)

Hope this helps...

Luis


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

Date: Fri, 18 Jun 1999 21:40:19 -0400
From: evil Japh <jeffp@crusoe.net>
Subject: Re: Beginner program
Message-Id: <Pine.GSO.3.96.990618213809.17149D-100000@crusoe.crusoe.net>

> @splitline = split(//,$line);      #$plitline[0] = maximum
>      				   #$splitline[1]= at
>      				   #$splitline[2]= 65

Not exactly.  You meant:
	@splitline = split / /, $line;

Splitting on // returns an array of EACH separate character.

Because TMTOWTDI (There's More Than One Way To Do It), you may want to use
a regular expression on each of those two lines:

($max) = $maxline =~ /(\d+)/;
($mean) = $meanline =~ /(\d+)/;

However, this is assuming you'll have integers, so it may be safer to go
with the more compact version:

$max = (split ' ', $maxline)[2];
# etc...

-- 
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp

Crusoe Communications, Inc.
732-728-9800
www.crusoe.net



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

Date: Fri, 18 Jun 1999 17:39:58 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Database Management Problem
Message-Id: <Pine.GSO.4.02A.9906181733140.5420-100000@user2.teleport.com>

On Fri, 18 Jun 1999, Matt wrote:

> I'm using a plain old text file delimited by colons :::: and certain
> routines just aren't working out.  

It's even better if you can cut the problem down to single statements (or
even operators or functions), rather than routines.

>  $newrecord =
> $id."::".$make."::".$model."::".$year."::".$miles."::".$price."::".$etc."::"
> .$image."\n";

I think that that would be easier to read, write, and maintain if you used
join().

>    $db =~ s/$id:+.*:+.*:+.*:+.*:+.*:+.*:+.*\n//;    # in ActiveState this
> WORKS!!!   In UNIX it seems not to!!!!

Ack! You don't really want a pattern like that.

I think that one version of Perl is more confused than the other about
whether the colon after $id means part of the variable name. (That is, one
is perhaps mis-parsing that as a variable called $id: or something like
that.)

But your real problem is that you seem to be reading your database into a
single scalar to work with that. That may be all right if you know it's
always going to be small, but it's not a good general solution. Consider a
tied hash, which is easy to work with and can grow essentially without
limit.

Cheers!

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



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

Date: Fri, 18 Jun 1999 19:08:29 -0700
From: Hal Mounce <whm10@amdahl.com>
Subject: Re: Hex to Decimal??
Message-Id: <376AFB9D.E19989B7@amdahl.com>

seong joon bae wrote:
> 
> How would you write a little script that converts hex to dec...?

Here's one I use to build binary files from scratch.  You might be able
to glean something from it.

#!/opt/perl5/bin/perl
# hexit:  A filter to convert a hexidecimal charachter stream into
binary data, it eats
#         whitespace and garbage and stuff.
# 01/20/99 whm10 initial coding

while (<>) {
    $_ = ($oddnibble ||= "") . $_;         #handle any extra nibble from
previous line
    tr/0-9a-fA-F//cd;                      #loose everything but the hex
stuff
    $len = tr/0-9a-fA-F/0-9A-FA-F/;        #capitalize, get a nibble
count
    # print "\$len is-->$len<--\n";
    if ($len % 2) {
        $oddnibble = chop;                 #we split a byte across a
line or something
    }
    else {
        $oddnibble = "";
    }
    # print "-->$_<--\n";
    # print "\$oddnibble is-->$oddnibble<--\n";
    $out = pack "H*", $_;
    print "$out";
}


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

Date: Fri, 18 Jun 1999 17:54:29 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: HOWTO compare two arrays, an get the difference
Message-Id: <MPG.11d48a1d690d695f989bff@nntp.hpl.hp.com>

In article <376a14a7.1442544@enews.newsguy.com> on Fri, 18 Jun 1999 
09:43:25 GMT, Marcel Grunauer <marcel.grunauer@lovely.net> says...
> On Fri, 18 Jun 1999 11:23:24 +0200, "Torfinn Keringen" <tor@kmd.dk>
> wrote:
> >I have @array1 @array2, both of them contains a few lines of text,
> >what I want is an @array3 containing the lines from @array1
> > that is missing in @array2
> 
> perlfaq4: How do I compute the difference of two arrays? How do I
> compute the intersection of two arrays?

We have short memories.  The following is from a thread dated June 10.

http://x22.deja.com/[ST_rn=ps]/getdoc.xp?AN=487949381

This *seems* like a FAQ.  `perldoc -q difference` would have led you to 
perlfaq4: "How do I compute the difference of two arrays? How do I 
compute the intersection of two arrays?"
 
But that would have given you a different answer from the one you 
wanted, because the 'difference' in the FAQ is the 'symmetric 
difference' -- elements in one or the other set but not both.  What you 
are asking for is the 'set difference' -- elements in one set but not in 
the other.

<SNIP> code and discussion...

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


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

Date: Fri, 18 Jun 1999 18:07:51 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Is Perl4 Y2K compliant?
Message-Id: <Pine.GSO.4.02A.9906181805200.5420-100000@user2.teleport.com>

On Fri, 18 Jun 1999, Daniel W. Burke wrote:

> Newsgroups: comp.lang.perl.misc, comp.lang.perl

If your news administrator still carries comp.lang.perl, please let him
or her know that that newsgroup has not existed since 1995. If you
have such an outdated newsgroup listing, you are probably missing out
on many other valid newsgroups as well. You'll be doing yourself and
many others a favor to use only comp.lang.perl.misc (and other valid
Perl newsgroups) instead.

> As a result of my seeking if perl4 is "Y2K Compliant" I've learned
> about the odd-ness (well, I think it's odd) of how localtime() returns
> the year, and was able to fix 2 scripts this morning.

Good!

> I think the problem is, that too many people have asked :)

They are the ones who put the F in FAQ, just as those who answer
put the F in RTFM. :-)

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



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

Date: Fri, 18 Jun 1999 18:25:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: JPEG height/width
Message-Id: <MPG.11d4916862339a5c989c00@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <376A7407.3806A7E3@freei.net> on Fri, 18 Jun 1999 09:30:00 -
0700, Steve Laybourn <redmeat@freei.net> says...
 ...
>    All I want to know this time around is: How can I get the height and
> width of a JPEG image using Perl?

sub do_JPEG	{	# Return width and height; adapted from Image::Size.
    my $MARKER      = 0xFF;	# Section marker.
    my $SIZE_FIRST  = 0xC0;	# Range of segment identifier codes
    my $SIZE_LAST   = 0xC3;	#  that hold size info.
    bin_read(2) or return;	# Skip header ID.
    while () {
	my ($marker, $code, $length) = unpack 'C C n' => bin_read(4);
	($marker || "") eq $MARKER or return;	# Verify valid segment.
	last if $SIZE_FIRST <= $code && $code <= $SIZE_LAST;
	bin_read($length - 2) or return;	# Skip over data.
    }
    unpack 'v v' => reverse bin_read(5);  # Return width and height.
}

bin_read(n) just returns the next 'n' bytes from a specific file.  Adapt 
your own input routine.

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


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

Date: Sat, 19 Jun 1999 01:43:53 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Match diff with '\s*' vs ' '
Message-Id: <376df594.5020408@enews.newsguy.com>

On Fri, 18 Jun 1999 12:59:54 -1000, David Pautler <pautler@hawaii.edu>
wrote:

>I'm new to Perl and using egrep to try to understand problems in my
>regexprs.
>
>Below, I'm getting a successful match with a regexpr that ends in ' <',
>but a regexpr that's the same except for ending in '\s*<' is failing.  I
>can only guess that this has something to do with the greediness of
>'\s*'.

I don't know the differences between egrep and Perl's regular
expressions, but your example works in Perl:

#!/usr/bin/perl -w

use strict;

undef $/;
$_ = <DATA>;
print "RE1:$1\n" if m#(Availability\s*</B>\s*:? <)#;
print "RE2:$1\n" if m#(Availability\s*</B>\s*:?\s*<)#;

__DATA__
<FONT FACE = "Arial, Helvetica"><B>Availability</B>: <FONT FACE =
"Arial, Helvetica" SIZE = "-1"><A
HREF="http://www.books.com/scripts/xahelp.exe?sid~vZWFlm3eIb4zBaP/index~AVAIL">Usually
ships in 2-3 business days</A></FONT>.


outputs:

RE1:Availability</B>: <
RE2:Availability</B>: <


HTH
Marcel



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

Date: Fri, 18 Jun 1999 20:13:31 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: Neet Perl Obfucation Program
Message-Id: <B39058EB96686CD6D@0.0.0.0>

In article <376aa644.50679323@news.nikoma.de>,
nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton) wrote:

>No. My From: address is
>
>    nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
>
>The 'Yes, that's my address' is suppose to be a clue that you *don't*
>have to remove anything to e-mail me. Just leave the address as it is;
>it's deliverable that way.
>
>My hope was that programs that filter out addresses would throw out
>the signal word, thus producing an undeliverable e-mail address and
>sparing me some spam. People are not suppose to de-mung the address.

You're too devious for your own good, Philip. :)

>I apologise for any inconvenience this has caused anyone.

I thought it was rather entertaining.

As for perl code that will interpret as-is but defy human comprehension, I
see two options:

1) write a script that turns variable names into gibberish, or

2) hire me. That's the sort of code I write.

Lee




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

Date: Fri, 18 Jun 1999 20:13:31 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: odd autoincrement behavior ?
Message-Id: <B39058EB96686CD4C@0.0.0.0>

In article <3774aae2.11612188@news.skynet.be>,
bart.lateur@skynet.be (Bart Lateur) wrote:

>Yes, yes, rub it in. The latest MacPerl port is out of date. Sigh.
>Matthias is far too busy right now, with his new life and all, to
>quickly fix that.

Matthias got a new life?

Sheesh! I'd settle for some minor repairs to my old one, just to get it
through another winter or two.

Lee

(a closet Macoholic)




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

Date: Fri, 18 Jun 1999 21:12:57 -0500
From: ktb <xyf@inetnebr.com>
Subject: Perl and artificial intelligence.
Message-Id: <376AFCA9.A4EE3ECD@inetnebr.com>

Hi, I've been searching for something on the net about artificial
intelligence using the Perl language.  Most of the programs seem to be
in 'C' and other languages I haven't heard of. I'm new to programming
but I thought it would be fun to mess around with this.  If anyone knows
of any A.I. programs written in Perl or links on the topic I'd love to
know about it.
Thanks,
kent


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

Date: Fri, 18 Jun 1999 17:41:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl scripts slows down servers?
Message-Id: <MPG.11d4870b626f48e3989bfe@nntp.hpl.hp.com>

In article <376A59E1.20B9E614@ericsson.com> on Fri, 18 Jun 1999 15:38:25 
+0100, Matt Sergeant <matt.sergeant@ericsson.com> says...
> Marcel Grunauer wrote:
> > Perl is faster than Java, 
> 
> What evidence do you have to back that up? Just curious (I prefer Perl,
> but I'm aware that Java is faster now for some situations/solutions, and
> that's OK with me :))

Kernighan & Pike, The Practice of Programming (1999), p. 81, has a 
comparative performance and code-size chart for a particular program.  
Here are excerpts:


       250 MHz    400 MHz       Lines of
       R10000     Pentium II   source code

Java   4.9 sec    9.2 sec         105

Perl   1.8 sec    1.0 sec          18


A good book (as you can see :-)!

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


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

Date: Fri, 18 Jun 1999 21:23:08 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: Perl scripts slows down servers?
Message-Id: <B390693C9668AA2AC@0.0.0.0>

In article <376c152f.1578329@enews.newsguy.com>,
marcel.grunauer@lovely.net (Marcel Grunauer) wrote:

>Perl is faster than Java, but slower than C++. It is, if well
>programmed, more readable (and elegant!) than either. But then, what
>response did you expect in a Perl newsgroup?

You can't beat C without the ++ for speed, but that doesn't mean you can't
hate it with a passion anyway.

If speed of development, ease of maintenance, and robustness count for
anything at all, use Perl and go to a faster server if you need to.

Lee

(now if I could only convince my employer of that!)




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

Date: Sat, 19 Jun 1999 02:13:02 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Perl scripts slows down servers?
Message-Id: <376efa31.6201307@enews.newsguy.com>

On Fri, 18 Jun 1999 11:52:14 -0700, David Cassell
<cassell@mail.cor.epa.gov> wrote:

>Matt Sergeant wrote:
>> 
>> Marcel Grunauer wrote:
>> >
>> > Perl is faster than Java,
>> 
>> What evidence do you have to back that up? Just curious (I prefer Perl,
>> but I'm aware that Java is faster now for some situations/solutions, and
>
>Is it?  The examples I have been shown are the artificial
>optimized-Java-situation vs Perl-with-no-optimization-and-no-
>mod_perl kind of cases.  You can always slow Perl down if you
>try.. or if you use scripts from Matt Wright.  :-)
>

Well, I have to admit, I didn't actually test it myself, but checked
with deja and found two instances within the last 6 weeks that said
Perl is faster than Java, but none to the contrary. Actually, on May
17, you (David, that is) said:

>> Are their any major advantages in using Java Servlets instead of
>>Perl/CGIs?
>                   
>You might want to go to http://language.perl.com/versus/index.html
>and read a couple views on the subject.
>                    
>If you want client-side computing, you can't guarantee that Perl is
>on the client's machine.  But then, you can't guarantee that java
>or javascript is enabled on the client's machine either.  They
>aren't on some of mine.  I haven't seen any java thing on the
>server side which Perl can't do, but I have seen a lot of Perl
>server progs which I wouldn't dream of trying to implement in java.
>
>Which one are you more adept in?  That should also be a prime
>consideration.
>
>> If one uses mod_perl, is the speed issue moot?
>
>Not at all.  Perl is way faster than java to begin with, and mod_perl
>just tilts the arrow farther toward the Perl side of the dial.

Maybe this is one of the artificial situations you refer to above, but
if so, I didn't catch that.

Sorry about the inconvenience/confusion/inaccuracy.

Marcel


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

Date: Fri, 18 Jun 1999 17:42:17 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl Sockets
Message-Id: <Pine.GSO.4.02A.9906181740340.5420-100000@user2.teleport.com>

On Fri, 18 Jun 1999, William Lewis wrote:

> I have a perl client/server program that is very simple in nature. I
> put this on one machine and it works fine, if I put it on another
> machine with the same perl version and installation is will not work.
> When it attempts to create the socket it gives a Bad File Number error
> and in fact the clients cannot create sockets either.

I wonder whether a program written in C can create sockets on both
machines. If so, one Perl seems to me to be miscompiled. But see what your
manpages say for the underlying system call which reports the error - it
may be trying to tell you something. Good luck!

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



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

Date: Fri, 18 Jun 1999 17:54:33 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: s/\s/ /g does not work for me... why??!!
Message-Id: <Pine.GSO.4.02A.9906181751380.5420-100000@user2.teleport.com>

On Fri, 18 Jun 1999, Luis F. Salas wrote:

> I am using $comments = param('comments'); and that's why I am trying
> to change the \n to a mere blank space, but so far I have been
> unsuccessful.

As I said before:

    If you can make a small, standalone, non-web program which shows what
    part of Perl is not doing what you want, we can try to help you. You
    should be able to do this with no more than about five lines of code:
    Just set up a variable with the data you've got, try getting rid of
    the return character, and print it out.

If you can't show us this kind of code, we probably won't be able to see
the problem well enough to fix it. Cheers!

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



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

Date: Sat, 19 Jun 1999 01:15:03 +0100
From: "Troy Knight" <troyknight@troyknight.eurobell.co.uk>
Subject: Scalar Names
Message-Id: <7ken8f$k1m$1@aub.eurobell.net>

At last I've found a decent perl newsgroups, been searching for one for
ages!
I have a script where I would like to assign a value to an scalar whose name
is an a followed by a number which is dependant on something, how would I do
this? If you place two scalar names together such as $a$two it comes up with
an error, and I can't really see how to it. I'd appreciate some help from
someone more experienced than me, Cheers.




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

Date: Fri, 18 Jun 1999 18:19:23 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Scalar Names
Message-Id: <Pine.GSO.4.02A.9906181813220.5420-100000@user2.teleport.com>

On Sat, 19 Jun 1999, Troy Knight wrote:

> At last I've found a decent perl newsgroups, been searching for one
> for ages!

We've been right here for ages. Where were you looking? Section two of the
FAQ would have sent you our way.

> I have a script where I would like to assign a value to an scalar
> whose name is an a followed by a number which is dependant on
> something, how would I do this?

Use an array, like $name[$num]. Or maybe you want a hash, like
$name{$something}.

Cheers!

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



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

Date: Sat, 19 Jun 1999 01:38:05 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Scalar Names
Message-Id: <slrn7mlqmr.1vc.dragons@dragons.duesouth.net>

On Sat, 19 Jun 1999 01:15:03 +0100, Troy Knight
<troyknight@troyknight.eurobell.co.uk> attempted to use the Perl
documentation, but somehow ended up posting this instead:
: At last I've found a decent perl newsgroups, been searching for one for
: ages!  [set your newsposter to wrap a little sooner]
: I have a script where I would like to assign a value to an scalar whose name
: is an a followed by a number which is dependant on something, how would I do
: this? If you place two scalar names together such as $a$two it comes up with
: an error, and I can't really see how to it. I'd appreciate some help from
: someone more experienced than me, Cheers.

Why do so many people want to do this?

If you're using small numbers, use an array:

$array[$index] = $value

If the numbers are large, or spaced far apart, use a hash:

$hash{$index} = $value;

The FFAQ will help you with this and many other common newbie problems:

    man perlfaq1
    perldoc perlfaq1

HTH,

--Matthew


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

Date: Sat, 19 Jun 1999 01:32:43 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Scalar Names
Message-Id: <376cf245.4173471@enews.newsguy.com>

On Sat, 19 Jun 1999 01:15:03 +0100, "Troy Knight"
<troyknight@troyknight.eurobell.co.uk> wrote:

>At last I've found a decent perl newsgroups, been searching for one for
>ages!

Sure beats alt.perl, doesn't it?

>I have a script where I would like to assign a value to an scalar whose name
>is an a followed by a number which is dependant on something, how would I do
>this? If you place two scalar names together such as $a$two it comes up with
>an error, and I can't really see how to it. I'd appreciate some help from
>someone more experienced than me, Cheers.

You might want to use an array, if the contents of $two are purely
numeric; otherwise use a hash. On your command line, enter

	perldoc perldata
and/or

	perldoc perldsc

Don't even try to construct variable names by concatenating other
variables. Down this path lies Tom Christiansen's wrath.

HTH
Marcel



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

Date: Fri, 18 Jun 1999 22:52:46 -0400
From: planb@newsreaders.com (J. Moreno)
Subject: Re: Signature removal regex?
Message-Id: <1dtm6mi.g7q4px1il3b05N@roxboro0-0010.dyn.interpath.net>

I.J. Garlick <ijg@csc.liv.ac.uk> wrote:

> planb@newsreaders.com (J. Moreno) writes:
> > I.J. Garlick <ijg@csc.liv.ac.uk> wrote:
> > 
> > Why would anybody tell you that?  It's not a sig if it's not preceded by
> > a sigdash.
> 
> You might think all sigs should start with "-- " on a line, and I would
> agree with you. I fear we are in the minority however despite what the
> rfc's say.

Complain to the newsreaders authors -- I do.
 
> > I'm not a guru, but what's wrong with
> > 
> > $msg =~ s/(.+)\n-- \n.+/$1/s; # delete the sig
> 
> Tried something like that and I too thought I had it. (I used * though)
> but it only works for the last signature found. Unfortunately this will
> remove anything resembling a signature anywhere in the message, even the
> wrong one.

Huh?  I don't seem to be understanding you -- that should remove the
last sig in a message and nothing else.  If you've got two, or three or
more shouldn't make a difference:

 $msg = q_
 I.J. Garlick <ijg@csc.liv.ac.uk> wrote:

 > Still I can't help feeling it's possible with a regex, and I just don't
 > know enough.

 -- 
 John "first sig" Moreno

 some more 
 -- 
 John "second sig" Moreno

 but no more.
 -- 
 John "third sig" Moreno
 _;

 $msg =~ s/(.+)\n-- \n.+/$1/s; # delete the sig

 print $msg;

Should print all the way up to the "no more." (after you reinsert the
spaces that my newsreader is going to strip off), which is what I thought
you wanted.

> I worded that badly. Basically what I am trying to do is supply the
> ability to save a message into a Draft folder for later completion. I want
> to remove the signature of the user but only if it was saved previously
> with one in the first place. That's why I said I would know there
> signature (assuming they don't change it in the mean time).

I'm still not clear on what you're looking for, what kind of failure modes
do you forsee for that regex?  And just what kind of information are you
going to have on this "sig"?

-- 
John Moreno


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

Date: 19 Jun 1999 02:11:30 GMT
From: Taswar Bhatti <taswar@DONTSPAMcs.ualberta.ca>
Subject: Simple question
Message-Id: <7keu8j$iav$1@scapa.cs.ualberta.ca>

I have a little problem in my cgi script.
All I want to do is get the user domain name. When
I use $ENV{'REMOTE_HOST'} what it returns to me
is a NULL string but I could get the IP address
of the user from $ENV{'REMOTE_ADDR'}.
What I really want is not their IP but
their domain name like www.yourdomain.com or 
even the machine they are on like proxy2.rdc1.ab.wave.home.com
Could someone tell me what I am doing incorrect or do I have
to use nslookup to find out their domain name.
Could it also be that there is some kind of 
server configuration that is not allowing me to get their
domain name from REMOTE_HOST???

Source code.

#!/usr/local/bin/perl

print "Content-type: text/html\n\n";

$name = $ENV{'REMOTE_ADDR'};
$domain = $ENV{'REMOTE_HOST'};
print "Name = $name<BR>"; 
print "Domain = $domain<BR>"; # $domain is empty
exit;

Any help would greatly appreciated:)
Bye,
Taswar




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

Date: Fri, 18 Jun 1999 19:53:11 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Simple question
Message-Id: <Pine.GSO.4.02A.9906181951370.5420-100000@user2.teleport.com>

On 19 Jun 1999, Taswar Bhatti wrote:

> Subject: Simple question

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> Could it also be that there is some kind of server configuration that
> is not allowing me to get their domain name from REMOTE_HOST???

Maybe you should check the docs, FAQs, and newsgroups about servers.
Cheers!

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



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

Date: Fri, 18 Jun 1999 18:04:30 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: sleeping vs stopping and restarting
Message-Id: <Pine.GSO.4.02A.9906181754540.5420-100000@user2.teleport.com>

On 18 Jun 1999, Gregory Snow wrote:

> What type of resources does a sleeping perl script consume?

This is probably more about Unix systems than about Perl, but they're
pretty close. :-)

You should start with your system's manpage for sleep(3c) (or whichever
section covers the system call on your machine). But sleep() essentially
tells the system that, so long as you're going to be sleeping, the system
can swap your process out to disk and forget about it until something
happens.

> I sometimes use perl to control some long but low priority simulations,
> and the program that perl calls to do the work is a real memory hog,
> so I want the script to run just at night.  One approach is to check
> the time each iteration and if it is after 5:00am, save the current
> state of everything, set up "at" or "chron" to restart the script that
> night and exit.  The other option is to call sleep and sleep for
> several hours, this would be simpler, but I don't want to do it if it
> is consuming a significant amount of system resources.

Probably this task is better done as a cron task than sleeping all day.
Startup cost once per day is small. But your program shouldn't need to use
cron to reschedule itself, normally - you should be able to keep the same
crontab entry for as long as you wish the program to keep running.

Cheers!

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



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

Date: Sat, 19 Jun 1999 02:03:10 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: UNIX: ~name won't work on system() as expected
Message-Id: <376AFA1B.E17DDEDF@home.com>

[posted & mailed]

Tom Christiansen wrote:
> 
>      [courtesy cc of this posting mailed to cited author]
> 
> In comp.lang.perl.misc, Marko Hoepken <marko.hoepken@sican.de> writes:
> 
> >$test="~hoepken/*";
> >@list=<'$test'>;
> 
> Why did you quote that variable?  Do you know what quotes
> are for?  They're for making new strings!  What was wrong
> with the one you already had?  Furthermore, those are the
> wrong quotes.

Your point is well made for

> >chdir('$test'); # DOES NOT WORK, stays in same dir,

but if he wants to glob the contents of $test using <> he will need
something to distinguish from <$test>.

>From perlop (formerly in perldata, I think):

  One level of double-quote interpretation is done first, but you can't
  say C<E<lt>$fooE<gt>> because that's an indirect filehandle as explained
  in the previous paragraph.  (In older versions of Perl, programmers
  would insert curly brackets to force interpretation as a filename glob:
  C<E<lt>${foo}E<gt>>.  These days, it's considered cleaner to call the
  internal function directly as C<glob($foo)>, which is probably the right
  way to have done it in the first place.)

Apparently <'$test'> is OWTDI (though it is very misleading).

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 19 Jun 1999 00:54:52 GMT
From: NewtronBoy@aol.com
Subject: Writing RTF with Perl
Message-Id: <7kepoq$fdl$1@nnrp1.deja.com>

Does anyone know of a specification
of Rich Text Format so I can create RTF files
with perl?

I'd appreciate any feedback.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 18 Jun 1999 21:23:07 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: Writing RTF with Perl
Message-Id: <B390693B9668AA291@0.0.0.0>

In article <7kepoq$fdl$1@nnrp1.deja.com>,
NewtronBoy@aol.com wrote:

>Does anyone know of a specification
>of Rich Text Format so I can create RTF files
>with perl?

Would those be RTFM files or RTF-FAQ files? I thought that Microsoft had
some new, improved notion for an industry-standard universally portable
format. Do you suppose they'll invent a round wheel one day, and then stop?

>I'd appreciate any feedback.

I think you're asking in the wrong place.

Lee




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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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