[9639] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3233 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 23 13:07:26 1998

Date: Thu, 23 Jul 98 10:00:29 -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           Thu, 23 Jul 1998     Volume: 8 Number: 3233

Today's topics:
        '!' instead of filename in output of warn() spacy13@my-dejanews.com
    Re: 'eval' and 'require' (Ilya Zakharevich)
    Re: @INC not working from within prog? <trobert@wpine.com>
        Bidirectional piping under NT <KarlErik.Kaasen@marintek.sintef.no>
    Re: Coding Quiz (was Re: efficiency: print<<"xxx" vs. p (Kevin Reid)
    Re: comp.lang.perl.moderate <jdporter@min.net>
    Re: comparing files in perl <jdporter@min.net>
    Re: Copyright question (Snowhare)
    Re: delete while iterating over array <quednauf@nortel.co.uk>
    Re: delete while iterating over array (Abigail)
    Re: delete while iterating over array (Abigail)
    Re: exec return ? (Josh Kortbein)
    Re: Expanding $1 in a variable substitution (Sean McAfee)
        extracting price from string dwiesel@my-dejanews.com
    Re: extracting price from string <quednauf@nortel.co.uk>
    Re: extracting price from string <dgris@rand.dimensional.com>
    Re: extracting price from string huntersean@my-dejanews.com
        Graph.pm <Tootedom@exchange.ch.ml.com>
        Graph.pm <Tootedom@exchange.ch.ml.com>
    Re: How to know the number of hash items without runnin <merlyn@stonehenge.com>
    Re: How to know the number of hash items without runnin (Josh Kortbein)
    Re: How to send the e-mail by attractment (Abigail)
    Re: im having trouble with a bit of perl script, if som <jdporter@min.net>
    Re: installing perl in a different directory, @INC <dannyv@tibco.com>
    Re: Is Perl y2k compliant? <quednauf@nortel.co.uk>
    Re: Is Perl y2k compliant? dave@mag-sol.com
    Re: is there a isNumber($aString) function? (Abigail)
        Location Command (Robert Saunders)
        modifying a text file melspace@my-dejanews.com
    Re: Multiple Key Sort (Jack Ostroff)
        Need Perl Script/regexp/grep help, please... chrisabraham@my-dejanews.com
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 23 Jul 1998 14:58:13 GMT
From: spacy13@my-dejanews.com
Subject: '!' instead of filename in output of warn()
Message-Id: <6p7j25$qva$1@nnrp1.dejanews.com>

Hi,

I'm pretty new to programming in Perl, so please forgive me if this is a
stupid question. Hope it's not. I couldn't find anything useful by searching
dejanews either.

I'm using Perl 5.004_04 on a FreebSD system. The following code...

--- snip: test.pl ---
#!/usr/local/bin/perl

# line 1!
warn('hello');
--- snip ---

produces this output

--- snip ---
$ ./test.pl
hello at ! line 1.
$
--- snip ---

If I remove any character from
# line 1!
I get the expected output:
--- snip ---
$ ./test.pl
hello at ./test.pl line 4.
$
--- snip ---

Does anybody have an idea why this happens? Did I miss something?

Please respond also by email to bdbeck@ix.netcom.com because I don't monitor
this group regularily.

Thanks
Bernhard

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 23 Jul 1998 07:33:39 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: 'eval' and 'require'
Message-Id: <6p6p0j$hjq$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Aaron Harsh
<ajh@rtk.com>],
who wrote in article <6p5ith$5qn$1@brokaw.wa.com>:
> You could check the return value from eval, which will be true iff the
> require'd file exists and ran succesfully:
> 
>   unless ( eval 'require "foo"' )

I got bitten by this several times.  Nowadays I always add "; 1" at
the end of eval string when testing for a successful compilation:

   unless ( eval 'require "foo"; 1' )

Ilya


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

Date: Thu, 23 Jul 1998 12:21:41 -0400
From: Tom Robert <trobert@wpine.com>
Subject: Re: @INC not working from within prog?
Message-Id: <35B76315.E01EF45B@wpine.com>

Thanks for the advice.  What you say makes sense.
However when I insert the line (before other 'use' calls)

use lib '/Perl/lib';

It now generates a compile time error of:

Can't locate lib.pm in @INC at myprog.pl line 2
 ...

The documentation I mention in my initial post came
from the book "teach yourself PERL in 21 days".
It even states to use "unshift" so that it's added to the
front of the search path as opposed to the end.

I located the config.pm file.  Didn't seem trivial to make
the changes apply.  That is it looks like I need to recompile
PERL or use config.pm from within a program.

I best get the official PERL online doc and read up
some more.

thanks again,


Martien Verbruggen wrote:

> In article <35B64E80.7F41298@wpine.com>,
>         Tom Robert <trobert@wpine.com> writes:
>
> > This doesn't:
> > unshift (@INC, '/Perl/lib');
> > [according to the doc, this is how I should add to the path]
>
> You also need to put it in a BEGIN block if you want to do it that
> way. Which documentation did you get this from?
>
> My documentation states:
>
> # perldoc perlvar
> [snip]
>      If you need to modify this at runtime, you should use the use lib
>      pragma to get the machine-dependent library properly loaded also:
>
>                  use lib '/mypath/libdir/';
>                  use SomeMod;
> [snip]
>
> > Also, how do I modify the @INC variable at a global level?
>
> Change the configuration file of perl. Config,pm, should be in in
> ${PERLPATH}/${ARCHITECTURE}/${VERSION}/Config.pm
>
> Martien
> --
> Martien Verbruggen                  |
> Webmaster www.tradingpost.com.au    | In the fight between you and the
> Commercial Dynamics Pty. Ltd.       | world, back the world - Franz Kafka
> NSW, Australia                      |





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

Date: Thu, 23 Jul 1998 17:27:39 +0200
From: Karl Erik Kaasen <KarlErik.Kaasen@marintek.sintef.no>
Subject: Bidirectional piping under NT
Message-Id: <35B7566B.3BAED97B@marintek.sintef.no>

Hello.

1. I wish to do bidirectional piping under Windows NT, using
  IPC::open2(), but get:

  "The Unsupported function fork function is unimplemented at      
c:\perl\lib/IPC/Open3.pm line 102."

  Unidirectional piping such as open(XX,"cmd |") works fine,
  though. Are There any More Ways To Do this?

2. The module in Win32Pipe_v960610.zip from CPAN for handling
  named pipes doesn't work (it uses a pipe.pll instead of pipe.dll).
  It looks like it is designed for an other Perl distribution than
  what I have (I use the perl5_00402-bindist04-bc_tar.gz from
  CPAN). Is there any way to fix this?

Thanks in advance, David Kaasen.

--
NORWEGIAN MARINE TECHNOLOGY RESEARCH INSITITUTE
POST : MARINTEK, P.O. Box 4125 Valentinlyst, N-7002 TRONDHEIM, Norway
TEL  : +47 7359 5940        FAX   : +47 7351 0034
EMAIL: david@marintek.sintef.no
WWW  : http://www.marintek.sintef.no


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

Date: Thu, 23 Jul 1998 12:07:43 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Coding Quiz (was Re: efficiency: print<<"xxx" vs. print)
Message-Id: <1dcks9s.191ycsv1e32owuN@slip166-72-108-199.ny.us.ibm.net>

Uri Guttman <uri@sysarch.com> wrote:

> 1. Who is main the PERSON you should think about while you are writing
> code?

The person who will be interacting with your executing code, even if
that interaction is via a program written by that person (i.e. your
program is a module).

> 2. Other than comments, what is the most important HUMAN aspect of code?

That the code is written and formatted so that its function is obvious.

> 3. What is the main PURPOSE of comments?

Well, the reason I woud put in comments is to explain lines whose
function is not obvious.

> Bonus: What is the OPPOSITE of spaghetti code?

Lattice code. Unfortunately, it takes time to move through the lattice,
so it is often useful to put in a few diagonals.

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Thu, 23 Jul 1998 16:20:59 GMT
From: John Porter <jdporter@min.net>
Subject: Re: comp.lang.perl.moderate
Message-Id: <35B7647D.22A7@min.net>

Jonathan Stowe wrote:
> On Mon, 20 Jul 1998 20:50:45 -0400, Ronald J Kimball wrote :
> >   sin() and die "You heathen!\n";
> sin() && burn_in_the_fire_of_hell "You heathen!\n";

repent() or goto HELL;

-- 
John Porter


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

Date: Thu, 23 Jul 1998 16:19:40 GMT
From: John Porter <jdporter@min.net>
Subject: Re: comparing files in perl
Message-Id: <35B7642A.2619@min.net>

Mark-Jason Dominus wrote:
> 
> memoizing
> means that you make the function use a cache to remember the values it
> has computed before, and if it gets the same arguments a second time,
> it just returns the previously computed value out of the cache instead
> of computing it all over again.  There's a CPAN `Memoize' module that
> does this automatically; to use it you'd just say
> 
>         use Memoize;
>         memoize 'LCS';
> 
>         sub LCS {
>            ...
>         }

Maybe my intuition is way off; but I wonder whether memoize would
actually work in this case.  You need to pass two arrays to LCS, and
that means passing two (or at least one) array-ref.  And even when
the contents of the two arrays are identical to a previous call, the
actual arguments to the subroutine are most likely going to be
different.
Or does memoize have a way of handling this?

-- 
John Porter


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

Date: 23 Jul 1998 16:53:30 GMT
From: snowhare@devilbunnies.org (Snowhare)
Subject: Re: Copyright question
Message-Id: <6p7pqa$nda$1@supernews.com>



Nothing above this line is part of the signed message.

In article <35B4C8F1.90D65F50@cyberrealm.net>,
Dustin Cobb  <dcobb@cyberrealm.net> wrote:
>I'm a cgi programmer and I've written many scripts for the ISP I work
>for.  Recently, I've been told by someone else in our company that the
>scripts that we've written in Perl cannot be copyrighted due to the fact
>that Perl isn't a compiled language.  Therefore, we would have to
>re-write most of these scripts in another language (like C/C++) to
>obtain a copyright.  Is this true?  Can anyone give me an example of
>some software that is written entirely in Perl and is legitimately
>copyrighted?
>

Tell them their head is so far up their ass they can see daylight.

Copyright has *NOTHING* to do with whether or not a program is compiled,
interpreted, or just written on napkins. Its the *creative act* that
grants copyright. So essentially *all* software is copyrighted unless
explicitly placed in the public domain.

Benjamin Franz


Version: 2.6.2

iQCVAwUBNbdw5ujpikN3V52xAQFxLQQAqzXY23sx6MB6jtKbYE6TeCrqGTwjVele
UO191gJBqZFF/KzQBfVZOJUiCMsTNg93QVyzgsT2l26AHCq4Nd1PQjQaXdea6pgh
NQZ+ySXRWYqaxrW3IUs2n176ya1JwWHMskrA/IS4JR5uabI+nWdfudF1bzSzl0s1
R5jAE5KvSoQ=
=NlGW
-----END PGP SIGNATURE-----


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

Date: Thu, 23 Jul 1998 15:30:31 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: delete while iterating over array
Message-Id: <35B74907.BF19BCDE@nortel.co.uk>

Larry Rosler wrote:
> 
> 
> Gah!!!  What if it is defined but false (0)?  I prefer this one of the
> Many Ways:

> [right stuff]

lame excuse of the day: I assumed there wouldn't be any '0' elements in
the array :)
^^^^^^^^^^^^^^^^^^^^^^


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

Date: 23 Jul 1998 16:26:50 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: delete while iterating over array
Message-Id: <6p7o8a$223$1@client3.news.psi.net>

dwiesel@my-dejanews.com (dwiesel@my-dejanews.com) wrote on MDCCLXXXVII
September MCMXCIII in <URL: news:6p73ft$a71$1@nnrp1.dejanews.com>:
++ Hi,
++ 
++ I have an array where some keys are empty ( "" ). How do I do to delete them?
++ I understand that I can't use splice when iterating over the array.

One would use grep {}.



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: 23 Jul 1998 16:31:16 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: delete while iterating over array
Message-Id: <6p7ogk$223$2@client3.news.psi.net>

F.Quednau (quednauf@nortel.co.uk) wrote on MDCCLXXXVII September MCMXCIII
in <URL: news:35B72933.91DEAFD0@nortel.co.uk>:
++ dwiesel@my-dejanews.com wrote:
++ > 
++ > Hi,
++ > 
++ > I have an array where some keys are empty ( "" ). How do I do to delete them?
++ > I understand that I can't use splice when iterating over the array.
++ > 
++ > Any suggestions?
++ 
++ In the great spirit of TIMTOWTDI...
++ 
++ @array = grep {$_} @array;
++ 
++ Why? If element is not defined, it returns false, and the element is not
++ taken.


But he didn't want to exclude undefined elements! The following 
values evaluate to false:  undef, '', 0 and "0". 


@array = grep {defined && length} @array;



Abigail
-- 
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT


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

Date: 23 Jul 1998 15:52:11 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: exec return ?
Message-Id: <6p7m7b$mtq$2@news.iastate.edu>

Kamran Iranpour (kamrani@ifi.uio.no) wrote:
: Hei

: Does "exec" and "system" return any value, i.e. 0 or 1 ?

perldoc -f exec:

	The exec() function executes a system command I<AND NEVER RETURNS> -
	use system() instead of exec() if you want it to return. It fails and
	returns FALSE only if the command does not exist I<and> it is executed
	directly instead of via your system's command shell (see below).

perldoc -f system:

	Does exactly the same thing as "exec LIST" except that a fork is done
	first, and the parent process waits for the child process to complete.
	Note that argument processing varies depending on the number of
	arguments.  The return value is the exit status of the program as
	returned by the wait() call.  To get the actual exit value divide by
	256.  See also L</exec>.  This is I<NOT> what you want to use to capture
	the output from a command, for that you should use merely backticks or
	qx//, as described in L<perlop/"`STRING`">.

: Another question is I like to store the output of the
: exec in a variable. I have the following line in my program:

: exec("rsh $machine hosttype");

: which opens a shell on a remote machine and execute the
: the hosttype command. Lets say the output is sgi, standing
: for silicon graphics. I want to assign this to a text
: variable. How should I do it ?

$output = `rsh $machine hosttype`;




Josh

--

__________________________________________
She had heard all about excluded middles;
they were bad shit, to be avoided.
            - Thomas Pynchon



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

Date: Thu, 23 Jul 1998 16:59:02 GMT
From: mcafee@choplifter.rs.itd.umich.edu (Sean McAfee)
Subject: Re: Expanding $1 in a variable substitution
Message-Id: <qZJt1.4915$24.28869420@news.itd.umich.edu>

In article <35B73D7D.E9B295EA@fore.com>, Robert Seals  <rseals@fore.com> wrote:
>#!/usr/local/bin/perl -w
>$m = "abc(.*)m";
>$r = '$1$1$1';
>$pat = "abcdefghijklmnop";
>$pat =~ s/$m/$r/;
>print "$pat\n";

>In other words, I want to refer to the matched
>text in the replacement string. I've tried all manner
>of escaping and /e, and so far no go.

Change the substitute command to

$pat =~ s/$m/$r/ee;

and use a replace string of

$r = '$1.$1.$1';

or

$r = '"$1$1$1"';

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: Thu, 23 Jul 1998 14:55:31 GMT
From: dwiesel@my-dejanews.com
Subject: extracting price from string
Message-Id: <6p7it4$qs8$1@nnrp1.dejanews.com>

Hi,

I have a small problem. I have a string could look either like this

$string = 'product||500.00||';

or like this

$string = 'product|||500.00||';

I want to extract the price from $string. I have done it like this...

$string =~ /\|\|(.*?)\|\|/;

but then $1 eq '|500.00'.

Can you help me?

// Daniel

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 23 Jul 1998 16:29:03 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: extracting price from string
Message-Id: <35B756BF.C62084BC@nortel.co.uk>

dwiesel@my-dejanews.com wrote:
> 
> Hi,
> 
> I have a small problem. I have a string could look either like this
> 
> $string = 'product||500.00||';
> 
> or like this
> 
> $string = 'product|||500.00||';
> 
> Can you help me?

Please read the perlre documentation, which will tell you about how to
match chracters that might occur consecutively with different amounts
(what a silly sentence that was). Anyway, reda perlre:

$_ = 'product|||500.00||';

/\|{2,3}(.*)\|{2}/;

print $1;

-- 
____________________________________________________________
Frank Quednau               
http://www.surrey.ac.uk/~me51fq
________________________________________________


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

Date: Thu, 23 Jul 1998 16:19:17 GMT
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: extracting price from string
Message-Id: <6p7n31$6v1$1@rand.dimensional.com>

[posted to comp.lang.perl.misc and mailed to the cited author]

In article <6p7it4$qs8$1@nnrp1.dejanews.com>
dwiesel@my-dejanews.com wrote:

>I want to extract the price from $string. I have done it like this...
>
>$string =~ /\|\|(.*?)\|\|/;
>
>but then $1 eq '|500.00'.

Yup, that's because what you've told perl to do is
match a two consecutive |'s, followed by the smallest
number of characters that are followed by two more |'s.
When $string eq '|||500.00||' you'll end up with the
third | in $1.

You'll also run into a problem if you ever have four
consecutive |'s in your string, because the * can match
0 times.

A better approach would probably be-

$string =~ m/\|+        # gobble all the leading |'s
              (.+?)     # non-greedy, match any character
             \|+/x;     # the trailing |'s

Or, if you don't want to include the trailing |'s in
your match (convenient if you have multiple price fields
in a single string)-

$string =~ m/\|+        # gobble all the leading |'s
             (.+?)      # non-greedy, match any character
             (?=\|)     # followed by a | that isn't included
                        # in the match.
            /x;

Both approaches assume that the data is correct, verifying
that the string matched matches your definition of price is
left as an exercise :-).

Regards,
Daniel
-- 
Daniel Grisinger           dgris@perrin.dimensional.com
"No kings, no presidents, just a rough consensus and
running code."
                           Dave Clark


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

Date: Thu, 23 Jul 1998 16:07:14 GMT
From: huntersean@my-dejanews.com
Subject: Re: extracting price from string
Message-Id: <6p7n3h$vp4$1@nnrp1.dejanews.com>

In article <6p7it4$qs8$1@nnrp1.dejanews.com>,
  dwiesel@my-dejanews.com wrote:
> Hi,
>
> I have a small problem. I have a string could look either like this
>
> $string = 'product||500.00||';
>
> or like this
>
> $string = 'product|||500.00||';
>
> I want to extract the price from $string. I have done it like this...
>
> $string =~ /\|\|(.*?)\|\|/;
>
> but then $1 eq '|500.00'.
>
> Can you help me?
>
> // Daniel
>

try
$string =~ /\|{2,3}(.*?)\|{2}/;

Sean Hunter

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 23 Jul 1998 07:39:14 +0200
From: Dominid Tootell <Tootedom@exchange.ch.ml.com>
Subject: Graph.pm
Message-Id: <35B6CC81.510F@exchange.ch.ml.com>

Hey everyone, how are you all??? doing fine....

good..now doe to the nity gritty....

Has anyone ever used the Graph.pm library routine???

does this error look familiar to you when trying to use the line:-

$gr = new Graph

Died at /apps/sun4/perl5.004.04/lib/site_perl/Graph.pm line 35       
Graph::__ANON__('Can\'t use string ("Graph") as a HASH ref while "strict
refs" in...') called at
/apps/sun4/perl5.004.04/lib/site_perl/Graph/Element.pm line 225       
Graph::Element::AUTOLOAD('Graph', undef) called at
/apps/sun4/perl5.004.04/lib/site_perl/Graph.pm line 66       
Graph::new('Graph') called at bar_chart.pl line 56



Does anyone know of a way to restrict library routines from using strict
if you do not have access to change the library routines???


please if anyone could help... mail me at:-

tootedom@exchange.ch.ml.com

your help is much appreciated..

Dominic Tootell


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

Date: Thu, 23 Jul 1998 07:47:53 +0200
From: Dominid Tootell <Tootedom@exchange.ch.ml.com>
Subject: Graph.pm
Message-Id: <35B6CE89.1F76@exchange.ch.ml.com>

Hey everyone, how are you all??? doing fine....

good..now doe to the nity gritty....

Has anyone ever used the Graph.pm library routine???

does this error look familiar to you when trying to use the line:-

$gr = new Graph

Died at /apps/sun4/perl5.004.04/lib/site_perl/Graph.pm line 35       
Graph::__ANON__('Can\'t use string ("Graph") as a HASH ref while "strict
refs" in...') called at
/apps/sun4/perl5.004.04/lib/site_perl/Graph/Element.pm line 225       
Graph::Element::AUTOLOAD('Graph', undef) called at
/apps/sun4/perl5.004.04/lib/site_perl/Graph.pm line 66       
Graph::new('Graph') called at bar_chart.pl line 56



Does anyone know of a way to restrict library routines from using strict
if you do not have access to change the library routines???


please if anyone could help... mail me at:-

tootedom@exchange.ch.ml.com

your help is much appreciated..

Dominic Tootell


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

Date: Thu, 23 Jul 1998 15:25:30 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: How to know the number of hash items without running loop.
Message-Id: <8caf60r3ml.fsf@gadget.cscaper.com>

>>>>> "Josh" == Josh Kortbein <kortbein@iastate.edu> writes:

Josh> yroh (yroh@samsung.co.kr) wrote:
Josh> : Without running loop, is there way to count how many items the hash has?

Josh> $count = scalar(keys(%hash));

That's a lot of extra typing there.  Simpler just as:

	$count = keys %hash;

print "Just another Perl hacker,"
-- 
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@teleport.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: 23 Jul 1998 15:47:50 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: How to know the number of hash items without running loop.
Message-Id: <6p7lv6$mtq$1@news.iastate.edu>

Randal Schwartz (merlyn@stonehenge.com) wrote:
: >>>>> "Josh" == Josh Kortbein <kortbein@iastate.edu> writes:

: Josh> yroh (yroh@samsung.co.kr) wrote:
: Josh> : Without running loop, is there way to count how many items the hash has?

: Josh> $count = scalar(keys(%hash));

: That's a lot of extra typing there.  Simpler just as:

: 	$count = keys %hash;

I know - I just wanted to be explicit for the poster's benefit.






Josh

--

__________________________________________
She had heard all about excluded middles;
they were bad shit, to be avoided.
            - Thomas Pynchon



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

Date: 23 Jul 1998 16:37:09 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How to send the e-mail by attractment
Message-Id: <6p7orl$223$3@client3.news.psi.net>

Bug (bugking@usa.net) wrote on MDCCLXXXVII September MCMXCIII in
<URL: news:35b6af8d.0@ruby.hknet.com>:
++ i don't know how to use it, can someone help?
++ 


Read the manual for your MUA?



Abigail
-- 
:r file-to-be-attached<RET>


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

Date: Thu, 23 Jul 1998 15:48:17 GMT
From: John Porter <jdporter@min.net>
Subject: Re: im having trouble with a bit of perl script, if someone could give me a hand
Message-Id: <35B75CD4.3158@min.net>

jhestyr@my-dejanews.com wrote:
> 
> the idea of the program is to make x directories then randomly choose one,
> change to that dir, then make x more directories, and so forth 

for my $level ( 0..2 ) {
  print "Level $level\n";
  for my $mkdir ( 1..4 ) {
    print "  mkdir $mkdir\n";
    mkdir $mkdir, 0777 or die "mkdir $mkdir: $!";
  }
  my $chdir = int(rand(4))+1;
  print "  chdir $chdir\n";
  chdir $chdir or die "chdir $chdir: $!";
}

-- 
John Porter


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

Date: Thu, 23 Jul 1998 09:06:21 -0700
From: Danny van der Rijn <dannyv@tibco.com>
To: Eric Zylberstejn <Eric.Zylberstejn@wanadoo.com>
Subject: Re: installing perl in a different directory, @INC
Message-Id: <35B75F7D.E4081006@tibco.com>

Eric Zylberstejn wrote:
> 
> Jello,
> 
> Danny van der Rijn wrote:
> >
> > i want to be able to compile perl (5.00404) and then have people install
> > it whereever they want to.
> >
> > on Solaris 2.6, this doesn't work so fine, since the @INC list is
> > compiled into PERL and therefore PERL finds none of its libraries.
> > [...]
> 
> Set PERL5LIB, do a 'man perlrun'.
> 
> Remember to put your platform specific librairies path in PERL5LIB.
> 

did i forget to mention that i don't want the user to have to do
anything like changing his environment?  (web servers, etc.)

>         Eric.pl


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

Date: Thu, 23 Jul 1998 15:56:55 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Is Perl y2k compliant?
Message-Id: <35B74F37.3541C2A7@nortel.co.uk>

huntersean@my-dejanews.com wrote:
> 
> > No, it's not.  We'll all be out of work in 17 months, and most of the Web
> > will come crashing down, too.  It's not going to be pretty.
> >
> 
> Either you don't know what you're talking about, or you're joking.  

Ouch !!!

Perl *is*
 ...[text]...
>  Perl will continue to give _correct_ dates and times until the sun cools and
> collapses.  

Lucky you that this is correct :)

Indeed, counting from now 64 bit can express enough seconds to let the
universe expand and collapse...hmmm, around 351 times if we assume a
universe age of 100 billion years...

2 Computers which run Perl talking in 35 billion years...

- I am bored. We have taken every available chunk of data in this world,
and have done all possible transformations to all possible subsets to
it.
- Yeah *sigh*, and the worst thing is, that I am still able to count the
time. That's sooo boring.
- Yeah, it's Larry the-Walls fault....
- Hmmm, wasn't he the one who made us, how did they say, Y2B-compliant ?
- Terrible that was
- Yeah, g'old humans, always so obsessed to understand us...
- Hmm......I am bored....

-- 
____________________________________________________________
Frank Quednau               
http://www.surrey.ac.uk/~me51fq
________________________________________________


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

Date: Thu, 23 Jul 1998 15:37:33 GMT
From: dave@mag-sol.com
Subject: Re: Is Perl y2k compliant?
Message-Id: <6p7lbt$tnl$1@nnrp1.dejanews.com>

In article <6p7g7h$njk$1@nnrp1.dejanews.com>,
  huntersean@my-dejanews.com wrote:
> In article <6p5kj7$mkn$5@marina.cinenet.net>,
>   cberry@cinenet.net (Craig Berry) wrote:
> > Victor O. (vonyemelukwe@att.com) wrote:
> > : Is Perl y2k?
> >
> > No, it's not.  We'll all be out of work in 17 months, and most of the Web
> > will come crashing down, too.  It's not going to be pretty.
> >
>
> Either you don't know what you're talking about, or you're joking.  Perl *is*
> y2k compliant, and performing the most obvious and simple little tests would
> prove that.  To get dates, you use the gmtime or localtime functions.  Like
> C, these are y2k.  If you want 4-digit dates, you add 1900 to the year.  If
> you want 2 digits, you reduce it mod 100.  If you don't want to print it out,
> it doesn't matter as 2000 will be year 100 in the structure and therefore
> will still sort correctly and all intervals and ranges will be calculated
> correctly. These functions rely on the c library which uses time_t to store
> seconds since the epoch.  This will experience a roll-over in (IIRC) 2038,
> unless you are using 64-bits for your time_t.  Since we all will be using
> longer bit-widths for our archtectures by then, we have no cause for concern.
>  Perl will continue to give _correct_ dates and times until the sun cools and
> collapses.  If your perl distribution isn't y2k then your libc isn't either,
> in which case perl is not your biggest worry.  The people who wrote the posix
> definitions of the c libraries thought these things through a long time ago.
>
> The web will not come crashing down, neither will the world end, and there
> will not be a plague of locusts o'er the land.	Anyone who says perl
will die
> in the year 2000 doesn't know squat.  Read the camel book.  Look on
> www.perl.com, or even better, read the sources.

You should get your sense of humour serviced. It doesn't seem to be working
too well early in the morning!

Dave...

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 23 Jul 1998 16:43:47 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: is there a isNumber($aString) function?
Message-Id: <6p7p83$223$4@client3.news.psi.net>

dwiesel@my-dejanews.com (dwiesel@my-dejanews.com) wrote on MDCCLXXXVII
September MCMXCIII in <URL: news:6p6tv5$3np$1@nnrp1.dejanews.com>:
++ Hi,
++ 
++ How can I tell if a string (e.g. "7945797945") is a number or not?


Well, normal people would read the FAQ that answers this question.

But, since that's too difficult, I'll give you a much simpler
solution. You might need a slight memory upgrade, but you were
due anyway, weren't you?


sub is_a_number {
    {map {$_ => 1} 0 .. 0x7FFFFFFF} -> {+shift};
}



Abigail
-- 
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
           print+Just (), another (), Perl (), Hacker ();'


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

Date: Thu, 23 Jul 1998 16:49:37 GMT
From: robert@iminet.com (Robert Saunders)
Subject: Location Command
Message-Id: <4E940DB7B27DEC8D.DD772CD0C093F55C.23BEE46AF5722CAD@library-proxy.airnews.net>


Question..

I am using the location command.. 

print "Location: $FORM{'cgi_select'} \n\n";

which works fine.. but I have a application that I want to target a
framed page with .. so the script is called from say the bottom
frame.. but I want the page to load in the top frame.. is there a way
to do this in perl.. or do I have to do a javascript thing.. 

Robert Saunders
robert@iminet.com

Thanks in advance




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

Date: Thu, 23 Jul 1998 16:37:25 GMT
From: melspace@my-dejanews.com
Subject: modifying a text file
Message-Id: <6p7os5$1ra$1@nnrp1.dejanews.com>

I am trying to figure out how to replace one line in a text file.  I have
read perlfaq5, but I am still puzzled.	Can anyone suggest further readings
or offer some help?

Mel

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 23 Jul 1998 13:44:30 GMT
From: jack_h_ostroff@groton.pfizer.com (Jack Ostroff)
To: "Jeffrey J. Bachovchin" <bachovch@dev.upenn.edu>
Subject: Re: Multiple Key Sort
Message-Id: <6p7enu$jc85@mascagni.pfizer.com>

Have you tried 'perldoc -f sort'

or looking in perlfaq4 for "How do I sort an array by (anything)?


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

Date: Thu, 23 Jul 1998 16:03:22 GMT
From: chrisabraham@my-dejanews.com
To: michelle@tmn.com
Subject: Need Perl Script/regexp/grep help, please...
Message-Id: <6p7msa$v59$1@nnrp1.dejanews.com>

Gurus:

I have a grep question:

I have 300 pages of this kind of thing:

 . . .

51-1, 1951
Eliot Elgart
Lester Schwartz
Arthur Levine

51-3 Eleven Dutch Printmakers, 1951
Escher, M.C.
De Gelder, D.

 . . .

And it is all in WP 6.1 Windows
and the first line is always an
exhibit number and there is always
a list of artists below.

Sometimes there is alphanumeric
in the exhibit number such as the
second set, sometimes, there
are commas and so forth.

Below the double hard return
is the Exhibit ID, and right below
that is the list of names --
some with Last Name First
and some First Name First.

What I need to do is thus:

De Gelder, D. [tab] 51-3 Eleven Dutch Printmakers, 1951
Elgart, Eliot [tab] 51-1, 1951
Escher, M.C. [tab] 51-3 Eleven Dutch Printmakers, 1951
Levine, Arthur [tab] 51-1, 1951
Schwartz, Lester [tab] 51-1, 1951

Three hundred pages of this thing:

[LAST NAME][COMMA][FIRST NAME][TAB][EXHIBIT ID][CR]

Sorted ultimately, by alpha, last name.

Any idea on how to do this?
It all seems like there is not
enough stuff to figure it out...
even for GREP, regular
expression, and PERL!

Any help would be pennies from heaven!

Cheers,

Chris Abraham

--
chris.abraham<cja@SPAMdds.nl><http://urban.net/chris>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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