[9508] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3102 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 9 00:07:35 1998

Date: Wed, 8 Jul 98 21:00:22 -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, 8 Jul 1998     Volume: 8 Number: 3102

Today's topics:
    Re: -- Abigail, A FIX to the space problem. <dfsdf@ziplink.net>
    Re: -- Abigail, Another Observation (Tad McClellan)
    Re: -- Abigail, Another Observation (Abigail)
    Re: -- Abigail, Here's an update for you. (Tad McClellan)
    Re: -- Abigail, Here's an update for you. (Abigail)
    Re: -w on production code (was Re: better way of gettin <ljz@asfast.com>
    Re: -w on production code (was Re: better way of gettin (Martien Verbruggen)
    Re: -w on production code (was Re: better way of gettin <mike.schleif@aquila.com>
    Re: -w on production code (was Re: better way of gettin <ljz@asfast.com>
    Re: -w on production code (was Re: better way of gettin <mike.schleif@aquila.com>
    Re: -w on production code (was Re: better way of gettin (Abigail)
        Asking for some info for a beginner, Please read i real <b1233@hotmail.com>
    Re: Bar and Line Charts in Perl <smorton@pobox.com>
    Re: Choosing DBMS: friendly to Linux, Apache, Perl, Jav (Leslie Mikesell)
    Re: Do I understand this? (Abigail)
    Re: explaining the whys of referencing... WAS Re: on th (Josh Kortbein)
    Re: fcntl - How do I call it with F_GETLK? <tchrist@mox.perl.com>
        Hash keys question gcarvell2@my-dejanews.com
    Re: How to use 'system ("...")' on WIN32. <"postmaster"@[127.0.0.1]>
    Re: NEVER "call warn() and return undef" (Re: question  <r.fulton@auckland.ac.nz>
    Re: NEVER "call warn() and return undef" (Re: question  <zenin@bawdycaste.org>
    Re: Perl and Win NT porting? (Craig Berry)
    Re: Perl CGI and warnings [Was: Re: -w on production co (Josh Kortbein)
    Re: Perl CGI and warnings [Was: Re: -w on production co (Abigail)
        question about cgi-lib (zhanglei)
    Re: question about objects (Josh Kortbein)
    Re: Splitting a difficult CSV file (Jim Michael)
    Re: taking in values from a form <maierc@chesco.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 07 Jul 1998 23:15:18 -0400
From: Webcruiser <dfsdf@ziplink.net>
Subject: Re: -- Abigail, A FIX to the space problem.
Message-Id: <35A2E446.2797@ziplink.net>

OK. I figured out that the html form doesn't like the @STATUS array. I
changed the form to use $STATUS instead. As far as reading the file from
the disk, I use the standard @STATUS = <FILE>, then I flatten the array
to a scaler variable as follows:

$numlines=@STATUS;   # determine the number of lines in the array
$STATUS="";          # clear out $STATUS
for ($x=0; $x<=$numlines; $x++){
	$STATUS = "$STATUS$STATUS[$x]";  # Build the $STATUS string
	}          

Now, when I pass the $STATUS variable as the default value to the form,
it picks up the string correctly, with line breaks and no leading space.

Crazy way to do this, but it now does what I want it to do.
Thanks again to all who contributed to my problem (Tom & Tad).


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

Date: Wed, 8 Jul 1998 22:07:25 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: -- Abigail, Another Observation
Message-Id: <d5c1o6.3h8.ln@localhost>

Webcruiser (dfsdf@ziplink.net) wrote:
: Abigail, I did some more analysis by taking the @STATUS variable and
: writing it to a file called debug.dta, using the &updatestatus routine
: in my program. Up to the point where the code shown below is called, the
: debug.dta file shows the file WITHOUT spaces! Once the form code is
: called, the @STATUS variable gets screwed up. Here is the code section:
                                                            ^^^^^^^^^^^^

That's not code.

That's markup.


:  <table border="1" cellpadding="0" cellspacing="0" width="100%"
: bgcolor="#89D8FA">
:     <tr>
:       <td width="20%" valign="top"><strong><font face="Arial">Account
: Status:</font></strong></td>
:       <td width="80%"><textarea rows="10" name="STATUS"
: cols="50">@STATUS</textarea></td>
            ^^^^^^^


Oh. Maybe it *is* code.

But it surely won't parse, it is not a complete statement. 

You have left off some parts of the statement.

The part you left off is germaine to getting your question answered.

So, I'll guess that this is a fragment of a "here doc" statement?

Something like:

print <<END_HTML;
<table border="1" cellpadding="0"...
 ... more tag soup here...
<textarea rows="10" name="STATUS" cols="50">@STATUS</textarea></td>
END_HTML



Correct?

If so, then I will eventually get to answering your question below  ;-)


:     </tr>
:   </table>

: Only at this point does the @STATUS info get displayed with spaces after
: the first line. Of course, unless I delete them out, the info gets saved
: that way.

: What would be causing this? 


The $" special variable is causing this.     <=== answer is here

Look it up in the 'perlvar' man page.


: Is it anything I have control over? 

Yes, see below.


: At least
: I know nothing is wrong with the rest of the PERL code.
                                               ^^^^


There is LOTS, really, LOTS wrong with the rest of your perl code
(though they do not have anything to do with this extra space problem).

1) You are in extreme, dire, urgent, immediate need of a "use strict"
   pragma. 

   Your other post contained a couple of subroutines with
   a whole bunch of *global* variables in them. Global variables are
   Bad. You should only make them global when they really must be
   global. They do not need to be global in those subs. Declare them
   with my(), or be prepared to have their values change willy nilly
   when the same variable is used for different things in different
   places...


2) You are trying to decode the form data yourself rather than using
   one of the modules that was specifically designed to decode
   form data...


(writing "PERL" rather than "Perl" or "perl" marks you as not really
 "up to speed" in regards to Things Perl too. You might want to see:

   What's the difference between "perl" and "Perl"?

 in perlfaq part 1...
)


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

OK. Now we can get to answering your question.

A here-doc with no quotes is "double quotish", that is, it acts
as if it was in a double quoted string.

My guess above is exactly the same as if I had written:

print <<"END_HTML";
<table border="1" cellpadding="0"...
 ... more tag soup here...
<textarea rows="10" name="STATUS" cols="50">@STATUS</textarea></td>
END_HTML

Note the double quotes around the first string terminator.

By now you will have had a look at the $" special variable in the
perlvar man page, so you know what happens to arrays (such as @STATUS)
when they are interpolated into a double quoted string (or similar 
interpreted string).

(what happens is that a space is inserted between each array element. 
 Sound familiar?  ;-)
)

So, you need to either:

1) don't print the array in a double quotish place,

or

2) change the value of $" (probably localizing it before changing it too).

or

3) join the array elements into a single scalar yourself, and then
   print the scalar in the double quotish place.


-----
Code for #1:

print <<'END_HTML';   # single quotish string here, no interpolation needed
<table border="1" cellpadding="0"...
 ... more tag soup here...
<textarea rows="10" name="STATUS" cols="50">
END_HTML

print @STATUS;   # no double quotes here

print <<'END_HTML';
</textarea></td>
END_HTML


-----
Code for #2:

{ 
local $";  # wrap in a BLOCK and localize it

print <<"END_HTML";
<table border="1" cellpadding="0"...
 ... more tag soup here...
<textarea rows="10" name="STATUS" cols="50">@STATUS</textarea></td>
END_HTML
}


-----
Code for #3:

$STATUS = join '', @STATUS;  # join with null strings

# now print $STATUS instead of @STATUS...

print <<"END_HTML";
<table border="1" cellpadding="0"...
 ... more tag soup here...
<textarea rows="10" name="STATUS" cols="50">$STATUS</textarea></td>
END_HTML


: Thanks for all your help. I made me look harder at the program to get
: this far.


Good luck!


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


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

Date: 9 Jul 1998 03:29:20 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: -- Abigail, Another Observation
Message-Id: <6o1deg$6br$2@client3.news.psi.net>

Webcruiser (dfsdf@ziplink.net) wrote on MDCCLXXII September MCMXCIII in
<URL: news:35A2B6C0.2502@ziplink.net>:
++ 
++ What would be causing this? Is it anything I have control over? At least
++ I know nothing is wrong with the rest of the PERL code.


I've told you already why.



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Wed, 8 Jul 1998 21:21:55 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: -- Abigail, Here's an update for you.
Message-Id: <3g91o6.5c8.ln@localhost>

Webcruiser (dfsdf@ziplink.net) wrote:


: It
: turns out that the spaces come in when I load the @STATUS as the default
: value in the form. 

   That is not where they are coming from.

   The are coming from a print() statement somewhere...


[ snip code that has not a single print() statement in it ]


: Somewhere in here the leading space is added to each line after the
: first line. 


   This statement is a dead giveaway that points all experienced
   perlers directly to the problem.

   It has been seen here many times before.

   I think this should be added to the FAQ...


: Can you figure this out?

   Yes.

   See my followup to your other post for the answer.



[ When you post to a Usenet newsgroup, you are speaking to everyone
  in the community. Individual correspondence is better conducted
  via email. Please stop addressing your posts to individuals,
  unless you have a question directly relating to something that
  the individual said/wrote.

  (and you don't have such a direct question here. Or you neglected
   to quote what Abigail wrote that you wish to discuss...)
]


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


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

Date: 9 Jul 1998 03:27:51 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: -- Abigail, Here's an update for you.
Message-Id: <6o1dbn$6br$1@client3.news.psi.net>

Webcruiser (dfsdf@ziplink.net) wrote on MDCCLXXI September MCMXCIII in
<URL: news:35A2B07F.415B@ziplink.net>:
++ Abigail, I did some more testing, calling the &getstatus and
++ &updatestatus subroutines directly, bypassing the html form. I looed at
++ the disk file and sure enough, the file was mot modified with spaces! It
++ turns out that the spaces come in when I load the @STATUS as the default
++ value in the form. The leading space shows up in the form, and becomes
++ written to the output file. I still can't force it to go away. Here is
++ the code that reads the environment variables and makes the variables:
++ 
++ sub form_parse  {
++ 	# Get the input 
++ 	read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

use CGI or die ();




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


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

Date: 08 Jul 1998 22:01:32 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <ltemvv7pfn.fsf@asfast.com>

mgjv@comdyn.com.au (Martien Verbruggen) writes:

> In article <lthg0r7sln.fsf@asfast.com>,
> 	Lloyd Zusman <ljz@asfast.com> writes:
> 
> >   unless (Getopt::Std::getopts('a')) {
> >     die "usage: $program [ -a ] ...\n";
> >   }
> > 
> >   if (defined($opt_a)) {
> >     handleOptionA();
> >   }
> 
> [snip]
> 
> >   Name "main::opt_a" used only once: possible typo at testscript line 12.
> 
> > Of course I could make this warning go away by strategically inserting
> > a `my $opt_a;', 
> 
> That won't work. You'll need use vars qw( $opt_a );

Inserting a `my $opt_a;' prior to the `getopts' call definitely
eliminated the warning message for me.  I didn't post my previous
message until I tested that case ... and yes, I did keep the `-w'
flag during that test.

This occurred when using Perl 5.004_04.  Perhaps the behavior you're
describing occurs in a different version.

> > or by making use of the second, hash-reference
> > argument to `getopts'.
> 
> You can also switch off the warnings around your getopts part of the
> code.

Yep.  That's another possibility.

> [ ... ] I would call this a problem with getopts, not with perl.

I don't consider it a problem with Perl at all, nor with `getopts',
for that matter ... just a behavior I was reporting as a way of
showing that there might actually be one or more valid, real-world
cases where a warning generated by `-w' is not "dangerous".

> [ ... ] And I would even go so far to say that I think that maybe
> getopts should never have allowed the silent setting of these
> variables. It should enforce the use of a hash or provide access
> methods to variables within the package. This behaviour is even
> worse than having non-private variables.
>
> But that's a different issue, and a different discussion :)

Agreed.  :)


-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: 9 Jul 1998 02:30:33 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <6o1a09$1p1$1@comdyn.comdyn.com.au>

In article <ltemvv7pfn.fsf@asfast.com>,
	Lloyd Zusman <ljz@asfast.com> writes:

>> > Of course I could make this warning go away by strategically inserting
>> > a `my $opt_a;', 
>> 
>> That won't work. You'll need use vars qw( $opt_a );
> 
> Inserting a `my $opt_a;' prior to the `getopts' call definitely
> eliminated the warning message for me.  I didn't post my previous
> message until I tested that case ... and yes, I did keep the `-w'
> flag during that test.

Ok, it does eliminate the warning, but it also prevents you from
accessing the 'global' $opt_a. Instead you'll be accessing a locally
scoped $opt_a. In other words: getopts will be setting $::$opt_a, and
you will have to refer to that $opt_a. Of course, this will once again
start warning messages appearing.

Let me rephrase it:

The best way of stopping the warnings, if you must use those globals,
is with use vars. locally scoping $opt_a with my will not work,
because the Getopt::Std module will not have access to that variable,
and therefore cannot set it.

Try this:

#!/usr/local/bin/perl -w
use strict;

use Getopt::Std;

# This is just the same as starting up the script with -a 2 as options
push(@ARGV, '-a', '2');

my $opt_a;

getopts("a");

if (defined $::opt_a)
{
	print "Got 'a' global\n";
}
if (defined $opt_a)
{
	print "Got 'a' local\n";
}

__END__

This will generate a warning, but it will demonstrate which of the two
variables is actually set.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd.       | make a better idiot.
NSW, Australia                      | 


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

Date: Thu, 09 Jul 1998 03:38:57 GMT
From: "Michael D. Schleif" <mike.schleif@aquila.com>
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <35A43A8F.567E8279@aquila.com>

I am very pleased to see Tom take this position.  I, for one, have been
wondering, with all of this noise on p5-porters, whether this
philosophy, that I mirror, is ill-begotten.

I came upon this thread only today.  When I began with Tina's reply, I
asked myself, "Self, if her developers are NOT using -w during
development, which it appears that they are not, then what other
surprises are waiting for her?  Screensful of -w errors would frighten
me to death!"

But, then I sat back and waited to see comments from the illuminati. 
Clearly, they can take advantage of their years of Perl coding
experience and forsake the long road of writing to -w.  As far as I am
concerned, I do not have confidence that any of the available shortcuts
will not trip me up on some unforeseen consequence of same shortcut.

When I write code "-w clean and use strict clean," and this under a
rigorous test plan, then I know that I have done the best that can be
done to alleviate unforeseen coding pitfalls.  With only a few years
experience, though, training wheels are quite a boon to me!

Thanks, Tom, perhaps there is hope for me . . .

Tom Christiansen wrote:
> Everything I write that takes more than two minutes to type in is done
> -w clean and use strict clean.  I feel much safer that way.  And I leave
> those in for production so that when conditions change that I wasn't
> expecting, I find the bugs in my code I didn't know about.  This has
> happened often enough that I consider it important to keep.  Imagine if
> someone told you that it was fine to develop your program under memory
> protection, but that for production, those checks would be removed.
> Nutty, I tell you.

-- 

Best Regards,

mds
mds resource
888.250.3987

"Dare to fix things before they break . . . "

"Our capacity for understanding is inversely proportional to how much we
think we know.  The more I know, the more I know I don't know . . . "


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

Date: 08 Jul 1998 23:42:24 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <lt67h77krj.fsf@asfast.com>

mgjv@comdyn.com.au (Martien Verbruggen) writes:

> In article <ltemvv7pfn.fsf@asfast.com>,
> 	Lloyd Zusman <ljz@asfast.com> writes:
> 
> >> > Of course I could make this warning go away by strategically inserting
> >> > a `my $opt_a;', 
> >> 
> >> That won't work. You'll need use vars qw( $opt_a );
> > 
> > Inserting a `my $opt_a;' prior to the `getopts' call definitely
> > eliminated the warning message for me.  I didn't post my previous
> > message until I tested that case ... and yes, I did keep the `-w'
> > flag during that test.
> 
> Ok, it does eliminate the warning, but it also prevents you from
> accessing the 'global' $opt_a. Instead you'll be accessing a locally
> scoped $opt_a. In other words: getopts will be setting $::$opt_a, and
> you will have to refer to that $opt_a. Of course, this will once again
> start warning messages appearing.
> 
> Let me rephrase it:

Not necessary.  I got it.

Entering a `local $opt_a;' also eliminates the warning, and it takes
care of the case you're referring to.

And ironically, one of the cases that eliminated the warning message
(the use of `my') was wrong, while the case where the warning showed
up (no pre-declaration of `$opt_a') actually exhibited the correct
behavior.

Of course, there are an infinite number of wrong ways to do things
which could conceivably inhibit warning messages that might otherwise
appear, so this isn't a particularly interesting point to make.
However, the other side of this irony is more pertinent: the fact that
perfectly correct behavior was flagged with a warning goes to show
that at least once in a while, `-w' causes a message to be output for
perfectly benign, non-"dangerous" constructs.

> [ ... ]

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: Thu, 09 Jul 1998 03:48:56 GMT
From: "Michael D. Schleif" <mike.schleif@aquila.com>
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <35A43CE9.12DE4274@aquila.com>

Wow!

This is really the coolest thread in quite sometime!

Let me toss this bone to the wolves:

	If "-w" and "use strict" were compiled-in-standard in Perl, how would
that affect the postings to clpm?  What would change here?

-- 

Best Regards,

mds
mds resource
888.250.3987

"Dare to fix things before they break . . . "

"Our capacity for understanding is inversely proportional to how much we
think we know.  The more I know, the more I know I don't know . . . "


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

Date: 9 Jul 1998 03:58:34 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <6o1f5a$6lf$2@client3.news.psi.net>

Lloyd Zusman (ljz@asfast.com) wrote on MDCCLXXIII September MCMXCIII in
<URL: news:lthg0r7sln.fsf@asfast.com>:
++ 
++ Consider the following fairly typical usage of the Getopt::Std module:
++ 
++   #!/usr/bin/perl -w
++   # -*- perl -*-
++ 
++   ($program = $0) =~ s:^.*/::;
++ 
++   use Getopt::Std;
++ 
++   unless (Getopt::Std::getopts('a')) {
++     die "usage: $program [ -a ] ...\n";
++   }
++ 
++   if (defined($opt_a)) {
++     handleOptionA();
++   }
++ 
++ This generates the following warning under `-w':
++ 
++   Name "main::opt_a" used only once: possible typo at testscript line 12.

use vars qw /$opt_a/;

Needed anyway, because you want 'use strict;' too!

++ Sure, this is *potentially* dangerous, but it takes someone who
++ understands Perl less than a second to realize that in actuality,
++ there is nothing harmful or dangerous about this particular case at
++ all.
++ 
++ Of course I could make this warning go away by strategically inserting
++ a `my $opt_a;', or by making use of the second, hash-reference

No... my $opt_a would be wrong. There's no way Getopt::Std is touching
your lexicals.



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Wed, 8 Jul 1998 20:36:50 -0700
From: "Calgary News" <b1233@hotmail.com>
Subject: Asking for some info for a beginner, Please read i really need some help here i so confused its not even funny
Message-Id: <6o1aga$8od@priv-sys04-le0.telusplanet.net>

Okay, i wanted to make a page that allows the user to enter data and then
have that data added to another page that showed all the data from other
people who have entered comments before them

On this search to learn how to do this, i have been lead to cgi and then to
perl, and now i am so messed up i have no idea which way is up

what is perl, cgi, is there any place for dummies wanting to learn this
language. i have used turbo pascal before, so i have some knowledge but i
can't find a site that explains in detail every line so that i can write my
own cgi and perl, and explains who these two work together




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

Date: 08 Jul 1998 19:15:24 -0700
From: Sanford Morton <smorton@pobox.com>
Subject: Re: Bar and Line Charts in Perl
Message-Id: <m367h7vkg2.fsf@pobox.com>

kelly@whitman.edu (Kevin Kelly) wrote:
>
> I would like to make bar or line graphs that I can update daily and put on a
> web page.  I know about the GD.pm module, but is there anything that will
> create a basic line or bar chart.  I have been making these charts using
> Excel, but there is no way to automate the process.

If you're not wedded to Excel, several modules are front ends for GD,
including GIFgraph, Chart::* and Chart::Plot. 

  CPAN/modules/by-category/18_Images_Pixmaps_Bitmaps/

Unless you know lots about OLE, one of these may be easier.

Sanford Morton


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

Date: 8 Jul 1998 22:08:07 -0500
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: Choosing DBMS: friendly to Linux, Apache, Perl, Java
Message-Id: <6o1c6n$7sr$1@Venus.mcs.net>

In article <6o0p5d$a80$1@nnrp1.dejanews.com>,  <gordo@pclink.com> wrote:
>I know that this question probably doesn't have a simple answer, and in
>fact I probably need lots of help just to formulate a better question,
>and maybe I'm not asking in the right place, either....  Anyway, here
>goes.
>
>I am just in the process of setting up Apache 1.3 on a small Linux (home
>office) server running RedHat 5.1.  I need a database backend for Apache
>and other uses, including Java and CORBA code and data repository.  I
>use Perl for most work so it's a plus if there already is a DBD module
>out there for the database.

Redhat should have postgresql already working out of the box.  Add
DBD::Pg and you should be set.  Note that RedHat moves some components
around to match their concept of where files should live and this
will cause some problems if you try to recompile a newer version from
original source unless you delete it all first.

>Database need not be free of cost or licensing restrictions.  Closer to
>ANSI-92(?) is better and probably closer to Oracle 7.3 is even better though
>I suppose that's a dream--until I started digging into this I didn't realize
>just how proprietary much of Oracle's working and development environment is.

Postgresql is close to standard sql (still lacks HAVING clause) and
lets you add functions, but it doesn't have a back-end programming
language.

  Les Mikesell
    les@mcs.com


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

Date: 9 Jul 1998 03:32:16 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Do I understand this?
Message-Id: <6o1dk0$6br$3@client3.news.psi.net>

Phillip George Geiger (geiger@cs.ucdavis.edu) wrote on MDCCLXXIII
September MCMXCIII in <URL: news:6o125p$54j$1@mark.ucdavis.edu>:
++ Abigail (abigail@fnx.com) wrote:
++ : Please read the RFC.
++ 
++ Thanks for the suggestion.  I'll look into it.
++ 
++ : This is not a Perl question.
++ 
++ My apologies if it's off topic here.  Which newsgroup would be a 
++ better place to ask it?


Some newsgroups with 3 w's in a row.



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


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

Date: 9 Jul 1998 02:30:25 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: explaining the whys of referencing... WAS Re: on the fly subs with special tag markers
Message-Id: <6o1a01$pur$3@news.iastate.edu>

Larry Rosler (lr@hpl.hp.com) wrote:
: In article <6o0lp4$a56$1@rand.dimensional.com> on Wed, 08 Jul 1998 
: 21:00:07 GMT, Daniel Grisinger <dgris@rand.dimensional.com> says...
: > In article <MPG.100d4e2f1fbc74ac9896f3@nntp.hpl.hp.com>
: > lr@hpl.hp.com (Larry Rosler) wrote:
: ...
: > >Understanding and using references may be the boundary between novice
: > >and intermediate in Perl programming, like switching from snowplow turns
: > >to stem turns in skiing.  Welcome to Middle School. :-)
: > 
: > Just curious, but where would you put your hypothetical division
: > between intermediate and advanced perl?  Personally I'd say that
: > effective use of C<eval> and regular expressions separate the two, 
: > but that's just my opinion :-).

: I use eval '...' and regexes effectively (for example, matching several 
: patterns specified at run time against a long list), and consider myself 
: an intermediate.

: Perhaps the boundary is between Chapter 5 and Chapter 6 of the Panther.  
: I'm making at least some use of everything before then and *nothing* 
: after then.  Of course, I may never make use of OOP, as I have yet to be 
: involved in a programming situation that benefits from it.  I think I'm 
: stuck with Structured Programming forever.

The OOP chapters don't do much for me yet either. Yes, I can read
them, but I don't have much cause to use them for anything. It's
difficult to think of any examples offhand that make OOP seem useful,
especially since I'm not in any sort of Team Programming situation.

However, I think that boundary might be very different for someone
used to OOP. Perhaps something to do with just writing more idiomatic
perl. A lot of the stuff after Ch. 7 in the Panther is still OO.
IMO the network stuff was easier, and the Tk stuff looks pretty basic
(since I've done Mac GUI junk before).

The last two chapters look much meatier. I haven't read them yet. :)


Josh

--

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



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

Date: 9 Jul 1998 02:04:47 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: fcntl - How do I call it with F_GETLK?
Message-Id: <6o18fv$1hp$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    "Larry P. Rosen" <lrosen@alum.mit.edu> writes:
:The perl fcntl() is just a wrapper to the c/unix
:fcntl().  When you call the fcntl() in c/unix
:with the F_GETLK, the 3rd argument is a pointer
:to the flock data structure:
:struct flock {
:   short l_type;
:   off_t l_start;
:   short l_whence;
:   off_t l_len;
:   pid_t l_pid;
:};
:
:The camel book says fcntl passes "a pointer to the
:string value of SCALAR", where SCALAR is the third
:argument to the function.  I don't understand this
:and don't understand how to use it.  It also isn't
:clear what the return value of fcntl will be when
:a lock exists or when a lock doesn't exist.
:
:Any help appreciated.  Thanks.

Prepare to be afraid.  Very afraid.  But there is beauty below also,
if you but look to it.

--tom

#!/usr/bin/perl -w
# lockarea - demo record locking with fcntl

use strict;

my $FORKS = shift || 1;
my $SLEEP = shift || 1;

use Fcntl;
use POSIX qw(:unistd_h :errno_h);

my $COLS = 80;
my $ROWS = 23;

# when's the last time you saw *this* mode used correctly?
open(FH, "+> /tmp/lkscreen")            or  die $!;

select(FH);
$| = 1;
select STDOUT;

# clear screen
for (1..$ROWS) {
    print FH " " x $COLS, "\n";
}

my $progenitor = $$;
fork while $FORKS-- > 0;

print "hello from $$\n";

if ($progenitor == $$) {
    $SIG{INT} = \&genocide;
} else {
    $SIG{INT} = sub { die "goodbye from $$" };
}

while (1) {
    my $line_num = int rand($ROWS);
    my $line;
    my $n;

    # move to line
    seek(FH, $n = $line_num * ($COLS+1), SEEK_SET)              or next;

    # get lock
    my $place = tell(FH);
    my $him;
    next unless defined($him = lock(*FH, $place, $COLS));

    # read line
    read(FH, $line, $COLS) == $COLS                             or next;
    my $count = ($line =~ /(\d+)/) ? $1 : 0;
    $count++;

    # update line
    seek(FH, $place, 0)                                         or die $!;
    my $update = sprintf($him
			? "%6d: %d ZAPPED %d"
			: "%6d: %d was just here",
		    $count, $$, $him);
    my $start = int(rand($COLS - length($update)));
    die "XXX" if $start + length($update) > $COLS;
    printf FH "%*.*s\n", -$COLS, $COLS, " " x $start . $update;

    # release lock and go to sleep
    unlock(*FH, $place, $COLS);
    sleep $SLEEP if $SLEEP;
}
die "NOT REACHED";				# just in case

# lock($handle, $offset, $timeout) - get an fcntl lock
sub lock {
    my ($fh, $start, $till) = @_;
    ##print "$$: Locking $start, $till\n";
    my $lock = struct_flock(F_WRLCK, SEEK_SET, $start, $till, 0);
    my $blocker = 0;
    unless (fcntl($fh, F_SETLK, $lock)) {
	die "F_SETLK $$ @_: $!" unless $! == EAGAIN || $! == EDEADLK;
	fcntl($fh, F_GETLK, $lock)          or die "F_GETLK $$ @_: $!";
	$blocker = (struct_flock($lock))[-1];
	##print "lock $$ @_: waiting for $blocker\n";
	$lock = struct_flock(F_WRLCK, SEEK_SET, $start, $till, 0);
	unless (fcntl($fh, F_SETLKW, $lock)) {
	    warn "F_SETLKW $$ @_: $!\n";
	    return;  # undef
	}
    }
    return $blocker;
}

# unlock($handle, $offset, $timeout) - release an fcntl lock
sub unlock {
    my ($fh, $start, $till) = @_;
    ##print "$$: Unlocking $start, $till\n";
    my $lock = struct_flock(F_UNLCK, SEEK_SET, $start, $till, 0);
    fcntl($fh, F_SETLK, $lock) or die "F_UNLCK $$ @_: $!";
}

# OS-dependent flock structures

# Linux struct flock
#   short l_type;
#   short l_whence;
#   off_t l_start;
#   off_t l_len;
#   pid_t l_pid;
BEGIN {
    # c2ph says: typedef='s2 l2 i', sizeof=16
    my $FLOCK_STRUCT = 's s l l i';

    sub linux_flock {
	if (wantarray) {
	    my ($type, $whence, $start, $len, $pid) =
		unpack($FLOCK_STRUCT, $_[0]);
	    return ($type, $whence, $start, $len, $pid);
	} else {
	    my ($type, $whence, $start, $len, $pid) = @_;
	    return pack($FLOCK_STRUCT,
		    $type, $whence, $start, $len, $pid);
	}
    }

}

# SunOS struct flock:
#   short   l_type;         /* F_RDLCK, F_WRLCK, or F_UNLCK */
#   short   l_whence;       /* flag to choose starting offset */
#   long    l_start;        /* relative offset, in bytes */
#   long    l_len;          /* length, in bytes; 0 means lock to EOF */
#   short   l_pid;          /* returned with F_GETLK */
#   short   l_xxx;          /* reserved for future use */
BEGIN {
    # c2ph says: typedef='s2 l2 s2', sizeof=16
    my $FLOCK_STRUCT = 's s l l s s';

    sub sunos_flock {
	if (wantarray) {
	    my ($type, $whence, $start, $len, $pid, $xxx) =
		unpack($FLOCK_STRUCT, $_[0]);
	    return ($type, $whence, $start, $len, $pid);
	} else {
	    my ($type, $whence, $start, $len, $pid) = @_;
	    return pack($FLOCK_STRUCT,
		    $type, $whence, $start, $len, $pid, 0);
	}
    }

}

# (Free)BSD struct flock:
#   off_t   l_start;        /* starting offset */
#   off_t   l_len;          /* len = 0 means until end of file */
#   pid_t   l_pid;          /* lock owner */
#   short   l_type;         /* lock type: read/write, etc. */
#   short   l_whence;       /* type of l_start */
BEGIN {
    # c2ph says: typedef="q2 i s2", size=24
    my $FLOCK_STRUCT = 'll ll i s s';   # XXX: q is ll

    sub bsd_flock {
	if (wantarray) {
	    my ($xxstart, $start, $xxlen, $len, $pid, $type, $whence) =
		unpack($FLOCK_STRUCT, $_[0]);
	    return ($type, $whence, $start, $len, $pid);
	} else {
	    my ($type, $whence, $start, $len, $pid) = @_;
	    my ($xxstart, $xxlen) = (0,0);
	    return pack($FLOCK_STRUCT,
		$xxstart, $start, $xxlen, $len, $pid, $type, $whence);
	}
    }
}

# alias the fcntl structure at compile time
BEGIN {
    for ($^O) {
	*struct_flock =                do                           {

				/bsd/  &&  \&bsd_flock
				       ||
			    /linux/    &&    \&linux_flock
				       ||
			  /sunos/      &&      \&sunos_flock
				       ||
		  die "unknown operating system $^O, bailing out";
	};
    }
}

# install signal handler for children
BEGIN {
    my $called = 0;

    sub genocide {
	exit if $called++;
	print "$$: Time to die, kiddies.\n" if $$ == $progenitor;
	my $job = getpgrp();
	$SIG{INT} = 'IGNORE';
	kill -2, $job if $job;  # killpg(SIGINT, job)
	1 while wait > 0;
	print "$$: My turn\n" if $$ == $progenitor;
	exit;
    }

}

END { &genocide }

__END__
-- 
    "No, I'm not going to explain it. If you can't figure it out, 
     you didn't want to know anyway..." --Larry Wall 


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

Date: Thu, 09 Jul 1998 02:25:35 GMT
From: gcarvell2@my-dejanews.com
Subject: Hash keys question
Message-Id: <6o19mv$4j5$1@nnrp1.dejanews.com>

I have a (probably dumb) hash/reference question (this is using perl
5.004_004). Basically my program started producing a lot of warnings
about "Ambiguous use of {a} resolved to {"a"}". This happened after I
added accessor functions to the class I was writing. This one-liner
illustrates what happened:

    perl -we 'sub a {}; $hash{a} = 1; $hash{b} = 1;'

The warning appears for {a}, but not for {b}. Given the explanations
in the Camel book (p. 42, bottom) and "man perlref" (quoted below), I
thought that anything within the braces would just be treated as a
string. Is that the case, or am I just missing something obvious?

If not, then one should always quote hash keys where the key conflicts
with a sub, correct? (This is assuming -w and "use strict").

Finally, looking at the Perl library code including LWP for
inspiration, I notice that some modules always quote hash keys (e.g.
refering to a member of an object's hash), and some never do. Can
someone explain why?

Thanks in advance for enlightening my ignorance...
Gary Carvell
gcarvell@wirefire.com


man perlref says:
> ... Similarly, because of all the subscripting that is done using
> single words, we've applied the same rule to any bareword that is
> used for subscripting a hash. So now, instead of writing
>                               --------------------------
>
>     $array{ "aaa" }{ "bbb" }{ "ccc" }
>     ---------------------------------
>
> you can write just
> ------------------
>
>     $array{ aaa }{ bbb }{ ccc }
>     ---------------------------
>
> and not worry about whether the subscripts are reserved words.

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


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

Date: Wed, 08 Jul 1998 22:42:44 -0500
From: Bobn <"postmaster"@[127.0.0.1]>
Subject: Re: How to use 'system ("...")' on WIN32.
Message-Id: <6o1du0$1t6$1@supernews.com>

Michael Pham wrote:
> 
> I have a script that calls another script using 'system()' function.
> It works fine on Unix.  I tried to port it to WIN32 and find that it
> does not work as expected.  Any WIN32 gurus?
> 
> Thanks in advance

The question isn't "how?", it's "why?".
{ set_troll_mode("off"); }


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

Date: Thu, 09 Jul 1998 14:49:09 +1200
From: Russell Fulton <r.fulton@auckland.ac.nz>
Subject: Re: NEVER "call warn() and return undef" (Re: question about objects)
Message-Id: <35A42FA5.1CB1C716@auckland.ac.nz>

Mark-Jason Dominus wrote:
> 
> I agree with your essential point.  But it's important to put the
> message somewhere that the program can get to it.  Printing it out to
> standard error is not such a place.  Errors should be propogated back
> up the call stack until they can be handled.  Whether to inform the
> user or not is a high-level decision and shouldn't be usurped by a
> module.

I implemented a system which used a stack to hold error messages, thus
as the call stack unwound after an error the error stack got built up. 
Normally you just want to look at the message on the top of the stack,
i.e. the message from the highest level module but, when things get
messy or its unclear why the error happened it is very useful to print
the whole error stack so you can see what actually failed and what the
intervening levels did about it.

It would be great to have a 'standard' module that handled errors in
this (or some other) way so we could integrate error handling in modules
without everyone reinventing the wheel (and nobody making an round one
;-)

Cheers, Russell.


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

Date: 9 Jul 1998 03:40:13 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: NEVER "call warn() and return undef" (Re: question about objects)
Message-Id: <899956151.387649@thrush.omix.com>

Russell Fulton <r.fulton@auckland.ac.nz> wrote:
: It would be great to have a 'standard' module that handled errors in
: this (or some other) way so we could integrate error handling in modules
: without everyone reinventing the wheel (and nobody making an round one

	Have you looked at Carp::confess()?
-- 
-Zenin
 zenin@archive.rhps.org


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

Date: 9 Jul 1998 02:06:14 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl and Win NT porting?
Message-Id: <6o18im$hn5$2@marina.cinenet.net>

Pascal7 (cycleman@usouthal.campus.mci.net) wrote:
: Hi, does anyone know where I can find information on Perl NT porting? Thank
: you.

Do you mean...

- Where to find a Perl executable for NT?

  www.perl.com or your favorite CPAN site.

- How to port Perl to NT?

  perl5porters mailing list.

- How to get a Perl app which runs elsewhere to work on NT?

  Ask us specific questions, we'll be glad to help.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 9 Jul 1998 02:37:41 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: Perl CGI and warnings [Was: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <6o1adl$pur$4@news.iastate.edu>

Mark W. Schumann (catfood@apk.net) wrote:
: I thought most httpds would run CGI code only if it were located in
: one in a list of specific directories given in a system-wide config
: file.  It can't be that hard to check those directories for active
: scripts.

I don't know which I prefer, really, using -w or not in order to
save work with CGIs, but some interesting data:

/home/kortbein% ls -l /var/local/httpd-cgi/*.* | wc
     183    1648   16130

That should be mostly scripts, plus or minus a few. That's an awful
lot of CGIs to hand-test, and I'm sure many sites have more.

If they weren't hand tested, it might take longer, given on how good
one's records for which CGI goes to which web page are (i.e. if you
had to hit all the CGIs normally from a browser).


Josh

--

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



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

Date: 9 Jul 1998 03:55:37 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl CGI and warnings [Was: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <6o1evp$6lf$1@client3.news.psi.net>

Mark W. Schumann (catfood@apk.net) wrote on MDCCLXXII September MCMXCIII
in <URL: news:6o0uda$ia8@junior.apk.net>:
++ 
++ I'm still trying to figure out where the CGI programs would be, other
++ than in /yaddayaddayadda/cgi-bin/.  Is that an odd out of the way
++ place?

But who cares where they are?

#!/usr/local/bin/perl -w

use strict;

my $FILE = "/usr/etc/webpeople";

local FILE;
open FILE, $FILE or die "Eeps: $!";
while (<FILE>) {
    chomp;
    open MAIL, qq '| elm -s "Perl upgrade" $_' or die "Oops: $!";
    print MAIL <<TEXT;
Hi,

Be aware that Perl will be upgraded to 5.004_05 Friday 10 July 1998
at 0.00. A version of 5.004_05 Perl can be found in /usr/local/bin/perl5.00405.

Please check your scripts.

The administration.
TEXT
    close MAIL or die "Aaaaiiii: $!";
}

__END__



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: Thu, 09 Jul 1998 02:05:01 GMT
From: zhlei@bj.china.com (zhanglei)
Subject: question about cgi-lib
Message-Id: <6o18fa$qo7@info.bta.net.cn>

 Hello! Mr. Steven E. Brenner and all:
 
I am a cgi-programmer useing your cgi-lib.pl.
When I use cgi-lib.pl Version 2.17, I find a strange error,"Short Read: wanted 
3590, got 0".
 
My part of program is here.

HTML program:
<form action="/cgi-bin/img.cgi">
<input type="text" name="imgamount" size="1" maxlength="1" value="1">
<input type="submit">
 
CGI program: img.cgi
 
#!/usr/bin/perl
 
require "./cgi-lib.pl";
 
print "Content-type: text/html\n\n";

&ReadParse(*in);
$img_amount = $in{'imgamount'};
print "img amount : $img_amount<BR>";
 
-------
Result appear a error "Short Read: wanted 3590, got 0".
 
------
second img.cgi :
 
#!/usr/bin/perl
 
require "./cgi-lib.pl";
 
print "Content-type: text/html\n\n";

&ReadParse(*in);
$img_amount = $in{'imgamount'};
print "img amount : $img_amount<BR>";
 
------
Result is : 
 
img amount : 0
 
 
These two different results, and both are error .
Please help me find reason, I will thanks a lot.
 
I am very honored and glad to be in touch with you by e-mail.
My e-mail is cleverlei@hotmail.com.
 
 
Thanks a lot.
Kind regards!
 
Hope your email soon !
 
Cindy Zhang
 


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

Date: 9 Jul 1998 02:18:39 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: question about objects
Message-Id: <6o199v$pur$2@news.iastate.edu>

Tye McQueen (tye@fohnix.metronet.com) wrote:
: As a few examples,

:     $val= shift;

: will silently change meaning depending on where it is.

Is there something inherently wrong with meaning depending on context?
The change isn't so silent if you understand a few basic perl concepts,
and know which functions expect which kinds of arguments.


Josh

--

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



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

Date: Thu, 9 Jul 1998 02:22:40 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Splitting a difficult CSV file
Message-Id: <genepoolEvt2Ls.HJr@netcom.com>

Matthew Giles (mgiles@mindspring.com) wrote:

: I am totally stumped on how to split this Excel exported CSV file that is
: being delivered to me each day.  I'm trying to read the file in and spit
: out an HTML document with the three nicely formatted tables.  I could read

Each line looked consistent throughout the file (7 data elements per
line), so I would look for the beginning of each table entry as I looped
through the file splitting each line on ',' and handle the differences in 
the data sets accordingly. This looks like the csv formatted output from 
a website, so one would wonder if the html wasn't also available? Usually 
you would want the csv so you could import into a database, rather than 
recreating a table.

Cheers,

Jim



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

Date: Thu, 09 Jul 1998 02:21:14 GMT
From: Charles Maier <maierc@chesco.com>
Subject: Re: taking in values from a form
Message-Id: <35A25626.15E3@chesco.com>

Howard Dierking wrote:
> 
> when a form returns the query string to my perl app, does it just retun
> those fields that have a value?  I guess my real question is, is there a way
> for me to determine if or if not a check box was checked?

Not a perl question.. but the form submission to perl contains all the
form's elements... checked or not. If it is a checkbox... it typically
contains "on" if no value is defined. Testing for empty works for most
cases.

-- 
Chuck Maier
CDM Consulting Services
http://www.cdmcon.com
(610) 943-2726


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

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

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