[29933] in Perl-Users-Digest
Perl-Users Digest, Issue: 1176 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 7 14:09:39 2008
Date: Mon, 7 Jan 2008 11:09:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 7 Jan 2008 Volume: 11 Number: 1176
Today's topics:
C Grammar for Parse::RecDescent necnecnecnec@gmail.com
Re: C Grammar for Parse::RecDescent <sensorflo@gmail.com>
Re: C Grammar for Parse::RecDescent <tzz@lifelogs.com>
Count differences between arrays <steve@mixmin.net>
Re: Count differences between arrays <abigail@abigail.be>
Re: Count differences between arrays <jurgenex@hotmail.com>
Re: Count differences between arrays <simon.chao@fmr.com>
Re: Create a script to manipulate a flat file <jurgenex@hotmail.com>
Re: Create a script to manipulate a flat file <someone@example.com>
E-classifieds review <ajauctionpro@gmail.com>
Hacking yahoo <sattar00786@gmail.com>
Re: how to simply parse raw image data and output to an <zen13097@zen.co.uk>
mod_perl -> Can't enable PerlResponseHandler in <Locati <regis44@gmail.com>
Re: mod_perl locking problem with Apache::Session <phippster@gmail.com>
Re: mod_perl locking problem with Apache::Session <lihao0129@gmail.com>
Re: PerlEx uploading a text file <findingAri@gmail.com>
Re: Print a perl array to html textarea ... <lihao0129@gmail.com>
Re: Print a perl array to html textarea ... <lihao0129@gmail.com>
syswrite "Bad file descriptor" after successfully writi <q2m3eft02@sneakemail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 6 Jan 2008 21:19:00 -0800 (PST)
From: necnecnecnec@gmail.com
Subject: C Grammar for Parse::RecDescent
Message-Id: <17345ed0-544b-4d2d-b987-faa5a2223bd8@e25g2000prg.googlegroups.com>
Hello,
I'm looking for a grammar to help with parsing C programs. Is there
something ready?
(I've seen in perlmonks some regular expression method, but it's a bit
weak to my needs).
Thanks,
Nec
------------------------------
Date: Sun, 6 Jan 2008 22:23:13 -0800 (PST)
From: Florian Kaufmann <sensorflo@gmail.com>
Subject: Re: C Grammar for Parse::RecDescent
Message-Id: <c3535e4b-fa50-4990-8881-ef76bcbba823@v46g2000hsv.googlegroups.com>
Thats what I have found when I googled for "c bnf":
Flo
http://c-faq.com/resources/grammars.html, which leads among others to
ftp://ftp.uu.net/usenet/net.sources/ansi.c.grammar.Z
http://lists.canonical.org/pipermail/kragen-hacks/1999-October/000201.html
http://www.cs.man.ac.uk/~pjj/bnf/c_syntax.bnf
------------------------------
Date: Mon, 07 Jan 2008 11:46:26 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: C Grammar for Parse::RecDescent
Message-Id: <863at9r0jx.fsf@lifelogs.com>
On Sun, 6 Jan 2008 21:19:00 -0800 (PST) necnecnecnec@gmail.com wrote:
n> I'm looking for a grammar to help with parsing C programs. Is there
n> something ready? (I've seen in perlmonks some regular expression
n> method, but it's a bit weak to my needs).
AFAIK this is a hard problem that hasn't been solved yet. P::RD could
do it, in theory, but what I've seen are only partial implementations.
If you or anyone else have an actual functioning lexer and parser or the
equivalent P::RD grammar, I'd be very interested in taking a look. I've
wished for something like that myself but never had the time to work on
it.
Florian's answer is a good starting point, but actually implementing the
BNF is the hard part.
Ted
------------------------------
Date: Mon, 7 Jan 2008 16:44:43 +0000 (UTC)
From: Steve <steve@mixmin.net>
Subject: Count differences between arrays
Message-Id: <fltktq$lp6$1@news.mixmin.net>
Hi all,
I'm trying to count occurrences of elements in array1 that aren't in
array2. Currently I'm doing this by converting one array to a hash and
using 'exists':-
my %foo;
my $score = 0;
@foo{@array2} = (); # Convert array to hash (for exists)
for (@array1) { $score++ unless exists $foo{$_} };
Whilst this seems to work I'm sure there's a more efficient method.
Any suggestions?
Thanks
--
pub 1024D/228761E7 2003-06-04 Steven Crook
Key fingerprint = 1CD9 95E1 E9CE 80D6 C885 B7EB B471 80D5 2287 61E7
uid Steven Crook <steve@mixmin.net>
------------------------------
Date: 07 Jan 2008 17:15:12 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Count differences between arrays
Message-Id: <slrnfo4nh0.d5.abigail@alexandra.abigail.be>
_
Steve (steve@mixmin.net) wrote on VCCXLII September MCMXCIII in
<URL:news:fltktq$lp6$1@news.mixmin.net>:
\\ Hi all,
\\
\\ I'm trying to count occurrences of elements in array1 that aren't in
\\ array2. Currently I'm doing this by converting one array to a hash and
\\ using 'exists':-
\\
\\ my %foo;
\\ my $score = 0;
\\ @foo{@array2} = (); # Convert array to hash (for exists)
\\ for (@array1) { $score++ unless exists $foo{$_} };
\\
\\ Whilst this seems to work I'm sure there's a more efficient method.
\\
\\ Any suggestions?
Read the FAQ?
Abigail
--
#!/opt/perl/bin/perl -w
$\ = $"; $SIG {TERM} = sub {print and exit};
kill 15 => fork for qw /Just another Perl Hacker/;
------------------------------
Date: Mon, 07 Jan 2008 18:19:10 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Count differences between arrays
Message-Id: <o7r4o3t02e9lfgl25lscu3b3lvcn66l19m@4ax.com>
Steve <steve@mixmin.net> wrote:
>I'm trying to count occurrences of elements in array1 that aren't in
>array2.
perldoc -q difference: "How do I compute the difference of two arrays?"
jue
------------------------------
Date: Mon, 7 Jan 2008 10:59:18 -0800 (PST)
From: nolo contendere <simon.chao@fmr.com>
Subject: Re: Count differences between arrays
Message-Id: <a94d6c8e-6db7-444f-a706-0907cf5389e0@41g2000hsy.googlegroups.com>
On Jan 7, 11:44=A0am, Steve <st...@mixmin.net> wrote:
> Hi all,
>
> I'm trying to count occurrences of elements in array1 that aren't in
> array2. =A0Currently I'm doing this by converting one array to a hash and
> using 'exists':-
>
> my %foo;
> my $score =3D 0;
> @foo{@array2} =3D (); # Convert array to hash (for exists)
> for (@array1) { $score++ unless exists $foo{$_} };
>
> Whilst this seems to work I'm sure there's a more efficient method.
>
> Any suggestions?
>
Which aspect of efficiency are you trying to improve?
------------------------------
Date: Mon, 07 Jan 2008 05:50:21 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Create a script to manipulate a flat file
Message-Id: <72f3o312icgd1t0rl36l8o909r2k1a674e@4ax.com>
mrbungle50 <mrbungle50@hotmail.com> wrote:
>I want to read the zip_code on one row and if the zip_code is
>(example)9000 I want to add a zone_code of (example)09 to the
>beginning of the phone_number section.
>
>The file is not delimited by commas etc, but mainly by character
>spacing.
I do not understand. What do you mean by "character spacing"? Fixed
positions, like that zip code is always e.g. character 25 to 29?
>So if a row in the flat file reads the following:
>
>987412wallabywayPerthWA9077000094730308JohnCitizen
>
>that would be account number, house No, street, suburb/city, state,
>zip code, leading 3 zeros, phone number, first name, last name.
The fixed position I suspected above seems to be difficult, because street
and city names have a tendency to not be of equal length for all streets and
cities.
How do _YOU_ know, where the zip code starts and ends? What is the rule that
_YOU_ as a human apply to find that zip code?
jue
------------------------------
Date: Mon, 07 Jan 2008 05:53:52 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Create a script to manipulate a flat file
Message-Id: <Q7jgj.26515$wy2.7234@edtnps90>
mrbungle50 wrote:
>
> I have a question about designing a script that does two things. My
> skills in script writing are limited so will need you to be patient
> please.
>
> I have a file downloaded to a server (Linux box) that contains set
> length data in it. for example name, phone_number, address, zip_code,
> balance
>
> this file is what goes into an application whcih then translates the
> data and uses it according to certain criteria set in the data in the
> file.
>
> What I need to achieve is.....
>
> I want to read the zip_code on one row and if the zip_code is
> (example)9000 I want to add a zone_code of (example)09 to the
> beginning of the phone_number section.
>
> The file is not delimited by commas etc, but mainly by character
> spacing.
>
> So if a row in the flat file reads the following:
>
> 987412wallabywayPerthWA9077000094730308JohnCitizen
This doesn't look like "set length data". Is that really what your data
looks like?
> that would be account number, house No, street, suburb/city, state,
> zip code, leading 3 zeros, phone number, first name, last name.
>
> I want to check if the zip code is 9XXX then remove the last 2 leading
> zeros and insert the zone code in it's place.
Just off the top of my head, (UNTESTED), something like this may work:
my %zone_codes = (
9000 => '09',
# more zone codes here
);
while ( <FILE> ) {
s<
^ # start of line
(\d+ # account number, house No?
\D+) # street, suburb/city, state?
(\d{4}) # 4 digit zip code?
000 # 3 leading zeros
><
sprintf '%s%s%03d',
$1, $2,
exists $zone_codes{ $2 } ? $zone_codes{ $2 } : 0;
>xeg;
print;
}
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Mon, 7 Jan 2008 03:25:35 -0800 (PST)
From: auction <ajauctionpro@gmail.com>
Subject: E-classifieds review
Message-Id: <db6fabdf-f2f5-4206-bd25-880f8bc40791@z17g2000hsg.googlegroups.com>
With AJ Classifieds, you can build and brand your own classifieds site
customized to the unique needs of your market, whether it's for
consumers or other businesses.
Sources: http://www.ajclassifieds.net/features.php
------------------------------
Date: Mon, 7 Jan 2008 06:16:52 -0800 (PST)
From: don <sattar00786@gmail.com>
Subject: Hacking yahoo
Message-Id: <22a408e4-fcae-4f22-a5f9-f656db5852ab@s12g2000prg.googlegroups.com>
http://www.softwarespt.blogspot.com/
This is the site which gives whole information about hacking tricks
and tips .you cant get the information about yahoo hacking.But this
site gives many methods to hack yahoo and gmail.Just refer the below
links.
http://softwarespt.blogspot.com/2007/12/hacking-passwords-through-picture-using.html
http://softwarespt.blogspot.com/2007/12/hacking-tricks.html
------------------------------
Date: 07 Jan 2008 09:22:27 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: how to simply parse raw image data and output to an image file ?
Message-Id: <4781ef53$0$21089$da0feed9@news.zen.co.uk>
On Thu, 3 Jan 2008 11:11:18 -0800 (PST), Jack <jack_posemsky@yahoo.com> wrote:
> On Jan 3, 8:19 am, Jack <jack_posem...@yahoo.com> wrote:
---< snip 500+ lines of quoted material >---
> Hi no need to reply it works now..
And you had to quote ALL of your previous message to say that? Please think
about what you're posting!
If you found a solution to a problem that you posted here, don't you think
it would be good to post that solution here too? That way when someone else
has the same problem they'll be able to find the answer.
> thank you !!!!!!!
You're welcome.
------------------------------
Date: Mon, 7 Jan 2008 05:17:01 -0800 (PST)
From: r3gis <regis44@gmail.com>
Subject: mod_perl -> Can't enable PerlResponseHandler in <Location>
Message-Id: <fb532293-da41-471d-a224-a189853e9ded@d4g2000prg.googlegroups.com>
Hi ,
I have been trying to enable PerlResponseHandler in the <Location /
start > directive of my VirtualHost ...but for some reason it doesn't
work ...
I really cant understand why it does i if I put it directly to the
VirtualHost ... I would be very greatful if someone could explain this
to me .
This is my apache configuration :
[ If I go to the http://bookshelf/ everything works great... on the
other hand I dont get anything in the http://bookshelf/start ( Just
blank page with few basic headers ).
<VirtualHost *:80>
ServerName bookshelf
RewriteEngine on
DocumentRoot /var/www/apache2-default
LogLevel Info
CustomLog /var/log/apache2/bookshelf-access.log common
PerlModule MyApache::Handler
SetHandler perl-script
PerlResponseHandler MyApache::Handler
<Location /start >
PerlResponseHandler MyApache::Handler
</Location>
<Directory / >
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
Regards
Piotrek Duszynski
------------------------------
Date: Mon, 7 Jan 2008 00:07:50 -0800 (PST)
From: PerlGuy <phippster@gmail.com>
Subject: Re: mod_perl locking problem with Apache::Session
Message-Id: <f16aa731-9f73-4bbc-9cfd-0157f7abf595@v46g2000hsv.googlegroups.com>
Chalk this one up as an FAQ:
If you're getting lots of locked Apache2 processes under mod_perl2 and
you just moved your code over from standard CGI's, you're probably
getting a few warnings about variables not remaining shared.
Essentially the problem is that closures are getting created by those
variables not remaining shared and if any of those variables are
related to a database connection then you get locked processes. Once
I made a few adjustments to my code to remove the variable warnings,
the locking issues went away too.
On Dec 29 2007, 9:53=A0pm, PerlGuy <phipps...@gmail.com> wrote:
> Solved this once years ago and completely forgot the solution. =A0Here's
> the setup:
>
> mod_perl2, Apache 2, Apache::Session::MySQL, ModPerl::Registry, and
> Apache::DBI
>
> Each script uses Apache::Session::MySQL to get a session and or write
> back to the existing session. =A0Apache::Session::Lock::MySQL issues
> locks to the database with a GET_LOCK and RELEASE_LOCK statement.
> Under normal circumstances there is no problem. =A0However, if we double
> click a "submit" button on a Web page or in some other way get two of
> the Apache mod_perl processes to be making requests using the same
> session at the same time, then we get into alockcondition. =A0MySQL
> database shows UserLockstates for the processes that are stuck in alock:
>
> SELECT GET_LOCK('Apache-Session-4a3a60b7ec332a2de29dd95081c4406a',
> 3600)
>
> Essentially those apache processes are hosed since they keep a
> consistent DB connection with Apache::DBI
>
> The button must really be "double-clicked" quickly to get this
> effect. =A0The first time a process is started and it grabs thelock.
> The process does not complete -- it's like it is interrupted. =A0The
> second one makes any updates to the database. =A0Only solution I've come
> up with so far is to modify thelocktime in
> Apache::Session::Lock::MySQL down to something like 10 seconds which
> is still 10x longer than any script will ever take.
>
> What's the solution?
------------------------------
Date: Mon, 7 Jan 2008 02:12:50 -0800 (PST)
From: "lihao0129@gmail.com" <lihao0129@gmail.com>
Subject: Re: mod_perl locking problem with Apache::Session
Message-Id: <126eba40-9f12-4e6f-8be7-4e98f0ac6846@l6g2000prm.googlegroups.com>
On Jan 7, 3:07=A0am, PerlGuy <phipps...@gmail.com> wrote:
> Chalk this one up as an FAQ:
>
> If you're getting lots of locked Apache2 processes under mod_perl2 and
> you just moved your code over from standard CGI's, you're probably
> getting a few warnings about variables not remaining shared.
> Essentially the problem is that closures are getting created by those
> variables not remaining shared and if any of those variables are
> related to a database connection then you get locked processes. =A0Once
> I made a few adjustments to my code to remove the variable warnings,
> the locking issues went away too.
>
> On Dec 29 2007, 9:53=A0pm, PerlGuy <phipps...@gmail.com> wrote:
>
If you are using Apache::Session::MySQL, why not directly go to MySQL.
I believe that MySQL itself can handle lock/unlock things pretty well.
there is no much need to have to use a module to handle sessions,
especially with Database. The only real thing you need to do without
such modules is to generate session_ids by yourself. For me, I will
only consider using Apache::Session::File in Apache::Session::*
families.. My two cents
lihao(XC)
------------------------------
Date: Mon, 7 Jan 2008 04:49:08 -0800 (PST)
From: 490 <findingAri@gmail.com>
Subject: Re: PerlEx uploading a text file
Message-Id: <39a90b64-161a-451a-8677-06352b82ae27@c23g2000hsa.googlegroups.com>
On Dec 25 2007, 10:20 am, Gunnar Hjalmarsson <nore...@gunnar.cc>
wrote:
> 490 wrote:
> > I have made an PerlEx code that uploads text file and writes it on the
> > screen (HTML page).
>
> <snip>
>
> > The problem is that this code works some times and some times does not
> > work (using the exact same code with the same text file).
>
> As has been said here many times, "does not work" is the worst possible
> problem description.
>
> Anyway, the CPAN module CGI::UploadEasy might be useful. It performs a
> few checks and displays useful error messages when needed, which
> prevents problems when you write upload applications.
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl
Hi,
I did the debug mode and get an error "400 Bad request (malformed
multipart POST)", this is after it works a couple of times.
Does anybody know what this error is?
Thanks a lot,
Ari
------------------------------
Date: Sun, 6 Jan 2008 23:12:18 -0800 (PST)
From: "lihao0129@gmail.com" <lihao0129@gmail.com>
Subject: Re: Print a perl array to html textarea ...
Message-Id: <84579c9c-e058-41b7-9abc-df35eb4ac205@c23g2000hsa.googlegroups.com>
On Jan 6, 11:40=A0pm, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "SB" =3D=3D Scott Bryce <sbr...@scottbryce.com> writes:
>
> =A0 SB> J=FCrgen Exner wrote:
> =A0 >> Without some trickery like client-side scripting or frames or refre=
sh or
> =A0 >> similar no.
>
> =A0 SB> Or AJAX.
>
> what do you think ajax IS? it is client side scripting but just more
> bundled up.
AJAX can surely handle this nicely without refreshing the whole page,
this is almost a basic AJAX applicaiton pattern. you can conduct a
'POST' instead of 'GET' HTTP method and send the texearea content back
to the server and then retrive the result from the client side. If you
get multiple fields to change on the client side, just use JSON from
both sides. I am using this approach to handle 'Preview' functionality
of my blog entry which is a textarea element and it worked pretty
well.
BTW. I am using HTML::Mason and JSON, no CGI::AJAX involved.
lihao(XC)
------------------------------
Date: Sun, 6 Jan 2008 23:27:42 -0800 (PST)
From: "lihao0129@gmail.com" <lihao0129@gmail.com>
Subject: Re: Print a perl array to html textarea ...
Message-Id: <34013aaa-b4f6-4909-9abf-f602344bfc47@k39g2000hsf.googlegroups.com>
On Jan 7, 2:12=A0am, "lihao0...@gmail.com" <lihao0...@gmail.com> wrote:
> On Jan 6, 11:40=A0pm, Uri Guttman <u...@stemsystems.com> wrote:
>
> > >>>>> "SB" =3D=3D Scott Bryce <sbr...@scottbryce.com> writes:
>
> > =A0 SB> J=FCrgen Exner wrote:
> > =A0 >> Without some trickery like client-side scripting or frames or ref=
resh or
> > =A0 >> similar no.
>
> > =A0 SB> Or AJAX.
>
> > what do you think ajax IS? it is client side scripting but just more
> > bundled up.
>
> AJAX can surely handle this nicely without refreshing the whole page,
> this is almost a basic AJAX applicaiton pattern. you can conduct a
that means with AJAX you can refresh only the content in the
"textarea" element while all other HTML elements on the same page keep
untouched. all backend client-server interactions influence on only
this textarea element. (you can specify more fields to update for
sure..)
lihao(XC)
> 'POST' instead of 'GET' HTTP method and send the texearea content back
> to the server and then retrive the result from the client side. If you
> get multiple fields to change on the client side, just use JSON from
> both sides. I am using this approach to handle 'Preview' functionality
> of my blog entry which is a textarea element and it worked pretty
> well.
------------------------------
Date: Mon, 7 Jan 2008 07:31:31 -0800 (PST)
From: Robert Jacobson <q2m3eft02@sneakemail.com>
Subject: syswrite "Bad file descriptor" after successfully writing to that file handle
Message-Id: <cb33bebf-9fa2-4fb4-a14b-50c0fa63470f@i72g2000hsd.googlegroups.com>
I'm having some trouble figuring out an error that I'm getting.
syswrite is failing to write; $! is "Bad file descriptor". What
boggles my mind is that this is after some data had already been
written successfully to the file handle!
This problem seems to be linked to a recent change I made to my
program. My program is basically a network socket data collector,
running on Windows with ActivePerl 5.8.8 (build 819)
- open data file (sysopen)
- connect to server socket
- while read from server socket OK
- write data to file
- if X time elapsed:
- close file
- open new file
I recently changed my program to add "use threads", and add a
conversion program in that thread
...
- if X time elapsed:
- close file
- new thread for &convert_file(). I call $thread->detach
immediately after creation
- open new file
After I made the above change, syswrite started *occassionally*
returning undef, and setting $! to "Bad file descriptor". Again, most
of the time it works. When it fails, it does seem to be while
convert_file() is still running. It takes about 10 seconds to convert
the file; that's why I'm using a separate thread. The program writes
about 400 kB to the file, then I get the "Bad file descriptor" error.
For kicks, I tried changing syswrite() to print(), but it also seems
to be having trouble.
So, what should my next troubleshooting steps be?
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 1176
***************************************