[8898] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2515 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 6 12:08:41 1998

Date: Wed, 6 May 98 09:00:45 -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, 6 May 1998     Volume: 8 Number: 2515

Today's topics:
    Re: $$#_ ? (Kevin Reid)
    Re: 256 char limitation? <pittdno@spamexecpc.com>
    Re: Another Odd Regexp Question - Buggy Behaviour? <jdf@pobox.com>
    Re: Another Odd Regexp Question - Buggy Behaviour? <dballing@speedchoice.com>
    Re: Array of Arrays, sorting and using (KevinCohen)
    Re: Compare integes is faster than compare strings also (Kevin Reid)
    Re: COUNTING DAYS UNTIL 2000 (Andy Squires)
    Re: Help with comma seperated file with "'s inside fiel <jdf@pobox.com>
        I need variable REMOTE_USER in an insecure script... <info@globalcoal.com>
    Re: I need variable REMOTE_USER in an insecure script.. <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: is it possible to parameterize a class name? <tchrist@mox.perl.com>
    Re: Localtime--dumb question probably <roach@necrosis.com>
    Re: Localtime--dumb question probably <shurik@iron.Te.NeT.UA>
    Re: Localtime--dumb question probably <mpeck@pobox.com>
    Re: Perl on Win95? (Hakan Hjelmstrom)
    Re: problem reading DB_File on win32 platform <gmarzot@baynetworks.com>
    Re: References <roach@necrosis.com>
    Re: References <qdtcall@esb.ericsson.se>
    Re: Regular Expression <jdf@pobox.com>
    Re: removing nested parentheses <jdf@pobox.com>
    Re: Rounding a number <jefpin@bergen.org>
        Setsuid and PERL5LIB <Francois@sequent.com>
    Re: Share an array <brian@Emma.COM>
        user friendly message on die <jasmatt@es.co.nz>
    Re: user friendly message on die <brianm@kodak.com>
    Re: user friendly message on die <jdf@pobox.com>
    Re: Using executable pathname to define include path <upsetter@shore.net>
    Re: What it perl? ptimmins@netserv.unmc.edu
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 6 May 1998 11:27:29 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: $$#_ ?
Message-Id: <1d8kaw9.1fv9aegit3i8N@slip166-72-108-159.ny.us.ibm.net>

John Porter <jdporter@min.net> wrote:

> On 5 May 1998 06:42:28 GMT,
> in article <6imcck$872$1@nntp1.ba.best.com>,
> dfetter@shell4.ba.best.com (David Fetter) wrote:
> > Phil R Lawrence <prl2@lehigh.edu> wrote:
> > > $_ is a hard reference to an array.  How do I determine the subscript
> > > of the final element of the array?
> > 
> > > $$#_ doesn't seem to work.
> > 
> > scalar($_)-1 does for me :)
> 
> That's odd, it doesn't for me.  But scalar(@$_)-1 does.
> However, scalar(@a)-1 is not necessarily the same as $#a.
> It depends on the value of $[.

*[ = \$junk;

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


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

Date: Wed, 06 May 1998 10:39:44 -0500
From: Daniel Pittenger <pittdno@spamexecpc.com>
Subject: Re: 256 char limitation?
Message-Id: <6iq04j$i6g@newsops.execpc.com>

if I try to send more than 256 chars from the client to the server, the
first 256 get lost and only the chars after that show up at the other
clients!
> 
> That's a sign that one of the programs you're using has a bug. Try using
> (say) telnet as the client and also as the server, then (if everything
> works) replace one end or the other with a program until you isolate the
> problem. Hope this helps!
> 
> --
> Tom Phoenix       

Tom,

Thanks. I tried telnet as the client. Same problem. I don't know how to
make telnet a server?, so I couldn't try that. 
But I'm still wondering if the Solaris terminal window has a 256 char
limitation or something like that. I am going to investigate that
further, plus try some modifications in the server code to see if it is
inducing the limitation somehow. 

Thanks for the good suggestion. 
At least I know its not the client now.

Dan

BTW -- I would be happy to post the code if you think it would help...


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

Date: 06 May 1998 11:37:55 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Derek Balling <dballing@speedchoice.com>
Subject: Re: Another Odd Regexp Question - Buggy Behaviour?
Message-Id: <k97zwe1o.fsf@mailhost.panix.com>

Derek Balling <dballing@speedchoice.com> writes:

> $foo = $1 if $request =~ /modem (\d{5,6})/gs;

That /g modifier is messing you up, I'm thinking.  Is it there for a
reason?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Wed, 06 May 1998 10:41:33 -0500
From: Derek Balling <dballing@speedchoice.com>
To: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Another Odd Regexp Question - Buggy Behaviour?
Message-Id: <3999D48435C969C5.0512F35D7205D689.693617C448E12E7B@library-proxy.airnews.net>

Jonathan Feinberg wrote:
> 
> The following message is a courtesy copy of an article
> that has been posted as well.
> 
> Derek Balling <dballing@speedchoice.com> writes:
> 
> > $foo = $1 if $request =~ /modem (\d{5,6})/gs;
> 
> That /g modifier is messing you up, I'm thinking.  Is it there for a
> reason?

Actually, it's "been there" and not been there.

I should have qualified that I've also tried the following
flag combinations:

/i
/is
/im
/gs
/s
/m

Sorry for the confusion in that regard.


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

Date: 06 May 1998 14:55:43 GMT
From: kevincohen@aol.com (KevinCohen)
Subject: Re: Array of Arrays, sorting and using
Message-Id: <1998050614554300.KAA11465@ladder01.news.aol.com>

hi, bernd--- you asked:

>can anybody tell me how I can sort an Array of Arrays (No Hashes),
>depending on the Arraysfields of the Array.
>And then put the sorted thing in another Array to use it?

it sounds like you could use a copy of "perl 5 for dummies", by Paul E.
Hoffman.  See pages 258-260 for navigating an array of arrays.  you might also
take a look at "advanced perl programming" by sriram srinivasan; chapter 2
talks about complex data structures in great detail.

kevin




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

Date: Wed, 6 May 1998 11:27:31 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Compare integes is faster than compare strings also in perl?
Message-Id: <1d8kcb4.vc8j9qar0mjsN@slip166-72-108-159.ny.us.ibm.net>

Peng Li <teilipe@tss.tei.ericsson.se> wrote:

> This is a multi-part message in MIME format.
> --------------0357A0905BBBFC5622118E81
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit

Please don't do this.

> Sorry for a stupid qustion, I am a new programer of PERL,
> someone told me in PERL all integers are converted to
> strings,

No. While this is true in Spectrum, in Perl, the variables are kept in
whatever format they were most recently used in:

$a = "1.0";
print $a;
# prints: 1.0

$a = $a + 1;
print $a;
# prints: 1

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


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

Date: Wed, 6 May 1998 15:49:09 GMT
From: asquires@netcom.com (Andy Squires)
Subject: Re: COUNTING DAYS UNTIL 2000
Message-Id: <asquiresEsJL9x.A8B@netcom.com>


Here's one I did without using a module.  There's no need to check for 
leap year, so you don't really need to convert to Julian days--at least I don't think so.


#!/usr/bin/perl


($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdt) = 
localtime(time);

$daysleft=((99-$year)*365)+(365-$yday);
if($isdt==1)     # Is it daylight savings?
{
   if($hour==0) {
      $hour=23;
   } else {
      $hour=$hour-1;
   }
}
$hoursleft=(23-$hour);
$minsleft=(59-$min);
$secsleft=(59-$sec);

print <<EOT;
Content-type: text/html

<HTML>
<HEAD>
<TITLE>Year 2000</TITLE> </HEAD>
<BODY>

<center>
<table border=2>
<caption>Time Left Until Jan. 1, 2000 for the Eastern Time Zone of the U.
S.</caption>
<tr>
<th>DAYS</th><th>HOURS</th><th>MINUTES</th><th>SECONDS</th>
</tr>
<tr align=center>
<td><strong>$daysleft</strong></td><td><strong>$hoursleft</strong></td>
<td><strong>$minsleft</strong></td><td><strong>$secsleft</strong></td>
</tr>
</table></center><p>
                                                                               
</BODY>
</HTML>
EOT

-- 
| Andy Squires                  "The trouble with life is
| asquires@netcom.com         there's no background music."
| Web Page is at http://www.announce.com/~asquires/andy.html



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

Date: 06 May 1998 11:35:18 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Tom Cross <tomc@kendeco.com>
Subject: Re: Help with comma seperated file with "'s inside fields
Message-Id: <n2cvwe61.fsf@mailhost.panix.com>

Tom Cross <tomc@kendeco.com> writes:

> I need to read in a comma seperated file with text fields that have "'s
> around it.

There is a module that does this.

Module id = Text::CSV
    DESCRIPTION  Manipulate comma-separated value strings
    CPAN_USERID  ALANCITT (Alan Citterman)
    CPAN_VERSION 0.01
    CPAN_FILE    ALANCITT/Text-CSV-0.01.tar.gz

To reach the CPAN, go to 

    http://www.perl.com/CPAN-local/

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: Wed, 6 May 1998 15:10:15 +0100
From: "Bevan Jones" <info@globalcoal.com>
Subject: I need variable REMOTE_USER in an insecure script...
Message-Id: <6ipqv0$q8i$1@plutonium.btinternet.com>

G'day perl people.

I am running some html pages in a protected directory with .htpasswd. These
access scripts in my cgi-bin directory which are not protected, as some of
them run from insecure html pages. How do I get the environment variable
$REMOTE_USER from the secure directory to be read from my perl scripts in
the unprotected directory...? Comments and replies by e-mail would be really
appreciated. Regards, Bevan.




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

Date: 06 May 1998 16:30:51 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: I need variable REMOTE_USER in an insecure script...
Message-Id: <7x4sz3lbdw.fsf@beavis.vcpc.univie.ac.at>

Re: I need variable REMOTE_USER in an insecure script...,
Bevan <info@globalcoal.com> said:

Bevan> pages. How do I get the environment variable
Bevan> $REMOTE_USER from the secure directory to be read
Bevan> from my perl scripts in the unprotected directory...?

Nothing to do with perl per se (or should that be "perl se"? :-)

Directories which don't require authentication won't have
REMOTE_USER set (usual WWW server behaviour anyway).

They'd probably have to pass the value over e.g. through a
HIDDEN field, or maybe a cookie solution?

Anyway, if you want perl pointers, use CGI.pm:

  http://www-genome.wi.mit.edu/ftp/pub/software/WWW/

-- 
Tony Curtis, Systems Manager, VCPC,      | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/

"You see? You see? Your stupid minds! Stupid! Stupid!" ~ Eros, Plan9 fOS.


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

Date: 6 May 1998 14:20:41 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: is it possible to parameterize a class name?
Message-Id: <6iprjp$2cv$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, edb@interport.net (Ed.Q.Bridges) writes:
:The first isr klugey.  Is there a better way? 

Yes; I posted it as a separate response.

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

    tmps_base = tmps_max;                /* protect our mortal string */
        --Larry Wall in stab.c from the perl source code


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

Date: Wed, 06 May 1998 14:07:10 +0000
From: Brian Roach <roach@necrosis.com>
Subject: Re: Localtime--dumb question probably
Message-Id: <35506E8E.1676F5F0@necrosis.com>

Michael Peck wrote:
> 
> johnny99@sydney.dialix.oz.au wrote:
> >
> > I've got
> >
> > $timesent=localtime;
> >
> > and then
> >
> > print (SM $timesent);
> >
> > but nothing comes out. It doesn't die, it just doesn't do anything.
> >
> 
> localtime is a function that accepts a optional 'time' parameter, and
> returns a list (array) of values.  It can be used like this:
> 
> ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
> localtime ;

And if it's called without arguments it returns a nice formatted
version of the current time. 

$time_string = localtime;

print "$time_string\n";

works perfectly fine (ugly, yes, and I wouldn't use it, but valid).
The output would be:

Wed May  6 10:04:47 1998

> > print (SM $timesent);

Two things here: 
1) what is "SM" ? If it's a filehandle you want
   print SM $timesent;
2) If you don't add a "\n" to '$timesent' you may not see it
   untill you fill or flush the output buffer.


- Brian


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

Date: 6 May 1998 13:59:43 GMT
From: Alexandr Dubovikov <shurik@iron.Te.NeT.UA>
Subject: Re: Localtime--dumb question probably
Message-Id: <6ipqcf$lka$1@toster.Te.NeT.UA>

johnny99@sydney.dialix.oz.au ( johnny99@sydney.dialix.oz.au ) RANEE PISAL:
> I'm using localtime in a script for a web form, to datestamp the emails it
> sends.

> I've got

> $timesent=localtime;

> and then

> print (SM $timesent);

> but nothing comes out. It doesn't die, it just doesn't do anything.

> Is the localtime thing universal, or do some servers use another term? Or,
> more likely, am I doing something wrong?

> TIA
Please , try it ->  


print "Content-type: text/html\n\n",
"<h3>$Msg</h3>\n",
"<pre>\n"; 

($sec, $min, $hour, $mday, $mon, $year, $wday, $ydat, $isdst) = localtime();
print("localtime() 19$year-$mon-$mday\n");


> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/   Now offering spam-free web-based newsreading

Good luck! 


 Alexandr Dubovikov * +380 (0482) 219093  
  baron@iRC RusNet  *  shurik@te.net.ua 

P.S. If you have got some questions , write to me , I aswer to you...
 


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

Date: 6 May 1998 09:30:01 -0500
From: Michael Peck <mpeck@pobox.com>
Subject: Re: Localtime--dumb question probably
Message-Id: <355073ED.CF99D21F@pobox.com>

> <snip>

Hakan Hjelmstrom wrote:
> Yes, but it can be used in a scalar context as well.
> "In a scalar context, returns the ctime value:
>   $now_string = localtime;  # e.g., "Thu Oct 13 04:54:34 1994"

Good call.  It'll teach me to turn the page :o)

Mike.


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

Date: Wed, 06 May 1998 14:04:16 GMT
From: hawk@algonet.se (Hakan Hjelmstrom)
Subject: Re: Perl on Win95?
Message-Id: <35536c08.84641327@news.algonet.se>

On Wed, 06 May 1998 09:16:38 -0700, Glenn Davis wrote:
> Is there a Win95 version or Perl?

Yes, I'd recommend you take a close look at http://www.perl.com/ or
more specific still, check http://www.perl.com/latest.html 
There's even a nice little description of the differences between the
two ports availible.

> If not, is it possible to run a Perl installed on a WinNT server from 
> Win95 workstations.

Yes.

Hekan Hjelmstrvm
hawk@algonet.se


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

Date: 06 May 1998 11:00:37 -0400
From: Joe Marzot <gmarzot@baynetworks.com>
Subject: Re: problem reading DB_File on win32 platform
Message-Id: <pdra27zboq.fsf@baynetworks.com>

robert@il.fontys.nl (robert) writes:

> 
> Hugo ter Doest <terdoest@cs.utwente.nl>:
>  >Piet van Oostrum wrote:
>  >> But DB files are binary files, so they should be in principle
>  >> transportable, without CR/LF problems.
>  >maybe it's a big/small-endian problem?
> 
> It could still be a cr/lf problem, if the keys in the database are
> stored including (a) newline character(s). A quick way to find out might
> be viewing the DB file with a binary editor/viewer.

the BSD DB databases underlying DB_File are in theory arch. independent
as long as the data you use for the keys and values are also
arch. independent - the problem you may be having is that the win32
distribution is built w/ db-2.3.6 which is incompatible with the older
db-1.85 in fact db-2.x versions sometimes need to match exactly for the
databases to be interoperable.

cheers, GSM

> 
>                                                                   robert

-- 
 G.S. Marzot                        email: gmarzot@baynetworks.com
 Bay Networks Inc.                  voice: (978)670-8888 x63990
 600 Tech Park  M/S BL60-101        pager: (800)409-6080 (4096080@skytel.com)
 Billerica, MA  01821                 fax: (978)670-8145


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

Date: Wed, 06 May 1998 14:12:47 +0000
From: Brian Roach <roach@necrosis.com>
Subject: Re: References
Message-Id: <35506FDF.BA276EE@necrosis.com>

Mike van Eck wrote:
 
> $selected_database = \%package_database;
> $selected_database = \@ { $package_database{$packagename}{other} };
> 
> (%package_database is quite a complex structure)
> 
> How can I approach this reference, for example, how do I retrieve the
> number of keys ? I've tried everything, but it seems that I'm

If '$selected_database' is a hash ref, you would get the
keys with
keys %{ $selected_database }

If you want the keys of a hash within a hash that you have a ref
to...

keys %{ $first_hash_ref->{key_for_second_hash} }

- Brian


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

Date: 06 May 1998 17:01:03 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: References
Message-Id: <isaf8ve95c.fsf@godzilla.kiere.ericsson.se>

Mike van Eck <eck@hl.siemens.de> writes:

> How can I approach this reference, for example, how do I retrieve the
> number of keys ?

The ways to get at the contents of references are described in the
perlref manpage, starting a little beyond halfways through. 

You can get the number of keys in a hash through a reference by
evaluating %{$ref} in a scalar context.

> I've tried everything, but it seems that I'm overlooking something.

Well, since you haven't got it right you obviously haven't tried
everything. It'd be much easier to guess what you've done wrong if you 
told us exactly what you've done.
-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: 06 May 1998 11:29:14 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Martin Arlt <arlt@dik.maschinenbau.tu-darmstadt.de>
Subject: Re: Regular Expression
Message-Id: <pvhrweg5.fsf@mailhost.panix.com>

Martin Arlt <arlt@dik.maschinenbau.tu-darmstadt.de> writes:

> ... \begin{note}hhh\end{note}\item abc[snip]\end{note}.
> The above line does not have a <cr>.

Well, if it doesn't have a carriage return, then it's not a "line."

> Now, I want to move the point in the middle of this line behind to \item abc
> so, that I have:
> 
> ... \begin{note}hhh\end{note}\item abc.[snip]\end{note}

The description of your problem is unclear.  Do you want to change
every occurrence of '\item abc' to '\item abc.', and change every
occurrence of '\end{note}.' to '\end{note}'?  If not, then what
*exactly* are you trying to do?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: 06 May 1998 11:22:54 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: "Doug E Fresh" <dhaber@seas.upenn.edu>
Subject: Re: removing nested parentheses
Message-Id: <somnweqp.fsf@mailhost.panix.com>

"Doug E Fresh" <dhaber@seas.upenn.edu> writes:

> Is it possible to create a search string that will find the most nested
> parentheses in a string or do I have to use index, substr etc. etc.
> 
> i.e.
> 
> $string = "2*(3+(4+5))"
> $string =~ s/somthing/&process($1)/e
> # where $1 = "4+5"

You need to define your problem a bit better.  Where are "the most
nested parentheses" here?

   $string = '2*(3+(4+5)*(3+1))';

At any rate, you'll probably want to write a parser, since generalized
nested things are not so easily tackled via regex.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Wed, 6 May 1998 10:26:13 -0400
From: Any more mini-dilemmas I should know about? <jefpin@bergen.org>
To: Michael Stearns <michael@datahost.com>
Subject: Re: Rounding a number
Message-Id: <Pine.SGI.3.95.980506102553.24060A-100000@vangogh.bergen.org>

>I looked in the perlfunc man page and did not see a function for
>rounding a number. Is there such a beast or could someone tell me a good
>way to round a number with Perl?

my favorite:
$rounded = int ($num + .5);

--
Experience is that marvelous thing that enables you recognize a
mistake when you make it again.
	                                            - F. P. Jones
-- Jeff Pinyan | users.bergen.org/%7Ejefpin | techmaster@bergen.org --
NYPM | ICQ# 10222129 | 10222129@pager.mirabilis.com | qw[jeff] on EFnet
&jp('"($``','','$)EDF8```','$*52J4```','$+E1G4```','#J``@','#2__`');sub
  jp{for$w(@_){$_=unpack('B48',unpack('u',$w));$c=~tr/10/# /;print;}}



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

Date: Wed, 06 May 1998 17:22:59 +0200
From: francois Simonneau <Francois@sequent.com>
Subject: Setsuid and PERL5LIB
Message-Id: <35508052.1D4C8885@sequent.com>

hi evryone,
basically i want to have a perl script which runs setsuid flag for the
user.
to do that i used the wrapsuid script delivered with the perl
distribution.

in the perl script i used a couple of module (use blabla;).

As long i change the owner of the wrapper with u+s  then it can't the
module anymore.
WHY ?
it looks like PERL5LIB or the environment is gone

any idea will be highly appreciated.
many thanks in advance.
Francois



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

Date: Wed, 06 May 1998 10:46:45 -0400
From: Brian Fuller <brian@Emma.COM>
Subject: Re: Share an array
Message-Id: <355077D5.CEDFB3E6@Emma.COM>

Tom Christiansen wrote:
> 
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc,
>     Razmik Khachikyan <rxk@cobra.jpl.nasa.gov> writes:
> :Does anyone know how to share an array?
> 
> Split it in two.  Give half to a friend.  Tell him to
> go and to likewise.
> 
> --tom
> --

An array a day keeps the doctor away... :-)


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

Date: Thu, 07 May 1998 03:11:44 +1200
From: Matt McKenzie <jasmatt@es.co.nz>
Subject: user friendly message on die
Message-Id: <35507DB0.3183CC00@es.co.nz>

I'm using the O_CREAT and O_EXCL flags from the Fcntl module to check to

see if a file exists in a dir before it creates one.....it works fine,
but I was wondering how to display to the user a nice friendly message
i.e. 'Sorry that user already exists...please try another Username'.
The way it is now, the script will just die without letting the user
know what happened.

<snip>

$username = $value[0]
$prefdir = "/data1/hypermart.net/blah blah blah";

use Fcntl;
   sysopen(OUTFILE, "$prefdir/$username.txt", O_WRONLY|O_EXCL|O_CREAT,
   0644) or die "can't open $prefdir/$username.txt: $!";

<snip>

tia
Matt



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

Date: Wed, 06 May 1998 11:23:03 -0400
From: Brian Mathis <brianm@kodak.com>
To: jasmatt@es.co.nz
Subject: Re: user friendly message on die
Message-Id: <35508057.F5470F2E@kodak.com>

Matt McKenzie wrote:
> 
> I'm using the O_CREAT and O_EXCL flags from the Fcntl module to check to
> 
> see if a file exists in a dir before it creates one.....it works fine,
> but I was wondering how to display to the user a nice friendly message
> i.e. 'Sorry that user already exists...please try another Username'.
> The way it is now, the script will just die without letting the user
> know what happened.
> 
> <snip>
> 
> $username = $value[0]
> $prefdir = "/data1/hypermart.net/blah blah blah";
> 
> use Fcntl;
>    sysopen(OUTFILE, "$prefdir/$username.txt", O_WRONLY|O_EXCL|O_CREAT,
>    0644) or die "can't open $prefdir/$username.txt: $!";
> 
> <snip>
> 
> tia
> Matt


Well, there a quite a few ways to go about something like this.  A
simple option is to write a function that will handle the error, and
display it however you would like.  Then, instead of 
    sysopen(BLAH...) or die('dying words');
you could use something like
    sysopen(BLAH...) or &showError('dying words');

then, function showError could display your message as you see fit, then
exit().

Of course, this is just one option.  Other options include using eval
and $@ to throw and catch exceptions, and, instead of using a function
call, you could use a do block.

Brian Mathis


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

Date: 06 May 1998 11:44:42 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: jasmatt@es.co.nz
Subject: Re: user friendly message on die
Message-Id: <hg33wdqd.fsf@mailhost.panix.com>

Matt McKenzie <jasmatt@es.co.nz> writes:

> but I was wondering how to display to the user a nice friendly message
> i.e. 'Sorry that user already exists...please try another Username'.
> The way it is now, the script will just die without letting the user
> know what happened.

>    sysopen(OUTFILE, "$prefdir/$username.txt", O_WRONLY|O_EXCL|O_CREAT,
>    0644) or die "can't open $prefdir/$username.txt: $!";

Is this a trick question?  If you don't want to die(), then don't
die().  Print out an error message and get new input and do whatever.

Here's some sample code that may give you an idea of how to use Perl's
control structures to loop until you've accomplished something:

     GET_FILE: 
       {
         print "\nEnter a file name: ";
         chop($name = <STDIN>);
	 last GET_FILE if sysopen(OUTFILE, etc.        
	 print "I couldn't cope with that input, because $!.\n"
       }

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf/


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

Date: 6 May 1998 14:59:39 GMT
From: Art Cohen <upsetter@shore.net>
Subject: Re: Using executable pathname to define include path
Message-Id: <6iptsr$hbh@fridge.shore.net>

In comp.lang.perl.misc Tom Christiansen <tchrist@mox.perl.com> wrote:

: The only correct documents are the ones with your system.
: The ones on the web are hopelessly out of date.  Here's why.

[snip]

I've seen Tom post this before, but it's a shame. I'm sure most of us find
it easier to search through a hyperlinked web document rather than reading
the docs in command-line mode on our local machines.

It seems kind of ironic, though, considering that Perl is touted as being
the text-handling language to end all text-handling languages. Isn't there
some way to automatically update the web site when the docs change (or at
some regular interval)?

--Art

National Ska/Reggae Calendar: www.ziplink.net/~upsetter/ska/calendar.html
        Boston Ska Home Page: www.ziplink.net/~upsetter/ska/index.html



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

Date: Wed, 06 May 1998 09:07:12 -0600
From: ptimmins@netserv.unmc.edu
Subject: Re: What it perl?
Message-Id: <6ipqqg$qg1$1@nnrp1.dejanews.com>

Perl is as Perl does, but it won't if you don't (unless
you want it to, then it will).

Try http://language.perl.com/info/synopsis.html

Hope that helps.

Patrick Timmins
ptimmins@netserv.unmc.edu

In article <354F024B.6EC5@but.auc.dk>#1/1,
  Lars Chr Hausmann <36haus@but.auc.dk> wrote:
>
> Hello!
>
> I have to write something about, what Perl is.
>
> I need some crystal clear info about, what perl is. So if any of you
> would be so kind just to mail. Then I would be grateful!
>
> Yours Lars
>


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

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

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