[9958] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3551 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 26 15:08:54 1998

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

Perl-Users Digest           Wed, 26 Aug 1998     Volume: 8 Number: 3551

Today's topics:
    Re: [Upgrade Prob] 5.005 causes "to late for -T" errors (Abigail)
    Re: [Upgrade Prob] 5.005 causes "to late for -T" errors (Mark-Jason Dominus)
    Re: _reverse_ lookahead? (Ilya Zakharevich)
    Re: _reverse_ lookahead? <ajohnson@gpu.srv.ualberta.ca>
        _XOPEN_SOURCE_EXTENDED ? k y n n <kj0@mailcity.com
    Re: _XOPEN_SOURCE_EXTENDED ? (Greg Bacon)
    Re: Blat and Filehandle main::MAIL opened only for inpu <r_larsen@image.dk>
    Re: comp.lang.perl.windows.misc <nguyend7@msu.edu>
    Re: comp.lang.perl.windows.misc (Bob Trieger)
    Re: comp.lang.perl.windows.misc (Greg Bacon)
    Re: comp.lang.perl.windows.misc (Greg Bacon)
    Re: comp.lang.perl.windows.misc (Greg Bacon)
    Re: comp.lang.perl.windows.misc (Norman UNsoliciteds)
    Re: Connecting a mSQL database using the Msql module (brian d foy)
    Re: Forking a daemon (Mark-Jason Dominus)
    Re: Forking a daemon (Matt Knecht)
    Re: getopts with hash problem (Karlon West)
        Help: Cannot Load or Save in Win32::Registry czsmith346@my-dejanews.com
        HELP: Problems installing PERL Eric_Strang@FAC.com
        how can I count number of line in file which has a EOF  (Dermot McKay)
    Re: how can I print 10 digit nos. using 0s as place hol <nonspammers.start.after.this.period.hot_redox@hotmail.com>
    Re: How to match anything but some characters (reg-exp) (Patrick Timmins)
    Re: How to match anything but some characters (reg-exp) huntersean@hotmail.com
    Re: Max value in an array (Abigail)
    Re: Max value in an array (Craig Berry)
    Re: Max value in an array (Greg Bacon)
    Re: Max value in an array (Larry Rosler)
        Memory Leaks (remove)readysite.net (Rob Zimmerman)
    Re: Memory Leaks (Larry Rosler)
    Re: Packed Decimal script <jdporter@min.net>
        pattern matching (James Stout)
    Re: pattern matching (Greg Bacon)
    Re: Perl compiler (Greg Bacon)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 26 Aug 1998 17:39:53 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: [Upgrade Prob] 5.005 causes "to late for -T" errors in scripts
Message-Id: <6s1h99$4nt$2@client3.news.psi.net>

Mark-Jason Dominus (mjd@op.net) wrote on MDCCCXXI September MCMXCIII in
<URL: news:6rvnib$jb8$1@monet.op.net>:
++ In article <35DD7A9F.7E91@usa.net>,
++ Matthew Wickline  <Matthew.Wickline@usa.net> wrote:
++ >If I remove -T from all my cgi scripts' #! lines, will pre-checking with
++ >-cT be enough to ensure that they're taint-safe?
++ 
++ No, not at all.  Taint checking is done at run time, not at compile time.  
++ -cT is (almost) exactly the same as using plain -c.


Yes, but if you're using "use", code *will* be executed with -c.
Just like BEGIN/END {} blocks.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: 26 Aug 1998 13:53:24 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: [Upgrade Prob] 5.005 causes "to late for -T" errors in scripts
Message-Id: <6s1i2k$ab4$1@monet.op.net>

In article <6s1h99$4nt$2@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>Yes, but if you're using "use", code *will* be executed with -c.
>Just like BEGIN/END {} blocks.

The question was ``will pre-checking with -cT be enough to ensure that
they're taint-safe?''

My answer was `no'.

If you're going to pick nits off my answer, you should be sure that
it's clear that the answer is still `no', because otherwise the
querent might be fooled into thinking my answer was wrong, and in this
case the result of that would be an invisible security disaster.



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

Date: 26 Aug 1998 17:44:27 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: _reverse_ lookahead?
Message-Id: <6s1hhr$hho$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Todd "Waxahachiefortudinouslyexportitionismistically" Hartman
<thartman@xxxx.xx>],
who wrote in article <6s18l2$11vk$1@ausnews.austin.ibm.com>:
> Does Perl have a RE feature that does reverse-lookahead (or look-behind)?

Yes.

Ilya


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

Date: Wed, 26 Aug 1998 13:02:35 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: _reverse_ lookahead?
Message-Id: <35E44DBB.22470FA7@gpu.srv.ualberta.ca>

Ilya Zakharevich wrote:
> 
> [A complimentary Cc of this posting was sent to Todd "Waxahachiefortudinouslyexportitionismistically" Hartman
> <thartman@xxxx.xx>],
> who wrote in article <6s18l2$11vk$1@ausnews.austin.ibm.com>:
> > Does Perl have a RE feature that does reverse-lookahead (or look-behind)?
> 
> Yes.
> 
> Ilya

that's still only for fixed width look-behinds, correct? are
there any plans to implement any sort of variable width 
look-behinds?

regards
andrew


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

Date: 26 Aug 1998 17:34:02 GMT
From: k y n n <kj0@mailcity.com
Subject: _XOPEN_SOURCE_EXTENDED ?
Message-Id: <6s1gub$370@news1.panix.com>




I'm trying to use a perl script I got from someone else, but it is
crashing on what appears to be a bug in the perl distribution library.
The script arrives, via a sequence of nested require statements, at
the following line (in standards.ph):

  eval 'sub _XOPEN4UX () {((defined( &_XOPEN_SOURCE) &  &_XOPEN_SOURCE_EXTENDED == 1) ||  &_SGIAPI ||  &_ANSIMODE);}' unless defined(&_XOPEN4UX);

Problem is, _XOPEN_SOURCE_EXTENDED doesn't seem to be defined
anywhere, so the script crashes.  I'm tempted to go in there and hack
around in the library source, but it would be pretty ignorant hacking,
since I have no idea what _XOPEN_SOURCE_EXTENDED is supposed to mean,
so I can't tell whether I want the == test above to be true or false.
Could someone tell me?  Is there a patch for this?  The system here is
IRIX6.2, in case this matters.

Thanks for your help,

K.


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

Date: 26 Aug 1998 18:44:15 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: _XOPEN_SOURCE_EXTENDED ?
Message-Id: <6s1l1v$mlt$7@info.uah.edu>

In article <6s1gub$370@news1.panix.com>,
	k y n n <kj0@mailcity.com writes:
: The script arrives, via a sequence of nested require statements, at
: the following line (in standards.ph):
: 
:   eval 'sub _XOPEN4UX () {((defined( &_XOPEN_SOURCE) &  [...]

It looks to me like the problem is the single ampersand after
C<defined(&_XOPEN_SOURCE)>.  Double it, and your problems should
disappear.

Hope this helps,
Greg
-- 
Politicians and diapers have one thing in common. They should both be changed
regularly and for the same reason. 
    -- Gerry Brooks


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

Date: Wed, 26 Aug 1998 20:00:04 +0200
From: R. A. Larsen <r_larsen@image.dk>
Subject: Re: Blat and Filehandle main::MAIL opened only for input
Message-Id: <VA.00000055.0024c036@octo>

ttoews@telusplanet.net (Tony Toews) wrote:
> 
> sholden@pgrad.cs.usyd.edu.au (Sam Holden) wrote:
> 
> >>open(MAIL,"$mailprog") || die print "Cannot open mailprog";
> >
> >It might help to open a pipe to the program rather than trying to open a file
> >called blat.exe...
> >open(MAIL,"|$mailprog");
> 
> Ok, thanks, wonder how the example worked then?  (Just went and looked
> and nope, no | in that example.)

Who said that the example worked? You know it could be a typo :-)

> >>Filehandle main::MAIL opened only for input at
> >>C:\Inetpub\scripts\sendform.pl line 8.
> >And look perl told you exactly what was wrong anyway...
> 
> Oh?  I can see no relationship between this error message and needing
> to open a pipe.  For an experienced Perl programmer who knows what
> they are doing.  Sure.  But I'm a newbie to Perl.  

It seems to me that perl works as if you are at a command prompt/shell. As the first 
char in an open() statement use:

   > if you want to write the output to a file
   | if you want a program to use the output
   < if you want to read from a file

See 'perldoc -f open' for more info.

HTH, Reni
-- 
Using Virtual Access
http://www.vamail.com



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

Date: 26 Aug 1998 17:42:24 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: comp.lang.perl.windows.misc
Message-Id: <6s1he0$cg$1@msunews.cl.msu.edu>

Bob Trieger <sowmaster@juicepigs.com> wrote:
: [ posted and mailed ]
: Dan Nguyen <nguyend7@msu.edu> wrote:
: -> IMHO, I realy think there is a need for comp.lang.perl.windows.misc,
: -> with all the Windows people (who don't know how to read the FAQs and
: -> wonder why chmod() doesn't work.)
: -> 
: -> I'd like to hear what some other people think about this.

: How will this help solve the problem with all the *nix and Mac people that 
: don't know how to read FAQs?

How about comp.lang.perl.illiterate.misc
:)

-- 
           Dan Nguyen            | There is only one happiness in
        nguyend7@msu.edu         |   life, to love and be loved.
http://www.cse.msu.edu/~nguyend7 |                   -George Sand



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

Date: Wed, 26 Aug 1998 18:07:57 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: comp.lang.perl.windows.misc
Message-Id: <6s1j3v$pjq$1@ligarius.ultra.net>

Dan Nguyen <nguyend7@msu.edu> wrote:
-> Bob Trieger <sowmaster@juicepigs.com> wrote:
-> : [ posted and mailed ]
-> : Dan Nguyen <nguyend7@msu.edu> wrote:
-> : -> IMHO, I realy think there is a need for comp.lang.perl.windows.misc,
-> : -> with all the Windows people (who don't know how to read the FAQs and
-> : -> wonder why chmod() doesn't work.)
-> : -> 
-> : -> I'd like to hear what some other people think about this.
-> 
-> : How will this help solve the problem with all the *nix and Mac people that 
-> : don't know how to read FAQs?
-> 
-> How about comp.lang.perl.illiterate.misc
-> :)

Nah, if you want to attract the illiterate lazy type, it would have to be 
something like:

comp.lang.perl.easy
comp.lang.perl.free
comp.lang.perl.answers


Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-400-1972 
  Ext: 1949 and let the jerk that answers know 
  that his toll free number was sent as spam. "


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

Date: 26 Aug 1998 18:24:44 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: comp.lang.perl.windows.misc
Message-Id: <6s1jtc$mlt$4@info.uah.edu>

In article <6s1aak$6cj$1@strato.ultra.net>,
	sowmaster@juicepigs.com (Bob Trieger) writes:
: How will this help solve the problem with all the *nix and Mac people that 
: don't know how to read FAQs?

I don't believe that there is nearly the proportion of such rude Unix
users.  Regardless of the proportion for Mac users, they're very small
in number compared to Unix and Win32.

When you consider that Win32 people are mostly rude or clueless (usually
both) and that there are lots of them, we lose doubly.  I'd be more than
happy to set aside a place just for them. :-)

Too bad X-Newsreader: doesn't always tell the real truth, or we might
be able to count.

Greg
-- 
There's a lovely paper which compares Unix to Zork in both cognitive and user
motivational terms.  Maybe you like Unix because it's an adventure game?
Still, I just don't think Unix will succeed as a theme park (some small
fraction of :-)  -- Bruce Cohen


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

Date: 26 Aug 1998 18:20:36 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: comp.lang.perl.windows.misc
Message-Id: <6s1jlk$mlt$3@info.uah.edu>

In article <6s18ga$e65$5@msunews.cl.msu.edu>,
	Dan Nguyen <nguyend7@msu.edu> writes:
: IMHO, I realy think there is a need for comp.lang.perl.windows.misc,
: with all the Windows people (who don't know how to read the FAQs and
: wonder why chmod() doesn't work.)

I talked to Russ about this (although the name I suggested was
comp.lang.perl.win32).  He told me that there is a mandatory three
month waiting period after a change in a hierarchy (such as the
addition of a group) before other proposals affecting that hierarchy
would be accepted.

I'd vote for it. :-)

Greg
-- 
The ability to quote is a serviceable substitute for wit. 
    -- Maugham


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

Date: 26 Aug 1998 18:31:22 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: comp.lang.perl.windows.misc
Message-Id: <6s1k9q$mlt$5@info.uah.edu>

In article <6s1he0$cg$1@msunews.cl.msu.edu>,
	Dan Nguyen <nguyend7@msu.edu> writes:
: How about comp.lang.perl.illiterate.misc

Some groups I'd like to see (but not necessarily read)

    comp.lang.perl.bedtime-faqs
    comp.lang.perl.bedtime-docs
    comp.lang.perl.hold-my-hand-i-dont-wanna-read-the-docs
    comp.lang.perl.i-want-to-fellate-bill-gates
    comp.lang.perl.handouts
    comp.lang.perl.mungers
    comp.lang.perl.pacifists
    comp.lang.perl.bitch-about-abigail
    comp.lang.perl.burnore.die.die.die
    comp.lang.perl.tchrist-vs-merlyn
    comp.lang.perl.faqs
    comp.lang.perl.newbie
    comp.lang.perl.wizards
    comp.lang.perl.cgi.wizards

Maybe those would help kill the noise. :-)

Greg
-- 
Kyle:    You're gonna need to kick more ass than that to beat the Cowboys.
Cartman: Hey, speaking of pounding ass, here comes Stan's little homo dog.


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

Date: Thu, 27 Aug 1998 04:02:50 +0900
From: No.unsoiliciteds@dead.end (Norman UNsoliciteds)
Subject: Re: comp.lang.perl.windows.misc
Message-Id: <No.unsoiliciteds-2708980402510001@cs11j08.ppp.infoweb.or.jp>



>++ Dan Nguyen <nguyend7@msu.edu> wrote:
>++ IMHO, I realy think there is a need for comp.lang.perl.windows.misc,

In article <6s1aak$6cj$1@strato.ultra.net>, sowmaster@juicepigs.com (Bob
Trieger) wrote:
> How will this help solve the problem with all the *nix and Mac people that 
> don't know how to read FAQs?

I dunno tho,  if comp.lang.perl.windows.misc and
comp.lang.perl.linux.misc  existed, it would cut down on a lot of the
traffic that seems to be so objectionable to everybody

-- 
The Dinosaurs were so stupid, they couldn't 
even devise the means of thier own extinction, 
they had to wait for Nature to do it for them.


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

Date: Wed, 26 Aug 1998 13:56:25 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Connecting a mSQL database using the Msql module
Message-Id: <comdog-ya02408000R2608981356250001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6s127j$3nu$1@nnrp1.dejanews.com>, sbernard@mail.esiea.fr posted:

>If anyone have already connect a mSQL database using the Msql module, can he
>send me what the script looks like ? In this case, it is a mSQL 2 database.
>Please help, it is vital ...

sri[7] perldoc Msql.pm

User Contributed Perl Documentation            site_perl::Msql(3)

NAME
     Msql / Mysql - Perl interfaces to the mSQL and mysql
     databases

SYNOPSIS
       use Msql;

       $dbh = Msql->connect;
       $dbh = Msql->connect($host);
       $dbh = Msql->connect($host, $database);

[snip]

also see the DBI docs.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>


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

Date: 26 Aug 1998 13:41:20 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Forking a daemon
Message-Id: <6s1hc0$a54$1@monet.op.net>


In article <35WE1.1027$pY1.4838905@news2.voicenet.com>,
Matt Knecht <hex@voicenet.com> wrote:
>What is a problem is how to get the value of TIOCNOTTY.  I qrote a
>quick C program to print out the value of TIOCNOTTY, which I image
>would work if I hard-coded it into my Perl program, but that seems
>like a Really Bad Thing to do.

(shrug.)  How do C programs solve this problem?  They #include some
file:

	#include <sys/ioctl.h>
	/* TIOCNOTTY is now properly defined */

Then the correct value is hard-coded in the executable file.  The
advantage is that when they move the source code to another system and
recomile it, they have different include files and include the new
correct value in the executable.

The best solution to your problem is analogous to the correct solution
for the C programmer:  If your program, put

	require 'sys/ioctl.ph';
	# $TIOCNOTTY is now properly defined.

The problem you are really facing is analogous to the problem faced by
a C programmer on a machine where the .h files have not been
installed.  Such a programmer is completely out of luck.  Fortunately,
you have other options.

The program has to get the magic value.  The magic value is defined in
the C include file.  Therefore, you must get it from the C include
file. The possibilities for doing that include:

  1. Find and interpret the include file somehow (difficult and complex)

  2. Look at the include file yourself, find out the magic value, and
     plug it into your program (you rejected this solution)

  3. Use an automatic tool for #1.

     3a. Perl is distributed with an automatic tool for this exact
         purpose, called `h2ph'.  (You rejected this solution also)

     3b. The C preprocessor is the original tool designed for
         automatic handling of #1.  You could use it in two ways:

         3b1. Run your program with the -P command-line flag

         3b2. Write a C program that prints out the value of
              TIOCNOTTY, bundle it with your perl program, and have
              the perl program do

    	      $TIOCNOTTY = qx{my_get_tiocnotty};

To me, the solutions you rejected look much better than the others,
but I'm not going to tell you what you want to do.



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

Date: Wed, 26 Aug 1998 18:19:16 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Forking a daemon
Message-Id: <EkYE1.1255$b16.4902447@news3.voicenet.com>

Mark-Jason Dominus <mjd@op.net> wrote:
>The best solution to your problem is analogous to the correct solution
>for the C programmer:  If your program, put
>
>	require 'sys/ioctl.ph';
>	# $TIOCNOTTY is now properly defined.

Here's where my problem started.  I did a bit of poking around and it
seems that TIOCNOTTY resides in sys/termios.ph and sys/ttold.ph.  This
is for sun4-solaris.

Unfortunately, termios.ph dies with an error when I require it.  I'm
stuck with the following:

sub TIOCNOTTY() { (ord('t')<<8)|113 }

Which I may as well just change to a constant.  I can't see spending all
the time to use h2xs to convert header files (With no guarentee that
it'll even work).  The only reason to do that would be for portability,
and, how many other Perl's are out there with these file h2xs'd?

Feh... none of these solutions are what I wanted to hear.  At least this
way works, though.

-- 
Matt Knecht - <hex@voicenet.com>


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

Date: 26 Aug 1998 17:07:10 GMT
From: karlon@bnr.ca (Karlon West)
Subject: Re: getopts with hash problem
Message-Id: <6s1fbu$990@crchh14.us.nortel.com>

Warren G Kafer (warrenk@mdhost.cse.tek.com) wrote:
> I'm trying to parse the command line with a hash and with
> a couple of trailing (required) parameters i.e.

> use Getopt::Std qw(getopts);    # Module to parse command line.

Maybe you want:

use Getopt::Long;


Karlon


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

Date: Wed, 26 Aug 1998 18:28:28 GMT
From: czsmith346@my-dejanews.com
Subject: Help: Cannot Load or Save in Win32::Registry
Message-Id: <6s1k4b$q5h$1@nnrp1.dejanews.com>

All attempts to load or save a registry key fail with Win32::Registry::Load or
Win32::Registry::Save.  Following code always returns "No such file or
directory".

	$HKEY_LOCAL_MACHINE->Open('SOFTWARE\UPS\TEST\BA1', $hKey)  ||
		die("\nCannot open BA1!");
	`erase c:\\temp\\XXBA1.*`;

	$hKey->Save('XXBA1.reg')  ||  die ("Cannot save BA1");
	$hKey->Close;


and


	$HKEY_LOCAL_MACHINE->Create('SOFTWARE\UPS\Test', $hKey)  ||
		die("\nCannot create work area in registry!");
	$hKey->Load('Test', 'XXBA1.reg')  ||  die ("Cannot load BA1 ($!)");
	$hKey->Close;


In both instances, the Load or Save dies with the "No such file or directory"
message.

I'm running Perl 5.003_07, Perl for @in32 build 315 (Yes, I know there's
later, but this one is deployed and I can't get a newer one done so
quickly..)

Please post or send help to nrd1czs at nrd dot ups dot com  ...  Thanks!

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


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

Date: Wed, 26 Aug 1998 18:01:03 GMT
From: Eric_Strang@FAC.com
Subject: HELP: Problems installing PERL
Message-Id: <6s1igu$obs$1@nnrp1.dejanews.com>

When I run setup.exe, I get the following message:
Couldn't find Perl Interpreter!!
*choke* *gasp* *wheez*

What are the steps to correct this problem

Eric

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


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

Date: Wed, 26 Aug 1998 18:29:46 GMT
From: MCKAYD@aplbt1.agw.bt.co.uk (Dermot McKay)
Subject: how can I count number of line in file which has a EOF in the middle of it.
Message-Id: <6s1kgp$41b$1@pheidippides.axion.bt.co.uk>

I have a problem with trying to count the number of lines in a file.

I'm using the method described in the Perl FAQ

                open(FILE, "$file");
                while (sysread FILE, $buffer, 4086) {
                        $lines += ($buffer =~ tr/\n//);
                }
                close FILE;

the only problem is there seems to be a EOF in the file I wish to count.

Using UNIX wc -l I get the correct value, but can't using my PERL script

Is there anyway I can do this using PERL as I what to run the script on an 
WIN32 machine so can't include wc -l to get the no of lines from within my 
perl script.


Thanks in advance Dermot



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

Date: 26 Aug 1998 18:27:28 GMT
From: "Sabre Taylor" <nonspammers.start.after.this.period.hot_redox@hotmail.com>
Subject: Re: how can I print 10 digit nos. using 0s as place holders
Message-Id: <01bdd11f$28338ba0$c1620c8a@lnxcompaq.lexis-nexis.com>

Mike Hammernik <mhammer@execpc.com> wrote in article
<6rvtsg$9kb@newsops.execpc.com>...
> I'm trying to create file that contain a 10 digit string. The first 6
> digits are given by the user. I then need to count but I need to keep
> the number in the 10 digit format. For example
> If given 111222 I now need to construct a file that contains

Looks like you've already gotten help, but I thought I'd throw in
a similar piece of code I wrote once.

   # Add 0's to $foo if need be.
    $foo=sprintf ("%d", $foo); # make SPI textual
    while (length $foo < 4) {
        $foo = "0$foo";
    }



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

Date: Wed, 26 Aug 1998 16:51:40 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: How to match anything but some characters (reg-exp)
Message-Id: <6s1eeu$jga$1@nnrp1.dejanews.com>

In article <35E416A5.9361608A@forumnett.no>,
  Hauk Langlo <hauk@forumnett.no> wrote:
> Hi there and sorry for bothering you with this.
>
> I'm about to check if the content of a string contains anything else
> than normal letters digits or one of these "---" I could ofcourse look
> for anything else by defining all other normal characters likely to
> appear ( _ / & ! @ " # etc), but that would not make me feel good about
> myselfe. I would be very happy if someone knew how to write a reg exp
> that works like this:
>
> If ($somescalar =~ /"anything exept a-z, 0-9, or -"/g){
>             do stuff
> }
[snip]

perldoc perlre
and search for "matches any character not in the list"

Patrick Timmins
U. Nebraska Medical Center

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


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

Date: Wed, 26 Aug 1998 17:24:19 GMT
From: huntersean@hotmail.com
Subject: Re: How to match anything but some characters (reg-exp)
Message-Id: <6s1gc3$lkq$1@nnrp1.dejanews.com>

In article <35E416A5.9361608A@forumnett.no>,
  Hauk Langlo <hauk@forumnett.no> wrote:
> Hi there and sorry for bothering you with this.
>
> I'm about to check if the content of a string contains anything else
> than normal letters digits or one of these "---" I could ofcourse look
> for anything else by defining all other normal characters likely to
> appear ( _ / & ! @ " # etc), but that would not make me feel good about
> myselfe. I would be very happy if someone knew how to write a reg exp
> that works like this:
>
> If ($somescalar =~ /"anything exept a-z, 0-9, or -"/g){
You may jhave some luck with
 if ($somescalar =~ /[^a-zA-Z0-9-]/g){
[...snip...]

>
> Regards
> Hauk Langlo
>
> --
>
See ya

Sean H

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


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

Date: 26 Aug 1998 17:28:03 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Max value in an array
Message-Id: <6s1gj3$4nt$1@client3.news.psi.net>

Mark Fergusson (mferg@hal.ddntl.didata.co.za) wrote on MDCCCXXI September
MCMXCIII in <URL: news:35E40C64.224E5D65@hal.ddntl.didata.co.za>:
++ Hello,
++ 
++ Please can someone help with the following:
++ I have an array which contains  numbers. What is the easiest way to
++ determine what the maximum value of the numbers is ?


map {} is your friend.

Here's a Randal-happy version:

sub max {
    return unless @_;
    my   $max = shift;
    map {$max = $_ if $_ > $max; ()} @_;
    $max;
}



Abigail
-- 
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT


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

Date: 26 Aug 1998 17:53:34 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Max value in an array
Message-Id: <6s1i2u$9pm$3@marina.cinenet.net>

Abigail (abigail@fnx.com) wrote:
: Mark Fergusson (mferg@hal.ddntl.didata.co.za) wrote on MDCCCXXI September
: MCMXCIII in <URL: news:35E40C64.224E5D65@hal.ddntl.didata.co.za>:
: ++ Please can someone help with the following:
: ++ I have an array which contains  numbers. What is the easiest way to
: ++ determine what the maximum value of the numbers is ?
: 
: map {} is your friend.
: 
: Here's a Randal-happy version:

Somehow I can't see Randal being happy about map in a void context.

: sub max {
:     return unless @_;
:     my   $max = shift;
:     map {$max = $_ if $_ > $max; ()} @_;

Why not just

      foreach (@_) { $max = $_ if $_ > $max };

instead of that last line?  No obfuscation with the () inside the braces,
no hint of building and throwing away a list of results (even if the ()
makes sure the list never grows, of course).

:     $max;
: }

I find that any time you find yourself doing map in a void context, you
should instead use foreach.  There may be some case where this is
inappropriate, but if so, I haven't encountered it yet. :)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: 26 Aug 1998 18:16:30 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Max value in an array
Message-Id: <6s1jdu$mlt$2@info.uah.edu>

In article <35E40C64.224E5D65@hal.ddntl.didata.co.za>,
	Mark Fergusson <mferg@hal.ddntl.didata.co.za> writes:
: Please can someone help with the following:
: I have an array which contains  numbers. What is the easiest way to
: determine what the maximum value of the numbers is ?

Arrange for the numbers to have a tournament such that the greatest
(valued) number will win.

    sub max {
        return unless @_;

        my $king = shift;

        foreach my $challenger (@_) {
            $king = $challenger if $challenger > $king;
        }

        $king;
    }

Greg
-- 
God does not play dice with the universe.  -- Albert Einstein
Who are you to tell God what to do?        -- Niels Bohr


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

Date: Wed, 26 Aug 1998 11:23:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Max value in an array
Message-Id: <MPG.104df287524064929897f6@nntp.hpl.hp.com>

In article <6s1i2u$9pm$3@marina.cinenet.net> on 26 Aug 1998 17:53:34 GMT, 
Craig Berry <cberry@cinenet.net> says...
 ... 
> Why not just
> 
>       foreach (@_) { $max = $_ if $_ > $max };
 ...

In 5.005, it can even be done this way, for the braces-impaired:

        $max = $_ if $_ > $max foreach @_;

Neat, huh?

(I can't test it, because no 5.005 yet.  Sigh...)

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


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

Date: Wed, 26 Aug 1998 20:38:20 GMT
From: rob@(remove)readysite.net (Rob Zimmerman)
Subject: Memory Leaks
Message-Id: <6s131q$5hs$1@newsy.ncia.net>

Is there an effective way to test scripts for memory leaks? I have
several scripts running on my server and it seems one of them is
robbing ram. How can I determine which it is without removing one at a
time....

many thanks,
Rob
----------



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

Date: Wed, 26 Aug 1998 11:06:15 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Memory Leaks
Message-Id: <MPG.104dee724fd75a9897f5@nntp.hpl.hp.com>

In article <6s131q$5hs$1@newsy.ncia.net> on Wed, 26 Aug 1998 20:38:20 
GMT, rob@(remove)readysite.net (Rob Zimmerman) <rob@(remove)readysite.net 
(Rob Zimmerman)> says...
> Is there an effective way to test scripts for memory leaks? I have
> several scripts running on my server and it seems one of them is
> robbing ram. How can I determine which it is without removing one at a
> time....

If your system is Unix-based, you might try the 'top' command.  For 
Windows NT, the three-fingered salute brings up the Task Manager, and the 
Processes tab will give you memory usage on the running processes.

No Perl here, though...

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


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

Date: Wed, 26 Aug 1998 13:44:52 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Packed Decimal script
Message-Id: <35E44993.1D65@min.net>

joe_tseng@hotmail.com wrote:
> 
> We are migrating our mainframe processes inhouse to a unix setup and we need
> some way to convert packed decimal to ascii.  Are there any scripts available
> that can do this?  If not, can anyone provide pseudocode as to how this is
> done?  Thanx.

To turn a string (buffer) containing BCD data into a string containing
the equivalent ascii digits, use the "H*" template with the unpack
function.  Of course, your program will still have to be encoded with
the knowledge on where each field ends...

-- 
John Porter


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

Date: Wed, 26 Aug 1998 17:09:23 GMT
From: itxjcs@unix.ccc.nottingham.ac.uk (James Stout)
Subject: pattern matching
Message-Id: <35e43cdd.29585853@news.nottingham.ac.uk>

Hi

I've chcked the FAQ's, and have an idea what to do, but I'm not
totally sure. My attempts have failed.

I am reading text from a database into scalar variables. I want to
check the text for the @ sign (i.e. and email address - so it would be
better to check for xxxxxxxxxxx@xxxxxxxxxx.xxxxxx.) If the text
contains the @ sign, I want to put <a href mailto:$variable_name> in
front of the text and </a> at the end of that text.

Something like:

$variable = "this could be an email address like
itxjcs@nottingham.ac.uk";
$variable = ~/@/;
if($variable)
{

	help please!

}

I've tried it, I get a match, but when I print the $variable, it's a
bunch of numbers. 

Any help would be greatly appreciated

James Stout  itxjcs@unix.ccc.nottingham.ac.uk

(oh, it's not a homework question, I'm developing a database driven
website for the Procurement Department)


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

Date: 26 Aug 1998 18:37:20 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: pattern matching
Message-Id: <6s1kl0$mlt$6@info.uah.edu>

In article <35e43cdd.29585853@news.nottingham.ac.uk>,
	itxjcs@unix.ccc.nottingham.ac.uk (James Stout) writes:
: $variable = "this could be an email address like itxjcs@nottingham.ac.uk";
: $variable = ~/@/;
: if($variable)

[snip]

: I've tried it, I get a match, but when I print the $variable, it's a
: bunch of numbers. 

You're misunderstanding how the match operator works.  When you sick
the match operator on some poor scalar, you're asking a question,
namely does this scalar's value match this regular expression?  The
match operator then answers yes or no (useful as the condition in an
if compound statement).

You probably want to do something like

    if ($variable =~ /@/) {
        print qq{<A Href="MAILTO:$variable">$variable</A>};
    }

Read the perlop manpage for the rest of the story.

Hope this helps,
Greg
-- 
VMS is a text-only adventure game. If you win you can use Unix.
    -- Bill Davidsen


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

Date: 26 Aug 1998 18:08:52 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Perl compiler
Message-Id: <6s1ivk$mlt$1@info.uah.edu>

In article <6s1dlu$9pm$1@marina.cinenet.net>,
	cberry@cinenet.net (Craig Berry) writes:
: So again, just to clarify your position,

Careful.  Those words (or words similar) are often a segway to a
doomed straw man.

: would it be fair to characterize
: your views as any of the following?  Choose all that apply:
: 
: a) All software, under all circumstances, should be distributed free-
:    in-the-GNU-sense.

How long have you been reading this group?  Were you not around when
Tom lambasted the GPL for its viral qualities?

Greg
-- 
Cop:     I can put you in Queens on the night of the hijacking.
Hocknet: Really?  I live in Queens.  Did you put that together yourself?


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

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

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