[11116] in Perl-Users-Digest
Perl-Users Digest, Issue: 4716 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 21 22:06:13 1999
Date: Thu, 21 Jan 99 19:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 21 Jan 1999 Volume: 8 Number: 4716
Today's topics:
Re: ancestry of perl features <dgris@moiraine.dimensional.com>
Re: CGI.pm Warnings <xah@bpower.com>
CGI/Perl: passing information to SSI? <mmorgan@gladstone.uoregon.edu>
deleting hash entries (Lori Flynn )
Re: deleting hash entries <rick.delaney@home.com>
Re: finding dirs with readdir (Andre L.)
Re: Finding if a file exists (Abigail)
fortran to C or perl <zotz@franchiseloan.com>
Re: How do I define a scalar name with a scalar (Abigail)
Re: How to set keyboard timeout <rick.delaney@home.com>
Re: Is there an HTML to CGI.pm converter?? (Abigail)
Re: length($string) in UNIX environment (Abigail)
Re: list of hashes (Abigail)
Re: NT and Perl problem <m_ching@hotmail.com>
Re: open() "bad file number" help! <m_ching@hotmail.com>
Re: Oracle from Linux <jim.michael@gecm.com>
Re: Pattern match behaves strangely (Tad McClellan)
Re: Perl Criticism <mds-resource@mediaone.net>
Perl5.00502 and @INC <clancy@eri.uchsc.edu>
Problems using Perl and Cygnus Bash randall_burns@hotmail.com
Re: Random Invoice # (Martien Verbruggen)
Re: Random Invoice # <m_ching@hotmail.com>
Re: Reading a log file from an HTML Page (Martien Verbruggen)
Return a blank form <darrensw@ix.netcom.com>
Re: Trying to match a variable with another variable. <STEVENHENDERSON@prodigy.net>
Re: undefined value warning when it is defined <rick.delaney@home.com>
whois search <hitbyabus@mindspring.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 Jan 1999 15:07:55 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: ancestry of perl features
Message-Id: <m37lug7004.fsf@moiraine.dimensional.com>
droby@copyright.com writes:
> Pardon me, I just realized I'm older than Fortran.
Wow! I'm younger than unix. :-)
dgris
- thinks age is mostly irrelevant
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Thu, 21 Jan 1999 17:11:31 -0800
From: "Xah Lee" <xah@bpower.com>
Subject: Re: CGI.pm Warnings
Message-Id: <788j8e$78f$1@remarQ.com>
>...
>... (discussion on the keyword naming aspects of CGI.pm module)...
The keyword naming is just a small area that CGI.pm really shines. Please
allow me to elaborate.
Sometimes a keyword MUST be preceded by a dash, sometimes the first letter
MUST be capitalized, and with all that, sometimes the quote is necessary to
prevent error messages when using "use strict".
A good design could use a consistent naming scheme (for ONE example: Cap all
first letters, no dash) and run smoothly under 'use strict': "but hey! it
ain't gonna be timtowtodi anymore, besides, we impatient, lazy, and
fantastically supercilious unix hackers can't be bothered to read docs, type
caps, or waste time to understand your consistency mumble-jumble. We just
want something that works out of the box as the way we intuitively would
type it."
Xah
xah@best.com
http://www.best.com/~xah/PageTwo_dir/more.html
"Windoz: a monstrous hack of greed;
unix: a monstrous hack of stupidity;
GNU: stamps out greed, stamps out stupidity."
In article <waa7luhibjp.fsf@ese.UCSC.EDU> , hermit@cats.ucsc.edu (William R.
Ward) wrote:
> "Neil Edmondson" <neiled@enteract.com> writes:
>> austin@mathworks.com wrote in message <77fkff$q26$1@turing.mathworks.com>...
>> >In comp.lang.perl.modules dave@mag-sol.com wrote:
>> >
>> >> To get round it, put values in single quotes when using it as a hash key.
>> >
>> >Or use -value instead of -values .
>>
>> single quotes work fine ... -value gives me the same warning. -style also
>> falls victim .... so i think from now on I'm just going to put the single
>> quotes around 'em all - if I remember.
>
> Since CGI.pm is case-insensitive about these things, you can also just
> use all caps for the argument names. Since there are no all-uppercase
> builtins, there can never be any conflicts. And that way you don't
> have to use any ugly quote marks.
>
> --Bill.
------------------------------
Date: Thu, 21 Jan 1999 17:05:36 -0800
From: "M. Morgan" <mmorgan@gladstone.uoregon.edu>
Subject: CGI/Perl: passing information to SSI?
Message-Id: <788ii3$6r$2@pith.uoregon.edu>
Hello,
This is a CGI/Perl question but I'm hoping you can help.
I have an SHTML document that has SSI (server-side includes) in it. The SSI
is:
<!--#exec cmd="perl myscript.cgi"-->
I need to be able to pass information to the SSI as if I were to execute the
CGI with appended $ENV{QUERY_STRING} from a web browser, i.e
http://www.somewhere.com/mydir/myscript.cgi?myquery
The SSI appears to be running from a command line on the server, so in that
case how do I pass information to a perl script from the command line? Or
am I missing it completely? Does anyone have a simple answer to this
question?
-Mike Morgan
------------------------------
Date: 22 Jan 1999 01:06:08 GMT
From: lori@cse.ucsc.edu (Lori Flynn )
Subject: deleting hash entries
Message-Id: <788iu0$2nj@darkstar.ucsc.edu>
Hi Everyone,
I'm having some trouble deleting an old hash entry. Any help would be **greatly**
appreciated!!
Here's the problem (the code at the bottom explains it the best,
actually!):
----------------------------------------------------------------
I create a complex hash (outer hashtable structure which contains
as one of the fields an inner hashtable) in the main function, and enter
within the inner hashtable, with a key of 6, *another* hashtable. (Thus there
are *3* hashtables, the latter being the innermost.)
Then, I call a function (subroutine) which copies the innermost hashtable
(the one with the key of 6) to a local hashtable, and changes a value within
the copied hashtable. Now the changed hashtable is re-entered into the
globally accessible outermost hashtable, but this time using a key of 5. This
is done within the subroutine.
All of the above WORKS. After returning to the main part of the program,
the outermost hash has the correct values entered for the key of 5.
PROBLEM: How do I get rid of the hash entry address for 6, within the function?
If I do
delete(outerHash->{innerHash}{6});
within the subroutine, I get some confusing results.
After that line, in the subroutine, when I write
print("address is outerHash->{innerHash}{6} (should be null)\n");
I get null. Good!
BUT... if I write the same thing, *after* the function
call, in the main part of the program,
print("address is outerHash->{innerHash}{6} (should be null)\n");
gives me an address!! Bad!!!
Anybody have ideas about what I can do to fix it so I won't have a hash remaining for the
key of 6 in the main part of the program, after deleting it in the subroutine?
-Lori
code example below:
###############################################################
#! /usr/local/bin/perl -w
use diagnostics;
sub subroutine;
$innerHash =
{
valueOne => 1,
valueTwo => 2,
valueThree => 3,
};
$middleHash->{6} = $innerHash;
$wayTopHash =
{
hash => $middleHash,
other => 0,
};
subroutine(); #subroutine call
print("After subroutine call value $wayTopHash->{hash}{5}->{valueOne} should be 100 \n");
#CORRECT
print("After subroutine call address $wayTopHash->{hash}{6} should be null \n");
#WRONG!!
print("After subroutine call value $wayTopHash->{hash}{6}->{valueOne} should be null \n");
#WRONG!!
sub subroutine
{
my %thisHash = ();
$thisHash = $wayTopHash->{hash}{6};
$thisHash->{valueOne} = 100;
$wayTopHash->{hash}{5} = $thisHash;
delete($wayTopHash->{hash}{6});
print("End of subroutine call value $wayTopHash->{hash}{5}->{valueOne} should be 100 \n");
print("End of subroutine call address $wayTopHash->{hash}{6} should be null \n");
print("End of subroutine call value $wayTopHash->{hash}{6}->{valueOne} should be null \n");
}
OUTPUT OF PROGRAM (problem has ****> before line):
End of subroutine call value 100 should be 100
End of subroutine call address should be null
Use of uninitialized value at post.pl line 41 (#1)
End of subroutine call value should be null
After subroutine call value 100 should be 100
*****> After subroutine call address HASH(0x1141a0) should be null
After subroutine call value should be null
------------------------------
Date: Fri, 22 Jan 1999 02:00:58 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: deleting hash entries
Message-Id: <36A7DDA9.18BD5E72@home.com>
[posted & mailed]
Lori Flynn wrote:
>
> delete($wayTopHash->{hash}{6});
>
> print("End of subroutine call value $wayTopHash->{hash}{5}->{valueOne} should be 100 \n");
> print("End of subroutine call address $wayTopHash->{hash}{6} should be null \n");
> print("End of subroutine call value $wayTopHash->{hash}{6}->{valueOne} should be null \n");
> }
You are a victim of autovivification. Print the 2nd line after the
third and you will see.
In order to lookup $wayTopHash->{hash}{6}->{valueOne}, an anonymous hash
is assigned to $wayTopHash->{hash}{6}. The delete worked, but then you
end up assigning a new anon hash for the key you just deleted.
Autovivification exists to allow you to say things like
$hash{stub}{banner} = 5;
without having to initialize $hash{stub} to a hashref first.
>
> OUTPUT OF PROGRAM (problem has ****> before line):
>
> End of subroutine call value 100 should be 100
> End of subroutine call address should be null
> Use of uninitialized value at post.pl line 41 (#1)
Because you deleted it.
> End of subroutine call value should be null
Because it has not been initialized. You have created
$wayTopHash->{hash}{6} = {}, here.
> After subroutine call value 100 should be 100
> *****> After subroutine call address HASH(0x1141a0) should be null
Nope. See last line.
> After subroutine call value should be null
Because it's not initialized.
perldoc perlref
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Thu, 21 Jan 1999 20:50:11 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: finding dirs with readdir
Message-Id: <alecler-2101992050110001@dialup-680.hip.cam.org>
In article <36A78F9B.2C082017@sgi.com>, bgilbert@sgi.com wrote:
> [...] This code seems to work fine for the images but not when
> listing the directories. [...]
> my $path = ".";
>
> opendir(DIR, $path) or die "couldn't open $path ($!)\n";
>
> my @img = grep { /\.jpg$/i || /\.gif$/i } readdir(DIR);
> rewinddir(DIR);
> my @dir = grep { -d } readdir(DIR);
>
> closedir (DIR);
You need to prepend the directory's path when filetesting a value returned
by readdir(). (See perlfunc, under readdir.)
my @img = grep { /\.jpg$|\.gif$/i } readdir(DIR); # that's OK
rewinddir(DIR);
my @dir = grep { -d "$path/$_" } readdir(DIR); # specify the path
HTH,
Andre
------------------------------
Date: 22 Jan 1999 00:52:11 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Finding if a file exists
Message-Id: <788i3r$53p$1@client2.news.psi.net>
colin@cinemas-online.co.uk (colin@cinemas-online.co.uk) wrote on MCMLXIX
September MCMXCIII in <URL:news:7889h4$cm3$1@nnrp1.dejanews.com>:
..
.. The question is how do I check that this file exists,
-e
Abigail
--
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT
------------------------------
Date: Thu, 21 Jan 1999 18:24:30 -0800
From: Heinz Hemken <zotz@franchiseloan.com>
Subject: fortran to C or perl
Message-Id: <36A7E15E.F50A641E@franchiseloan.com>
Does anyone know of a freely available tool to convert fortran to perl
or C/C++ (aside from f2c)? A perl script would be nice.
--
Heinz Hemken
IFC Capital Corporation
San Diego, California
------------------------------
Date: 22 Jan 1999 00:54:54 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How do I define a scalar name with a scalar
Message-Id: <788i8u$53p$2@client2.news.psi.net>
Matt Johnson (cpuweb@cpuweb.com) wrote on MCMLXIX September MCMXCIII in
<URL:news:7885tb$2ur$1@news.ipa.net>:
%%
%%
%% $scalar1 = 1;
%% $scalar2 = _long;
%%
%% $special1 = "Have a nice day";
%% $special_long = "This is a long long line of nonsense";
%%
%% print $special$scalar1;
print ${"special$scalar1"};
$name = "special$scalar1"; print $$name;
Or you use a hash. (${"special$scalar1"} is actually using a hash)
Abigail
--
perl -wleprint -eqq-@{[ -eqw\\\\- -eJust -eanother -ePerl -eHacker -e\\\\-]}-
------------------------------
Date: Fri, 22 Jan 1999 02:44:00 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: How to set keyboard timeout
Message-Id: <36A7E7C4.E0712673@home.com>
[posted & mailed]
Mark Fearer wrote:
>
> Anyone know how to have a perl program terminate execution if the
> user running it
> hasn't touched the keyboard in a predermined amount of time?
Use the method from perlfaq8, "How do I timeout a slow event?"
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: 22 Jan 1999 00:55:49 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Is there an HTML to CGI.pm converter??
Message-Id: <788ial$53p$3@client2.news.psi.net>
Jete Software Inc. (jete@dgs.dgsys.com) wrote on MCMLXIX September
MCMXCIII in <URL:news:7885jf$1sl@dgs.dgsys.com>:
?? We have reams and reams of HTML code which needs to be converted so
?? that it is expressed in terms of CGI.pm code. Is there a converter
?? which will accept a file of HTML code and produce the appropriate
?? calls to CGI.pm routines to produce output which is identical to its
?? HMTL input??
Is there anything wrong with print?
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|8;
.qq;8768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F;
.qq;76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V
/=$^U}while$^V!=$^W'
------------------------------
Date: 22 Jan 1999 00:58:15 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: length($string) in UNIX environment
Message-Id: <788if7$53p$4@client2.news.psi.net>
sysadmin (charlesjourdan@worldnet.att.net) wrote on MCMLXX September
MCMXCIII in <URL:news:788fbp$7m8@bgtnsc03.worldnet.att.net>:
"" I want to count each character in a string which is a series of numbers
"" My debug output seems like there are 2 hidden chars
"" Are these [\n][NULL] ?
"" Notice how next to last position causes a newline
No. If the length is 52, the last character is in position 51.
Which is the newline. There's nothing in position 52.
Had you use -w, it would have told you so.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|8;
.qq;8768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F;
.qq;76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V
/=$^U}while$^V!=$^W'
------------------------------
Date: 22 Jan 1999 00:33:58 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: list of hashes
Message-Id: <788h1m$4me$1@client2.news.psi.net>
dhosek@webley.com (dhosek@webley.com) wrote on MCMLXIX September MCMXCIII
in <URL:news:788c48$f0f$1@nnrp1.dejanews.com>:
//
// It would have been nice if the docs had mentioned that you can get an actual
// array returned from ct_fetch
HUh?
It's right there! The first 5 words of the section about ct_fetch!
@data = $dbh->ct_fetch([$doAssoc [, $wantRef]])
Retrieve one row of data.
You *do* know what that `@' means, I hope. Or know what a "a row" is.
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";`$@`'
------------------------------
Date: Thu, 21 Jan 1999 04:02:18 -1000
From: "Michael Ching" <m_ching@hotmail.com>
Subject: Re: NT and Perl problem
Message-Id: <36a7c0f5.0@news.hawaii.rr.com>
Try a microsoft iis newsgroup
------------------------------
Date: Thu, 21 Jan 1999 04:05:19 -1000
From: "Michael Ching" <m_ching@hotmail.com>
Subject: Re: open() "bad file number" help!
Message-Id: <36a7c447.0@news.hawaii.rr.com>
cometsoft@yahoo.com wrote in message <788bb6$ecu$1@nnrp1.dejanews.com>...
>I am having a problem with a Perl/CGI script. It returns a "Bad file
number"
>error.
not sure about this but see below for one definite problem
>
>the only pertinent lines of code I _believe_ are :
>
>$filename = "../incoming/junk.dat";
$filename=">../incoming/junk.dat";
you need to open for output if you want to print to it
>$file_contents = "this is some stuff for the file...";
>open (F, $filename);
>print F $file_contents;
>close (F);
>
>Thanks
>Craig
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 21 Jan 1999 15:38:08 -0500
From: Jim Michael <jim.michael@gecm.com>
Subject: Re: Oracle from Linux
Message-Id: <36A79030.C60@gecm.com>
Rolf Howarth wrote:
>
> What's the easiest way to connect to an Oracle database (on NT) from
> Perl (on Linux)? I've got the DBD::Oracle module but this requires Pro*C
<deletia>
> It can't be very difficult to design or implement a simple, *open*
> database access protocol that lets you talk ODBC (or JDBC) down a TCP/IP
OpenLink has ODBC drivers for Linux. See http://www.openlinksw.com/ for
a compatibility matrix across RDBMS/client platforms. Last time I looked
there was a free 30 day eval you could download for performance testing.
HTH.
Cheers,
Jim
--
------------------------------
Date: Thu, 21 Jan 1999 19:14:34 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Pattern match behaves strangely
Message-Id: <qdj887.m6v.ln@magna.metronet.com>
Richard Rowell (no.richro.spam@acm.org) wrote:
: $cline=" DeleteFile(RFileFunctions.GetTempPath +
: '\LIST.TXT');";
: if (($cline =~/\s*constructor/i) ||
: ($cline =~/\s*destructor/i) ||
: ($cline =~/\s*procedure/i) ||
: ($cline =~/\s*function/i))
: {
: print "YUP\n";
: }else{
: print "NOPE\b";
: }
: This prints YUP for some reason. I thought that \s* would only match
: spaces, \t,\n,\r, and \f
It matches *zero* or more of those.
The string you are matching against _does_ have zero whitespace
followed by 'function' (ignoring case)
So the match succeeds.
: (whatever \r, and \f are).
Carriage return and Form feed.
: However if I
: replace the \s* with just a \s or a " " then it works, why?
Because those cannot match zero spaces.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 21 Jan 1999 20:11:42 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: Perl Criticism
Message-Id: <36A7DE5E.50EE7766@mediaone.net>
topmind@technologist.com wrote:
>
> The bottom line is what works best in a REAL EXISTING environment.
Please, sir, *don't* patronize us with that crap!
Feel free to reference *any* major project in *any* major corporate
Enterprise in which you participated substantively.
By-the-by, what constitutes ``REAL EXISTING environment?'' In my
clients' Fortune 100 environments, Perl `works best' for somethings, C
for others and Prolog for others. I couldn't begin to tell what works
best on MVS ;)
--
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: Thu, 21 Jan 1999 18:41:20 -0700
From: Kevin Clancy PhD <clancy@eri.uchsc.edu>
Subject: Perl5.00502 and @INC
Message-Id: <36A7D740.D417A561@eri.uchsc.edu>
Hi Folks
Has something changed with pushing scripts and needed files to @INC in
the latest Perl?
I have a program which worked well up to 5.00401 with the following
start stateements:
#!/usr/local/bin
require 5.002; #this is to use Tkperl later on...
$version = "1.20";
require "program-paths.pl"; # a series of configurable paths...
...
the program then continues
When I now call the prog under the latest perl, I get a message that
program-paths.pl cannot be found in @INC (it lists all the direcories it
can see but doesn't include the program-paths.pl directory. Do I now
need to push @INC the directories?
Second question - should I use use rather than require?
Thanks for the help
kevin
Kevin Clancy
Eleanor Roosevelt Institute
Denver, CO
------------------------------
Date: Fri, 22 Jan 1999 01:18:19 GMT
From: randall_burns@hotmail.com
Subject: Problems using Perl and Cygnus Bash
Message-Id: <788jkh$lkl$1@nnrp1.dejanews.com>
I've just tried several variations on using
build 509 from ActiveState with bash from Cygnus.
Specifically, I was trying to set $ENV{PERL5SHELL} to bash.exe
so that I could use the same techniques I tend to use
on Unix systems:
I tried
1) setting PERL5SHELL to the full path name of bash.exe
2) setting the path to the include the location of bash and
then setting $ENV{PERL5SHELL} to bash.exe
3) eval'ing a string that is made to look like little shell script
Has anyone actually gotten this combination to work?
Thanks!
RJB
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 22 Jan 1999 01:16:59 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Random Invoice #
Message-Id: <fkQp2.67$CB1.4392@nsw.nnrp.telstra.net>
In article <788icg$i0l$1@camel18.mindspring.com>,
"Brian Thompson" <hitbyabus@mindspring.com> writes:
> Is there anyway that I can assign a random number to a scalar? I'm using it
# perldoc -f rand
> for invoice numbers....I want it to begin with 00000000 and then goto
> 00000001 and so on, everytime the form is submitted
That is not random! That is incremental.
Store the last created number somewhere
Have every process that creates an invoice, read that number,
increment it, and store it again. If multiple processes can run at
once, make sure that you use proper locking, or use a storage medium
that will do it for you.
use sprintf to get the padding zeroes.
# perldoc -f sprintf
Martien
--
Martien Verbruggen |
Interactive Media Division | Inside every anarchy lurks an old boy
Commercial Dynamics Pty. Ltd. | network - Mitchell Kapor
NSW, Australia |
------------------------------
Date: Thu, 21 Jan 1999 04:01:42 -1000
From: "Michael Ching" <m_ching@hotmail.com>
Subject: Re: Random Invoice #
Message-Id: <36a7c0d2.0@news.hawaii.rr.com>
What does random mean to you?
to get a random number (sorta-- you can use a better srand)
srand( time );
$scalar = rand( HIGHEST );
but for what you're saying..
just create a info file with the current invoince number, and every time you
make an invoice, increment it. Be sure to use secure method of incrementing
file, or two processes could hit at once (use flock to prevent) or if script
dies while writing, it could reset it to 0.
Brian Thompson wrote in message <788icg$i0l$1@camel18.mindspring.com>...
>Is there anyway that I can assign a random number to a scalar? I'm using it
>for invoice numbers....I want it to begin with 00000000 and then goto
>00000001 and so on, everytime the form is submitted
>
>
------------------------------
Date: Fri, 22 Jan 1999 01:12:42 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Reading a log file from an HTML Page
Message-Id: <egQp2.65$CB1.4392@nsw.nnrp.telstra.net>
In article <788arj$blb$1@camel18.mindspring.com>,
"Brian Thompson" <hitbyabus@mindspring.com> writes:
> I am trying to give some employees access to a log file for security
> monitoring........how do I access a log file? I try using the standard
> technique:
1) You are not reading a log file from a HTML page, as you state in
the subject.
2) You do not have a perl problem
3) You seem to have a HTML formatting problem, and it's most likely
because you don't understand HTML
4) We do not discuss HTML here. One of the groups in the
comp.infosystem.www.* hierarchy may be better.
Some things:
> #!/usr/local/bin/perl
no -w? bad. Asking for problems. Asking for long debugging cycles.
no use strict? See comments above.
> open (LOG, "<../../logs/logfile.txt") || &ErrorMessage;
This program seems to be a CGI program. You may consider using the CGI
module for that sort of stuff.
> #Here's where my problem is-----------------------------
That's right. But it's not a perl problem. It's HTML.
Martien
--
Martien Verbruggen |
Interactive Media Division | Advertising: The science of arresting
Commercial Dynamics Pty. Ltd. | the human intelligence long enough to
NSW, Australia | get money from it.
------------------------------
Date: Thu, 21 Jan 1999 17:27:37 -0800
From: "Darren" <darrensw@ix.netcom.com>
Subject: Return a blank form
Message-Id: <788kah$jgj@sjx-ixn10.ix.netcom.com>
Hi all,
I am not new to Perl but have a problem and am stumped as to how to solve it
.... although my guess is it's very simple.
I have created, on our company intranet, a html/Perl dB interface to allow
users to read and write to the dB from the web as opposed to a software
package.
All I need to do is ... when a user submits something to the dB from the
html page, I want to return straight back to that page only with all the
fields blank ready for the next record. I don't want it to show a
confirmation page or anything like that just submit the record and blank out
the fields ready for the next record to be added.
What am i missing here ? I would imagine it is very simple but it's got me!!
Thanks for all help,
Darren
------------------------------
Date: Thu, 21 Jan 1999 17:30:20 -0800
From: "steven t henderson" <STEVENHENDERSON@prodigy.net>
Subject: Re: Trying to match a variable with another variable.
Message-Id: <788ksa$2m32$1@newssvr03-int.news.prodigy.com>
how about:
foreach $var ($field1, $field2, $field'N'....)
{
if(<test operation>)
{
you have it!
}
}
Matt Johnson wrote in message <788fb6$6pq$1@news.ipa.net>...
>This is the code I have so far:
>
>if ($fields{'sort1'} eq $fieldname1 or $fieldname2 or $fieldname3 or
>$fieldname4 or $more) {
># Do somehting.
>}
>
>
>What I want to do is find out which one of them it matched and be able to
>asign it to a variable, instead of making an if statement for each one. I
>know there is a way to do it but can't seem to find it.
>
>
------------------------------
Date: Fri, 22 Jan 1999 02:26:08 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: undefined value warning when it is defined
Message-Id: <36A7E393.98B038F2@home.com>
[posted & mailed]
Bradley W. Langhorst wrote:
>
> the following code give me an undefined value warning
> anybody know why?
Because you're accessing an uninitialized variable.
> for ($row=0;$row<=@OrderedKeys;$row++) {
^
^
remove this.
> #print $row . "\n";
> for($i=$row; $i<=@OrderedKeys; $i++) {
^
^
here too.
All references to $OrderedKeys[$row] will be undefined for
$row = @OrderedKeys.
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Thu, 21 Jan 1999 20:46:27 -0500
From: "Brian Thompson" <hitbyabus@mindspring.com>
Subject: whois search
Message-Id: <788ld3$lif$1@camel18.mindspring.com>
I've been looking for a good whois search script. I've been using some
scripts I found on www.cgi-resources.com but none of them are working
successfully, could anyone send me a script?
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4716
**************************************