[15681] in Perl-Users-Digest
Perl-Users Digest, Issue: 3094 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 19 00:05:31 2000
Date: Thu, 18 May 2000 21:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958709109-v9-i3094@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 18 May 2000 Volume: 9 Number: 3094
Today's topics:
Re: "Breakthrough" Perl compiler? (brian d foy)
Re: Bug or Feature: Can't dereference array ref inside (Steve Leibel)
Data Structures (complex) <nospam@devnull.com>
File upload using CGI.pm jamalone@earthlink.net
Re: File upload using CGI.pm (Kragen Sitaker)
Re: generating gif image from cgi <edbubbleluk@hotmail.com>
Re: Giving a string the name of a string (Tad McClellan)
Re: glueing a scalar onto a variable <bmb@dataserv.libs.uga.edu>
Re: How can I read the volume label of a CDROM on Linux (Monte Phillips)
How can I tell if there is data in a pipe without doing <rbratt@home.com>
Re: Manipulate all *values* using CGI.pm? (David Efflandt)
Re: need starting point: manipulating graphics (Kragen Sitaker)
Newbie ~~ Please Help !! <agiNOagSPAM@feib.com.tw.invalid>
Re: Newbie ~~ Please Help !! <bmb@dataserv.libs.uga.edu>
Re: Numbers module to normalize numbers and/or smooth c <bray@virtualcreations.net>
Parse::RecDescent problem, $::RD_TRACE showing somethin <ocschwar@NOSPAM.mit.edu>
Perl - MySQL - Notify using sendmail <megan@aracnet.com>
Putting file's variable in a database.How? <kana_krishna@netcel360.com>
Re: Reading Binary Files (Kragen Sitaker)
SNMP via Perl mcnuttj@missouri.edu
Re: suid problem under Solaris 2.7 <elaine@chaos.wustl.edu>
Using DBM for simple database? (Jesse T Sheidlower)
Re: Using DBM for simple database? <jeff@vpservices.com>
Re: Using DBM for simple database? (Kragen Sitaker)
variable.pm (Abigail)
Re: variable.pm <Tbone@pimpdaddy.com>
Re: variable.pm <johnlin@chttl.com.tw>
Re: zen and the art of trolling [OT] <nospam@devnull.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 May 2000 21:32:50 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: "Breakthrough" Perl compiler?
Message-Id: <brian-ya02408000R1805002132500001@news.panix.com>
In article <8g1on0$2e3i$1@news4.isdnet.net>, "Charles Henry" <charles.henry@engineer2k.com> posted:
> Great but you seem to forget the *ONE* interesting reason to compile Perl
> script : one doesn't have to have Perl installed in order to run your
> program!
unless you're talking about perl compiling a script to machine code,
you are still going to need an interpreter. and if you are, you then
have to compile it for every different architecture.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Thu, 18 May 2000 20:35:22 -0700
From: stevel@coastside.net (Steve Leibel)
Subject: Re: Bug or Feature: Can't dereference array ref inside hash
Message-Id: <stevel-1805002035220001@192.168.100.2>
In article <slrn8i91pq.lb4.abigail@ucan.foad.org>, abigail@arena-i.com wrote:
> On Wed, 17 May 2000 23:03:51 -0700, Steve Leibel <stevel@coastside.net> wrote:
> ++ If I have a hash reference, one of whose keys is an array ref, like this:
> ++
> ++ $myhash = {
> ++ arrayref => (),
> ++ };
>
> Had you used -w, you wouldn't have to ask, as Perl would have told you
> the above as an error.
>
> () is an empty list. [] creates an array reference.
>
Abigail,
When I ran this program with -w and 'use strict' it gave the error
"Odd number of elements in hash assignment"
This is Perl 5.005_03 on FreeBSD.
Steve L
------------------------------
Date: 19 May 2000 03:48:00 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Data Structures (complex)
Message-Id: <8g2dhg$h0e$0@216.155.33.32>
working on a new project based loosely on my previous ones.
working with a CGI form script that creates a database of the form:
gametype|reviewername|mapname|
that as it fills will resemble something like this:
utassault|FuzzBuster|AS-Infiltrator|
utdm|FuzzBuster|DM-Test123|
utdomination|Nacher|DOM-Query|
where there are 7 gametypes, 15 reviwers and a choice of around 1450 maps to
review.
as this database is parsed in, and read back out via the CGI script, it will
list each gametype, underneath which it will list the reviewer name and what
maps of that TYPE they will be reviewing that week (this is to prevent two
reviewers from reviewing the same map, and allows one to 'claim' the review of
that map for themselves)
(if this is unclear, let me know.. I'll be happy to answer your questions if it
helps you answer mine)
my problem is that I am not exactly certain which type of complex hash I requre.
:)
if I read in the database.txt file like this:
open(IN, "<database.txt");
chomp(@database = <IN>);
close IN;
foreach (@database) {
my($type, $reviewer, $map) = split /\|/;
$masterlist{$type}{$reviewer} = $map;
}
my question becomes -fold --
A> Is this the best way to format this data, when a gametype will have several
reviewers listed under it, and each reviewer may have 1 or more maps listed
after their name, UNDER that gametype.. then we proceed to the next gametype,
and so on.
B> if I want to append a LIST to $masterlist{$type}{$reviewer}, how do I write
it properly, if they are going to be added one at a time? Would I write it like
this?
$masterlist{$type}{$reviewer} .= [$map]; # would this work?
My question is more one of making sure I use the most elegant and efficient
structure for this to make my life easier. I already understand the basic
concepts in perldsc and perllol, and know how to de-reference these properly.
Building databases in your head is fine to start with, but when it comes time to
HANDLE that data in an efficient manner, is the crucial thing.
Can anyone offer some insights?
Scott
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Fri, 19 May 2000 01:55:24 GMT
From: jamalone@earthlink.net
Subject: File upload using CGI.pm
Message-Id: <5o59is0q2ci0gm2huvniq0gfbkndsg9mp1@4ax.com>
I know that I will get flamed for this one but I have researched
everywhere that I can think of and can not figure it out. I need to
upload a file into a directory on my web server. I know that CGI.pm
can do this but HOW?
I have read the example code and I see how it figures the file size
but not where it actually uploads the file.
This is straight from http://www.wiley.com/compbooks/stein/source.html
#!/usr/bin/perl
#file: upload.pl
use CGI qw/:standard/;
*******************start*********************
print header,
start_html('file upload'),
h1('file upload');
print_form() unless param;
print_results() if param;
print end_html;
sub print_form {
print start_multipart_form(),
filefield(-name=>'upload',-size=>60),br,
submit(-label=>'Upload File'),
end_form;
}
I am not using this because I am using a custom static HTML form for
the upload selection so I don't need it right?
*******************end**********************
******************start**********************
sub print_results {
my $length;
my $file = param('upload');
if (!$file) {
print "No file uploaded.";
return;
}
print h2('File name'),$file;
print h2('File MIME type'),
uploadInfo($file)->{'Content-Type'};
while (<$file>) {
$length += length($_);
}
print h2('File length'),$length;
}
This is the part I am having the problem with. Where here does it say
where and how to store the file on the server?
***************end***********************
I know this topic has been covered here but I am still having
problems.
Thanks
Jason Malone
------------------------------
Date: Fri, 19 May 2000 02:57:56 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: File upload using CGI.pm
Message-Id: <U42V4.12697$nm6.173677@news-east.usenetserver.com>
In article <5o59is0q2ci0gm2huvniq0gfbkndsg9mp1@4ax.com>,
<jamalone@earthlink.net> wrote:
>I know that I will get flamed for this one but I have researched
>everywhere that I can think of and can not figure it out. I need to
>upload a file into a directory on my web server. I know that CGI.pm
>can do this but HOW?
From the "CREATING A FILE UPLOAD FIELD" section of perldoc CGI:
The filename returned is also a file handle. You can read
the contents of the file using standard Perl file reading
calls:
. . . followed by example code.
I'm assuming you're not using the example code from the CGI doc,
because it doesn't figure the file size, but it does read it.
>I am not using this because I am using a custom static HTML form for
>the upload selection so I don't need it right?
Right. Make sure you have multipart forms selected though :)
> while (<$file>) {
> $length += length($_);
> }
Hmm, there you're reading from the uploaded file right there.
>This is the part I am having the problem with. Where here does it say
>where and how to store the file on the server?
The man page example is probably more helpful.
BTW, it's possible to find the temporary name under which it is stored
on the server. It's probably not a good idea; Lincoln might change
that in the future, it's not part of the published interface, and it's
likely to tempt you to do nonportable things like try to rename it
someplace safe.
HTH. Post again if you're still having trouble.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
The power didn't go out on 2000-01-01 either. :)
------------------------------
Date: Thu, 18 May 2000 22:16:16 -0400
From: "Ed" <edbubbleluk@hotmail.com>
Subject: Re: generating gif image from cgi
Message-Id: <8g27tu$jdk$1@slb1.atl.mindspring.net>
Reo,
THis works fine, but how can I return not a list of images, but I guess one
.gif file so I can use this cgi in static html, so I can put the counter
wherever I like....
<img src = 'image.cgi'>
I tried this with your addition, and it does not return a .gif.
Thanks
Ed
Reo M. <reo@infi.net> wrote in message
news:3923304d.10545267@news.infi.net...
> On Wed, 17 May 2000 15:06:24 -0700, Makarand Kulkarni
> <makarand_kulkarni@My-Deja.com> wrote:
>
>
> use php3
>
> >No special cgi script is required ( unless you want to determine
> >the characteristics of the gif file at runtime ..)
> >
> >if $counter has the number --
> >
> >print join ( '',map { "<image border=0 src=$_\.gif>"} split ( //,
$counter )
> >);
> >
> >--
> >
>
------------------------------
Date: Thu, 18 May 2000 22:54:13 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Giving a string the name of a string
Message-Id: <slrn8i9b6l.6pj.tadmc@magna.metronet.com>
On Thu, 18 May 2000 21:52:35 +0200, Penpal International <ppi@searchy.net> wrote:
>I tought this question could be found I the faq's, but I couldn't find
>any which even looks like it:
>
>How can I give a string a name from the contents of an other string. I
>want this:
It is in perlref.pod, in the section named "Symbolic references".
Now that you know where it is DO NOT READ IT!
(Well, you can read it if you are curious, but don't use them.
You probably _can't_ use them because they are not allowed
with the "use strict" pragma, and everybody uses that.
)
Because it is Bad and there are Good alternatives (hashes).
You do not want to do what you want to do :-)
>$string = "1-16";
># what now?
Use a hash:
$cat{$string} = 'Content';
>print "$cat1-16"; # Content should be given at the point "what now?"
print "$cat{'1-16'}";
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 May 2000 22:56:07 -0400
From: Brad Baxter <bmb@dataserv.libs.uga.edu>
Subject: Re: glueing a scalar onto a variable
Message-Id: <Pine.GSO.4.21.0005182255300.11977-100000@dataserv.libs.uga.edu>
On Thu, 18 May 2000, Daniel van den Oord wrote:
> damn got it thanks
> using an array
> $count[number] = "selected"
Well put! :-)
--
Brad
------------------------------
Date: Fri, 19 May 2000 01:47:13 GMT
From: montep@hal-pc.org (Monte Phillips)
Subject: Re: How can I read the volume label of a CDROM on Linux?
Message-Id: <39269d1e.43752233@news.hal-pc.org>
On Wed, 17 May 2000 12:03:38 -0500, rgb <tiemaster@home.com> wrote:
>The title says it all. I looked for a Linux program to do this, but I
>must be blind or not very good at searching for things. Can anyone
>point me in the right direction? Thanks.
The answer to your dilemma lies in 'C', not in PERL.
------------------------------
Date: Thu, 18 May 2000 21:22:15 -0500
From: rgb <rbratt@home.com>
Subject: How can I tell if there is data in a pipe without doing a blocking read? & Possible Async bug - example given
Message-Id: <B47D101558B20E82.F413A9B05346A7F1.527E96A8922CFCB0@lp.airnews.net>
The perlipc doc didn't seem to shed light on this, nor did the pipe
writeup. This is probably a common question, but I can't seem to find
the answer. I've happily spun off a dozen forked devils which happily
compute and return the right answers (via individual pipes) but i
can't seem to find the magic to let me grab them as they finish rather
than in some predetermined order. This actually matters to this app
for reasons not worth elaborating. select looked very promising, but
its return code (which i thought to be which index into the vec has
data) doen't seem to always be that???
BTW: maybe i'm making a rookie mistake, but I think there is a bad
race condition in the Async module. I think this should print out
Outer f1f2..f20 but if prints out various *different* variants (e.g.,
f1f3f4f5f19 or 1f2f3f4f8, etc.). I'd appreciate knowing whty i'm
wrong.
use Async;
my @son;
my $nprocs=20;
my $l="";
for ($i=1; $i<=$nprocs; $i++) {
my $sbr = sub { doit("f".$i) };
$son[$i] = Async->new($sbr);
}
foreach $ix (1..$nprocs) {
redo unless $son[$ix]->ready();
if (my $err = $son[$ix]->error) {
print "Gak, $ix got error $err\n";
}
else {
my $res = $son[$ix]->result();
$l = $l . $res;
}
}
print "Outer $l\n";
exit;
sub doit {
my $name = shift;
print "I'm $name\n";
return $name;
}
------------------------------
Date: 19 May 2000 01:18:46 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Manipulate all *values* using CGI.pm?
Message-Id: <slrn8i95ja.gfb.efflandt@efflandt.xnet.com>
On Thu, 18 May 2000 16:11:27 -0700, Trent <trent@jps.net> wrote:
>
>Hi Gents, Ladies -
>
>I'm changing all of my scripts to utilize CGI.pm for obvious reasons...
>But, my old "roll your own" forms processing allowed me to easily manipulate
>all my form values at once.
>
>e.g.(during the value pair loop)
> $value =~ s/(\w+)/\u\L$1/g;
>
>Question- The CGI.pm docs explain how to
>return *all input keys*(@names = $new_query->param;), and get
>the values for specific keys, but I'm not clear on how to
>grab and modify *all input values* in a single stroke...
>
>Any help or productive tounge lashing appreciated :)
Example using function method (without param prefix needed for object
method):
foreach $key (param) {
$_ = param($key);
s/(\w+)/\u\L$1/g;
# add any other filters here
param($key,$_);
}
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: Fri, 19 May 2000 02:30:04 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: need starting point: manipulating graphics
Message-Id: <MG1V4.12499$nm6.166302@news-east.usenetserver.com>
In article <GPZU4.49$A81.7983@news.shore.net>,
<aaronp@removeme-shore.net> wrote:
> Hi, I need to take an image file and manipulate it. Basically, I need to
>draw a simple box somewhere on it. Any recommendations on where I should
>start learning about this? I see lots of graphics options for Perl, but
>which ones allow you to edit a previously made graphics file as opposed to
>just creating a brand new one?
PerlMagick, among others. (I see some folks have suggested GD.)
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
The power didn't go out on 2000-01-01 either. :)
------------------------------
Date: Thu, 18 May 2000 19:27:48 -0700
From: agichen <agiNOagSPAM@feib.com.tw.invalid>
Subject: Newbie ~~ Please Help !!
Message-Id: <01903e20.0d60983a@usw-ex0103-019.remarq.com>
Hello,everyone,
I'm new in Perl.
I have a billing system on Oracle.
I retrive some customers info to a text file.
I have a task to split the big text file to lots
of HTML files.
Besides,each customer's data contains different
types of records, and I can't extract with separator.
Here is my text layout.
A11111 0100 10049 Jack No.1,Park Rd. 1973/03/31
A11111 0200 Manager Microsoft Corp.
B22222 0100 12345 Mary No.3,Park Rd. 1975/03/04
B22222 0200 Clerk Zyxel Inc.
.......
field length specified for different type ( 0100,0200 )
0100
| 6 | |4 | | 5 | | 6 | | 20 | | 10 |
^ ^ ^ ^ ^
id type zipcd name address birthday
0200
| 6 | |4 | | 13 | | 20 |
^ ^ ^
id type Job position Company
Just by the text above.
How to separate the text to A11111.htm & B22222.htm ??
I do appreciate for any suggestions !!
Best Regards,
Agi Chen
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Fri, 19 May 2000 00:00:45 -0400
From: Brad Baxter <bmb@dataserv.libs.uga.edu>
Subject: Re: Newbie ~~ Please Help !!
Message-Id: <Pine.GSO.4.21.0005182303301.11977-100000@dataserv.libs.uga.edu>
On Thu, 18 May 2000, agichen wrote:
...
> A11111 0100 10049 Jack No.1,Park Rd. 1973/03/31
> A11111 0200 Manager Microsoft Corp.
> B22222 0100 12345 Mary No.3,Park Rd. 1975/03/04
> B22222 0200 Clerk Zyxel Inc.
> .......
>
> field length specified for different type ( 0100,0200 )
>
> 0100
> | 6 | |4 | | 5 | | 6 | | 20 | | 10 |
> ^ ^ ^ ^ ^
> id type zipcd name address birthday
>
> 0200
> | 6 | |4 | | 13 | | 20 |
> ^ ^ ^
> id type Job position Company
>
> Just by the text above.
> How to separate the text to A11111.htm & B22222.htm ??
...
Nice specs. Here's one way you might do this (name appears to be 7
characters, by the way).
1 #!/usr/local/bin/perl -w
2 use strict;
3
4 my $regx0100 = '^(.{5}) (.{7}) (.{20}) (.*)';
5 my $regx0200 = '^(.{13}) (.*)';
6 my $common_regx = '^(.{6}) (.{4}) (.*)';
7
8 while( <DATA> ) {
9 chomp;
10 my( $id, $type, $remainder ) = /$common_regx/;
11
12 if( $type eq '0100' ) {
13 my( $zipcd, $name, $address, $birthday ) =
14 $remainder =~ /$regx0100/;
15 print "\n(to file $id.htm)\n", <<_end_;
16 id: $id
17 type: $type
18 zipcd: $zipcd
19 name: $name
20 address: $address
21 birthday: $birthday
22 _end_
23 } # if
24
25 elsif( $type eq '0200' ) {
26 my( $position, $company ) =
27 $remainder =~ /$regx0200/;
28 print "\n(to file $id.htm)\n", <<_end_;
29 id: $id
30 type: $type
31 position: $position
32 company: $company
33 _end_
34 } # elsif
35
36 else {
37 die "Unrecognized type: $type, line $.";
38 } # else
39
40 } # while
41
42 __DATA__
43 A11111 0100 10049 Jack No.1,Park Rd. 1973/03/31
44 A11111 0200 Manager Microsoft Corp.
45 B22222 0100 12345 Mary No.3,Park Rd. 1975/03/04
46 B22222 0200 Clerk Zyxel Inc.
Output:
(to file A11111.htm)
id: A11111
type: 0100
zipcd: 10049
name: Jack
address: No.1,Park Rd.
birthday: 1973/03/31
(to file A11111.htm)
id: A11111
type: 0200
position: Manager
company: Microsoft Corp.
(to file B22222.htm)
id: B22222
type: 0100
zipcd: 12345
name: Mary
address: No.3,Park Rd.
birthday: 1975/03/04
(to file B22222.htm)
id: B22222
type: 0200
position: Clerk
company: Zyxel Inc.
This is not perfect. If your data deviates from the regular
expression, you may not get anything useful, even for error messages.
However, it should give you a start. It's up to you, of course, to
open the appropriate files and format the html, etc. Enjoy!
--
Brad
print <<_;
Just another Perl hacker
_
------------------------------
Date: Thu, 18 May 2000 23:00:22 -0400
From: "Bray Jones" <bray@virtualcreations.net>
Subject: Re: Numbers module to normalize numbers and/or smooth curves?
Message-Id: <8g2ac5$k1d$1@news3.infoave.net>
Sure... where are the Statistics::BogusData or Statistics::Cheating modules.
:-)
You are right in that I don't want to change the numbers, just show a
smoother curve for visualization. As they drill down into the data I will
give them more real graphs. Just the "50,000ft" view, I want the curve.
Already looked in the Statistics::* section, but didn't see anything that I
thought would help. I'll look again.
Thanks.
Tom Phoenix <rootbeer@redcat.com> wrote in message
news:Pine.GSO.4.10.10005180645240.25459-100000@user2.teleport.com...
> On Thu, 18 May 2000, Bray Jones wrote:
>
> > I have a large array of numbers that when graphed, looks very
> > "jagged". Meaning I can have considerable differences in two numbers
> > all through the graph making the lines take sharp turns up and down in
> > short time frames.
> >
> > Are there any modules to take those numbers and normalize them before
> > I graph them to make a smoother curve in the graph?
>
> Do you want Statistics::Cheating? :-)
>
> But I think you want to do some kind of curve fitting to your data, rather
> than changing the numbers. Does that get you closer to a solution? Of
> course, there are many possible curves you might want. Maybe something in
> the Statistics::* section of CPAN would do what you want. Or maybe you'll
> need to make Statistics::BogusData after all. :-)
>
> Cheers!
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
------------------------------
Date: Fri, 19 May 2000 03:26:05 +0000
From: Omri <ocschwar@NOSPAM.mit.edu>
Subject: Parse::RecDescent problem, $::RD_TRACE showing something very odd.
Message-Id: <3924B44D.38AD153@NOSPAM.mit.edu>
Hi, everyone.
I'm still working on my long RecDescent grammar,
and right now my script dies with
ERROR (line 1264): Untranslatable item encountered: "}"
(Hint: Did you misspell "}" or forget to comment it
out?)
Bad grammar!
Turning on RD_TRACE shows that before dying, the interpreter gets as far
as this
before quitting:
.......
Parse::RecDescent: Treating "goto" as a literal terminal
Parse::RecDescent: Treating "|" as a new production
Parse::RecDescent: Treating "long" as a literal terminal
Parse::RecDescent: Treating "|" as a new production
Parse::RecDescent: Treating "register" as a literal terminal
Parse::RecDescent: Treating "|" as a new production
Parse::RecDescent: Treating "sizeof" as a literal terminal
Parse::RecDescent: Treating "|" as a new production
Parse::RecDescent: Treating "static" as a literal terminal
Parse::RecDescent: Treating "|" as a new production
Parse::RecDescent: Treating "typedef" as a literal terminal
Parse::RecDescent: Treating "|" as a new production
Parse::RecDescent: Treating ""union"" as an interpolated literal
terminal
The last rule in my grammar is this:
identifier : ...!reserved identifier_word
identifier_word : / [a-z_] # LEADING ALPHA OR UNDERSCORE
[a-z0-9_]* # THEN DIGITS ALSO ALLOWED
/ix # CASE/SPACE/COMMENT INSENSITIVE
#todo : complete the list.
reserved: 'int' | 'double' | 'short' | 'volatile' | 'register' |
'float' | 'signed' | 'unsigned' | 'char' |
'for' | 'if' | 'switch' | 'case' | 'while' | 'do' | 'case' |
'extern' | 'void' | 'exit' | 'return' |
'auto' | 'break' | 'const' | 'continue' | 'default' | 'else' |
'enum' | 'struct' | 'goto' | 'long' | 'register' |
'sizeof' | 'static' | 'typedef' | "union"
}};
So you can see that it does treat the last rule correctly.
The second closing curly brace is an experiment. If I delete it I get
this error message:
Can't find string terminator "}" anywhere before EOF at www/decss.pl
line 33.
THis leaves me at a loss to what might be happening.
Any suggestions, anyone?
Regards,
Omri Schwarz
------------------------------
Date: Thu, 18 May 2000 20:40:27 -0700
From: "Megan Garrison" <megan@aracnet.com>
Subject: Perl - MySQL - Notify using sendmail
Message-Id: <kE2V4.995$NX3.25715@typhoon.aracnet.com>
This is a multi-part message in MIME format.
------=_NextPart_000_000A_01BFC109.4C9D31E0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello~=20
I have just recently gotten a MySQL database up and running and =
connecting to the tables via a set of generic Perl scripts. Everything =
is working great, but I would really like to modify the add.pl script so =
that it emails me whenever someone adds a record (or possibly creat a =
notify.pl script). Ditto the update.pl when someone updates a record. I =
looked through some guestbook & formmail scripts that do this type of =
thing, but I do not know perl (have only installed a few scripts) and I =
can tell from my investigations that doing this by myself is beyond my =
capability. Can anyone either offer constructive suggestions of what I =
need to do or point me in the direction of some online instruction/help. =
~Thanks, Megan
------=_NextPart_000_000A_01BFC109.4C9D31E0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3013.2600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hello~=20
<P>I have just recently gotten a MySQL database up and running and =
connecting to=20
the tables via a set of generic Perl scripts. Everything is working =
great, but I=20
would really like to modify the add.pl script so that it emails me =
whenever=20
someone adds a record (or possibly creat a notify.pl script). Ditto the=20
update.pl when someone updates a record. I looked through some guestbook =
&=20
formmail scripts that do this type of thing, but I do not know perl =
(have only=20
installed a few scripts) and I can tell from my investigations that =
doing this=20
by myself is beyond my capability. Can anyone either offer constructive=20
suggestions of what I need to do or point me in the direction of some =
online=20
instruction/help. ~Thanks, Megan</P></FONT></DIV></BODY></HTML>
------=_NextPart_000_000A_01BFC109.4C9D31E0--
------------------------------
Date: Fri, 19 May 2000 11:15:22 +0800
From: "kana_krishna" <kana_krishna@netcel360.com>
Subject: Putting file's variable in a database.How?
Message-Id: <8g2c2c$3ii$1@news.sysnet.net.tw>
I need to do script that gets a file from a server to a local PC through a
ftp using 'expect' script .That I have already done but the problem is that
I have to put the file's attribute (name,size,modified date,current date
etc) into a database(Oracle or Access - if can both) each time I get a file
. I got to know that this can be done writing a ftp client program in
perl that can extract the files attribute and put it into a database . I am
new to perl .Can anybody help me.
------------------------------
Date: Fri, 19 May 2000 02:37:47 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Reading Binary Files
Message-Id: <%N1V4.12524$nm6.168399@news-east.usenetserver.com>
In article <39248A86.E99AE888@prism.gatech.edu>,
Bob <gt7314c@prism.gatech.edu> wrote:
>I would like to know how to read a binary file with PERL. In most
>cases, the binary file will have been created by a FORTRAN program and I
>will know the format of the data in it.
Generally you read binary files the same way you read any other files,
but you should probably say binmode FILEHANDLE; (where FILEHANDLE is
the filehandle to the file) before you try to read or write anything
from them.
You may find the seek, read, and unpack functions (documented in
perldoc perlfunc) to be helpful in this pursuit.
>Also, can anything at all be decifered if I know nothing about the
>format of its data?
This is one species of what is known as "hacking" --- specifically,
"reverse engineering a file format". Occasionally this merges with
"cryptanalysis".
The basic procedure is this:
1- guess something about the file format.
2- make a prediction about the contents of a data file based on your guess.
3- write or modify a program, or look at a data file in an editor, to
test your prediction. Run it. Write down the results.
4- decide whether the results were what you expected.
5- go back to step 1 if you still need to know more.
This is not a fast process.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
The power didn't go out on 2000-01-01 either. :)
------------------------------
Date: 19 May 2000 02:54:36 GMT
From: mcnuttj@missouri.edu
Subject: SNMP via Perl
Message-Id: <8g2adc$vcj$1@dipsy.missouri.edu>
Okay, guys, I think I've got a real winner here.
I'm trying to query a *specific* instance of a *specific* MIB using the
UCD SNMP perl module (UCD SNMP 4.1.1).
If I do this:
######## BEGIN CODE
# Create a socket.
$sess = new SNMP::Session(DestHost => $ip, Community => $comm);
# This is the MIB to query the layer 2 forwarding table of a switch.
$mib = 'dot1dTpFdbPort';
# This is the object used for multi-instance queries.
$vb = new SNMP::Varbind([$mib]);
# Set the instance to the decimal equivalent of the MAC address I'm
# looking for (that's how they're stored in the forwarding table, in
# numeric order).
$vb->[$SNMP::Varbind::iid_f] = '8.0.32.47.24.108';
# Get the next instance of the MIB.
$var = $sess->getnext($vb);
######## END CODE
If I do all that, what I get is the instance of the MIB that's immediately
*after* the one I'm looking for.
Now, the intelligent person would say, "Okay, just subtract one and you'll
get the one you're looking for." Nay, not so, my friends. I *still* get
the one *after*. Not until I reduced the *third* octet to less than *10*
was I able to get the one I was looking for.
The problem is, I can't make any sense of that. Therefore, the only
reliable algorithm I have for searching the forwarding table for an
arbitrary MAC address is to begin at the beginning and just go until I hit
the one I want. This is pretty slow when the table is large. The idea
was to speed up this process (sometimes it will have to run over a modem
link).
Any ideas?
For reference, the instances in the table immediately surrounding the one
I want (in *this* case) are as follows:
8.0.9.151.248.74
8.0.9.186.64.8
8.0.17.12.111.225
8.0.32.27.47.108 (This is the one I want)
8.0.105.2.216.245
8.0.105.2.252.38
8.0.105.2.252.237
(Apparently, the "8.0.105" OUI is a popular vendor. I haven't bothered to
look it up.)
Anyway, any ideas, folks?
Thanks!
--J
------------------------------
Date: Fri, 19 May 2000 03:08:41 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: suid problem under Solaris 2.7
Message-Id: <B54A2877.4523%elaine@chaos.wustl.edu>
in article Pine.GSO.4.10.10005180958180.25459-100000@user2.teleport.com, Tom
Phoenix at rootbeer@redcat.com quoth:
> Well, you could do that to disable set-id scripting in Perl. :-) At
> least, if I'm figuring everything right, that's what would happen. perl
> starts up, sees that it's already set-id. But it shouldn't be set-id
> unless sperl (suidperl) is handling things, on systems built that way. So,
> it makes a big noise and dies.
You can also mount all the filesystems as nosuid and be done with both :)
>> I don't remember if there is a FAQ for this but it might be useful for
>> people in this sort of situation.
>
> Good idea. I'll have to (finish) writing one. :-)
I actually dug around a bit today at lunch and couldn't really find anything
dealing with both and explaining the what why and how so indeed, this would
be nice to have.
e.
------------------------------
Date: 18 May 2000 21:44:35 -0400
From: jester@panix.com (Jesse T Sheidlower)
Subject: Using DBM for simple database?
Message-Id: <8g26a3$2vr$1@panix2.panix.com>
I'm trying to design a relatively straightforward database, and
I'm a bit unclear on just how DBM's work, or what makes them
practical. Basically they just store a hash to disk. Now, I
understand the value of hashes for some things, but it's not
clear to me how you would use them for what one would normally
call a "database."
For instance, if you had a database of books, with fields for
title, author, pub date, price paid, etc., and you had a hash of
$book{title}, $book{author}, etc., you would only have one book
per hash, which doesn't work. If you had, say,
$title{unique_identifier}, $author{unique_identifier}, that's a
little better, but you still need one DBM for each field in your
database. And while you could use references to create a complex
data structure to do it in one hash, you can't then store it in
a DBM unless you use MLDBM, which I don't quite understand.
I assume I'm missing something, because this seems to be something
that one would want to do fairly often, but I can't really find a
clear explanation in the docs or books I've checked. But there
has to be a way of dealing with this in between a flat file and
an SQL, which seems to difficult to learn and I don't have a way
to serve it anyway.
Thanks for any suggestions.
Jesse Sheidlower
<jester@panix.com>
------------------------------
Date: Thu, 18 May 2000 18:50:54 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Using DBM for simple database?
Message-Id: <39249DFE.A3B5B66E@vpservices.com>
Jesse T Sheidlower wrote:
> I'm trying to design a relatively straightforward database, and
> I'm a bit unclear on just how DBM's work, or what makes them
> practical. Basically they just store a hash to disk. Now, I
> understand the value of hashes for some things, but it's not
> clear to me how you would use them for what one would normally
> call a "database."
It takes a bit of monkeying, but it can be done with DBM, see chapter 2
in _Programming the Perl DBI_ by Descartes and Bunce.
> But there
> has to be a way of dealing with this in between a flat file and
> an SQL, which seems to difficult to learn and I don't have a way
> to serve it anyway.
SQL is not that difficult and does not require anything special to
serve. You can use it in combination with many kinds of flat files
using either DBD::CSV or DBD::RAM without anything but Perl and easily
obtainable/installable Perl modules.
--
Jeff
------------------------------
Date: Fri, 19 May 2000 02:50:53 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Using DBM for simple database?
Message-Id: <h_1V4.12632$nm6.172027@news-east.usenetserver.com>
In article <8g26a3$2vr$1@panix2.panix.com>,
Jesse T Sheidlower <jester@panix.com> wrote:
>If you had, say,
>$title{unique_identifier}, $author{unique_identifier}, that's a
>little better, but you still need one DBM for each field in your
>database. And while you could use references to create a complex
>data structure to do it in one hash, you can't then store it in
>a DBM unless you use MLDBM, which I don't quite understand.
DBM files store strings. So you can encode your thing as a string:
$books{$unique_id} = join ',', $title, $author, $whatever;
# . . .
my ($title, $author, $whatever) = split /,/, $books{$another_unique_id};
That's assuming you won't have commas in your fields. If you need to
store arbitrary data, you have several options:
- make fixed-length fields and use pack and unpack instead of join and
split. Eww.
- turn the commas into something else --- for example, s/~/~t/g; s/,/~c/g;
and the reverse on reading --- s/~c/,/g; s/~t/~/g;, or my favorite,
pack and unpack with templates of "H*".
- use MLDBM or something similar; BoulderIO also seems suitable, and I
think there's some XML module that would work equally well for this.
(Although MLDBM does the DBM part for you.)
Note that any of these except for MLDBM or BoulderIO would make it
difficult to add or delete fields.
HTH.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
The power didn't go out on 2000-01-01 either. :)
------------------------------
Date: 19 May 2000 02:21:22 GMT
From: abigail@foad.org (Abigail)
Subject: variable.pm
Message-Id: <slrn8i9992.q9h.abigail@ucan.foad.org>
Here's a way to use scalar variables without the needing a '$'.
Abigail
package variable;
require 5.6.0;
use strict;
use warnings::register;
use vars qw /%declared $VERSION/;
$VERSION = '1.0';
sub croak {
require Carp;
goto &Carp::croak (@_);
}
my %keywords = map {$_ => 1} qw /BEGIN INIT CHECK END DESTROY AUTOLOAD/;
my %forced_into_main = map {$_ => 1} qw /STDIN STDOUT STDERR ARGV ARGVOUT
ENV INC SIG/;
my %forbidden = (%keywords, %forced_into_main);
sub import {
my $package = shift;
return unless @_; # Ignore 'use variable;'.
my $caller = caller;
my $name = shift;
croak "Can't use undef as variable name" unless defined $name;
if ($name =~ /^_?[^\W_\d]\w*\z/ && !$forbidden {$name}) {
# Ok.
}
elsif ($forced_into_main {$name} and $caller ne 'main') {
croak "Variable name '$name' is forced into main::";
}
elsif ($name =~ /^__/) {
croak "Variable name '$name' begins with '__'";
}
elsif ($name =~ /^[A-Za-z_]\w*\z/) {
# Perhaps give a warning.
if (warnings::enabled ()) {
if ($keywords {$name}) {
warnings::warn ("Variable name '$name' is a Perl keyword");
}
elsif ($forced_into_main {$name}) {
warnings::warn ("Variable name '$name' is forced into " .
"package main::");
}
else {
warnings::warn ("Variable name '$name' has unknown problems");
}
}
}
elsif ($name =~ /^[01]?\z/) {
if (@_) {
croak "Variable name '$name' is invalid";
}
else {
croak "Variable name looks like a boolean value";
}
}
else {
# Must have bad characters.
croak "Variable name '$name' has invalid characters";
}
if (@_ > 1) {
croak "Variables have to be scalar";
}
{
no strict 'refs';
my $value = shift; # Might be undef, which is ok.
my $full = "${caller}::$name";
$declared {$full} ++;
*$full = sub () : lvalue {$value};
}
}
1;
__END__
=pod
=head1 NAME
variable - Perl pragma to declare (scalar) variables without a leading C<$>.
=head1 SYNOPSIS
use variable spam => 17;
use variable eggs => spam + 25;
use variable "i"; # Makes "i" undefined.
use variable arr => [qw /aap noot mies wim zus jet/];
print eggs, "\n"; # Print 42.
eggs += 27;
print eggs, "\n"; # Print 69.
for (i = 0; defined (arr -> [i]); i ++) {
print arr -> [i], " "; # Print aap noot mies wim zus jet.
}
=head1 DESCRIPTION
This simple module allows you to create scalar variables that do not need
a leading C<$>. This will make people coming from a B<C> or a B<Python>
background feel more at home.
=head1 NOTES
This module requires perl 5.6.0.
The values given to the variables are evaluated in list context. You may
wish to override this by using C<scalar>.
These variables do not directly interpolate into doublequotish strings,
although you may do so indirectly. (See the perlref manpage for details
about how this works.)
print "The value of eggs is ${\eggs}.\n";
This only works for scalar variables, not arrays or hashes.
Naming of variables follow the same rules as in C<constant.pm>. Names must
begin with a letter or underscore. Names beginning with a double underscore
are reserved. Some poor choices for names will generate warnings, if warnings
are enabled at compile time.
Variable symbols are package scoped (rather than block scoped, as
C<use strict;> is. That is, you can refer to a variable from
package C<Other> as C<Other::var>.
As with all C<use> directives, defining a variable happens at compile time.
This, it's probably not correct to put a variable declaration inside of
a conditional statement (like C<if ($foo) {use variable ...}>).
Omitting the value for a symbol gives it the value of C<undef>. This isn't
so nice as it may sound, though, because in this case you must either
quote the symbol name, or use a big arrow C<< => >> with nothing to point to.
It is probably best to declare these explicitly.
use variable bacon => ();
use variable ham => undef;
The result from evaluating a list constant in a scalar context is B<not>
documented, and is not guaranteed to be any particular value in the
future. In particular, you should not rely upon it being the number of
elements in the list, especially since it is not B<necessarily> that value
in the current implementation.
In the rare case in which you need to discover at run time whether a
particular variable has been declared via this module, you may use
this function to examine the hash C<%variable::declared>. If the given
variable name does not include a package name, the current package is
used.
sub declared ($) {
use variable; # don't omit this!
my $name = shift;
$name =~ s/^::/main::/;
my $pkg = caller;
my $full = $name =~ /::/ ? $name : "${pkg}::$name";
$variable::declared {$full};
}
=head1 BUGS
A variable with the name in the list
C<STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG>
is not allowed anywhere but in package C<main::>, for technical reasons.
You can get into trouble if you use variables in a context which
automatically quotes barewords (as is true for any subroutine call).
For example, you can't say C<$hash {variable}> because
C<variable> will be interpreted as a string. Use
C<$hash {variable ()}> or C<$hash {+variable}> to prevent the
bareword quoting mechanism from kicking in. Similarly, since the
C<< => >> operator quotes a bareword immediately to its left,
you have to say C<< variable () => 'value' >> (or simple use a comma
in place of the big arrow) instead of C<< variable => 'value' >>
=head1 AUTHOR
This package was written by Abigail, <abigail@delanet.com>.
=head1 COPYRIGHT AND LICENSE
This package is copyright 2000 by Abigail.
This program is free and open software. You can redistribute it or
modify it under the same terms as Perl itself.
=head1 THANKS
The author wishes to thank EFNet's B<#python> IRC channel for
the inspiration to write this module.
A lot of the code and documentation of C<constant.pm> was cut and
pasted in.
=cut
------------------------------
Date: 19 May 2000 02:46:17 GMT
From: Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
Subject: Re: variable.pm
Message-Id: <8g29tp$1f52$1@news.enteract.com>
abigail@arena-i.com writes:
>Here's a way to use scalar variables without the needing a '$'.
Now how about overloading "." so you can look up attributes with
a.b.c etc?
------------------------------
Date: Fri, 19 May 2000 11:26:47 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: variable.pm
Message-Id: <8g2c9r$c9k@netnews.hinet.net>
Intergalactic Denizen of Mystery wrote
> Abigail writes:
> >Here's a way to use scalar variables without the needing a '$'.
> Now how about overloading "." so you can look up attributes with
> a.b.c etc?
This was once in my wish list. I asked the same question last year.
Subject: "dot is too precious to be only for string concatenation"
After getting used to '->', and having lvalue subs, I no more think
$john.friends[2].name = 'Tom';
has any significant difference from
$john->{friends}[2]->{name} = 'Tom';
or
$john->friends(2)->name = 'Tom';
But, as a Perl learner, I still wonder whether it is achievable or not
in new version of Perl to MAKE this kind of syntax. Is it possible?
Thank you.
John Lin
------------------------------
Date: 19 May 2000 04:01:23 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: zen and the art of trolling [OT]
Message-Id: <8g2eaj$i5s$0@216.155.33.32>
In article <B547A14B.9CF0%xah@xahlee.org>, Xah <xah@xahlee.org> wrote:
| Dear Paul:
|
| This is a technical newsgroup.
| Please shove your asinine moralization back in your ass.
|
| I get so tired of this fucking class of shit droppers who don't spent time
| to think about the nature of things and consequences but bloat their
| righteous ego and promptly rush forward to demonstrate their stupidity in
| sincereness as if the world care about their contribution to noise.
|
| Tell your class of Perl cronies to shut their fucking beer-holes, and you
| will immediately save 80% of the most worthless posts in this group.
|
| Fly over to comp.lang.perl.moderated, see if they want you there.
|
| Xah
| xah@xahlee.org
| http://xahlee.org/PageTwo_dir/more.html
*plonk*
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 3094
**************************************