[12923] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 333 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 2 12:07:15 1999

Date: Mon, 2 Aug 1999 09:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 2 Aug 1999     Volume: 9 Number: 333

Today's topics:
    Re: [Summary] Korn Shell or Perl? <uri@sysarch.com>
    Re: [Summary] Korn Shell or Perl? <dgris@moiraine.dimensional.com>
    Re: [Summary] Korn Shell or Perl? (Abigail)
    Re: binary data (Abigail)
    Re: binary data (Larry Rosler)
        cargo-cult programming <tchrist@mox.perl.com>
        CGI.pm Example <GEOFFREY.HALLIWELL@Sun.COM>
    Re: changing output format (Abigail)
    Re: Creating new files and directories (Tad McClellan)
    Re: Date incrementing <paulm@dirigo.com>
    Re: defconfaq - Q&A on arguments against the hypothetic <garethr@cre.canon.co.uk>
    Re: defconfaq - Q&A on arguments against the hypothetic <tchrist@mox.perl.com>
        Files exploding on me and I'm not sure why vertigotwo@my-deja.com
        How do I pass arguments from one CGI script to another? <mark.thomas@gsc.gte.com>
    Re: how to check if scalar is blank? (Andreas Fehr)
    Re: how to check if scalar is blank? (Abigail)
    Re: how to check if scalar is blank? psdsp@my-deja.com
    Re: How to read the submit button as a name or value <uri@sysarch.com>
    Re: How to read the submit button as a name or value (Anno Siegel)
    Re: http_referer problems velo1@earthlink.net
        Installing JPL on HPUX psdsp@my-deja.com
        IP Address validation dave4000@my-deja.com
        IP Validation dave4000@my-deja.com
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 02 Aug 1999 10:18:17 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: [Summary] Korn Shell or Perl?
Message-Id: <x7emhml106.fsf@home.sysarch.com>

>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

  AS> Ken Pizzini <ken@halcyon.com> wrote in comp.lang.perl.misc:
  >> my $pid = open(P, "-|);
                        ^^
that is an implied fork. read open again.

  AS> This can't be right.  (Open will either fail or return a true value.)
  AS> Looks like a fork got lost somewhere along the way.

uri

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


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

Date: 02 Aug 1999 08:40:02 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: [Summary] Korn Shell or Perl?
Message-Id: <m3zp0a9rgd.fsf@moiraine.dimensional.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:

> Ken Pizzini <ken@halcyon.com> wrote in comp.lang.perl.misc:
> 
> >  my $pid = open(P, "-|);

> This can't be right.

Well, it is.  :-)

> (Open will either fail or return a true value.)

Except when it returns the pid of a forked process.

> Looks like a fork got lost somewhere along the way.

Nope, it's right there-
  
  my $pid = open(P, "-|);  # this forks

dgris
- I could make a smartass comment about RTFM'ers needing
  to follow their own advice, but I won't.  :-)
-- 
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: 2 Aug 1999 10:14:00 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: [Summary] Korn Shell or Perl?
Message-Id: <slrn7qbdcl.r33.abigail@alexandra.delanet.com>

Daniel Grisinger (dgris@moiraine.dimensional.com) wrote on MMCLXII
September MCMXCIII in <URL:news:m3zp0a9rgd.fsf@moiraine.dimensional.com>:
 .. anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
 .. 
 .. > Ken Pizzini <ken@halcyon.com> wrote in comp.lang.perl.misc:
 .. > 
 .. > >  my $pid = open(P, "-|);
 .. 
 .. > This can't be right.
 .. 
 .. Well, it is.  :-)

No it isn't. It doesn't compile.

 .. > (Open will either fail or return a true value.)
 .. 
 .. Except when it returns the pid of a forked process.

Which tends to be a true value....

 .. > Looks like a fork got lost somewhere along the way.
 .. 
 .. Nope, it's right there-
 ..   
 ..   my $pid = open(P, "-|);  # this forks


Only if you make it compile....


Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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


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

Date: 2 Aug 1999 10:04:42 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: binary data
Message-Id: <slrn7qbcr6.r33.abigail@alexandra.delanet.com>

Giorgos Zervas (giorgos@perlfect.com) wrote on MMCLXII September MCMXCIII
in <URL:news:37A58B18.E86F41E4@perlfect.com>:
,, 
,, It is an open source project and your contributions will be gladly
,, accepted. That's why it is open source actually. Because we are experts
,, on one thing yet may not be as good on another and we expect others to
,, help us.
,, 
,, This is a program developed by one person having to do much more
,, important work, both professional and academic, at the same time so
,, (guess) it is not perfect.

The point is that you're calling yourself "perl experts" while you clearly
aren't. That's insulting and damaging for people who *are* experts. You
are hollowing out the term. And that's something which shouldn't be taking
lightly. 

Expect to be publicly mocked as long as you call yourselves "perl experts".



Abigail
-- 
sub camel (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
h[{e **###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@#@);
print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.| |d)&&$llama."\n");


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


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

Date: Mon, 2 Aug 1999 08:44:22 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: binary data
Message-Id: <MPG.120f5caa3e3eddcf989d96@nntp.hpl.hp.com>

In article <slrn7qb5af.pju.fl_aggie@thepentagon.com> on 2 Aug 1999 
12:53:30 GMT, I R A Darth Aggie <fl_aggie@thepentagon.com> says...
> On Mon, 02 Aug 1999 12:12:08 +0000, Giorgos Zervas <giorgos@perlfect.com>, in
> <37A58B18.E86F41E4@perlfect.com> wrote:
> 
> + Also you don't like upper case variables it seems. Well, it helps us
> + recognise the variables that are defined in the configuration file...
> + What's the problem with that?
> 
> 'man perlstyle' or 'perldoc perlstyle' will give details, but the short
> and skinny:
> 
> UPPERCASE for file handles, lowercase for variables. Doesn't mean you can't
> have something like $Config_variable or the like.

But you have omitted constants.  UPPERCASE for subroutine-like constants 
(for example, LOCK_SH from 'use Fcntl;') or pseudo-constants for pre-
5.004 systems (for example, $PI = 4 * atan2(1, 1);).

My style is to use ucfirst form (initial capital) for global variables 
shared amongst files (thus $Variable for your $Config_variable).  But I 
see no harm in using all uppercase for them, if they are treated as 
constants for the duration of the execution.

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


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

Date: 2 Aug 1999 09:50:53 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: cargo-cult programming
Message-Id: <37a5be5d@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    tadmc@metronet.com (Tad McClellan) writes:
:: i do not know if this is cargo-cult ? whatever that means.
:   It means:
:      "Copied and used without any understanding of how it works"

Got any lexicon entries for the http://language.perl.com/misc/geekspeak.html
contest? :-)  I've had several word suggestions, but only one program
entry.

--tom

-- 
"Many a good hanging prevents a bad marriage."
				- William Shakespeare


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

Date: Mon, 02 Aug 1999 08:21:48 -0700
From: GEOFFREY HALLIWELL <GEOFFREY.HALLIWELL@Sun.COM>
Subject: CGI.pm Example
Message-Id: <37A5B78C.AC8C4CD5@Sun.COM>

Hi,

I'm trying to run one of Lincoln Stein's CGI.pm examples
(see below) and it won't allow me to view or 
write to the guestbook file.  It is unable to secure 
the lock on the file system so it bails with "Sorry, an 
error occurred: unable to open  guestbook file."

Any ideas?

I'm using 5.005_03 on Solaris 2.6.

Thanks,

Geoff

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

#!/usr/local/bin/perl
# guestbook.pl

$| = 1;
use CGI qw/:standard :html3 :netscape /;
use POSIX;

@REQUIRED = qw/name e-mail/;
@OPTIONAL = qw/location comments/;
$TIMEOUT = 10;  # allow up to 10 seconds for waiting on a locked
guestbook
$GUESTBOOKFILE = "/tmp/guestbookfile.txt";
%ENTITIES = ('&'=>'&amp;', '>'=>'&gt;', '<'=>'&lt;', '\"'=>'&quot;' );

print header,
    start_html('Guestbook'),
    h1("Guestbook");

$_ = param('action');

 CASE: {
     /^sign/i and do    { sign_guestbook(); last CASE; };
     /^confirm/i and do { write_guestbook() and view_guestbook(); last
CASE; };
     /^view/i and do    { view_guestbook(); last CASE; };
     # default
     generate_form();
 }

#!/usr/local/bin/perl
# guestbook.pl

$| = 1;
use CGI qw/:standard :html3 :netscape /;
use POSIX;

@REQUIRED = qw/name e-mail/;
@OPTIONAL = qw/location comments/;
$TIMEOUT = 10;  # allow up to 10 seconds for waiting on a locked
guestbook
$GUESTBOOKFILE = "/tmp/guestbookfile.txt";
%ENTITIES = ('&'=>'&amp;', '>'=>'&gt;', '<'=>'&lt;', '\"'=>'&quot;' );

print header,
    start_html('Guestbook'),
    h1("Guestbook");

$_ = param('action');

 CASE: {
     /^sign/i and do    { sign_guestbook(); last CASE; };
     /^confirm/i and do { write_guestbook() and view_guestbook(); last
CASE; };
     /^view/i and do    { view_guestbook(); last CASE; };
     # default
     generate_form();
 }

sub sign_guestbook {
    my @missing = check_missing(param());
    if (@missing) {
        print_warning(@missing);
        generate_form();
        return undef;
    }
    my @rows;
    foreach (@REQUIRED,@OPTIONAL) {
        push(@rows,TR(th({-align=>LEFT},$_),td(escapeHTML(param($_)))));
    }
    print "Here is your guestbook entry.  Press ",
          em('Confirm')," to save it, or ",em('Change'),
          " to change it.",
          hr,
          table(@rows),
          hr;

    print start_form;
    foreach (@REQUIRED,@OPTIONAL) {
        print hidden(-name=>$_);
    }
    print submit(-name=>'action',
                 -value=>'Change Entry'),
          submit(-name=>'action',
                 -value=>'Confirm Entry'),
          end_form;
}

sub check_missing {
    my (%p);
    grep (param($_) ne '' && $p{$_}++,@_);
    return grep(!$p{$_},@REQUIRED);
}

sub print_warning {
    print font({-color=>'red'},
          'Please fill in the following fields: ',
          em(join(', ',@_)),
          '.');
}

sub generate_form {
    print start_form,
     table(
        TR({-align=>LEFT},
          th('Your name'),
          td(textfield(-name=>'name',-size=>50))
        ),
        TR({-align=>LEFT},
          th('Your e-mail address'),
          td(textfield(-name=>'e-mail',-size=>50))
        ),
        TR({-align=>LEFT},
          th('Your location (optional)'),
          td(textfield(-name=>'location',-size=>50))
        ),
        TR({-align=>LEFT},
          th('Comments (optional)'),
          td(textarea(-name=>'comments',-rows=>4,
                      -columns=>50,
                      -wrap=>1))
        )
     ),
     br,
     submit(-name=>'action',-value=>'View Guestbook'),
     submit(-name=>'action',-value=>'Sign Guestbook'),
     end_form;
}
sub write_guestbook {
    my $fh = lock($GUESTBOOKFILE,1);
    unless ($fh) {
       print strong('Sorry, an error occurred: unable to open guestbook
file.'),p();
       Delete('action');
       print a({-href=>self_url},'Try again');
       return undef;
    }
    my $date = strftime('%D',localtime);
    print $fh join("\t",$date,map {CGI::escape(param($_))}
(@REQUIRED,@OPTIONAL)),"\n";
    print $fh "\n";
    print "Thank you, ",param('name'),", for signing the guestbook.\n",
      p(),
      a({href=>"../source.html"},'Code Examples');
    unlock($fh);
    1;
}

sub view_guestbook {

    print start_form,
          submit(-name=>'Sign Guestbook'),
          end_form
          unless param('name');

    my $fh = lock($GUESTBOOKFILE,0);

    my @rows;
    unless ($fh) {
       print strong('Sorry, an error occurred: unable to open guestbook
file.'),br;
       Delete('action');
       print a({-href=>self_url},'Try again');
       return undef;
    }
    while (<$fh>) {
       chomp;
       my @data = map {CGI::unescape($_)} split("\t");
       foreach (@data) { $_ = escapeHTML($_); }
       unshift(@rows,td(\@data));
    }
    unshift(@rows,th(['Date',@REQUIRED,@OPTIONAL]));
    print table({-border=>''},
          caption(strong('Previous Guests')),
          TR(\@rows));
    print p,a({href=>"../source.html"},'Code Examples');
    1;
}

sub escapeHTML {
    my $text = shift;
    $text =~ s/([&\"><])/$ENTITIES{$1}/ge;
    return $text;
}

sub LOCK_SH { 1 }
sub LOCK_EX { 2 }
sub LOCK_UN { 8 }

sub lock {
    my $path = shift;
    my $for_writing = shift;

    my ($lock_type,$path_name,$description);
    if ($for_writing) {
        $lock_type = LOCK_EX;
        $path_name = ">>$path";
        $description = 'writing';
    } else {
        $lock_type = LOCK_SH;
        $path_name = $path;
        $description = 'reading';
    }

    local($msg,$oldsig);
    my $handler = sub { $msg='timed out'; $SIG{ALRM}=$oldsig; };
    ($oldsig,$SIG{ALRM}) = ($SIG{ALRM},$handler);
    alarm($TIMEOUT);

    open (FH,$path_name) or
       warn("Couldn't open $path for $description: $!"), return undef;

    # now try to lock it
    unless (flock (FH,$lock_type)) {
       warn("Couldn't get lock for $description (" . ($msg || "$!") .
")");
       alarm(0);
       close FH;
       return undef;
    }

    alarm(0);
    return FH;
}

sub unlock {
    my $fh = shift;
    flock($fh,LOCK_UN);
    close $fh;
}


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

Date: 2 Aug 1999 10:06:03 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: changing output format
Message-Id: <slrn7qbctp.r33.abigail@alexandra.delanet.com>

Cistron News (jkotvis@grip.nl) wrote on MMCLXII September MCMXCIII in
<URL:news:7o44mg$lho$1@enterprise.cistron.net>:
<> 
<> Is there any way that I can foprce Perl to only output the whole number
<> (without any numbers behind the dot). In this case the actual output should
<> be converted for example from 2.7 to 3..


RTFFAQ



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


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


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

Date: Mon, 2 Aug 1999 06:15:52 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Creating new files and directories
Message-Id: <o4r3o7.d94.ln@magna.metronet.com>

James Williamson (james.williamson@bbc.co.uk) wrote:

: Abigail wrote in message ...
: >Vox (v0xman@yahoo.com) wrote on MMCLXII September MCMXCIII in
: ><URL:news:W5ap3.45659$jl.31864525@newscontent-01.sprint.ca>:

: >\\ but I don't know how to dynamically make a new files or directories and
: name
: >\\ them.  All i know how to do is open and modify files but not create
: files or
: >\\ even new directories.

: >The manual knows how to do this. Go bug the manual.
: >
: >Abigail


: Can see Abigail is being her most helpful (as usual), try
: opening a non existent file such as


   Can see that James is trying to be helpful, but ends up steering
   them wrong, when reading the manual, as suggested by Abigail,
   would have steered them right.

   If you are going to try and replace the manual, then you should
   at least be as accurate as the manual (which is Hard To Do, so
   don't try and replace the manual).

   We don't refer people to the manual because we are lazy.

   We refer people to the manual because we might make a mistake
   in answering the question. 

   Then the poster gets _more_ confused...

   ... and someone else has to post the correct way ...

   ... and others who are clever enough to search deja.com will find 
   the bad advice and may not see the fixing of the bad advice ...

   ... and the bad advice will propogate ...

   ... and we will have to answer yet another bunch of questions 
   from all the people who believed the bad advice.


   Your followup has hurt more than it has helped.


: open(FILEHANDLE,">filename.pl")


   1) there is a syntax error there

   2) it asks for variable interpolation and/or backslash escapes,
      but then does not use variable interpolation and/or 
      backslash escapes.

   3) it does not check the return value, the open might fail you know...


    open(FILEHANDLE,'>filename.pl') || die "could not open 'filename.pl' $!";
                    ^            ^  ^^^^^^                 ^           ^ ^^
                    ^            ^  ^^^^^^                 ^           ^ ^^

: You'll find that if the file doesn't exist Perl will create one for you.
: Try the 'open' function in perldoc for more info on files and the 'mkdir'
: function for directories.


   Now _that_ part is very helpful. Thanks.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 02 Aug 1999 14:06:44 GMT
From: Stone Cold <paulm@dirigo.com>
Subject: Re: Date incrementing
Message-Id: <7o48ld$klc$1@nnrp1.deja.com>

Yeah, I know.  But if I can figure out how to increment the date, I'll
change the year to 4-digits.

In article <si7lnhn5xx.fsf@cre.canon.co.uk>,
  Gareth Rees <garethr@cre.canon.co.uk> wrote:
> Stone Cold <paulm@dirigo.com> wrote:
> > For example, if the user enters in "may-99" in the user form, the
> > output would show like follows:
> >
> > May-99     Jun-99     Jul-99    Aug-99     Sep-99      Oct-99
>
> You're asking for year 2000 trouble with those 2-digit years.
>
> --
> Gareth Rees
>

--
Paul R. Mesker
System Engineer
Dirigo Inc.


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


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

Date: Mon, 2 Aug 1999 14:29:00 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
To: tchrist@mox.perl.com (Tom Christiansen)
Subject: Re: defconfaq - Q&A on arguments against the hypothetical ?? operator
Message-Id: <sipv16l0ib.fsf@cre.canon.co.uk>

Tom Christiansen <tchrist@mox.perl.com> wrote:
> But it's not just C that has macros, and other implementations are not
> so frequently denigrated--nor if truth be told, so well known. For
> example, Franz Liszt, a dialect of Lisp, had macros.

That should be "Franz Lisp" ("Liszt" was the compiler, not the
language).  Franz now sells the commerical "Allegro Common Lisp"- see
http://www.franz.com/.

If the Perl developers are thinking about adding macros - or functions
which receive arguments unevaluated - then it would be a mistake not to
learn from the Lisp and Scheme families of languages.

See for example Kent Pitman's 1980 paper "Special Forms in Lisp"
comparing three ways of doing macros
http://world.std.com/~pitman/Papers/Special-Forms.html

-- 
Gareth Rees


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

Date: 2 Aug 1999 08:41:21 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: defconfaq - Q&A on arguments against the hypothetical ?? operator
Message-Id: <37a5ae11@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    Gareth Rees <garethr@cre.canon.co.uk> writes:
:That should be "Franz Lisp" ("Liszt" was the compiler, not the
:language).  Franz now sells the commercial "Allegro Common Lisp"- see
:http://www.franz.com/.

It's a terrible think-o on my part.  I knew that, but my fingers just
kept right on typing.  I did very serious updates on the document at
http://www.perl.com/tchrist/defop/defconfaq.html yesterday.  And this
one got fixed then.

--tom
-- 
    "You're flame-proof in the same sense that certain plastics are fluorine-proof."
    	--Larry Wall


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

Date: Mon, 02 Aug 1999 15:47:59 GMT
From: vertigotwo@my-deja.com
Subject: Files exploding on me and I'm not sure why
Message-Id: <7o4ejb$p2s$1@nnrp1.deja.com>

Hi --

I'm pretty much a newbie to Perl, and I have a problem with a script in
which people are simultaneously accessing a file, which then gets
corrupted every couple of days. It seems to do it in a similar fashion
each time.

The situation is this: It's a game which stores a lot of information on
each player in a datafile all seperated by \n's: name, password,
points, etc. I tried to lock the file before I write to it, but
apparently that's not working. What happens is that every once in
awhile, the name field is filled in with an arbitrary number of null
characters (ASCII CHR(0)), and a lot of players drop off the list

Below is the code for the save routine:

sub savedata{
 open(FILE, ">ff/playerindex") || IllegalRefresh("PlayerIndex file
cannot be opened - $!");
 flock(FILE, 2) || IllegalRefresh("PlayerIndex cannot be flocked - $!");
 seek (FILE, 0, 2) || IllegalRefresh("PlayerIndex cannot be seeked -
$!");

 foreach $elem (keys(%person)){
  $money{$elem}= int($money{$elem} * 100) /100;

  print FILE "---\n";
  print FILE "$person{$elem}\n";
  print FILE "$password{$elem}\n";
  print FILE "$lastplay{$elem}\n";
  print FILE "$points{$elem}\n";
  print FILE "$money{$elem}\n";
  print FILE "$inventory{$elem}\n";
  print FILE "$playnum{$elem}\n";
  print FILE "$mailbool{$elem}\n";
  print FILE "$address{$elem}\n";
  print FILE "$hoursbtw{$elem}\n";
  print FILE "$mailday{$elem}\n";
  print FILE "$awards{$elem}\n";
  print FILE "$penalties{$elem}\n";
  print FILE "$salary{$elem}\n";
  print FILE "$lastsignon{$elem}\n";
  print FILE "$karma{$elem}\n";
  print FILE "$imps{$elem}\n";
  print FILE "$bonusp{$elem}\n";


 }

 close(FILE);
}


The webhosting service has Perl 5.005 I believe, although I can check
(if I can figure out how to do that.) I'm not sure what difference that
makes.

I know I'm probably missing something obvious here, but like I said,
I'm new to Perl.

-- Steve



P.S. I've read the FAQ's and the Llama and Camel books' file locking
sections, but to no avail. Thanks in advance



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


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

Date: Mon, 2 Aug 1999 10:35:03 -0400
From: "Justin Development" <mark.thomas@gsc.gte.com>
Subject: How do I pass arguments from one CGI script to another?
Message-Id: <7o4aak$19a$1@news.gte.com>

I have an HTML file (my.html) that passes a username and password to a CGI
script (let's call it my1.cgi), the  my1.cgi script then passes name,
address, phone number to another CGI script (my2.cgi) which prints it out to
a file.

How do I pass the username and password from my.html to my2.cgi so I can
print it to a file? my1.cgi knows about the username and password but
my2.cgi doesn't. I know it has something to do with the scope of the
namespace but I don't know how?

Thanks




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

Date: Mon, 02 Aug 1999 14:25:57 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: how to check if scalar is blank?
Message-Id: <37a5aa49.32686761@news.uniplus.ch>

On Mon, 02 Aug 1999 21:56:07 GMT, hoz@rocketmail.com (hoz) wrote:

>sub is_blank {
>local($var) = @_;
>if ($var eq "") {
>print "$var string is blank\n"; #debug
>}
>if ($var eq "0") {
>print "$var is zero\n"; #debug
>}
>if (!defined $var) {
>print "$! $filename: the variable $var is undefined\n";
>}
>}
>

Hmmm, what happens if you try:

my $blo;
is_blank ($blo);


Andreas


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

Date: 2 Aug 1999 10:28:38 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: how to check if scalar is blank?
Message-Id: <slrn7qbe82.r33.abigail@alexandra.delanet.com>

hoz (hoz@rocketmail.com) wrote on MMCLXII September MCMXCIII in
<URL:news:37a61329.330820223@news.netvision.net.il>:
\\ seems trivial but wondering how to check if a scalar is blank, i.e.
\\ has no value....this is what I have so far...

Well, that depends on your definition of 'blank'.

\\ --8<---
\\ sub is_blank {
\\ local($var) = @_;

local? Why local and not my?

\\ if ($var eq "") {
\\ print "$var string is blank\n"; #debug
\\ }

But that will give a warning if $var is undefined.

\\ if ($var eq "0") {
\\ print "$var is zero\n"; #debug
\\ }

That will give a warning if $var is undefined. And why "0", and not 0?

\\ if (!defined $var) {
\\ print "$! $filename: the variable $var is undefined\n";
\\ }

Where are $filename and $! coming from?

\\ }
\\ 
\\ Does this covers all cases?

That depends on what you mean by "blank". It looks like you want to
know whether $var contains a false value. In which case, you can just
say !$var.



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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


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

Date: Mon, 02 Aug 1999 15:21:52 GMT
From: psdsp@my-deja.com
Subject: Re: how to check if scalar is blank?
Message-Id: <7o4d24$o22$1@nnrp1.deja.com>


> seems trivial but wondering how to check if a scalar is blank, i.e.
> has no value....this is what I have so far...
> --8<---
> sub is_blank {
> local($var) = @_;
> if ($var eq "") {
> print "$var string is blank\n"; #debug
> }
> if ($var eq "0") {
> print "$var is zero\n"; #debug
> }
> if (!defined $var) {
> print "$! $filename: the variable $var is undefined\n";
> }
> }
>
> Does this covers all cases?
> -hoz
>

Pls. refer to camel book page 21 for the rules determining
whether a scalar is true.

The string "", "0", and undefined values are false.
So, you can just write
if (!$var) {
   print "$! $filename: the variable is undefined\n";
}
Dont use $var in print statement. Anyway it is undefined.

Hope that helps.
-Deva


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


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

Date: 02 Aug 1999 10:12:15 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How to read the submit button as a name or value
Message-Id: <x7iu6yl1a8.fsf@home.sysarch.com>

>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:

  BL> Tom Christiansen wrote:
  >> :A "dirty hack" is a my name for it.
  >> 
  >> It's a shame Perl permits such "dirty hacks".  Otherwise 
  >> you would all be more content with things running slowly.

  BL> I don't really mind Perl permitting these "dirty hacks". But a fine code
  BL> example for newbies to follow, it is not. Code in a string? Yuck.

cgi.pm does that to speed up load time. it only evals the code on demand
to create subs as needed. since it is a large module and speed critical
it has many tricks which are not very obvious to speed up its load time.

uri

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


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

Date: 2 Aug 1999 15:58:50 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to read the submit button as a name or value
Message-Id: <7o4f7q$8n5$1@lublin.zrz.tu-berlin.de>

Paul J. Schinder <schinder@leprss.gsfc.nasa.gov> wrote in comp.lang.perl.misc:

[cpan testers]

>
>That's exactly right.  When I'm testing for cpan-testers, I frequently
>don't even look at the README, let alone the code.  The only time I
>look at the code itself is if something goes wrong.  We make no
>guarantees about code quality or suitability for a given task.  All a
>"PASS" means is that the package unpacked, built, and passed the
>author's tests without any discernable problems.

Would this include a test whether

  perl Makefile.PL PREFIX=/u/mydir/perl
  (etc)

works as advertised?  I don't think MakeMaker enforces a particular
use of PREFIX, and a recent posting complained (rightly) that a module
installed in /u/mydir/perl/lib (to stay with the example above).
This is at odds with the promise that the above works in conjunction
with use lib '/u/mydir/perl', so the check would have some relevance.

Anno


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

Date: Mon, 02 Aug 1999 15:10:14 GMT
From: velo1@earthlink.net
Subject: Re: http_referer problems
Message-Id: <37a5b341.253692557@news.giganews.com>

Try this. 

Seems someone else here should have known this. I am 
amazed that everyone else just gives lip about going elsewhere to get
the info. I am relatively new with perl so maybe I have not yet
developed the lousy attitude protrayed by some of the other posters
here.

Hope this helps, I've tried it on several machines and it seems to
work fine.

$referrer = $ENV{'HTTP_REFERER'} ;
$errmsg = "<p>Bad Referrer</p>\n" ;

if ($referrer ne "http://www.coffeecup.com/cgi-bin/download.pl") {
	$message = $message.$errmsg ;
	$found_err = 1 ; }

if ($found_err) {
	&PrintError; }

sub PrintError { 
print "Content-type: text/html\n\n";
print $message ;

exit 0 ;
return 1 ; 
}


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

Date: Mon, 02 Aug 1999 15:02:58 GMT
From: psdsp@my-deja.com
Subject: Installing JPL on HPUX
Message-Id: <7o4bur$n6h$1@nnrp1.deja.com>

I am trying to install JPL on HPUX 10.20.
We have perl 5.005_03, JDK 1.1.7 and HPUX ansi c compiler.

When I try to install-jpl, I get the following errors:
I tried installing JPL on HPUX 10.20.
I used the information in the archive.

But, I am getting the following compilation errors:

	javac PerlInterpreter.java
	javah -jni PerlInterpreter
	cc +z -Ae -D_HPUX_SOURCE -Wl,-E -Wl,-B,deferred  -b
-L/usr/local/lib -c +u4 -Ae
-I/nmlprodpkgs/perl/lib/5.00503/PA-RISC1.1/CORE  -I/opt/java/include
-I/nmlprodpkgs/perl/os2  -I/opt/java/include/hp-ux
-I/opt/java/include/genunix PerlInterpreter.c \
	cc +z -Ae -D_HPUX_SOURCE -Wl,-E -Wl,-B,deferred  -b
-L/usr/local/lib -c +u4 -Ae
-I/nmlprodpkgs/perl/lib/5.00503/PA-RISC1.1/CORE  -I/opt/java/include
-I/nmlprodpkgs/perl/os2  -I/opt/java/include/hp-ux
-I/opt/java/include/genunix -I/nmlpkgs/perl5.005/ext/DynaLoader
/nmlpkgs/perl5.005/ext/DynaLoader/DynaLoader.c \
	-o DynaLoader.o
cc: warning 422: Unknown option "b" ignored.
cc: warning 422: Unknown option "b" ignored.
PerlInterpreter.c:
cc: "PerlInterpreter.c", line 19: error 1506: Parameters allowed in
function definition only.
cc: "PerlInterpreter.c", line 65: error 1711: Inconsistent parameter
list declaration for "Java_PerlInterpreter_eval".
cc: "PerlInterpreter.c", line 77: warning 527: Integral value implicitly
converted to pointer in assignment.
cc: "PerlInterpreter.c", line 79: warning 527: Integral value implicitly
converted to pointer in assignment.
cc: "PerlInterpreter.c", line 100: warning 604: Pointers are not
assignment-compatible.
cc: "PerlInterpreter.c", line 100: warning 563: Argument #3 is not the
correct type.
cc: "PerlInterpreter.c", line 109: error 1000: Unexpected symbol: "CV".
cc: error 2017: Cannot recover from earlier errors, terminating.
/nmlpkgs/perl5.005/ext/DynaLoader/DynaLoader.c:
*** Error exit code 1

Stop.
Couldn't install PerlInterpreter


Any help would be gratefully appreciated.
-Deva


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


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

Date: Mon, 02 Aug 1999 15:37:12 GMT
From: dave4000@my-deja.com
Subject: IP Address validation
Message-Id: <7o4dv7$ojq$1@nnrp1.deja.com>

I require a small routine that validates an IP address that has been
entered.

The following routine, accepts invalid addresses such as 123.45 or
123.45...67

sub ip_add_chk {

	if (($ip=~/(\d+)\.*(\d+)\.*(\d+)\.*(\d+)/) &
			(($1>=0 && $1<256) & ($2>=0 && $2<256) &
				($3>=0 && $3<256) & ($4>=0 && $4<256)))
{

		$_[0]="$1.$2.$3.$4";
		$retry=0;
		return $retry;
		}
	else {
		print ("\nError, Please enter again!\n");
		$retry=1;
		return $retry;
	}

}

Any help would be great.  Thanks

Dave


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


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

Date: Mon, 02 Aug 1999 15:23:17 GMT
From: dave4000@my-deja.com
Subject: IP Validation
Message-Id: <7o4d4o$o2s$1@nnrp1.deja.com>

I need a small routine that checks the validation
of an IP address.

sub ip_add_chk {

	if ($ip=~/[0-9].[0-9].[0-9].[0-9]/) {

		$ip="$1.$2.$3.$4";
		$retry=0;
		return $retry;
		}
	else {
		print ("\nError, Please enter
again!\n");
		$retry=1;
		return $retry;
	}
	}

This routine enables the input of invalid IP
addresses, it's not robust enough!

Any help would be great

Thanks

Dave


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


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 333
*************************************


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