[19958] in Perl-Users-Digest
Perl-Users Digest, Issue: 2153 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 18 18:05:40 2001
Date: Sun, 18 Nov 2001 15:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1006124706-v10-i2153@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 18 Nov 2001 Volume: 10 Number: 2153
Today's topics:
Re: attach file <tintin@snowy.calculus>
Re: Directory problem... again (BUCK NAKED1)
Re: HELP: creating regexps on the fly and backslashes.. (Tad McClellan)
Re: HELP: creating regexps on the fly and backslashes.. (Bruno Boettcher)
Intrusion Vulerability ActiveState ActivePerl 5.6.1.630 (Chris Welch)
Re: Intrusion Vulerability ActiveState ActivePerl 5.6.1 <vze2r2j8@verizon.net>
Re: Intrusion Vulerability ActiveState ActivePerl 5.6.1 <vze2r2j8@verizon.net>
Net::NNTP question <stevet@ex-pressnet.com>
Net::NNTP question <stevet@ex-pressnet.com>
Re: Net::NNTP question <godzilla@stomp.stomp.tokyo>
Re: Net::NNTP question <Tassilo.Parseval@post.rwth-aachen.de>
Re: Net::NNTP question (Ralph Corderoy)
Re: Net::NNTP question <godzilla@stomp.stomp.tokyo>
Re: Net::NNTP question <Tassilo.Parseval@post.rwth-aachen.de>
Re: Net::NNTP question <stevet@ex-pressnet.com>
Re: Newbie Need Help <henders@math.rice.edu>
Re: Parse::RecDescent suitability question <bart.lateur@skynet.be>
Re: Please Kindly Help With DBI <jeff@vpservices.com>
Setting Cookie (Wiliam Stephens)
Re: shorten a pattern-matching-statement <mgjv@tradingpost.com.au>
Re: Sorting of arrays by an element of each <mikecook@cigarpool.com>
Re: Which ISPs support perl scripts? (BUCK NAKED1)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 19 Nov 2001 08:16:09 +1100
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: attach file
Message-Id: <3bf824aa_2@news.iprimus.com.au>
"Kris" <kris@iknowtek.com> wrote in message
news:tve5c5411qarc0@corp.supernews.com...
> Dennis,
>
> Thanks for sending the script. I do have a few questions tho. Can you tell
> me when I see something like the following, if this is something that came
> across incorrectly or if that is something that should be there.
>
> &error("3o-O CGI ?Y-n¢DI?W cgi.pm cM mime::base64 3o¡La-O Perl 5.005
> ao£g{|!Rw!I<br>$@ <br>$!") if($@);
>
> some of this makes sense to my non perl brain but alot does not.
Y-n¢DI?W
> ?????
Ignore the script that was posted. Use the very simple MIME::Lite
Here's an example attachment from the MIME::Lite documentation:
### Create a new multipart message:
$msg = MIME::Lite->new(
From =>'me@myhost.com',
To =>'you@yourhost.com',
Cc =>'some@other.com, some@more.com',
Subject =>'A message with 2 parts...',
Type =>'multipart/mixed'
);
### Add parts (each "attach" has same arguments as "new"):
$msg->attach(Type =>'TEXT',
Data =>"Here's the GIF file you wanted"
);
$msg->attach(Type =>'image/gif',
Path =>'aaa000123.gif',
Filename =>'logo.gif',
Disposition => 'attachment'
);
------------------------------
Date: Sun, 18 Nov 2001 13:41:43 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Directory problem... again
Message-Id: <14154-3BF80EF7-154@storefull-241.iap.bryant.webtv.net>
What can I say? If I don't understand, I don't understand. Some of the
docs I understand, and some of them I don't. I think most of the docs
are unclear and unthorough; but maybe it's just me.
mgjv@tradingpost.com.au (Martien=A0Verbruggen)
> Was there anything not clear about the utime() entry in perlfunc?
Yes.... this statement... "The first two elements of the list must be
the NUMERICAL access and modification times, in that order." To me that
still doesn't explain why you use the same 2 scalar arguments together.
It seems to me that you'd need 2 different scalars, such as in the case
of rename $oldfile, $newfile
.. in order to change the old value to the new value.
And URI, considering your history with me, I can't take your comments
seriously. You've never helped me. All you've ever done is criticize and
send me angry emails when I was recently being civil to someone here in
this group.
Regards,
--Dennis
------------------------------
Date: Sun, 18 Nov 2001 16:28:23 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: HELP: creating regexps on the fly and backslashes...?
Message-Id: <slrn9vfhn2.c4g.tadmc@tadmc26.august.net>
Bruno Boettcher <bboett@bboett.dyndns.org> wrote:
>now i want the
>thing to react on empty lines or lines that contain a [\]
print "react\n" if $line =~ /^$|\\/;
>but depending
>on some previously parsed stuff....
Huh?
>so i thought i set up a thing like this:
>my $characteristicString = "" or '\[\\\\\]';
You should *always* enable warnings when developing Perl code!
>so is there an easy way to get this working?
^^^^^^^
I cannot figure out what you want done, so I don't know what
"working" might mean. I cannot understand your problem specification.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 18 Nov 2001 17:12:30 GMT
From: bboett@bboett.dyndns.org (Bruno Boettcher)
Subject: Re: HELP: creating regexps on the fly and backslashes...?
Message-Id: <9t8q5u$ib0$1@wanadoo.fr>
In article <9t88rv$j74$00$1@news.t-online.com>,
Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
>I really don't understand this, but...
ok, maybe i make myself more clear...
somewhere in the code i have
$characteristicString = "";
if at some other part in the code something happens, i change it to
$characteristicString = '\[\\\]';
>
>> if($line =~ /^\s*$characteristicString\s*$/)
>> { ... process... }
>>
>> but somehow this line gets never triggered....
>> as far as i can tell there's some problem with the backlsashes....
>
>No, there must be other problems. I guess somewhere in the logic.
you were right, in fact i was mislead by the way $characteristicString
was issued in a print statement...
--
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
------------------------------
Date: 18 Nov 2001 11:29:59 -0800
From: macspert@webnautica.net (Chris Welch)
Subject: Intrusion Vulerability ActiveState ActivePerl 5.6.1.630
Message-Id: <675406f5.0111181129.5a37a4d8@posting.google.com>
Last week I installed ActivePerl 5.6.1.630 on Windows 2000 Server with
IIS 5.0. Days later our email was down. After further inspection I
found that someone had intruded into our system and was using the
"Perl" directory for storing pirated software and movies (some good
stuff too). After uninstalling ActivePerl, and removing the files we
determined that the hacker had most likely not gained system-wide
control of the server.
After reading the event logs there were 7 errors posted about 34 hours
before the disk full errors occured. One of the event messages follows:
------------------------------------
Event Type: Error
Event Source: W3SVC
Event Category: None
Event ID: 16
Date: 11/14/2001
Time: 8:16:16 AM
User: N/A
Computer: WIN10518
Description:
The script started from the URL
'/scripts/..%5c../winnt/system32/cmd.exe' with parameters '%2' has not
responded within the configured timeout period. The HTTP server is
terminating the script.
For additional information specific to this message please visit the
Microsoft Online Support site located at:
http://www.microsoft.com/contentredirect.asp.
------------------------------------
Each error is similar but has different apps attempted to be run.
If you can shed any light on this or believe this may be an Intrusion
Vulnerability please contact me as soon as possible. Thank you for your
help.
~ Chris
------------------------------
Date: Sun, 18 Nov 2001 22:59:06 GMT
From: "Kurt Stephens" <vze2r2j8@verizon.net>
Subject: Re: Intrusion Vulerability ActiveState ActivePerl 5.6.1.630
Message-Id: <_2XJ7.1648$%y5.104307@typhoon1.gnilink.net>
"Chris Welch" <macspert@webnautica.net> wrote in message
news:675406f5.0111181129.5a37a4d8@posting.google.com...
> Last week I installed ActivePerl 5.6.1.630 on Windows 2000 Server with
> IIS 5.0. Days later our email was down. After further inspection I
> found that someone had intruded into our system and was using the
> "Perl" directory for storing pirated software and movies (some good
> stuff too). After uninstalling ActivePerl, and removing the files we
> determined that the hacker had most likely not gained system-wide
> control of the server.
This has nothing to do with ActiveState Perl - It is a server configuration
issue (See below).
> After reading the event logs there were 7 errors posted about 34 hours
> before the disk full errors occured. One of the event messages follows:
>
> ------------------------------------
>
> Event Type: Error
> Event Source: W3SVC
> Event Category: None
> Event ID: 16
> Date: 11/14/2001
> Time: 8:16:16 AM
> User: N/A
> Computer: WIN10518
> Description:
> The script started from the URL
> '/scripts/..%5c../winnt/system32/cmd.exe' with parameters '%2' has not
> responded within the configured timeout period. The HTTP server is
> terminating the script.
Let's see... 0x5C = '\', so assuming that your HTTP root is C:\Inetpub, then
the URL would map to C:\Inetpub\scripts\..\..\winnt\system32\cmd.exe, in
other words, C:\winnt\system32\cmd.exe. You've been had, and ActiveState
Perl is never being called.
> For additional information specific to this message please visit the
> Microsoft Online Support site located at:
> http://www.microsoft.com/contentredirect.asp.
>
> ------------------------------------
>
> Each error is similar but has different apps attempted to be run.
>
> If you can shed any light on this or believe this may be an Intrusion
> Vulnerability please contact me as soon as possible. Thank you for your
> help.
>
> ~ Chris
Could it be that your NT permissions allow C:\ to be world readable? I
could not replicate this vulnerability on my development server, but that is
because I moved C:\InetPub to D:\InetPub. (I'm not too woried about
security on this system; It responds only to a local IP address on my LAN,
in a locked building, with no connection to the Internet.) I would query
the Microsoft Knowlege Base, or check the section under Security on their
IIS web site.
Again, this has nothing to do with ActiveState Perl. That is, unless
someone types in http://yourdomain/scripts/..%5C../perl/bin/perl.exe ;)
HTH,
Kurt Stephens
------------------------------
Date: Sun, 18 Nov 2001 23:00:48 GMT
From: "Kurt Stephens" <vze2r2j8@verizon.net>
Subject: Re: Intrusion Vulerability ActiveState ActivePerl 5.6.1.630
Message-Id: <A4XJ7.1649$%y5.106076@typhoon1.gnilink.net>
"Chris Welch" <macspert@webnautica.net> wrote in message
news:675406f5.0111181129.5a37a4d8@posting.google.com...
> Last week I installed ActivePerl 5.6.1.630 on Windows 2000 Server with
> IIS 5.0. Days later our email was down. After further inspection I
> found that someone had intruded into our system and was using the
> "Perl" directory for storing pirated software and movies (some good
> stuff too). After uninstalling ActivePerl, and removing the files we
> determined that the hacker had most likely not gained system-wide
> control of the server.
This has nothing to do with ActiveState Perl - It is a server configuration
issue (See below).
> After reading the event logs there were 7 errors posted about 34 hours
> before the disk full errors occured. One of the event messages follows:
>
> ------------------------------------
>
> Event Type: Error
> Event Source: W3SVC
> Event Category: None
> Event ID: 16
> Date: 11/14/2001
> Time: 8:16:16 AM
> User: N/A
> Computer: WIN10518
> Description:
> The script started from the URL
> '/scripts/..%5c../winnt/system32/cmd.exe' with parameters '%2' has not
> responded within the configured timeout period. The HTTP server is
> terminating the script.
Let's see... 0x5C = '\', so assuming that your HTTP root is C:\Inetpub, then
the URL would map to C:\Inetpub\scripts\..\..\winnt\system32\cmd.exe, in
other words, C:\winnt\system32\cmd.exe. You've been had, and ActiveState
Perl is never being called.
> For additional information specific to this message please visit the
> Microsoft Online Support site located at:
> http://www.microsoft.com/contentredirect.asp.
>
> ------------------------------------
>
> Each error is similar but has different apps attempted to be run.
>
> If you can shed any light on this or believe this may be an Intrusion
> Vulnerability please contact me as soon as possible. Thank you for your
> help.
>
> ~ Chris
Could it be that your NT permissions allow C:\ to be world readable? I
could not replicate this vulnerability on my development server, but that is
because I moved C:\InetPub to D:\InetPub. (I'm not too woried about
security on this system; It responds only to a local IP address on my LAN,
in a locked building, with no connection to the Internet.) I would query
the Microsoft Knowlege Base, or check the section under Security on their
IIS web site.
Again, this has nothing to do with ActiveState Perl. That is, unless
someone types in http://yourdomain/scripts/..%5C../perl/bin/perl.exe ;)
HTH,
Kurt Stephens
------------------------------
Date: Sun, 18 Nov 2001 10:39:22 -0500
From: steve <stevet@ex-pressnet.com>
Subject: Net::NNTP question
Message-Id: <3BF7D62A.CE2D6A95@ex-pressnet.com>
This is a multi-part message in MIME format.
--------------899A293E3BCEE43CF5B5E08E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
New to perl. i have been trying write a script to list newsgroup of a
certain pattern. I get this error when i run the script.
Global symbol $groups requires explicit package at ./newsstat.pl line 16
also same fo line 18.
Here is the script
#!/usr/bin/perl
# file:newsstats.pl
use strict;
use Net::NNTP;
my $nntp = Net::NNTP->new() or die "Couldn't connect : $!\n";
print_stats($nntp,$_) while $_ = shift;
$nntp->quit;
sub print_stats {
my $nntp =shift;
my $pattern = shift;
my $group = $nntp->newsgroups($pattern);
return print "$pattern: No matching newgroups\n"
unless $groups && keys %$groups;
for my $g (sort keys %$groups) {
my ($articles,$first,$last) = $nntp->group($g);
printf "%-60s %5d articles\n", $g,$articles;
}
}
-----------------------
Could there be a missing package? I appreciate any help.
thanks
--------------899A293E3BCEE43CF5B5E08E
Content-Type: text/x-vcard; charset=us-ascii;
name="stevet.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for steve
Content-Disposition: attachment;
filename="stevet.vcf"
begin:vcard
n:;Centipede
x-mozilla-html:FALSE
org:kungfumovies.net;kungfumovies.net
adr:;;;;;;
version:2.1
email;internet:centipede@kungfumovies.net
title:www.kungfumovies.net
note:Kung fu movies specialty store online. On DVD, VHS, and VideoCD.
x-mozilla-cpt:;0
fn:Centipede
end:vcard
--------------899A293E3BCEE43CF5B5E08E--
------------------------------
Date: Sun, 18 Nov 2001 13:52:46 -0500
From: steve <stevet@ex-pressnet.com>
Subject: Net::NNTP question
Message-Id: <3BF8037E.38BE256F@ex-pressnet.com>
This is a multi-part message in MIME format.
--------------5DAAE987F02DBAE8A12C586C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newbie. I am trying to post a message to a newsgroup but i get this
error
send article to be posted
invalid article
Here is the code
#!/usr/bin/perl -w
# file:newsstats.pl
use strict;
use Net::NNTP;
my $nntp = Net::NNTP->new('news.ex-pressnet.com') or die "Couldn't
connect : $!\n";
my $success= $nntp->authinfo('STEVET'=>'GRAPE');
print "success is: $success\n";
my $ok = $nntp->postok();
print "ok: $ok\n";
my $group = $nntp->group('alt.tv.kungfu');
print "group $group\n";
$success = $nntp->post("Hello this is a test");
print "success is: $success\n";
print $nntp->message;
$nntp->quit;
---------------
is there something missing from the nntp->post method.
Thanks for any help.
--------------5DAAE987F02DBAE8A12C586C
Content-Type: text/x-vcard; charset=us-ascii;
name="stevet.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for steve
Content-Disposition: attachment;
filename="stevet.vcf"
begin:vcard
n:;Centipede
x-mozilla-html:FALSE
org:kungfumovies.net;kungfumovies.net
adr:;;;;;;
version:2.1
email;internet:centipede@kungfumovies.net
title:www.kungfumovies.net
note:Kung fu movies specialty store online. On DVD, VHS, and VideoCD.
x-mozilla-cpt:;0
fn:Centipede
end:vcard
--------------5DAAE987F02DBAE8A12C586C--
------------------------------
Date: Sun, 18 Nov 2001 07:58:38 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Net::NNTP question
Message-Id: <3BF7DAAE.D4B1499D@stomp.stomp.tokyo>
steve wrote:
(snipped)
> New to perl. i have been trying write a script to list newsgroup of a
> certain pattern. I get this error when i run the script.
> Global symbol $groups requires explicit package at ./newsstat.pl line 16
> also same fo line 18.
Add this at an appropriate position in your script:
my ($groups);
> Here is the script
> #!/usr/bin/perl
> # file:newsstats.pl
> use strict;
> use Net::NNTP;
my ($groups); <- acts like a global variable here.
sub print_stats {
my ($groups); <- restricted to scope of sub-routine.
my $nntp =shift;
my $pattern = shift;
You may also use our ($groups); if you need a true global.
A good idea is to turn off strict once you have finished
writing your script. Pragma such as strict, warnings and
similar only serve to decrease efficiency of a script
once it is written in its final version. Your script
will run a minimum two percent slower and up to an
unacceptable ten percent slower, depending on its
complexity and degree of pragma invoked.
Godzilla!
------------------------------
Date: Sun, 18 Nov 2001 17:01:55 +0100
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Net::NNTP question
Message-Id: <9t8m1j$pnv$06$1@news.t-online.com>
On Sun, 18 Nov 2001 10:39:22 -0500, steve wrote:
> New to perl. i have been trying write a script to list newsgroup of a
> certain pattern. I get this error when i run the script.
> Global symbol $groups requires explicit package at ./newsstat.pl line 16
> also same fo line 18.
That's an excellent example why strictures are so useful.
> Here is the script
> #!/usr/bin/perl
^ -w # add this and have even more fun
[...]
> sub print_stats {
> my $nntp =shift;
> my $pattern = shift;
> my $group = $nntp->newsgroups($pattern);
^^^^^^
> return print "$pattern: No matching newgroups\n"
> unless $groups && keys %$groups;
^^^^^^A ^^^^^^^A
> for my $g (sort keys %$groups) {
^^^^^^^A
> Could there be a missing package? I appreciate any help.
No. Compare the three marked spots above. You created a variable $group
but you after that it has magically transformed into $groups (marked by
the 'A'). $group has been correctly declared, $groups not.
Tassilo
--
The major sin is the sin of being born.
-- Samuel Beckett
------------------------------
Date: 18 Nov 2001 17:02:18 GMT
From: ralph@inputplus.demon.co.uk (Ralph Corderoy)
Subject: Re: Net::NNTP question
Message-Id: <9t8piq$fp1$1@inputplus.demon.co.uk>
> A good idea is to turn off strict once you have finished writing your
> script.
Hey Godzilla, rather than dishing out more dubious advice can you reply
to my question concerning your view that browsers think .cgi URLs are
special?
Ralph.
------------------------------
Date: Sun, 18 Nov 2001 10:07:00 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Net::NNTP question
Message-Id: <3BF7F8C4.250A08CB@stomp.stomp.tokyo>
Ralph Corderoy wrote:
> > A good idea is to turn off strict once you have finished
> > writing your script.
> Hey Godzilla, rather than dishing out more dubious advice
> can you reply to my question concerning your view that browsers
> think .cgi URLs are special?
Browsers do not think much like yourself.
I have not presented this viewpoint you attribute
to me, quite falsely and quite deliberately.
I have already answered your question, at length,
in a professional fashion, as you well know.
You believe my advice is dubious. Why are you asking
me for advice? This is mondo beyondo oxymoronic.
I am interested why you have stalked me here from a
different newsgroup and are trolling me. Did I make
a comment which bruised your fragile masculine ego?
You be careful. The history of this group well shows
almost all sissified geeks become psychotically
obsessed with me. I own a lot of minds around here.
Your stalking of me indicates you are becoming or
are psychotically obsessed with me and, you are
placing your mind up for grabs. I just may take it.
Might be, I already have.
Godzilla! Queen Of Mind Munchers.
------------------------------
Date: Sun, 18 Nov 2001 19:54:37 +0100
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Net::NNTP question
Message-Id: <9t905d$f9j$04$1@news.t-online.com>
On Sun, 18 Nov 2001 13:52:46 -0500, steve wrote:
> Newbie. I am trying to post a message to a newsgroup but i get this
> error
> send article to be posted
> invalid article
>
> Here is the code
[...]
> $success = $nntp->post("Hello this is a test");
You haven't read the docs carefully:
post ( [ MESSAGE ] )
Post a new article to the news server. If "MESSAGE" is
specified and posting is allowed then the message will
be sent.
[...]
"MESSAGE" can be either an array of lines or a refer
ence to an array.
"Hello this is a test" is not a valid NNTP-message. A message consists
of a head and a body. Just look at the source of the posts to this
newsgroup and you'll get an idea.
Tassilo
--
Have a nice day!
------------------------------
Date: Sun, 18 Nov 2001 16:48:09 -0500
From: steve <stevet@ex-pressnet.com>
Subject: Re: Net::NNTP question
Message-Id: <3BF82C99.A8310B8C@ex-pressnet.com>
This is a multi-part message in MIME format.
--------------7A93B4249B96ED22F17B7809
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
"Tassilo v. Parseval" wrote:
> On Sun, 18 Nov 2001 13:52:46 -0500, steve wrote:
>
> > Newbie. I am trying to post a message to a newsgroup but i get this
> > error
> > send article to be posted
> > invalid article
> >
> > Here is the code
>
> [...]
>
> > $success = $nntp->post("Hello this is a test");
>
> You haven't read the docs carefully:
>
> post ( [ MESSAGE ] )
> Post a new article to the news server. If "MESSAGE" is
> specified and posting is allowed then the message will
> be sent.
> [...]
> "MESSAGE" can be either an array of lines or a refer
> ence to an array.
>
> "Hello this is a test" is not a valid NNTP-message. A message consists
> of a head and a body. Just look at the source of the posts to this
> newsgroup and you'll get an idea.
>
> Tassilo
> --
> Have a nice day!
I still have no clue how to set this up. Do you have a sample.
thanks
--------------7A93B4249B96ED22F17B7809
Content-Type: text/x-vcard; charset=us-ascii;
name="stevet.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for steve
Content-Disposition: attachment;
filename="stevet.vcf"
begin:vcard
n:;Centipede
x-mozilla-html:FALSE
org:kungfumovies.net;kungfumovies.net
adr:;;;;;;
version:2.1
email;internet:centipede@kungfumovies.net
title:www.kungfumovies.net
note:Kung fu movies specialty store online. On DVD, VHS, and VideoCD.
x-mozilla-cpt:;0
fn:Centipede
end:vcard
--------------7A93B4249B96ED22F17B7809--
------------------------------
Date: 18 Nov 2001 14:32:10 -0600
From: Dale Henderson <henders@math.rice.edu>
Subject: Re: Newbie Need Help
Message-Id: <qkkadxj252t.fsf@math.rice.edu>
>>>>> "JM" == Josef Möllers <josef.moellers@fujitsu-siemens.com> writes:
JM> April Harmon wrote:
>> =
>> What Perl codes (or functions) should I use to execute C/C++
>> programs? Thanks in advance.
JM> system or fork+exec
or back ticks (`)
------------------------------
Date: Sun, 18 Nov 2001 14:31:47 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Parse::RecDescent suitability question
Message-Id: <doffvtsdra71rtis7rjhmnfm73t2b2i3c0@4ax.com>
Barry Hemphill wrote:
>I would like to create a parser for a report definition language with
>the format shown below. Before I started writing from scratch I
>thought I'd look at some modules which might help, and
>Parse::RecDescent certainly looked to be the thing. It also looks to
>have a fairly steep learning curve, and unfortunately I don't have any
>yacc experience, so before I put a lot of time in going down the wrong
>path, I'm wondering if anyone could give me an idea if RecDescent
>would be suitable. Here's a quick overview of the format:
>
>Basically, we have 3 types of assignments:
>- simple
> keyword value
>- complex
> keyword {
> keyword value
> }
>- complex with tagname
> keyword tagname {
> keyword value
> }
First of all, your definition of the grammar doesn't agree with your
example. Damian Conway already gave an improved version. In essence, you
forgot to indicate that the syntax can be recursively nested.
Sure, you can use Parse::RecDescent for something like this. As one
alternative, MJD's little project "py", to be found on his website,
<http://perl.plover.com/py/>, can be used to turn the output when
feeding the grammar through Bison (an improved Yacc clone) into a set of
states, to be included in a simple script, with a "driver" to step
through the states interpreting the input.
But, because of the structure of the syntax, you don't really need to do
this. The reason is the embedded newlines, which form an essential part
of the syntax. For the same reason, a language like BASIC is easier to
parse with a hand built parser than, say, C.
So here's a simple, pure perl solution, which simply maintains nesting
state on a stack. For each simple assignment, you can keep track of how
deeply it is nested, by examining the state of this stack.
use Data::Dumper;
while(<DATA>) {
if(/^\s*(\w+)\s*([^{}]+?)\s*$/) { # simple
print Dumper [ @stack,
{ type => 'simple', keyword => $1, value => $2 } ];
} elsif(/^\s*(\w+)\s*\{\s*$/) { # open untagged complex
push @stack, { type => 'complex', keyword => $1 };
} elsif(/^\s*(\w+)\s*(\S+)\s*\{\s*$/) { # open tagged complex
push @stack, { type => 'tagged complex', keyword => $1,
tag => $2 };
} elsif(/^\s*\}\s*$/) { # closing brace
pop @stack or die "Too many closing braces"
} else {
die "Syntax error";
}
}
@stack and die "Not enough closing braces"
Each time this encounters a simple assignment, it will dump out the
state of the stack For example, for the first simple assignment in your
example:
chartStyles {
chartStyle stdChartNoLegendTemplate {
xAxis {
drawOffset 0.0
}
}
}
this dumps:
$VAR1 = [
{
'keyword' => 'chartStyles',
'type' => 'complex'
},
{
'keyword' => 'chartStyle',
'tag' => 'stdChartNoLegendTemplate',
'type' => 'tagged complex'
},
{
'keyword' => 'xAxis',
'type' => 'complex'
},
{
'keyword' => 'drawOffset',
'value' => '0.0',
'type' => 'simple'
}
];
The top of the stack is underneath, here followed by a record describing
the simple assignment itself.
Of course, you can do anything you want instead of printing out the
stackdump, for example, build a complex data structure for processing
later. Maybe you should be aware of the fact the if you simply duplicate
the contents of the stack, you'll likely end up with several references
to the same hashes.
--
Bart.
------------------------------
Date: Sun, 18 Nov 2001 10:37:49 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Please Kindly Help With DBI
Message-Id: <3BF7FFFD.6BE7BCBF@vpservices.com>
Susan Weiss wrote:
>
> DBD::AnyData::db selectrow_array failed: unknown column: employeeFile.elname
> at
> C:/perl/site/lib/SQL/Statement.pm line 53
The only thing I can think of is that you are running into line-ending
issues. What line endings does the C program output? Try setting the
line endings specifically by inserting an eol like this:
> > ...
> > $dbh->func( 'employeeFile','CSV','prog.txt', {
> > col_names => 'enum,elname,efname',
eol => "\015\012",
> > sep_char => ' ',
> > },'ad_catalog');
> > ...
You may need to experiment with other line endings or use emacs or a hex
editor to see what the acutal endings in the file are.
--
Jeff
------------------------------
Date: 18 Nov 2001 08:24:39 -0800
From: wil@fbagroup.co.uk (Wiliam Stephens)
Subject: Setting Cookie
Message-Id: <39e3e00a.0111180824.7da8dcb7@posting.google.com>
Hi
I'm trying to use the following sub to set a cookie to the browser.
However, for some reason the cookie never gets set and no error ever
gets returned?
I'm calling the sub "set_cookie;" which should go and find a random
number and then set the cookie from $randid.
Any help would be most appreciated.
#######################################################################################
#######################################################################################
sub get_unique_id {
my $randlet = chr(65 + int(rand(26))) . chr(65 + int(rand(26)));
my $randnum = 100_000 + int rand 900_000;
my $randid = $randlet . $randnum;
&connect_to_db;
$sth = $dbh->prepare("SELECT id FROM bs_sessions WHERE id =
$randid");
$sth->execute();
my $isnumrand = $sth->fetchrow_hashref;
$sth->finish();
if ($isnumrand->{id}) {
&get_unique_id;
}
if (!$randid) {
&error_html("Random ID is empty.");
}
return $randid;
}
#######################################################################################
#######################################################################################
sub set_cookie {
my $randid = &get_unique_id;
$cookie_id = $query->cookie (
-name => 'id',
-value => $randid,
-expires => '+1w',
-path => '/',
-domain => 'www.fbagroup.co.uk'
);
print $query->header(-cookie=>$cookie_id);
}
#######################################################################################
#######################################################################################
Rgds
Wil Stephens
------------------------------
Date: Mon, 19 Nov 2001 05:25:32 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: shorten a pattern-matching-statement
Message-Id: <slrn9vfv8r.i3u.mgjv@martien.heliotrope.home>
On Sun, 18 Nov 2001 11:56:03 +0100,
Laocoon <Laocoon@eudoramail.com> wrote:
> "Rene Scheibe" <Rene.Scheibe@gmx.net> wrote in news:9t82m8$s836$1@ID-
> 65612.news.dfncis.de:
>
>> How can I shorten or merge this pattern matching statement into one?
>>
>> if (($line =~ /(^192.168.)/) && !($line =~ /(0\.0KB\/s.*0\.0KB\/s)/)) {
>> ...
>> }
>
>
> if ( $line =~ /^192.168./ && $line !~ m#(0\.KB/s).*\1# ) { ... }
>
> if ( $line !~ m#^(?=192.168.).*(0\.KB/s).*\1# { ... }
These are of course, not the same. Try $line = "a"; You could use a
negative lookahead, but I generally prefer to keep these things as
separate matches. The first solution will do quite well.
Martien
--
|
Martien Verbruggen | That's not a lie, it's a terminological
| inexactitude.
|
------------------------------
Date: Sun, 18 Nov 2001 15:40:59 -0700
From: "Michael Cook" <mikecook@cigarpool.com>
Subject: Re: Sorting of arrays by an element of each
Message-Id: <mOWJ7.540$l03.183981@news.uswest.net>
"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7y9l7gbr9.fsf@home.sysarch.com...
<snip>
> @1001 is a very poor way to name an array. and it looks like you will be
> donw the path to symbolic references if you need to manage many of those
> arrays.
>
> so you should go to an array of arrays (also called list of lists)
> arrangement. read perllol and perldsc for more on that.
>
> then you want to sort an LoL which is covered in an FAQ on how to sort
> by anything. also read this paper on sorting:
>
> http://www.sysarch.com/perl/sort_paper.html
</snip>
Hi again!
I am stuck in this sorting the LoL. I have read the FAQ linked above and
can't figure out how to apply it to my data, I am guessing an indexed sort
rather than the ST sort, like:
my $i = 0;
keys my %h = @in;
@h{ map pack('C4 A x N' => $_->[0]
=~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/,
$_->[1], $i++) => @in } = @in;
@out = @h{ sort keys %h };
Here is how I am creating the LoL:
foreach $CHOSENPRODNUM (@CHOSENPRODNUMS)
{
if ( $CHOSENPRODNUM eq "$row[12]" )
{
$LoL[$count]=( [ "$row[0]", "$row[1]", "$row[2]", "$row[12]",
"$row[13]", "$row[14]", "$row[15]", "$row[16]", "$row[17]" ] );
$count++;
}
}
I need to display these items in alphabetical order, sorted by $row[0]
(brand name). I am stumped...
Thanks!!!
Michael
--
== CigarPool ==
http://www.cigarpool.com
------------------------------
Date: Sun, 18 Nov 2001 13:57:34 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Which ISPs support perl scripts?
Message-Id: <14155-3BF812AE-73@storefull-241.iap.bryant.webtv.net>
> www.tripod.com
> Bill Segraves
No, no. Please don't recommend Tripod. They are terrible for perl and
cgi. Most cgi's will not work there. Their cgi capabilities are severely
limited.
Regards,
--Dennis
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 2153
***************************************