[22857] in Perl-Users-Digest
Perl-Users Digest, Issue: 5078 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 5 11:06:10 2003
Date: Thu, 5 Jun 2003 08: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)
Perl-Users Digest Thu, 5 Jun 2003 Volume: 10 Number: 5078
Today's topics:
Re: Daemon Script n' system() function - for gurus: Ran <grazz@pobox.com>
DBD::Sybase and stored procedures <newgroups@healeysonline.com_SPAMMENOT>
Re: Email Extraction (Graham Smith)
Help fixing my code needed (Mark Smith)
Re: Help fixing my code needed <noreply@gunnar.cc>
Re: Help fixing my code needed <jurgenex@hotmail.com>
Re: Help needed checking if paths are the same (Mark Smith)
Re: Help needed checking if paths are the same <noreply@gunnar.cc>
How do I get a history of entries in a text field for a (KS)
Re: How? Multiple perl scripts on two different hosts n ctcgag@hotmail.com
How? Multiple perl scripts on two different hosts need <r26375@motorola.com>
Re: How? Multiple perl scripts on two different hosts n <ubl@schaffhausen.de>
Re: How? Multiple perl scripts on two different hosts n <r26375@motorola.com>
Re: Hy guys,I need some help(opening directories) (C Marshall)
Is it possible to do ? <beaudet@cyber.kodak.com>
Re: Is it possible to do ? <noreply@gunnar.cc>
only replace the NUMBERth match of the regexp <jidanni@jidanni.org>
Re: only replace the NUMBERth match of the regexp (Rick Ferrante)
Parsing issue kamp@inl.nl
perl and surveys <pryce@ucla.edu>
Re: perl and surveys <noreply@gunnar.cc>
Re: perl (C Marshall)
Re: permissions mnemonic (Damian James)
Re: Printing VISIO documents using PERL. (Graham Smith)
Re: Problems with & operator news@roaima.freeserve.co.uk
Re: Problems with suidperl on AIX, "Can't reswap uid an (Villy Kruse)
Re: regex based on numeric value (Rick Ferrante)
Re: Replacing Unsafe HTML Characters (Steven Danna)
Time limit Zvezdoshka@nowhere.ru
Re: Yabb woes. <someone@microsoft.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 05 Jun 2003 09:33:34 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Daemon Script n' system() function - for gurus: Randal L. Schwartz, Larry Wall, Joseph N. Hall, and others
Message-Id: <O7EDa.35813$ca5.29425@nwrdny02.gnilink.net>
Euler <eulerpereira@hotmail.com> wrote:
> but when i try execute system( 'system_command' ) function from
> daemon, the return code ( $? ) from system() is -1. The same happens
> when i try use quotation `system_command` or exec( 'system_command' ).
>
> but, the command is executed sucefully!!! What's wrong?
[ snip lots of code ]
You probably don't realize it, but your script doesn't show either
of these symptoms.
We don't know whether system() returned -1 (or anything else)
because the diagnostic is redirected to /dev/null. And we can't
see any output or error messages from "ls" for the same reason.
Try to come up with a short[*] script that actually demonstrates
the problem you're having.
http://mail.augustmail.com/~tadmc/clpmisc.shtml
[*] if you trim 150 lines you'll have made a good start
--
Steve
------------------------------
Date: Thu, 05 Jun 2003 13:10:06 GMT
From: "Kevin Healey" <newgroups@healeysonline.com_SPAMMENOT>
Subject: DBD::Sybase and stored procedures
Message-Id: <OiHDa.105$fh.19@news2.east.cox.net>
I am having some trouble preparing and executing a Sybase stored procedure
using DBI.
My stored procedure has a numeric output parameter, and I would like to
use placeholders so that I can prepare the procedure once and call it
multiple
times. The stored procedure is used by other applications, so I don't
really have the ability to change it.
Here is an example stored procedure:
___BEGIN SP___
create procedure sp_test
@In varchar(10),
@Out numeric(10) output
as begin
select @Out = 12345
end
___END SP___
Here is what I am attempting with perl:
____BEGIN PERL SNIPPET____
use DBI ":sql_types";
my $dbh = DBI->connect('dbi:Sybase:server=server;database=db', 'pw',
'user');
my $sth = $dbh->prepare("exec sp_test ?, ? OUTPUT");
$sth->bind_param(1, 'test', SQL_CHAR);
$sth->bind_param(2, 1, SQL_NUMERIC);
$sth->execute();
my @results = $sth->func('syb_output_params');
____END PERL SNIPPET____
When I run this I get the following error on the $sth->execute call:
"Arithmetic overflow during implicit conversion of NUMERIC value '12345'
to a NUMERIC field ."
By the way, if I change the output parameter in the test stored
procedure to a character datatype, then I do not get errors. I suppose
this has something to do with "DBD::Sybase defaults all the parameters
to SQL_CHAR" (from the DBD::Sybase docs).
Also, I do have success if I try the following prepare:
my $sth = $dbh->prepare("declare \@Out numeric(10) exec sp_test 'test',
\@Out OUTPUT");
But this doesn't allow me to use placeholders. If I replace 'test' with
a placeholder, I get the following error on the $dbh->prepare call:
"The untyped variable ? is allowed only in a WHERE clause or the SET
clause of an UPDATE statement or the VALUES list of an INSERT statement"
I suppose this comes from the fact that when using placeholders "the
stored procedure call must be initiated with an exec and it must be the
only statement in the batch that is being prepared" (from the
DBD::Sybase docs).
So, if I understand everything here (unlikely!), you cannot use
placeholders with a Stored Procedure that has a numeric output
parameter. If this is true, then I suppose I can use string
concatenation and prepare the statement for each call to the SP.
However, I fear that this will not be as fast, and I will have to deal
with escaping quotes, etc...
Thanks,
Kevin Healey
newgroups@healeysonline.com_SPAMMENOT
(Remove _SPAMMENOT to send me email)
------------------------------
Date: 5 Jun 2003 01:43:22 -0700
From: grehom@ntlworld.com (Graham Smith)
Subject: Re: Email Extraction
Message-Id: <98eb7f13.0306050043.4c0c41c6@posting.google.com>
Very few changes made, pay special regard to curly bracket vs.
parenthesis and capitilisation (Perl is case sensitive), hope this
helps:
use strict;
use Win32::OLE;
use Win32::OLE::Variant;
use Win32::OLE::Const 'Microsoft Outlook';
my $Outlook = Win32::OLE->new('Outlook.Application', 'Quit');
my $ol = Win32::OLE::Const->Load($Outlook);
my $namespace = $Outlook->GetNamespace("MAPI");
my $Folder = $namespace->GetDefaultFolder(olFolderInbox);
my $items = $Folder->Items;
print $items->Count;
for my $itemIndex (1..$items->Count) {
my $message = $items->Item($itemIndex);
next if not defined $message;
print "Sender: ", $message->{SenderName}, "\n";
print "Received:", $message->{ReceivedTime}, "\n";
print "To:", $message->{To}, "\n";
print "Subject:", $message->{Subject}, "\n";
print "Body:\n", $message->{Body}, "\n";
print "================================================\n";
}
------------------------------
Date: 5 Jun 2003 02:36:12 -0700
From: Mark.Smith@sonyericsson.com (Mark Smith)
Subject: Help fixing my code needed
Message-Id: <cf24885e.0306050136.67126c00@posting.google.com>
I have two file which contain file paths and other details. One
contains paths in the format:
d:\path\somepath\path1\filename.exe
The other contains paths in the format:
\Path\ANOTHERPATH\Pathname\somefile.txt
What I need to do is compare every path from the first file against
every path from the second file and peform some output when they
match. Now I need to disregard the drive letter and case so I would
get a match for the following strings:
d:\path\somepath\path1\filename.exe
and
\PATH\somepath\Path1\Filename.exe
I've tried pattern matching the second against the first but I get the
error:
Can't find unicode character property definition via main->W or W.pl
at C:\Perl\bin\dev\failed_source\extract_failed.pl line 70
Here is the full source:
#!perl
use strict;
my @content;
my @evcontent;
my $out_file1 = "evalid.txt";
my $out_file2 = "envinfo.txt";
open(OF1,"$out_file1" ) || die "Unable to open
'$out_file1'.Aborting.\n";
while (my $contents=<OF1>)
{
@content = split( ' ', $contents );
chomp(@content);
&compare_against_envinfo(
@content[0],@content[1],@content[2]);
}
close(OF1);
sub compare_against_envinfo
{
my $path = shift;
my $reason = shift." ".shift;
open(OF2,"$out_file2" ) || die "Unable to open
'$out_file2'.Aborting.\n";
while (my $evcontents=<OF2>)
{
@evcontent = split( ' ', $evcontents );
chomp(@evcontent);
my $envpath = @evcontent[2];
if ( $envpath =~ m/$path/i )
{
print "@evcontent $reason\n";
# Add ouput to file stuff here when this is working
last;
}
}
close(OF2);
}
------------------------------
Date: Thu, 05 Jun 2003 12:30:01 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Help fixing my code needed
Message-Id: <bbn63h$b8lp6$1@ID-184292.news.dfncis.de>
I just posted a (probable) solution in the thread "Help needed
checking if paths are the same". Any particular reason to post the
same problem again?
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 05 Jun 2003 13:40:49 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Help fixing my code needed
Message-Id: <BLHDa.47343$da1.6938@nwrddc03.gnilink.net>
Mark Smith wrote:
[...]
> match. Now I need to disregard the drive letter and case so I would
> get a match for the following strings:
>
> d:\path\somepath\path1\filename.exe
>
> and
>
> \PATH\somepath\Path1\Filename.exe
A very typical algorithmic question that has little to do with Perl (you
would use the same approach in any other programming language, too).
The solution is trivial: define a normal form, tranform both(!) values into
the normal form, and compare them.
In your case:
- normal form: you could use e.g. no drive letter and path all upper case
(just an example).
- the write a function that converts any path into normal form:
normalform { #untested, for illustration only
$_[0] =~ s/^.://;
return uc($_[0]);
}
- and then simply compare your names
if (normalform($file1) eq normalform($file2)) {
print "The names $file1 and $file2 are the same\n";
}
jue
------------------------------
Date: 5 Jun 2003 02:24:47 -0700
From: Mark.Smith@sonyericsson.com (Mark Smith)
Subject: Re: Help needed checking if paths are the same
Message-Id: <cf24885e.0306050124.50573b91@posting.google.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<bbkt6t$aql7v$1@ID-184292.news.dfncis.de>...
> Mark Smith wrote:
> > What I need to do is compare every path from the first array
> > against every path from the second array and peform some output
> > when they match. Now I need to disregard the drive letter and case
> > ...
>
> <snip>
>
> > I've tried pattern matching the second against the first with \i
> > but with no success.
>
> Let's see what you've got.
>
> / Gunnar
Made a few changes but get the same problem. I now read each line
from a file, split the contents and then pass the contents as
parameters to a sub routine. This opens the other file and reads each
line performing a check against the passed in path.
I perform the comparison with:
if ( $envpath =~ m/$path/i )
However at this line I get the error:
Can't find unicode character property definition via main->W or W.pl
at C:\Perl\bin\dev\failed_source\extract_failed.pl line 70
Here is the full source:
#!perl
use strict;
my @content;
my @evcontent;
my $out_file1 = "evalid.txt";
my $out_file2 = "envinfo.txt";
open(OF1,"$out_file1" ) || die "Unable to open '$out_file1'.
Aborting.\n";
while (my $contents=<OF1>)
{
@content = split( ' ', $contents );
chomp(@content);
&compare_against_envinfo( @content[0],@content[1],@content[2]
);
}
close(OF1);
sub compare_against_envinfo
{
my $path = shift;
my $reason = shift." ".shift;
open(OF2,"$out_file2" ) || die "Unable to open '$out_file2'.
Aborting.\n";
while (my $evcontents=<OF2>)
{
@evcontent = split( ' ', $evcontents );
chomp(@evcontent);
my $envpath = @evcontent[2];
if ( $envpath =~ m/$path/i )
{
print "@evcontent $reason\n";
# Add ouput to file stuff here when this is working
last;
}
}
close(OF2);
}
------------------------------
Date: Thu, 05 Jun 2003 12:14:19 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Help needed checking if paths are the same
Message-Id: <bbn564$b2oi5$1@ID-184292.news.dfncis.de>
Mark Smith wrote:
> I have two arrays of file paths. One contains paths in the format:
>
> d:\path\somepath\path1\filename.exe
>
> The other contains paths in the format:
>
> \Path\ANOTHERPATH\Pathname\somefile.txt
<snip>
> I perform the comparison with:
>
> if ( $envpath =~ m/$path/i )
>
> However at this line I get the error:
> Can't find unicode character property definition via main->W or
> W.pl at C:\Perl\bin\dev\failed_source\extract_failed.pl line 70
You need to quote the backslashes in the pattern:
if ( $envpath =~ m/\Q$path/i )
-----------------------^^
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 5 Jun 2003 07:41:18 -0700
From: k437184@hotmail.com (KS)
Subject: How do I get a history of entries in a text field for a perl GUI?
Message-Id: <fda57e57.0306050641.bf20114@posting.google.com>
What I am trying to mimic is behavior similar to Windows or any
mozilla URL field. You know how a drop down window with previous URL's
pops up and as you type does an incremental match.... how do I do that
with Perl TK?
Thx a bunch in advance.
------------------------------
Date: 05 Jun 2003 14:46:08 GMT
From: ctcgag@hotmail.com
Subject: Re: How? Multiple perl scripts on two different hosts need Mutex to lock critical code section.
Message-Id: <20030605104608.067$qt@newsreader.com>
Klaus FOERSTER <r26375@motorola.com> wrote:
...
> What mechanism can be used to make sure, that only one of the perl
> scripts enters a critical code section (locking)?
...
> One option would be to have a lock server, that listens on a socket and
> hands mutexes over to any of the active perl scripts.
> This seems to be a little overkill for me (having a lock server), but
> that's the only idea, that I have so far.
Are you already using a database connection within the script? If so,
most RDBMS have the capacity to operate as a lock server.
If you are not already using a database, I'd still consider using on as the
lock server. In mysql, you would do something like this:
my $success = $dbh->selectrow_array('select get_lock(?,?)', undef,
$mutex_name, $seconds_willing_to_wait
);
# Test $success to see if you got the lock
# do something protected by the mutex named $mutex_name
$dbh->do('release_lock(?)', undef, $mutex_name);
Of course, both/all programs have to coordinate that they use the same
string for the mutex name.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Thu, 05 Jun 2003 14:53:56 +0200
From: Klaus FOERSTER <r26375@motorola.com>
Subject: How? Multiple perl scripts on two different hosts need Mutex to lock critical code section.
Message-Id: <3EDF3D64.7060500@motorola.com>
Hi everybody.
I'm not very good with interprocess communication therefore my question
I'm having multiple perl scripts running on different hosts
and operating systems (solaris, linux).
What mechanism can be used to make sure, that only one of the perl scripts enters a
critical code section (locking)?
I tried to use the flock mechanism to lock files and use them by this means as mutex.
However this seems only to work reliable if all processes do run on the same host.
When running on multiple hosts this does not seem to be reliable.
Is there anything generic enough, that could be used to achieve this?
One option would be to have a lock server, that listens on a socket and hands mutexes over
to any of the active perl scripts.
This seems to be a little overkill for me (having a lock server), but that's the only idea,
that I have so far.
any feedback welcome
bye
Klaus
P.S. The solution could also be in C or as a shell script, but perl would be preferred.
--
===============================================================
Klaus Foerster ! email: klaus.foerster@motorola.com
Motorola Toulouse !
------------------------------
Date: Thu, 05 Jun 2003 15:22:32 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: How? Multiple perl scripts on two different hosts need Mutex to lock critical code section.
Message-Id: <bbnjba$rmd$1@news.dtag.de>
Klaus FOERSTER wrote:
> What mechanism can be used to make sure, that only one of the perl
> scripts enters a
> critical code section (locking)
Dunno, if it actually works, bu worth a try:
http://search.cpan.org/author/RONALDWS/LockFile-NetLock-0.29/NetLock.pm
There are other solutions for the same problem space on CPAN.
malte
------------------------------
Date: Thu, 05 Jun 2003 15:49:34 +0200
From: Klaus FOERSTER <r26375@motorola.com>
To: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: How? Multiple perl scripts on two different hosts need Mutex to lock critical code section.
Message-Id: <3EDF4A6E.90409@motorola.com>
Hi Malte,
Thanks a lot for this link.
This is interesting. Unfortunately it requires a username, a password and a ftp server.
In my context I cannot include a password in the script.
So I still have to look for another solution.
Thanks anyway.
Malte Ubl wrote:
> Klaus FOERSTER wrote:
>
>> What mechanism can be used to make sure, that only one of the perl
>> scripts enters a
>> critical code section (locking)
>
>
> Dunno, if it actually works, bu worth a try:
> http://search.cpan.org/author/RONALDWS/LockFile-NetLock-0.29/NetLock.pm
>
> There are other solutions for the same problem space on CPAN.
>
> malte
>
>
>
--
===============================================================
Klaus Foerster ! email: klaus.foerster@motorola.com
System Design Engineer ! priv.: klausf@dungeon.de
Motorola Toulouse !
tel +33-561 19 17 58 !
fax +33-561 19 14 70
------------------------------
Date: 5 Jun 2003 07:34:45 -0700
From: c_j_marshall@hotmail.com (C Marshall)
Subject: Re: Hy guys,I need some help(opening directories)
Message-Id: <cb9c7b76.0306050634.7f202120@posting.google.com>
tadmc@augustmail.com (Tad McClellan) wrote in message
> > Can someone explain me what's wrong with my code?
>
> It is not indented so as to reveal its structure.
Speaking of which is there an equivalent of "cb" for tidying up perl
code ?
I just tried running cb on a perl script - it makes a valiant attempt
though the {}s in hashes are thrown apart.
------------------------------
Date: Thu, 05 Jun 2003 15:20:03 +0200
From: Jean-Luc BEAUDET <beaudet@cyber.kodak.com>
Subject: Is it possible to do ?
Message-Id: <3EDF4383.6000100@cyber.kodak.com>
Hi all,
I use smth like
use strict;
use Date::Calc qw/Today Date_to_Text Add_Delta_Days/;
../..
($year,$month,$day) = Today();
($dtt = Date_to_Text($year,$month,$day)) =~ tr/ /-/s; # 1
@dtt = split /-/, $dtt;
# 2
$pattern = $dtt[0]." ".$dtt[2]." ".$dtt[1];
Does some one knows about a way to write lines #1 & #2 in only one line ???
Regards.
Jean-Luc B :-)
------------------------------
Date: Thu, 05 Jun 2003 16:20:13 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Is it possible to do ?
Message-Id: <bbnjj7$bhdsa$1@ID-184292.news.dfncis.de>
Jean-Luc BEAUDET wrote:
> ($dtt = Date_to_Text($year,$month,$day)) =~ tr/ /-/s; # 1
> @dtt = split /-/, $dtt; # 2
>
> $pattern = $dtt[0]." ".$dtt[2]." ".$dtt[1];
>
> Does some one knows about a way to write lines #1 & #2 in only one
> line ???
@dtt = split /[ -]/, Date_to_Text($year,$month,$day);
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 05 Jun 2003 11:45:21 +0800
From: Dan Jacobson <jidanni@jidanni.org>
Subject: only replace the NUMBERth match of the regexp
Message-Id: <87k7c1chm6.fsf@jidanni.org>
In sed: s///flags:
`NUMBER'
Only replace the NUMBERth match of the REGEXP.
$ s2p s/X/Y/7
...{ $n = 7;
while( --$n && ( $s = m /X/g ) ){}
$s = ( substr( $_, pos() ) =~ s /X/Y/s ) if $s;
$CondReg ||= $s;...
My question is is the ease of writing simply s/X/Y/7 of sed not
available in perl, and one must make a big deal of it, or is s2p just
making its usual big deal about everything? man perlop just shows
s/PATTERN/REPLACEMENT/egimosx
--
http://jidanni.org/ Taiwan(04)25854780
------------------------------
Date: 5 Jun 2003 06:20:06 -0700
From: rferrante@tnsi.com (Rick Ferrante)
Subject: Re: only replace the NUMBERth match of the regexp
Message-Id: <726cd874.0306050520.7723c2de@posting.google.com>
Its not too hard in perl.
you could use something like s/((X[^X]*){6})X/\1Y/
which replaces char X with Y.
$a="a;lkj;lkja;lkj;lkjakja;lkjakjkj akjlkjljakja;lkj";
$a=~s/((a[^a]*){6})a/\1B/;
print $a
a;lkj;lkja;lkj;lkjakja;lkjakjkj akjlkjljBkja;lkj
Dan Jacobson <jidanni@jidanni.org> wrote in message news:<87k7c1chm6.fsf@jidanni.org>...
> In sed: s///flags:
> `NUMBER'
> Only replace the NUMBERth match of the REGEXP.
> $ s2p s/X/Y/7
> ...{ $n = 7;
> while( --$n && ( $s = m /X/g ) ){}
> $s = ( substr( $_, pos() ) =~ s /X/Y/s ) if $s;
> $CondReg ||= $s;...
> My question is is the ease of writing simply s/X/Y/7 of sed not
> available in perl, and one must make a big deal of it, or is s2p just
> making its usual big deal about everything? man perlop just shows
> s/PATTERN/REPLACEMENT/egimosx
------------------------------
Date: Thu, 05 Jun 2003 14:02:00 +0200
From: kamp@inl.nl
Subject: Parsing issue
Message-Id: <39cudv4chh2imaegu8fq48g99api0t0cuu@4ax.com>
Hello,
I'm developing an application for selecting items from a bibliographic
database. For several reasons we do not let the user work directly
with SQL, but via a simpler language. The queries will then be
translated into SQL. E.g. the users enters:
medium='Book' or medium='Paper'. This must be translated to
select * from Items where medium = 'Book' or medium='Paper';
More complex queries are also possible.
I have the following questions.
I want to use Parse::RecDescent for this job. As I'm absolutely new to
parsing and formal languages: do you need to traverse the parse tree
to construct valid SQL? I do not quite understand the data structure
generated by the <autotree> directive. Are there ways to make it more
explicit?
Are there other ways to build the application or is my decision to use
RecDescent the right one?
Below you will find the script I build so far.
Thanks for any help.
Peter van der Kamp
----------------------------------------------------------------
use Parse::RecDescent;
use Data::Dumper;
my $parser = new Parse::RecDescent q{
<autotree>
zoekVraag:
andZoekVraag 'or' zoekVraag
|
andZoekVraag
|
<error>
andZoekVraag:
notZoekVraag 'and' andZoekVraag
|
notZoekVraag
notZoekVraag:
'not' haakZoekVraag
|
haakZoekVraag
haakZoekVraag:
'(' zoekVraag ')'
|
basisZoekVraag
basisZoekVraag:
mediumZoekVraag
|
onderwerpZoekVraag
|
titelZoekVraag
|
auteurZoekVraag
|
periodZoekVraag
mediumZoekVraag:
'medium=' zoekString
onderwerpZoekVraag:
'topic=' zoekString
titelZoekVraag:
'title=' zoekString
auteurZoekVraag:
'author=' zoekString
periodZoekVraag:
rangePeriodZoekVraag
|
singlePeriodZoekVraag
singlePeriodZoekVraag:
'p=' cijfers
rangePeriodZoekVraag:
'p=' cijfers '-' cijfers
|
'p=' '-' cijfers
|
'p=' cijfers '-'
zoekString: /\'[a-zA-Z:\. ]+\'/
cijfers: /[0-9]{4}/
};
undef $/;
my $text = <STDIN>;
print Data::Dumper->Dump([$parser->zoekVraag($text)]);
------------------------------
Date: Thu, 5 Jun 2003 02:26:29 -0700
From: "BitZer0" <pryce@ucla.edu>
Subject: perl and surveys
Message-Id: <bbn2gu$ihe$2@gladiola.noc.ucla.edu>
Hi,
I'm trying to make site that'll display different surveys depending on the
count of visitors. Can anyone help me out? I have 12 different surveys
that needs to be properly cycled through. The surveys also need to store
the results to an appropriately named file (ie, survey1, survey2, ...,
survey12). I'm not much of a perl script programmer, but I know I need to
use an array (or perhaps a hash table?) to cycle through the names.
Hit me up for clarifications or suggestions!
Btw, I'm using MS IIS and ActivePerl.
Thanks,
Paul
_______________
Bitzer0
------------------------------
Date: Thu, 05 Jun 2003 12:23:26 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: perl and surveys
Message-Id: <bbn5n7$9tmsv$1@ID-184292.news.dfncis.de>
BitZer0 wrote:
> I'm trying to make site that'll display different surveys depending
> on the count of visitors. Can anyone help me out? I have 12
> different surveys that needs to be properly cycled through. The
> surveys also need to store the results to an appropriately named
> file (ie, survey1, survey2, ..., survey12). I'm not much of a perl
> script programmer, ...
Then hire somebody who is. Or learn it yourself.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 5 Jun 2003 07:29:46 -0700
From: c_j_marshall@hotmail.com (C Marshall)
Subject: Re: perl
Message-Id: <cb9c7b76.0306050629.3f22508d@posting.google.com>
tadmc@augustmail.com (Tad McClellan) wrote in message
> Have you seen the docs about Perl books?
>
> perldoc -q book
>
> perldoc perlbook
Crikey - is there no end to what is available under perldoc ?
The guys who maintain that must be costing Oreilly a fortune
------------------------------
Date: 5 Jun 2003 10:16:20 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: permissions mnemonic
Message-Id: <slrnbdu63h.gj7.damian@puma.qimr.edu.au>
On Sun, 25 May 2003 11:07:20 GMT, John W. Krahn said:
>Eric Wilhelm wrote:
>>
>> foreach $r (0,r) {
>> foreach $w (0,w) {
>> foreach $x (0,x) {
>> $h=($r||"-").($w||"-").($x||"-");
>> print "$h -> ",($r&&1).($w&&1).($x&&1),
>> " -> ",($r&&1)*4+($w&&1)*2+($x&&1),"\n";
>> }
>> }
>> }
>
>Well, you don't need nested loops.
>for$n(0..7){
> $_=$x=sprintf"%03b",$n;
> s/^1/r/;s/1$/x/;s/1/w/;y/0/-/;
> print"$_ -> $x -> $n\n"
> }
perl -le 'print sub{map{$_[$_]?(qw/r w x/)[$_]:"-"}0..$#_}->(\
split//,$_->[0])," @$_"for map[sprintf("%03b",$_),$_],0..7'
--damian
------------------------------
Date: 5 Jun 2003 03:17:29 -0700
From: grehom@ntlworld.com (Graham Smith)
Subject: Re: Printing VISIO documents using PERL.
Message-Id: <98eb7f13.0306050217.43c77e02@posting.google.com>
I'm pretty sure you could do it using the Win32::OLE interface,
unfortunately I don't have a copy of Visio to write a demonstration
script for you.
If you're using the Activestate Perl the documentation gives examples
for M$ Excel spreadsheets and Word documents - if you go this route
and you have a copy of Microsoft Word - try Alt+F11, in a new
document, to start the Object browser, pull down the Tools menu and
click References, scroll down the list of
available references and tick the Visio entry, you should then be able
to specify Visio as the library you are interested in. The classes
and members of the visio library should then be readable - this is not
what I would call Newbie territory - but there are newbies and
newbies!! Try using the object browser with the Word and Excel
libraries as you study the examples in documentation - don't be afraid
to e-mail if you get stuck
cjohnso9@amfam.com (Chad Johnson) wrote in message news:<a3c05aa8.0306041053.6e656430@posting.google.com>...
> I am new to PERL and I am trying to write a script to do the
> following:
> 1. Read in a VISIO document.
> 2. Change the printing options to 'TRUE TYPE FONT' and 'DOWNLOAD AS
> SOFTFONT'.
> 3. Print the document.
>
> Does anyone have any examples of scripts that can do something like
> this. If so please send me them.
>
> Thanks
------------------------------
Date: Thu, 5 Jun 2003 13:33:26 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: Problems with & operator
Message-Id: <mtp3r-pvj.ln1@moldev.cmagroup.co.uk>
Shane McDaniel <shanem@nospam.ll.mit.edu> wrote:
> I have a text file with rows that looks as such
> 0x12345678 0x9abcdef0
> I basically want to print out with same line but with the second number
> bit masked with a certain mask.
> #!/usr/local/bin/perl
Remember to get all the help you can:
use strict;
use warnings; # Or -w if earlier Perl interpreter
> open( IN, "$ARGV[0]" ) || die "ERROR: can't open file $ARGV[0]\n";
Don't quote needlessly, and whenever possible provide a reason for the dying:
open(IN, $ARGV[0]) or die "ERROR: can't open file $ARGV[0]: $!\n";
> foreach $line ( <IN> )
I hope your file isn't too big, as your foreach() will slurp the entire
file into memory before processing it. Generally in this sort of situation
you'll be better off using while():
while (my $line = <IN>) {
> chomp $line;
> ($first, $second ) = split /\s+/, $line;
I suspect you're better using split's special feature that splits on
whitespace in a DWIM manner:
my ($first, $second) = split (' ', $line);
At this point both $first and $second are strings that start with 0
(and therefore are numerically zero when coerced); neither are a number,
hex or otherwise. You need to state explicitly that you want them treated
as a hex value.
If you want both $first and $second to be treated as numbers, you can
do this in a modified version of my "split" line (above), otherwise you
can coerce $second by itself:
my ($first, $second) = map { hex } split (' ', $line);
> print "$first $second -> ";
But now $first won't print in hex "by itself" - you have to say you want
it so:
printf "0x%x 0x%x -> ", $first, $second;
> $second &= 0x3ffffff;
This line's now fine, because $second is already numeric.
> print "$first $second\n";
Ditto (assuming you want hex results rather than decimal):
printf "0x%x 0x%x\n", $first, $second;
> }
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: 05 Jun 2003 07:30:51 GMT
From: vek@station02.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Problems with suidperl on AIX, "Can't reswap uid and euid."
Message-Id: <slrnbdtsda.ddg.vek@station02.ohout.pharmapartners.nl>
On 4 Jun 2003 14:13:40 -0700,
LOlson <lolson@lynx.nisc.cc> wrote:
>I need to get suid PERL scripts working on AIX.
>First, let me say I know suid scripts are "bad" and suidperl is
>deprecated, but we already have a number of PERL scripts that work on
>Linux, Tru64, and SCO and I need to get them working ASAP on AIX as
>well and do not have the time to rewrite them all, and would very much
>like to keep them as portable as they are now.
Tha AIX system doesn't allow changing the real uid, unless the effective
uid is zero and both real and effective uid is set at the same time,
as is done with the C function setuid(). Doing that also permanently
disable the posibility to become superuser again.
The AIX system also allows the effective user id to be swapped between
the original effective user id and the value of the real user id; again
using the C function setuid() if neither the effective nor the real uid
is zero, or the C function seteuid(). As of perl 5.8 the POSIX::setuid
is using the C function setuid(), earlier perl version try to manipulate
$< and $> which in mane cases would not work as expected on AIX systems.
This AIX behaviour is quite similar to System V rel 3 except SVR3 does not
have seteuid().
>I am trying to get PERL 5.6.1 working on AIX 4.3.3 and 5.1, but so far
>I keep getting the "Can't reswap uid and euid." error.
If seems the suid perl is trying to do something AIX doesn't allow.
Villy
------------------------------
Date: 5 Jun 2003 06:06:46 -0700
From: rferrante@tnsi.com (Rick Ferrante)
Subject: Re: regex based on numeric value
Message-Id: <726cd874.0306050506.119eee@posting.google.com>
Tad,
You're right. I was looking because I have an operational NMS system
that applies regex patterns to incoming syslog messages where the
regex's are stored in Oracle. Therefore, I don't know in advance what
kind of tests users may want to apply to the match variable
($1,$2,...). Therefore, I was hoping to deal with it in the regex
itself and be done.
But its just not that easy.
I'm thinking about encoding the additional requirements in a regex
comment, parse that out and eval it if necessary.
Thanks!
Rick
tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnbdt5j1.nvd.tadmc@magna.augustmail.com>...
> Rick Ferrante <rferrante@tnsi.com> wrote:
>
> > Given a string like "Level 87.34"
> >
> > Is there a regex that will match if the string is like "Level
> > ([0-9.]+)" and \1 is > 75 ?
>
>
> Why do you want to do mathematics with string operators?
>
> Perl comes with numeric operators for working with numbers,
> use them for your comparisons:
>
> if ($num =~ /(\d+\.\d+)/ and $1 > 75 )
------------------------------
Date: 5 Jun 2003 07:17:11 -0700
From: MissingWords@hotmail.com (Steven Danna)
Subject: Re: Replacing Unsafe HTML Characters
Message-Id: <e78d8c5a.0306050617.f8015c9@posting.google.com>
"Brad Walton" <sammie@greatergreen.com> wrote in message news:<nSwDa.867408$Zo.197872@sccrnsc03>...
> > use HTML::Entities qw(encode_entities);
> > $htmlparams[1] = encode_entities( $htmlparams[1], '&<>' );
>
> I could not get that module to install on any of my Perl installations. My
> only guess is it doesn't like ActiveState installation for Win32, or nmake.
> This has happened to me on a couple of other modules also, notably DBI.
If you don't mind me asking, are you using an older version of
ActivePerl? When I checked my own installation of ActivePerl 5.8,
HTML::Entities was already installed by default.
------------------------------
Date: Thu, 05 Jun 2003 18:17:37 +0400
From: Zvezdoshka@nowhere.ru
Subject: Time limit
Message-Id: <14kudvc0gvng14ranu54jjp11ah4rkintc@4ax.com>
I don't know where to ask, so I try here :-)
In a quizz, I want setup a time limit for users to reply to each
question. What's the best way to do this ? A cookie that expires in xx
seconds, is that the only way ?
Thank you !
ZZ
------------------------------
Date: Thu, 5 Jun 2003 02:25:15 -0700
From: "john smith" <someone@microsoft.com>
Subject: Re: Yabb woes.
Message-Id: <bbn24u$j2a$1@bob.news.rcn.net>
Nevermind. I fixed it.
------------------------------
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 5078
***************************************