[6447] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 72 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 7 18:16:08 1997

Date: Fri, 7 Mar 97 15:00:24 -0800
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, 7 Mar 1997     Volume: 8 Number: 72

Today's topics:
     Re: "define"-status doesn't follow on assignment? <wkuhn@uconect.net>
     .bat errors (The next Pele)
     Re: Bill Kuhn     College Students need help KimmNSteve @Worldnet.att.net
     Re: Building variable variable names ?? <jgm@dynamicweb.com>
     Re: Creating a new empty file from within Perl.. <bartolonem@med.ge.com>
     Re: Deamons (or Services)  on WinNT--Anyone written any <dduncan@realogic.com>
     Re: Directory traversal and symbolic links <rootbeer@teleport.com>
     Re: Generate Makefile and execute it from PERL <jeff@networkers.com>
     Re: Help with -T filetype in Linux <rootbeer@teleport.com>
     Re: How can I find cause of bloated memory consumption  (Ilya Zakharevich)
     Is there a less clumsy looking way to do this? <cherold@pathfinder.com>
     Re: NDBM and flock <tchrist@mox.perl.com>
     Re: NDBM and flock (Chris Nandor)
     Re: Perl -- compiled? C converter? (John Goerzen)
     Perl help required. Begginer :( <Tom@intermart.co.uk>
     Perl5 (Ind study)
     Re: persistence in perl <rootbeer@teleport.com>
     Re: Point a socket client at an HTTP server <rootbeer@teleport.com>
     Re: Possible bug in regular expression form /\d{x,x}/ (Brian L. Matthews)
     Re: Possible bug in regular expression form /\d{x,x}/ (Mik Firestone)
     Q: Status of RDB (by Walter Hobbs) under Perl 5? (Gregory Tucker-Kellogg)
     Re: Rounding Numbers in Perl (Honza Pazdziora)
     script to make symlink tree? (Conrad E. Kimball)
     Re: simple new question! <Postmaster@dozyrosy.demon.co.uk>
     Re: Stored Procedures For ORACLE <dduncan@realogic.com>
     Re: Trapping Segmentation Fault <rootbeer@teleport.com>
     Re: Why are my rand() values so tiny? <tchrist@mox.perl.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 07 Mar 1997 16:08:18 -0500
From: Bill Kuhn <wkuhn@uconect.net>
Subject: Re: "define"-status doesn't follow on assignment?
Message-Id: <332083C2.3A6AAE50@uconect.net>

No chapter or verse.

No assignment, no definition.

Incidentally, I would use to following to create (define) two empty
arrays:

@a = @b = () ;

-Bill
-- 
Bill Kuhn
Chief Developer
Wired Markets, Inc.
http://www.buyersindex.com


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

Date: 7 Mar 1997 20:14:04 GMT
From: gt1535b@acmey.gatech.edu (The next Pele)
Subject: .bat errors
Message-Id: <5fpsuc$f4t@catapult.gatech.edu>

I'm running perl5 on win95, and I have some perl scripts (converted to
batch files) that I call from another perl script.  When I call it the
first time it runs fine, but when I call it a second time from the same
script, I get a 'Can't open perl script "myscript.bat": No such file or
directory.'  The file is definitely there, and this same procedure (calling
the same program twice) has worked before.  I'm not sure if this is a 
DOS problem or a perl problem, but if anyone out there has run into this
kind of thin before, I'd _greatly_ appreciate any suggestions that you could
give.

thanks,
Daryl

--
<>< Daryl Bowen	<><
Georgia Institute of Technology
Internet: gt1535b@prism.gatech.edu
Siemens Stromberg-Carlson Co-op


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

Date: Fri, 07 Mar 1997 22:37:56 GMT
From: KimmNSteve @Worldnet.att.net
Subject: Re: Bill Kuhn     College Students need help
Message-Id: <332189e3.2275770@netnews2.worldnet.att.net>

On Tue, 04 Mar 1997 09:34:28 -0500, Bill Kuhn <wkuhn@uconect.net>
wrote:

>Uh, don't post unless you have some specific question.
>
>The subject of the original posting implied that some help was needed,
>but all that was posted was a CGI program written in perl and what I can
>only guess is its associated HTML form.
>
>So, what help is needed?
>

I apologize for my brother's original posting - he thought it would be
funny to post it from Bozo and be anonymous from the school we are at.

I need a perl script that will allow students at my college the
opportunity to make web pages online. Once they make the web page I
need to have it copied into a directory on the same server and append
an html file listing the names of the students who have web pages.

Any such critter?




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

Date: Fri, 07 Mar 1997 14:18:18 -0500
From: JG Motolanez <jgm@dynamicweb.com>
To: Wolfgang Reimann <reimann@merck.de>
Subject: Re: Building variable variable names ??
Message-Id: <332069FA.2E0E@dynamicweb.com>

Wolfgang Reimann wrote:
> 
 ...
> Building a variable name that contains a variable part, so that
> the result is a list of variables. In the following example i want to
> create variables $p1,$p2,$p3,$p4 and so on. I need these to fill a
> format. Do i have to use an array?
> 
> #!perl
>       @Privs = qw (SETPRV READALL BACKUP SHUTDOWN) ;
>           for ($n = 0; $n <= $#Privs ; $n++) {
>                $p$n   = $Privs[$n] ;
>               printf "%-10s %-10s\n","Variable ",$p$n
> 
#!/usr/local/bin/perl

@Privs = qw (SETPRV READALL BACKUP SHUTDOWN) ;
for ($n = 0; $n <= $#Privs ; $n++) {
        ${p. ${n}}   = $Privs[$n] ;
        printf "%-10s %-10s\n","Variable ",${p. ${n}};
}

print "(p0:$p0)\n(p1:$p1)\n(p2:$p2)\n(p3:$p3)\n(p4:$p4)\n";

Seems to work for me.
--
JG Motolanez <jgm@dynamicweb.com>


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

Date: Fri, 07 Mar 1997 13:21:05 -0600
From: Mike Bartolone 5-4266 <bartolonem@med.ge.com>
To: Aegir@www.dma.be
Subject: Re: Creating a new empty file from within Perl..
Message-Id: <33206AA1.167E@med.ge.com>

Aegir wrote:
> 
> Following problem :
> 
>create a none existing new file (a new one for each new
> user). I can't do this with the open command, which will die when I
> open a none existing file..

Not if you use open correctly...

open(FILEHANDLE,">$newfilename");

should make a new file.

> 
> Ok, how do I create a new file from within perl ? It's running on an
> UNIX server...Would this mean I have to send an UNIX command like
> ? If yes, what command ? I can't find one..

If you insist, how about this:

system("touch $newfilename");


-- 
Michel Bartolone            | Everything in excess! To enjoy the 
bartolonem@med.ge.com or    | flavor of life, take big bites. 
bartolon@execpc.com         | Moderation is for monks.   Lazarus Long


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

Date: Fri, 07 Mar 1997 16:00:14 -0500
From: Diana Duncan <dduncan@realogic.com>
Subject: Re: Deamons (or Services)  on WinNT--Anyone written any?
Message-Id: <332081DE.696C@realogic.com>

Thank you to all those who replied.  The general consensus was that I
needed to use the NT Resource Kit which would turn my program into a
Service.  Another helpful soul suggested that there might be a "product
to emulate inetd deamon for defined service on certain TCP/IP port".
Hmmm.

I also searched the usenet archives and saw a suggestion which appealed
to my lazy nature.  "Why not use the AT job utility?"  Why not, indeed.

So anyway, that is what I ended up doing.  I must say, however, that
DOS's AT functionality severely lags behind cron or UNIX at.  I wanted
my job to run every 10 minutes between 0700 and 1700.  I had to schedule
50+ seperate jobs to do this ;-)
-- 
Diana Duncan	     | My opinions are my own.
Sr. Consultant	     | 
REALOGIC, Inc.	     | Excitement, Adventure and
dduncan@realogic.com | Really Wild Things - Z.B.


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

Date: Fri, 7 Mar 1997 12:34:11 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: David M Holmes <david.holmes@bigfoot.com>
Subject: Re: Directory traversal and symbolic links
Message-Id: <Pine.GSO.3.95q.970307122509.10043A-100000@kelly.teleport.com>

On Thu, 6 Mar 1997, David M Holmes wrote: 

> I wrote this simple script a while ago, as a prelude to allowing me to
> do various things on bunches of files within a directory hierarchy. 
> 
> It sort of works - it outputs a tree structure for the first few
> subdirectories, then stops, only printing out the names for the rest of
> the directories found initially in $startdir.  No error messages are
> output, and so I wondered what could be wrong.  But then I noticed that
> it goes wrong just after it has output the entries for a symlinked
> directory. 

Did the symlink point back at its own directory? :-)  If you're going to
follow symlinks, you may get hopelessly lost unless you leave a trail of
breadcrumbs. In this case, the usual breadcrumbs are a list of all of the
directories you've already processed, so that you don't do one twice. And
that's still no assurance that you won't end up processing all mounted
disks, or even following a symlink off into nfs-space. (It's scary; you
could scan an nfs-mounted directory which includes its own nfs-mounted
directory exported from your own system!) 

I didn't read your script enough to see where your trouble is, if that's
not the source of it. My advice, though, is to not follow any symlinks at
all. (You can identify them with the -l filetest.) 

Hope this helps! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 07 Mar 1997 10:09:02 -0800
From: Jeff Coffin <jeff@networkers.com>
Subject: Re: Generate Makefile and execute it from PERL
Message-Id: <m2iv33d16p.fsf@networkers.com>

>>>>> "JL" == Jean-Yves Levesque <jyves@nortel.ca> writes:

JL> I am trying to generate a Makefile from PERL.  At the end of my
JL> perl script, I try to run make depend as in the following:

JL> 	my $x=("gmake depend);
missing quote               ^here 
I'll assume that this is a typo...

JL> But it returns 'no such file or directory'. 

If you define the $x variable within a block and use it outside of
said block it will no longer contain the value you set it to, nor be
defined.  But then again based on what you told us, it's hard to say
what the real problem is.  To wit, more code please.

JL> I close my makefile
JL> before calling make depend. Is there something I am missing or am
JL> I trying to do something that cannot be done?

You can do it:

$cmd = '/full/path/to/gmake -f /full/path/to/Makefile depend';
exec $cmd;

Good Luck

-jeff


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

Date: Fri, 7 Mar 1997 08:25:12 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: a.maclennan@rgu.ac.uk
Subject: Re: Help with -T filetype in Linux
Message-Id: <Pine.GSO.3.95q.970307081649.23882H-100000@kelly.teleport.com>

On Thu, 6 Mar 1997 a.maclennan@rgu.ac.uk wrote:

> I'm trying out example listings in the Camel and Llama books, and can't
> seem to get the -T filetype to select text files in Linux - is this
> Unix-only? 

That ought to work on Linux. If it doesn't, check that you have a recent
version of Perl (at least 5.003). Could your files have characters
with the high bit set, such as accented characters? (-T isn't very smart
about non-English text files.) Also, remember that filetest operators have
a default argument. Does your perl pass all tests in t/op/stat.t? 

> Also, does the UID stuff for passwords work in Linux (it's
> used in the first Llama progs)?

Sure should. Did you remember to try it before you posted? :-)

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 7 Mar 1997 20:55:33 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: How can I find cause of bloated memory consumption in large Perl program?
Message-Id: <5fpvc5$oc1$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tim Wilson 6093 
<tim.wilson@cambridge.simoco.com>],
who wrote in article <pybu8vdcex.fsf@cambridge.simoco.com>:
> We have written a compiler[1] in O-O Perl 5; it contains about 20-30,000
> executable lines in a few dozen packages.
> 
> On smaller inputs it is fine, but on larger source files it consumes
> huge amounts of memory -- eg about 400MB to compile a 6000 line module.
> 
>  * How can I find out what is causing this bloated memory consumption?

Good question. How would people like watchpoints when some memory
limit is exceeded?

Currenlty you need to insert Devel::Peek::mstat's into key places.

>  * Are there any Perl constructs that use surprisingly large amounts of
>    memory, or that create garbage?

Unfortunately, most of them. But if you use Perl's malloc, try
switching to system one (though this _cannot_ safe more than 50%).

Ilya


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

Date: Fri, 07 Mar 1997 16:16:38 +0000
From: Charles Herold <cherold@pathfinder.com>
Subject: Is there a less clumsy looking way to do this?
Message-Id: <33203F6C.35A3@pathfinder.com>

Hi,

The code below works, but it's rather awkward, and I hate that.  What I
need, of course, is a two-dimensional array, which I believe can be done
in Perl5 but this is a large script someone wrote years ago in an
earlier Perl so let's keep within the limits of that.  So, is there some
nifty little Perl trick that will let me turn this into something a bit
neater?



#!/usr/local/bin/perl

%in = ("category", "clothing", "op", "showpage");

%scheme_default = ("bgcolor", "#003366", "text", "#ffffff", "link",
"#ffcd31",
        "vlink", "#006aff", "alink", "#003366", "background", "" );
%scheme_showcategory = ("bgcolor", "#003366", "text", "#ffffff", "link",
"#006aff",
        "vlink", "#ffcd31", "alink", "#003366", "background",
        "$fixed/categorybkg_" . $in{"category"} . ".gif");
%scheme_showpage = ("bgcolor", "#ffffff", "text", "#000000", "link",
"#ffcd31",
        "vlink", "#006aff", "alink", "#003366", "background",
        "$fixed/categorybkg_" . $in{"category"} . ".gif");
%scheme_showbasket = ("bgcolor", "#ffffff", "text", "#000000", "link",
"#ffcd31",
        "vlink", "#006aff", "alink", "#003366", "background", "");


sub Header {
  local(%scheme);

  if ($in{'op'} eq 'showcategory') {
        %scheme = %scheme_showcategory;
  } elsif ($in{'op'} eq 'showpage') {
        %scheme = %scheme_showpage;
  } elsif ($in{'op'} eq 'showbasket') {
        %scheme = %scheme_showbasket;
  } else {
        %scheme = %scheme_default;
  }


  if($scheme == "") {
        %scheme == %scheme_default;
  }

  print "<head><title>test</title></head>\n";

  print '<body';
  foreach $key (keys %scheme) {
        next if $scheme{$key} eq "";
        print " $key=\"$scheme{$key}\"";
  }
  print '>';
}
-- 
Best regards,

       Charles Herold
         Assistant Producer
          Pathfinder Production
           cherold@pathfinder.com
               (212) 522-5190


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

Date: 7 Mar 1997 21:08:27 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: NDBM and flock
Message-Id: <5fq04b$5m1$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, pudge@pobox.com (Chris Nandor) writes:
:Does anyobdy have a snippet of code for flock'ing an NDBM database?
:
:I tried the example in the Blue Camel (p. 393), but it NDBM_File doesn't
:have the fd() or sync() methods.  

Use DB_File instead.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

It is, of course, written in Perl.  Translation to C is left as an
exercise for the reader.  :-)  --Larry Wall in <7448@jpl-devvax.JPL.NASA.GOV>


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

Date: Fri, 07 Mar 1997 16:22:23 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: NDBM and flock
Message-Id: <pudge-ya02408000R0703971622230001@news.idt.net>

In article <5fq04b$5m1$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com (Tom
Christiansen) wrote:

#Use DB_File instead.

DB_File isn't on all systems though, is it?  I am programming for someone
else and I cannot guarantee that their crappy system will have DB_File
available.  I will try to install it, but in case I cannot, let me ask
again:  Does anyobdy have a snippet of code for flock'ing an NDBM database? 
Is it possible, Tom?

Thanks,

#================================================================
I saw a sign:  "Rest Area 25 Miles".  That's pretty big.  Some
people must be really tired.

   --Steven Wright

Chris Nandor                                      pudge@pobox.com
PGP Key 1024/B76E72AD                           http://pudge.net/
Keyfingerprint = 08 24 09 0B CE 73 CA 10  1F F7 7F 13 81 80 B6 B6


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

Date: 7 Mar 1997 02:13:45 GMT
From: jgoerzen@complete.org (John Goerzen)
Subject: Re: Perl -- compiled? C converter?
Message-Id: <slrn5huueo.uer.jgoerzen@complete.org>

Thanks for your reply, Tom!

On 6 Mar 1997 03:33:31 GMT, Tom Christiansen <tchrist@mox.perl.com> wrote:

>=head2 How can I compile my Perl program into byte-code or C?
>
>Malcolm Beattie has written a multifunction backend compiler,
>available from CPAN, that can do both these things.  It is as of
>I<Please> understand that merely compiling into C does not in and of
>itself guarantee that your code will run very much faster.  That's

I perhaps should have explained a little more about *why* I want to convert
to C or compile, rather than just saying that I want to do it :-)

There are several issues here.  Speed or code-hiding are not important to me
at this point (although speed of compilation of Perl scripts may be
important in the future with CGI programs, will see...).  The most important
things are: having a "plug-in" program that does not require installation of
the Perl system, and having a binary that is self-sustaining and does not
require additional support to run.  (eg, a statically linked Linux binary
would not require certain versions of libc, perl, ncurses, etc. to be
installed -- it would just "work"!)

As I am just new to Perl, I likely won't be using any of the potential
pitfalls mentioned in the brief documentation for the compiler that I have
read so far (partially because I don't even know what some of those things
are yet! <G>)

I just want to say that I strongly support the effort going on to develop a
Perl compiler/translator.  It will be very beneficial to me to be able to
save tremendous development time by using Perl instead of C and yet still be
able to have the simplicity of distributing a single (albeit somewhat
larger) binary.

On a slightly different topic...

While I'm writing anyway, I just thought I'd mention that I am very
surprised and pleased that I immediately got two helpful responses to my
question.  This is a level of support I know I would not be able to find in
commercial settings, and I expect that I may be picking your brains some
more as I learn Perl :-)  (And hopefully, sometime down the road, I will
have enough knowledge to return the favor by helping out others.)

It especially surprised me to get messages back from two of the three
authors of the excellent Programming Perl (2nd ed.) book. 

You people are doing a great job, and from what I've seen so far of Perl (I
know it's not a lot), it looks like a great language and an excellent
solutions to some of the things I've had to struggle with in C for quite
some time.  (These Perl regular expressions sure beat C's strtok()
function!)




>because except for lucky cases where a lot of native type inferencing
>is possible, the normal Perl run time system is still present and thus
>will still take just as long to run and be just as big.  Most programs
>save little more than compilation time, leaving execution no more than
>10-30% faster.  A few rare programs actually benefit significantly
>(like several times faster), but this takes some tweaking of your
>code.

-- 
John Goerzen          | Running Debian GNU/Linux (www.debian.org)
Custom Programming    | 
jgoerzen@complete.org | 


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

Date: Fri, 7 Mar 1997 22:43:38 +0000
From: Tom Holder <Tom@intermart.co.uk>
Subject: Perl help required. Begginer :(
Message-Id: <2d0dWAAaoJIzEwiu@resmon.demon.co.uk>

Hi,

I'm after some help regarding Perl and CGI. I want to program my CGI
scripts in perl because I understand it's the done thing and it's also a
requirement of my server so that decision was made quite easily.

Unfortunately I don't have a clue about programming in Perl, I know a
fair bit about C and am quite experienced in using PASCAL but I have
never used an interpreted language which I understand Perl is. This
worries me slightly to say the least.

I have very little in the way of funds being a student and would like to
know if there is an idiots guide to perl and CGI on the web (I mean
idiots! :) I've looked and couldn't find anything that helped.

Also, where can I get Perl? I used to have it but it just seemed like a
bunch of meaningless files without any kind of program, a bit daunting
and as I didn't 'need' to learn it that point I didn't, sadly now I do
and would apreciate any help that you can give me on the subject.

What exaclty do I put in my CGI bin? Just the uncompiled program? How do
you call it? I really need all my stupid/trivial questions answered.
Please help me :(

I am using Win95 by the way if that has any bearing on the copy of perl
I should use.

Thanks for your time and any help you can offer me,

P.S. Erm, anyone know of a Pascal > Perl converter? Nope? Thought not!
:(
-- 
Tom,
Tom@ednet.co.uk
Tom@intermart.co.uk


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

Date: 7 Mar 1997 14:39:04 -0700
From: vkomandu@mnemosyne.cs.du.edu (Ind study)
Subject: Perl5
Message-Id: <5fq1to$r1v@mnemosyne.cs.du.edu>

 Hello,

Can any one out there mail me the  brief list of the main operations performed 
by the C files of perl5,I need this to draw Data flow diagrams.I would be  
really grateful if you could do this at the earliest.


Thanking you,
Yours Sincerely

Vikram

Email:vkomandu@cs.du.edu


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

Date: Fri, 7 Mar 1997 08:32:04 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Chris Busch <cbusch@member.com>
Subject: Re: persistence in perl
Message-Id: <Pine.GSO.3.95q.970307082937.23882I-100000@kelly.teleport.com>

On Wed, 5 Mar 1997, Chris Busch wrote:

> I am wondering if anyone patched perl so it has persistence.
> 
> For example, perhaps a function called "savestate".  This function would
> create a file that could then be used to restart the process in the
> exact same state.  The file should be 100% portable to other platforms
> (or at least to other machines running the same OS). 

CPAN has modules for Freeze/Thaw of data, but I think you're seeking
something more. If you don't find what you want on CPAN, feel free to
code it up and submit it yourself. It sounds potentially useful.

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

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Fri, 7 Mar 1997 12:51:10 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Michael Stearns <mstearns@darkwing.uoregon.edu>
Subject: Re: Point a socket client at an HTTP server
Message-Id: <Pine.GSO.3.95q.970307125011.10043C-100000@kelly.teleport.com>

On Fri, 7 Mar 1997, Michael Stearns wrote:

> I would like to create a socket that connects to an HTTP server, but I
> can't get it.

Why aren't you using the LWP modules? It looks like you're re-inventing
the wheel. :-)

   http://www.perl.org/CPAN/

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 7 Mar 1997 10:15:40 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: Possible bug in regular expression form /\d{x,x}/
Message-Id: <5fpm0c$8ks$1@halcyon.com>

In article <Pine.HPP.3.91.970307000525.20984B-100000@romulus.spd.louisville.edu>,
William J. Sandman <wjsand01@starbase.spd.louisville.edu> wrote:
|	if( @dog =~ /\d{5,5}/){

I'll assume you mean $dog and not @dog.

|		do stuff
|	}
|	where dog is $dog = 12345; the if evaluates to true.

As it should.

|When $dog is less that 5 digits the if evaluates to false.

As it should.

|If there are more that 5 digits the if SHOULD evaluate to false.

Bzzzt! Say $dog is 12345678, then $dog =~ /\d{5,5}/ matches at the
first character, and matches the first 5 characters (check $&), because
the first five characters are a string of not less than and not more
than 5 digits.

If you want to find strings that are only 5 digits, try anchoring the
search: $dog =~ /^\d{5}$/

If you want to find strings of exactly five digits embedded in other
text, try: $dog =~ /(?:^|\D)(\d{5})(?:\D|$)/, which will leave the
digits matched in $1.

Brian
-- 
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: 7 Mar 1997 15:18:29 GMT
From: mfiresto@vnet.ibm.com (Mik Firestone)
Subject: Re: Possible bug in regular expression form /\d{x,x}/
Message-Id: <5fpbk5$nle$1@mail.lexington.ibm.com>

William J. Sandman <wjsand01@starbase.spd.louisville.edu> wrote:
>
>	if( @dog =~ /\d{5,5}/){
>		do stuff
>	}
>
>	where dog is $dog = 12345; the if evaluates to true.
>
>When $dog is less that 5 digits the if evaluates to false. Since the 
>upper limit is also 5. If there are more that 5 digits the if SHOULD 
>evaluate to false. In my applications it is evaluating to true in cases 
>where the upper limit (second value is either the same as the first of if 
>different.

The match is successful when there are more than 5 digits.  You may want to
try something like $dog =~ /^\d{5}$/ to force the issue.  Of course,
the anchors could be changed to word boundaries as well ( as in /\b\d{5}\b/
), depending on the input format of your data.  According to my tests, 
this did what you want.  I personally would use the word boundaries - it
the least assumption about how your input will be formatted.

>Community feedback on this is welcom, as I'm fairly comfortable with 
>Perl, I've always had conceptual problems with regular expressions.
At the risk of turning myself into a salesperson for O'Reilly, I would
strongly recommend "Mastering Regular Expressions", by Jeffery Friedl,
to overcome your conceptual problems.

Mik
-----
Mik Firestone  mfiresto@mindspring.com
Evil Overlord Rule #24: I will not have a son. Although his laughably
under-planned attempt to usurp power would easily fail, it would provide
a fatal distraction at a crucial point in time.



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

Date: 7 Mar 1997 21:52:05 GMT
From: gtk@walsh.med.harvard.edu (Gregory Tucker-Kellogg)
Subject: Q: Status of RDB (by Walter Hobbs) under Perl 5?
Message-Id: <5fq2m5$hd@mufasa.harvard.edu>

For a while now, I've had occasion to use the RDB tools written by
Walter Hobbs.  Does anybody know the status of these tools under Perl
5?  Any attempts to create a Tie:RDB module?  Does anybody besides me
use RDB?  

--
Gregory Tucker-Kellogg
Department of Biological Chemistry and Molecular Pharmacology
Harvard Medical School, Boston MA 02115
"Mojo Dobro"    Finger for PGP info



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

Date: Fri, 7 Mar 1997 19:09:32 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Rounding Numbers in Perl
Message-Id: <adelton.857761772@aisa.fi.muni.cz>

sunny@mem.net (Dan Davis) writes:

> Hey
> 
> I have what is probobally a very basic question.  I have
> been using perl to write some cgi scripts to keep up with
> wins and losses for an online gaming leauge.  Everything is
> working fine, however I would like to round some of the
> scores off to just 2 or 3 significant digits.  The problem
> is, I havent been able to find anything in Perl that rounds
> floating point numbers.  For that matter, I havent found
> anything that will even truncate them.  Am i missing
> something here?  

You round using printf:

$ perl -e ' printf "%.3f\n", 4.34567; '

yields

4.346

If you want to truncate, use s///.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Fri, 7 Mar 1997 21:41:53 GMT
From: cek@tblv002.boeing.COM (Conrad E. Kimball)
Subject: script to make symlink tree?
Message-Id: <E6p09t.7q3@news.boeing.com>

I need a perl script that will create a duplicate of a specified
directory structure, in which the leaf nodes are symlinks to the leaf
nodes of the original directory.  I have a shell script that does this
but I'd like one in perl (for performance and to incorporate into a
larger perl script - I seem to recall having seen a perl script to
do this, but I haven't been able to locate it in CPAN.  Any pointers?

--
Conrad Kimball           | Client Server Tech Svcs, Boeing Information & Supt.
cek@bcstec.ca.boeing.com | P.O. Box 24346, MS 7M-HC
(206) 865-6410           | Seattle, WA  98124-0346


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

Date: Thu, 6 Mar 1997 23:21:20 +0000
From: Rosemary I H Powell <Postmaster@dozyrosy.demon.co.uk>
Subject: Re: simple new question!
Message-Id: <xdz6WLAwF1HzEw6g@dozyrosy.demon.co.uk>

In article <Pine.GSO.3.95q.970221192125.23547O-
100000@kelly.teleport.com>, Tom Phoenix <rootbeer@teleport.com> writes
>On 21 Feb 1997, Jonas Bofjall wrote:
>
>> 2. this code, shouldn't it work??:
>>    $abc = TRUE;
>>    if (abc) { print "this won't print!" }
>
>You've left the dollar sign off of abc in the second line. Also, TRUE is a
>bareword on the first line; generally, that's not a good idea. I'd
>recommend 'TRUE' instead - except that then you might think that 'FALSE'
>was false! Maybe you want to use 0 for false and 1 for true? 

Speaking as a 'baby' Perl programmer, I do:

    $true = 1;
    $false = 0;
    $abc = $false; # or whatever, to start with
    ....
    # more whatever
    ....
    $abc = $true;
    if ($abc) {print "this WILL print!"}

which helps me keep things straight in my mind - and hopefully also in
Perl's.

I learned this trick when using REXX -  it actually makes better sense
not having to use variables prefixed with Perlish "squiggly" bits
 ;-(( 

    true = 1
    false = 0
    ....
    abc = true
    if abc....etc


Rosemary
-------------------------------------------------------------------
| Rosemary I.H.Powell  EMail: Home: rosemary@dozyrosy.demon.co.uk |     
|                             Work: r.i.h.powell@rl.ac.uk         |
|                       http://www.netlink.co.uk/users/dozyrosy/  |
|                       http://www.dozyrosy.demon.co.uk/          | 
-------------------------------------------------------------------


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

Date: Fri, 07 Mar 1997 16:23:32 -0500
From: Diana Duncan <dduncan@realogic.com>
Subject: Re: Stored Procedures For ORACLE
Message-Id: <33208754.381E@realogic.com>

Michael Shannon wrote:
> 
> Hi,
> 
> I am attempting to run a perl script that will will invoke an Oracle
> stored procedure and return results of the stored procedure through an
> IN/OUT variable that is passed as a parameter to the procedure. I know
> there are examples for using straight SQL but I have not seen anything
> for stored procdures. Can anyone give me some direction on this or
> better yet an example, if in fact it can be done?
> 
> Thanks...Mike

I honestly don't think it can be done.  However, you CAN use a
user-defined function, as in
	select my_function(:1, :2, :3) from dual
and then just fetch from your cursor normally.
-- 
Diana Duncan	     | My opinions are my own.
Sr. Consultant	     | 
REALOGIC, Inc.	     | Excitement, Adventure and
dduncan@realogic.com | Really Wild Things - Z.B.


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

Date: Fri, 7 Mar 1997 12:49:02 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Joe Moore <joemoore@att.com>
Subject: Re: Trapping Segmentation Fault
Message-Id: <Pine.GSO.3.95q.970307123430.10043B-100000@kelly.teleport.com>

On Fri, 7 Mar 1997, Joe Moore wrote:

> I have a program that uses an eval block to execute some code.
> The program dumps core with a segmentation fault, but $@ is
> not set.  Why not?  Is there a way to catch all faults so I can
> exit gracefully instead of dumping core?

Good question. The problem, as I understand it, is that a segfault is the
software equivalent of driving your car off a cliff. Thelma and Louise
aren't going to have a sequel. In other words, by the time the segfault
has happened, the perl binary itself has stopped running. It has no way to
pick up the pieces and come back to life. 

The good news is that Perl should only dump core in a few situations, and
they should all be avoidable. The bad news is that Perl isn't perfect, and
so some of those core dumps will happen anyway. (And some aren't even
Perl's fault; they happen when some system library routine goofs up.) 

Since it's happening in an eval, is there any chance that you're passing
bad code? That's one of the avoidable situations; you run some risk of
fatally confusing Perl if you eval syntactically-invalid Perl. 

Another possibility is that you're using eval multiple times in your
script, and (due to a memory leak of some sort) you're running out of
memory (real or virtual). If that might be the case, and if it's not due
to something which you can find in your own code, there's a somewhat
technical remedy: Compile Perl with Perl's own malloc, and see whether its
diagnostics can help you to find and plug the leak. 

Still having troubles? Well, if you can make a small script which reliably
fails (and isn't _that_ a good oxymoron?), run the perlbug program to send
in the bug report. There's a pretty good chance that the bug will be fixed
in a future version of Perl.  Heck, sometimes it's fixed an hour after you
send the bug report. Good luck!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 7 Mar 1997 21:52:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Why are my rand() values so tiny?
Message-Id: <5fq2m9$822$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, Jay Tomlin <ltomlin@ucs.indiana.edu> writes:
:	srand;
:	for ($i=0; $i<5; $i++) { print rand(10), "\n"; }
:
:yielded this:
:
:	0.000113327987492085

Did it ever occur to you to give srand an argument?

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


I'm TRYING to be a back end!  - --Andrew Hume


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 72
************************************

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