[12649] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 58 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 7 13:37:20 1999

Date: Wed, 7 Jul 1999 10:36:07 -0700 (PDT)
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, 7 Jul 1999     Volume: 9 Number: 58

Today's topics:
    Re: finding relative path between two files (Abigail)
    Re: finding relative path between two files (Abigail)
        Floating Point Number With Time Function <troyknight@troyknight.eurobell.co.uk>
    Re: force it to match? (elephant)
    Re: force it to match? (Neko)
        Getting time more granular than seconds (Boekhout's Collectibles Mall)
    Re: Getting time more granular than seconds <gellyfish@gellyfish.com>
        help please!! <me@sixs.com>
    Re: help please!! <sjs@yorku.ca>
    Re: help please!! <gellyfish@gellyfish.com>
    Re: help with read( ) <debot@xs4all.nl>
    Re: help with read( ) (Abigail)
        help: how to delete the spaces? <gump_xu@sc.mcel.mot.com>
    Re: help: how to delete the spaces? <sjs@yorku.ca>
    Re: help: how to delete the spaces? (Abigail)
    Re: help: how to delete the spaces? <uri@sysarch.com>
    Re: hiring perl programmers <latsharj@my-deja.com>
    Re: hiring perl programmers (Andrew Johnson)
    Re: hiring perl programmers (Bart Lateur)
    Re: hiring perl programmers <gbartels@xli.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 6 Jul 1999 17:55:27 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: finding relative path between two files
Message-Id: <slrn7o52aa.tch.abigail@alexandra.delanet.com>

Neale Morison (nmorison@ozemail.com.au) wrote on MMCXXXV September
MCMXCIII in <URL:news:cNng3.3153$A55.21785@ozemail.com.au>:
!! Is there anything substantially different to your code in the code below?
!! 
!! sub find_relative_path2 ($$) {
!!     my @f = split m {/}, shift;
!!     pop @f;
!!     my @s = split m {/}, shift;
!!     while (@f && @s && $f [0] eq $s [0]) {shift @f; shift @s}
!!     join q {/}, ('..') x @f, @s or ('.');
!! }


Nope, they are the same. 



Abigail
-- 
sub J::FETCH{Just   }$_.='print+"@{[map';sub J::TIESCALAR{bless\my$J,J}
sub A::FETCH{Another}$_.='{tie my($x),$';sub A::TIESCALAR{bless\my$A,A}
sub P::FETCH{Perl   }$_.='_;$x}qw/J A P';sub P::TIESCALAR{bless\my$P,P}
sub H::FETCH{Hacker }$_.=' H/]}\n"';eval;sub H::TIESCALAR{bless\my$H,H}


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 6 Jul 1999 17:57:16 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: finding relative path between two files
Message-Id: <slrn7o52dm.tch.abigail@alexandra.delanet.com>

elephant (e-lephant@b-igpond.com) wrote on MMCXXXV September MCMXCIII in
<URL:news:MPG.11ec74ab2480904989b03@news-server>:
'' Abigail writes ..
'' ><> I was wondering if anybody knew of a module that handles this or has any
'' ><> suggestions for turning this into two lines of taut, lean code.
'' >
'' >    while (@f && @s && $f [0] == $s [0]) {shift @f; shift @s}
'' 
'' of course she meant 'eq' not '=='


Uhm, yes. I just forgot to fix it. (I first typed in the reply, then
I decided to test it. Found that error, made a few other fixes, applied
all the fixes to the one in the reply, except the '==' one.)



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 7 Jul 1999 16:33:43 +0100
From: "Troy Knight" <troyknight@troyknight.eurobell.co.uk>
Subject: Floating Point Number With Time Function
Message-Id: <7lvrpo$9u2$1@aub.eurobell.net>

Is there a way to return the time to a certain amount of decimal places. It
is done on the submitted page of Altavista but I think they use a different
language. Help Appreciated.




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

Date: Wed, 7 Jul 1999 09:39:54 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: force it to match?
Message-Id: <MPG.11ed3ed72e883e7f989b08@news-server>

bing-du@tamu.edu writes ..
>if ($test2 =~ /$test1/i)

while I don't think that this is the best way to do this (look at the cmp 
operator - and - as suggested - the File:: module collection) .. changing 
your comparison above to

  if ($test2 =~ /\Q$test1\E/i)

will work .. \Q and \E are documented in perlre

-- 
 jason - remove all hyphens for email reply -


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

Date: 7 Jul 1999 04:27:53 GMT
From: tgy@chocobo.org (Neko)
Subject: Re: force it to match?
Message-Id: <7lul09$397$0@216.39.141.200>

On Tue, 06 Jul 1999 16:49:53 GMT, bing-du@tamu.edu wrote:

>Hello there,
>
>I need to compare two big files.  $test1 is used to represent each
>line in file1 and $test2 is used to represent each line in file2.  Some
>entries in these files look similar to the following $test1 and $test2.
>
>#!/usr/local/bin/perl
>$test1 = '(a...';
>$test2 = '(a...';
>
>if ($test2 =~ /$test1/i)
>{ print "match\n";}
>else { print "do not match\n";}

if (lc $test2 eq lc $test1) {
    print "MATCH\n";
} else {
    print "FAIL\n";
}

You may also want to check out 'diff' and 'cmp', of which the former has been
implemented in Perl:  http://language.perl.com/ppt/

-- 
Neko | tgy@chocobo.org | I want a moogle stuffy!


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

Date: Wed, 07 Jul 1999 04:03:46 GMT
From: boekhout@azww.com (Boekhout's Collectibles Mall)
Subject: Getting time more granular than seconds
Message-Id: <3782d120.9467577@news.uswest.net>

I'm trying to do some performance measurements for a script that takes
a long time to run, so I can figure out what to improve.  I'm trying
to get the system time in msec if possible, certainly better than
seconds, since seconds is useless for this type of thing.  Is there a
way to do this?  I'm running Windows '95.

Please email me at john@azww.com

Thanks!
John.


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

Date: 7 Jul 1999 09:43:59 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Getting time more granular than seconds
Message-Id: <3783134f@newsread3.dircon.co.uk>

Boekhout's Collectibles Mall <boekhout@azww.com> wrote:
> I'm trying to do some performance measurements for a script that takes
> a long time to run, so I can figure out what to improve.  I'm trying
> to get the system time in msec if possible, certainly better than
> seconds, since seconds is useless for this type of thing.  Is there a
> way to do this?  I'm running Windows '95.
> 

Have you looked at the Benchmark module ?

/J\
-- 
"I can't believe Elton John recorded that song again. Exactly how do you
live your life like a spurgis in the wind?" - Ronnie, Veronica's Closet


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

Date: Tue, 06 Jul 1999 19:16:25 -0700
From: { R a N d i } <me@sixs.com>
Subject: help please!!
Message-Id: <3782B879.8B2C3E20@sixs.com>

hi there, i need a few scripts but in my search i have become a bit
confused and now i feel like i am not really sure what i need to look
for, so i was wondering if someone could clue me in...

what i am looking to do...
i have been looking at a ton of scripts and i can't figure what is the
best route..

all i want to do is collect user information and be able to input it
into a mailing list db easily. i have a calendar of classes that i
recently started posting on the web. so all of the clients that look at
the calendar on the web no longer call me with their name and address so

i am missing out on building my mailing list for a catalog i am
creating!

i want to give these people the opportunity to leave their information
if they would like to receive the catalog..

i am also looking for an easy script that will allow a client to
update/change news information via a html form with a preview feature...

any thoughts or ideas would be greatly appreciated

sincerely, randi
randi@sixs.com





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

Date: Tue, 6 Jul 1999 21:14:18 -0400
From: Steven Smolinski <sjs@yorku.ca>
Subject: Re: help please!!
Message-Id: <931310198.1318652158@newshub.ccs.yorku.ca>

On Tue, 06 Jul 1999, { R a N d i } wrote:

>all i want to do is collect user information and be able to input it
>into a mailing list db easily. i have a calendar of classes that i
>recently started posting on the web. so all of the clients that look at
>the calendar on the web no longer call me with their name and address so

This is too customized and difficult to just pull a preformed script off the
web I'll bet.  I suggest your best course of action is to pay a decent Perl
programmer to do it for you, or to buy _Programming Perl_ buy Larry Wall, Tom
Christiansen and Randall Schwartz, and learn it yourself.

Steve



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

Date: 7 Jul 1999 09:58:27 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: help please!!
Message-Id: <378316b3@newsread3.dircon.co.uk>

Steven Smolinski <sjs@yorku.ca> wrote:
>                                                           buy Larry Wall, Tom
> Christiansen and Randall Schwartz, and learn it yourself.
> 

But if you've *bought them* why bother learning anything ;-}

/J\
-- 
"It's times like this I wish I had a penis" - Duckman


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

Date: Wed, 07 Jul 1999 00:23:53 +0200
From: Frank de Bot <debot@xs4all.nl>
Subject: Re: help with read( )
Message-Id: <378281F9.8DA6565E@xs4all.nl>

It works like this (little example script)

open (TEST, "test.txt") || die "Can't find test.txt";
read (TEST, $data1, 17);
close (TEST);

open (TEST, "test.txt") || die "Can't find test.txt";
read (TEST, $data2, 17, 4);
close (TEST);


This is the syntax


read(FILE_VARIABLE, $scalar, num)
read(FILE_VARIABLE, $scalar, num, num2)


FILE_VARIABLE = How did you called the file. In this case it is: TEST
$scalar = The String where the text should be written to
num = How many bytes do you want to read from the file starting from the
start of the file. Returns also included
num2 = Buffer space. At the second part of the script it's 4. You will
get 4 empty bytes at the beginning of the string.


If test.txt contains the following values: "Hello Perl World!"  (WITHOUT
the "'s ) it would return this:
(1st part):  "Hello Perl World!"                 (Without the "'s )
(2nd part): "    Hello Perl World!"         (Without the "'s )




Bob Bridges wrote:

> How do I use the read ( ) operator.  Please help me.

--
Contact Information:

                         \\\|///
                       \\  - -  //
                        (  @ @  )
----------------------oOOo-(_)-oOOo--------------------|
| General:                                             |
|                                                      |
| EMAIL: debot@xs4all.nl                               |
|------------------------------------------------------|
| Penpal International                                 |
|                                                      |
| URL: http://www.debot.nl/ppi/  or  http://fly.to/ppi |
| EMAIL: debot@xs4all.nl  or  ppi@debot.nl             |
-------------------------------Oooo---------------------
                        oooO    (   )
                       (   )    ) /
                       \ (     (_/
                        \_)




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

Date: 6 Jul 1999 18:23:21 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: help with read( )
Message-Id: <slrn7o53uk.tch.abigail@alexandra.delanet.com>

Bob Bridges (bbridges@seark.net) wrote on MMCXXXV September MCMXCIII in
<URL:news:01bec7ea$945c3c60$8764f5d0@bbridges.seark.net>:
&& How do I use the read ( ) operator.  Please help me.

People usually call it a function. But we all know there isn't a 
real difference between functions and operators. 

I haven't the faintest idea on how to use read() though. I know it's
in the manual, but only fools read the manual! And I ain't no fool!



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 7 Jul 1999 09:45:48 +0800
From: "Gump Xu" <gump_xu@sc.mcel.mot.com>
Subject: help: how to delete the spaces?
Message-Id: <7lubcg$l8c$1@schbbs.mot.com>

Hi,
  I want to delete all spaces at the head(and tail) of a string.
For example:

   "   test string  "=========>"test string"

how to do that effectively in Perl ?

thank you so much,
Gump




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

Date: Tue, 6 Jul 1999 21:16:53 -0400
From: Steven Smolinski <sjs@yorku.ca>
Subject: Re: help: how to delete the spaces?
Message-Id: <931311227.1903193047@newshub.ccs.yorku.ca>

On Tue, 06 Jul 1999, Gump Xu wrote:
>Hi,
>  I want to delete all spaces at the head(and tail) of a string.
>For example:
>
>   "   test string  "=========>"test string"
>
>how to do that effectively in Perl ?

try:

#!/usr/bin/perl -w
$test_string = "     silly string       ";

$test_string =~ s/^\s+//;
$test_string =~ s/\s+$//;

print $test_string;  

(BTW, I originally ripped those substitution strings right out of _Perl
Cookbook_.  You should check it out.)

Steve


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

Date: 6 Jul 1999 21:50:48 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: help: how to delete the spaces?
Message-Id: <slrn7o5g3j.tch.abigail@alexandra.delanet.com>

Gump Xu (gump_xu@sc.mcel.mot.com) wrote on MMCXXXVI September MCMXCIII in
<URL:news:7lubcg$l8c$1@schbbs.mot.com>:
$$
$$   I want to delete all spaces at the head(and tail) of a string.
$$ how to do that effectively in Perl ?


You read the FAQ. Reading the FAQ is often the most effective thing
for a Perl programmer to do.



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 06 Jul 1999 23:20:12 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: help: how to delete the spaces?
Message-Id: <x7d7y5uowj.fsf@home.sysarch.com>

>>>>> "GX" == Gump Xu <gump_xu@sc.mcel.mot.com> writes:

  GX> Hi,
  GX>   I want to delete all spaces at the head(and tail) of a string.
  GX> For example:

  GX>    "   test string  "=========>"test string"

  GX> how to do that effectively in Perl ?


FAQ. please read it and you will find the answer. 

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Tue, 06 Jul 1999 21:30:33 GMT
From: Dick Latshaw <latsharj@my-deja.com>
Subject: Re: hiring perl programmers
Message-Id: <7ltshp$ps2$1@nnrp1.deja.com>

In article <7ltgtb$ksc$1@info2.uah.edu>,
  Greg Bacon <gbacon@cs.uah.edu> wrote:
> : That's why I'm a programmer and not a mathematician.
>
> I don't believe in the existence of such a beast.  Programming is
> mathematics in action.

Got that right!

--
Regards,
Dick
MS in Applied Mathematics, N.C. State Univ.


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


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

Date: Tue, 06 Jul 1999 22:19:46 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: hiring perl programmers
Message-Id: <6ivg3.4568$SH6.109370@news1.rdc2.on.home.com>

In article <3782625f.405840@news.skynet.be>,
 Bart Lateur <bart.lateur@skynet.be> wrote:

[snip]
 
! First getting a feel for it, is what matters. Prototypes definitely
! help. If it turns out that the prototype is absolute crap, there's no
! reason in wasting time, in making the bordercases work.
! 
! Another example:
! 
! 	open(HANDLE,$file) or die "Cannot open file: $!";
! 
! The "ordinary case" is when opening the file succeeds. The bordercase is
! where it failed.

I certainly hope you aren't advocating leaving off the 'or die' from
open() statements while in the prototype stage! That is what your
argument implies you know.

regards
andrew


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

Date: Wed, 07 Jul 1999 07:31:49 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: hiring perl programmers
Message-Id: <3787022f.3652842@news.skynet.be>

Andrew Johnson wrote:

>I certainly hope you aren't advocating leaving off the 'or die' from
>open() statements while in the prototype stage! That is what your
>argument implies you know.

No. I was afraid it would appear like this. I'm advocating programming
using "exceptions", i.e. do not let the exceptional cases dominate your
flow of control, as standard procedure, including for non-error
exceptions.

	Bart.


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

Date: Wed, 07 Jul 1999 07:33:27 -0400
From: Greg Bartels <gbartels@xli.com>
Subject: Re: hiring perl programmers
Message-Id: <37833B07.35E14B09@xli.com>

Dick Latshaw wrote:
> 
> In article <7ltgtb$ksc$1@info2.uah.edu>,
>   Greg Bacon <gbacon@cs.uah.edu> wrote:
> > : That's why I'm a programmer and not a mathematician.
> >
> > I don't believe in the existence of such a beast.  Programming is
> > mathematics in action.
> 
> Got that right!
> 

dont know why this came up:
An intellectual conference was being plagued by a pyromaniac.

The first victim was an engineer who woke up to find the
wastebasket in his room ablaze. he quickly ran to the bathroom,
grabbed the wastebasket there, filled it with water, ran back
to his room, and quickly doused the fire, splashing water all
over the floor.

Later that night, the pyro struck again. This time a physicist
woke up to find the wastebasket in her room burning. she jumped
up, made a quick calculation, ran to the bathroom and returned
with just enough wather to put out the fire in a neat and tidy
manner.

just before dawn, the pyrso struck again. A mathematician 
woke in his room to find his wastebasket on fire. He ran to
the bathroom, thought a moment, and then took out a match
and lit it. holding it under the faucet, he turned on the
water which put out the flame.

"Ah," he said, "it can be done"

and went back to bed.

Greg
oh, man, I couldn't resist.


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

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


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