[21847] in Perl-Users-Digest
Perl-Users Digest, Issue: 4051 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 31 09:05:50 2002
Date: Thu, 31 Oct 2002 06:05:12 -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 Thu, 31 Oct 2002 Volume: 10 Number: 4051
Today's topics:
Re: [OT] Re: Open a HTML page not using redirect <ee@ee.ee>
Error in running Perl Program (Vishva Rajput)
Re: Error in running Perl Program <rereidy@indra.com>
Re: getting data out of database for downloading <simon.andrews@bbsrc.ac.uk>
how can i delete files older than a certain number of d <zahid@chambersandpartners.co.uk>
Re: how can i delete files older than a certain number <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Re: how can i delete files older than a certain number (Helgi Briem)
how to share socket handle across related process <noorix@yahoo.com>
Re: How to trap carp? <nobull@mail.com>
IMAP4 mailbox - mail retrieving and deleting <a@b.c>
Re: Limit output of examine (x) and return (r) in debug (tî'pô)
Re: Limit output of examine (x) and return (r) in debug (tî'pô)
Re: Limit output of examine (x) and return (r) in debug (tî'pô)
Open2 - fails when run from perl program as a backgroun <mark.fuller@northgate-is.com>
Re: Open2 - fails when run from perl program as a backg <wksmith@optonline.net>
Re: Pascal comment RE (Fredrik Andersson)
Re: Pascal comment RE <bart.lateur@pandora.be>
pass a parameter in win32? <ryan@jimryan.com>
Re: pass a parameter in win32? <bernard.el-hagin@DODGE_THISlido-tech.net>
perl error with oracle <g-preston1@ti.com>
printing on Win32 Platform <spp@monaco377.com>
Re: printing on Win32 Platform <simon.andrews@bbsrc.ac.uk>
Regex Pattern Evaluation <phileasfog@hotmail.com>
Regexp to match a C-style string (Roger Shrubber)
sub procedure question <dmueller@fhtw-berlin.de>
Re: sub procedure question <nobull@mail.com>
Re: UTF-8 translation? <jurgenex@hotmail.com>
Re: UTF-8 translation? (Helgi Briem)
Re: UTF-8 translation? <bernard.el-hagin@DODGE_THISlido-tech.net>
Why is this an infine loop??? <ilovebritishbeef@yahoo.com>
Re: Why is this an infine loop??? <derek@wedgetail.com>
Windows File Attributes (dulux)
Re: Windows File Attributes (Helgi Briem)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 31 Oct 2002 08:49:44 +0000 (UTC)
From: "ee ee" <ee@ee.ee>
Subject: Re: [OT] Re: Open a HTML page not using redirect
Message-Id: <apqqr8$k5s$1@knossos.btinternet.com>
I disagree that it's nothing to do with Perl - i'm trying to control HTML
from within Perl using the Perl commands, ok there is an element of HTML in
there but you guys seem to have the broadest knowledge because Perl is such
an all encompasing language ;)
I've been looking through the CGI documentation and it seems to indicate
that sending an output to a non-existent frame will cause a new window to
open, but i can't get it to work man.
#!c:/perl/bin/perl.exe
use CGI qw(:standard);
$w=new CGI;
print $w->header(-target=>'Window1'),
$w->start_html('hello1'),
$w->h1('hello world1'),
$w->end_html;
$q=new CGI;
print $q->header(-target=>'Window2'),
$q->start_html('hello2'),
$q->h1('hello world2'),
$q->end_html;
regards,
"Jeff Zucker" <jeff@vpservices.com> wrote in message
news:3DC0647E.90702@vpservices.com...
> TBN wrote:
>
> >>>the returned results will be in the same window as the submitted form.
> >>>
> >>
> >>Not necessarily. The results will go to wherever the TARGET tag of the
> >>form is aimed at or wherever the page's base TARGET is aimed at. Those
> >>targets may or may not be the same window the form was submitted from.
> >>
> >
> > Good point, I forgot about that, but that's outside scope since it still
> > won't return results to a designated popup window that has not yet been
> > created.
>
>
> Balderdash. Where do you think this goes, regardless of what has or
> hasn't been created previously and regardless of the level of javascript
> support?
>
> <a href="foo" target="newWin">bar</a>
>
> But since this has nothing to do with perl, why don't we just drop it.
>
> --
> Jeff
>
------------------------------
Date: 30 Oct 2002 21:58:48 -0800
From: vhrajput@yahoo.com (Vishva Rajput)
Subject: Error in running Perl Program
Message-Id: <7e7dbd59.0210302158.7fe778b9@posting.google.com>
I had a perl program for sending automatic e mails. THe program
employed Sender module. It was running fine for months until one day
it started showing me the following error
Use of uninitialized value in substitution (s///) at
/home/axon/vishvah/public_h
tml/cgi-bin/Mail/Sender.pm line 89.
Use of uninitialized value in pattern match (m//) at
/home/axon/vishvah/public_h
tml/cgi-bin/Mail/Sender.pm line 1469.
Use of uninitialized value in substitution (s///) at
/home/axon/vishvah/public_h
tml/cgi-bin/Mail/Sender.pm line 89.
THere were no changes that i made to the code.
THese warnings go away when i get rid of w from #!/usr/local/bin/perl
-wT, but it still doesn not send the mail.
WHat can be the reason???
Vishva
------------------------------
Date: Thu, 31 Oct 2002 05:18:57 -0700
From: Ron Reidy <rereidy@indra.com>
Subject: Re: Error in running Perl Program
Message-Id: <3DC11FB1.26B3D7D@indra.com>
Vishva Rajput wrote:
>
> I had a perl program for sending automatic e mails. THe program
> employed Sender module. It was running fine for months until one day
> it started showing me the following error
> Use of uninitialized value in substitution (s///) at
> /home/axon/vishvah/public_h
> tml/cgi-bin/Mail/Sender.pm line 89.
> Use of uninitialized value in pattern match (m//) at
> /home/axon/vishvah/public_h
> tml/cgi-bin/Mail/Sender.pm line 1469.
> Use of uninitialized value in substitution (s///) at
> /home/axon/vishvah/public_h
> tml/cgi-bin/Mail/Sender.pm line 89.
> THere were no changes that i made to the code.
> THese warnings go away when i get rid of w from #!/usr/local/bin/perl
> -wT, but it still doesn not send the mail.
> WHat can be the reason???
>
> Vishva
Maybe the data coming into the program is bad? Have you used the
debugger on this program?
--
Ron Reidy
Oracle DBA
------------------------------
Date: Thu, 31 Oct 2002 12:23:49 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: getting data out of database for downloading
Message-Id: <3DC120D5.69ED13D9@bbsrc.ac.uk>
Hans wrote:
>
> Hello,
>
> I have different types of data (like little images, pfd-documents
> etc.) saved in a mysql-database.
> Now I would like to build a website in perl with download-links for
> these data. Is there a way to do this (direct way out of mysql to
> download)?
You should certainly be able to do this using Perl and CGI.
You can retrieve the information out of the database using the DBI
module with the mysql DBD plugin. See perldoc DBI for all the details
of how this module works.
Once you have the information you simply print it out to STDOUT
(+binmode if on windows), after sending an appropriate content type
header for the data you are returning. For all the CGI interaction
(picking up parameters from the submitted link and sending back the
correct headers) you should use the CGI module. perldoc CGI will help
you with that.
Have a read through those documents and have a play with the two modules
then feel free to come back with more specific questions about any
problems you have implementing this.
Hope this helps
Simon.
------------------------------
Date: Thu, 31 Oct 2002 12:22:11 -0000
From: "Zahid Ali" <zahid@chambersandpartners.co.uk>
Subject: how can i delete files older than a certain number of days
Message-Id: <apr79j$48l$1$8302bc10@news.demon.co.uk>
I have redhat 7.3 running squid proxy server. I am using a HTML report
generator (sarg) which creates reports of the proxy logs and puts the output
on a windows samba share ready to be displayed on IIS. The reports are quite
big and I would like a script that can delete any files modified before 1
week. The following is the contents of the folder on the windows share. Does
anyone know how to write script to do this.
[root@Linux1 squid]# ls -all
total 90
drwxr-xr-x 1 root root 4096 Oct 31 2002 .
drwxr-xr-x 1 root root 4096 Oct 30 11:28 ..
drwxr-xr-x 1 root root 4096 Oct 13 00:01 12Oct2002-13Oct2002
drwxr-xr-x 1 root root 4096 Oct 15 00:06 14Oct2002-15Oct2002
drwxr-xr-x 1 root root 4096 Oct 16 00:05 15Oct2002-16Oct2002
drwxr-xr-x 1 root root 4096 Oct 17 00:06 16Oct2002-17Oct2002
drwxr-xr-x 1 root root 4096 Oct 18 00:05 17Oct2002-18Oct2002
drwxr-xr-x 1 root root 4096 Oct 19 00:06 18Oct2002-19Oct2002
drwxr-xr-x 1 root root 4096 Oct 20 00:02 19Oct2002-20Oct2002
drwxr-xr-x 1 root root 4096 Oct 21 00:01 20Oct2002-21Oct2002
drwxr-xr-x 1 root root 4096 Oct 22 00:05 21Oct2002-22Oct2002
drwxr-xr-x 1 root root 4096 Oct 23 00:06 22Oct2002-23Oct2002
drwxr-xr-x 1 root root 4096 Oct 24 00:05 23Oct2002-24Oct2002
drwxr-xr-x 1 root root 4096 Oct 25 00:06 24Oct2002-25Oct2002
drwxr-xr-x 1 root root 4096 Oct 26 00:05 25Oct2002-26Oct2002
drwxr-xr-x 1 root root 4096 Oct 27 00:02 26Oct2002-27Oct2002
drwxr-xr-x 1 root root 4096 Oct 28 00:02 27Oct2002-28Oct2002
drwxr-xr-x 1 root root 4096 Oct 29 00:06 28Oct2002-29Oct2002
drwxr-xr-x 1 root root 4096 Oct 30 00:07 29Oct2002-30Oct2002
drwxr-xr-x 1 root root 4096 Oct 31 00:05 30Oct2002-31Oct2002
-rwxr-xr-x 1 root root 7762 Oct 31 00:04 index.html
-rwxr-xr-x 1 root root 1338 Aug 30 15:53 squid1
[root@Linux1 squid]#
Thanks
--
Zahid Ali
Network Administrator
Chambers and Partners Ltd
Tel: 0207 606 1300 Extn: (306)
Fax: 0207 606 0906
www.chambersandpartners.com
------------------------------
Date: Thu, 31 Oct 2002 14:01:44 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: how can i delete files older than a certain number of days
Message-Id: <newscache$w6ku4h$mim$1@news.emea.compuware.com>
Zahid Ali wrote (Thursday 31 October 2002 13:22):
> I have redhat 7.3 running squid proxy server. I am using a HTML report
> generator (sarg) which creates reports of the proxy logs and puts the
> output on a windows samba share ready to be displayed on IIS. The reports
> are quite big and I would like a script that can delete any files modified
> before 1 week. The following is the contents of the folder on the windows
> share. Does anyone know how to write script to do this.
Start reading 'perldoc -f stat'. Come back later with the script you have
created sofar and we will be glad to step in with any help.
--
KP
------------------------------
Date: Thu, 31 Oct 2002 13:14:24 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: how can i delete files older than a certain number of days
Message-Id: <3dc12c1d.1332069344@news.cis.dfn.de>
On Thu, 31 Oct 2002 14:01:44 +0100, Koos Pol
<koos_pol@NO.nl.JUNK.compuware.MAIL.com> wrote:
>Zahid Ali wrote (Thursday 31 October 2002 13:22):
>
>> I have redhat 7.3 running squid proxy server. I am using a HTML report
>> generator (sarg) which creates reports of the proxy logs and puts the
>> output on a windows samba share ready to be displayed on IIS. The reports
>> are quite big and I would like a script that can delete any files modified
>> before 1 week. The following is the contents of the folder on the windows
>> share. Does anyone know how to write script to do this.
>
>Start reading 'perldoc -f stat'. Come back later with the script you have
>created sofar and we will be glad to step in with any help.
No, I don't think the stat function is what he wants.
The -M check for file age ( perldoc -f -X) and the unlink
function (perldoc -f unlink) are what he should use.
if (-M $file > 7) { unlink $file; }
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Thu, 31 Oct 2002 15:22:06 +0500
From: "Murtaza Nooruddin" <noorix@yahoo.com>
Subject: how to share socket handle across related process
Message-Id: <apr086$48rpl$1@ID-165850.news.dfncis.de>
I am having a hard time sharing a socket handle between parent and child
process.
The Parent is a listening socket, and accepts a new connection, and I must
give this newly connected socket handle to the child process. Sharing it in
shared memory does work, IPC::Shareable says that it can't share GLOB
variables. I believe there is a way using /proc filesystem under linux, but
not sure how.
Pleae help.
------------------------------
Date: 31 Oct 2002 12:12:09 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: How to trap carp?
Message-Id: <u9znsug63q.fsf@wcl-l.bham.ac.uk>
Da Witch <heather710101@yahoo.com> writes:
> Is there a way to trap carp errors? eval doesn't seem to do it:
carp() does not generate errors, it generates warnings.
You can trap warnings using the $SIG{__WARN__} mechanism.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 31 Oct 2002 13:10:06 +0100
From: ZZT <a@b.c>
Subject: IMAP4 mailbox - mail retrieving and deleting
Message-Id: <apr6iv$ete$1@news1.wdf.sap-ag.de>
Hello,
is there a not to difficult way to retrieve+delete mails from an IMAP
server within a perl-script? I am interested in how to do this.
thanks for an answer :)
bye
------------------------------
Date: Thu, 31 Oct 2002 10:03:36 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: Limit output of examine (x) and return (r) in debugger.
Message-Id: <2am1sugmv4vi3lr4f9bsmghuoothon00bv@4ax.com>
Peter Scott bravely attempted to attach 53 electrodes of knowledge to
the nipples of comp.lang.perl.misc by saying:
>In article <phfvrugv9olne9emrk6hrepdd2fm4b1ard@4ax.com>,
> "Teh (tî'pô)" <teh@mindless.com> writes:
>>I'm working on a project with rather large data structures, that is
>>many objects hold references to other objects which also hold
>>references to still more objects.
>>[snip]
>>My question is, is there a way to tell 'x' I only want to follow a
>>certain number of levels. Or at least to tell the debugger not to
>>print out the full return value of a function I'm returning from?
>
>perldoc perldebug
I found "O PrintRet=0" which is what I was looking for in my second
question, thanks.
> DB<3> O arrayDepth=5
This and hashDepth work for the top level, they don't pervert
recursive printing.
my $h = {};
my $it = $h;
for(1..100000) { $it = $it->{h} = {}; }
Now how can I limit "x $h"?
------------------------------
Date: Thu, 31 Oct 2002 10:05:28 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: Limit output of examine (x) and return (r) in debugger.
Message-Id: <s0p1suknk1di5bra5o49upar5pejlr7tcb@4ax.com>
Mark Jason Dominus bravely attempted to attach 23 electrodes of
knowledge to the nipples of comp.lang.perl.misc by saying:
>However, this is only available in Perl version 5.7.3 and later.
Sadly I'm using an older version.
------------------------------
Date: Thu, 31 Oct 2002 10:07:11 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: Limit output of examine (x) and return (r) in debugger.
Message-Id: <k2p1suo1oesajjcvff2keahe4e6nb8snvs@4ax.com>
Ilya Zakharevich bravely attempted to attach 22 electrodes of
knowledge to the nipples of comp.lang.perl.misc by saying:
>>
>> If I hit ^C as I would in a C[++] debugger the debugger exits.
>
>It should not. I tried it with
>
> x (0..10000)
>
>and it does not. (Both 5.005_53 and 5.6.1 I have nearby.)
>
You're right, when I test it on trivial samples (like your array and
the nested hashes in my previous mail) I get my debugger prompt back.
I don't know why this doesn't happen in my real life project.
------------------------------
Date: Thu, 31 Oct 2002 11:34:51 -0000
From: "Mark Fuller" <mark.fuller@northgate-is.com>
Subject: Open2 - fails when run from perl program as a background task
Message-Id: <apr4cj$q76@relay1.northgate-is.com>
Please help.
I'm using open2 to give me interaction between a program and perl script
running as a background process, The program waits for input, and the perl
script sends the input required. This works perfectly okay on UNIX, but
fails on Win2000, NT, XP. The process kicked off via the open2 dies with an
'invalid File descriptor' when data sent back to it via the pipe....
This all works if I run the perl program interactively.
Has anyone else come across this, and is there a workaround for it.
Thanks in advance
Mark
------------------------------
Date: Thu, 31 Oct 2002 13:35:01 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Open2 - fails when run from perl program as a background task
Message-Id: <9kaw9.5313$sZ4.4264@news4.srv.hcvlny.cv.net>
"Mark Fuller" <mark.fuller@northgate-is.com> wrote in message
news:apr4cj$q76@relay1.northgate-is.com...
> Please help.
>
> I'm using open2 to give me interaction between a program and perl script
> running as a background process, The program waits for input, and the perl
> script sends the input required. This works perfectly okay on UNIX, but
> fails on Win2000, NT, XP. The process kicked off via the open2 dies with
an
> 'invalid File descriptor' when data sent back to it via the pipe....
>
> This all works if I run the perl program interactively.
>
> Has anyone else come across this, and is there a workaround for it.
This sounds like a problem with quote marks. Did you remember to escape the
backslashes?
Good Luck,
Bill
------------------------------
Date: 31 Oct 2002 00:43:03 -0800
From: fredrik.andersson@avionics.saab.se (Fredrik Andersson)
Subject: Re: Pascal comment RE
Message-Id: <9df19bab.0210310043.7836bd5e@posting.google.com>
Hi,again
Thank you for the tip but it do not work.
} elsif (/\S+)|^\s*\(\*.*\*\)\s*$/) {
I'm looks for below result.
I do NOT want a match if:
1. If one line contains nothing
or
2. If the line contains a single Pascal comment (with or without space
before, after or inside the comment).
For example:(* Text *), (* Text*),(**) ,(*Text*)
Bye the way is my OR syntax correct?
(Find nothing on a line)|(Find something that's not a Pascal comment)
I use Perl 5.004_01 in Solaris and I'm not allowed to use any later
versions.
This has maybe someting to do with the problem ? If so tell me why?
Thanks for any tip!
Best Regards
Fredrik Andersson
clists@perrin.socsci.unc.edu (Andrew Perrin (CLists)) wrote in message news:<84lm4gkmui.fsf@perrin.socsci.unc.edu>...
> fredrik.andersson@avionics.saab.se (Fredrik Andersson) writes:
>
> > [snip]
>
> > ^\(\*.*\*\)
> > A line that only contains a Pascal comment (* text *)
>
> How about:
>
> /^\s*\(\*.*\*\)\s*$/
>
> It works for me on a cursory test, but I haven't tried it out thoroughly.
>
> ap
------------------------------
Date: Thu, 31 Oct 2002 11:46:05 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Pascal comment RE
Message-Id: <lg52suknbo95qco5j0uvnh3a060ou6vqv6@4ax.com>
Fredrik Andersson wrote:
>I do NOT want a match if:
>2. If the line contains a single Pascal comment (with or without space
> before, after or inside the comment).
> For example:(* Text *), (* Text*),(**) ,(*Text*)
You mean "if there's more than one single Pascal comment"?
Ah. your error is here. What you want is not to match if there's
anything following a "*)". Maybe:
/^\s*\(\*(?!.*\*\)\s*\S).*\*\)\s*$/
But that won't work for
( * one * ) ( * two *)
which contains nothing but Pascal comments. Perhaps that's how you want
it.
An approach for that would be to delete all Pascal comments, and when
you're done, see if there's anything left in the string. Like:
s/\(\*.*?\*\)//g and !/\S/
Drop the /g modifier if you only want to test for just one comment.
--
Bart.
------------------------------
Date: Thu, 31 Oct 2002 11:02:23 GMT
From: Jim Ryan <ryan@jimryan.com>
Subject: pass a parameter in win32?
Message-Id: <MPG.182ad7cb59e3908a989707@news1.news.adelphia.net>
How can I pass a parameter to my perl script at the command line in
NT/2000? What variable does it become? Thanks in advance.
--
Jim
Please CC: by E-mail
------------------------------
Date: Thu, 31 Oct 2002 11:15:49 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: pass a parameter in win32?
Message-Id: <slrnas242s.rma.bernard.el-hagin@gdndev25.lido-tech>
In article <MPG.182ad7cb59e3908a989707@news1.news.adelphia.net>, Jim Ryan wrote:
> How can I pass a parameter to my perl script at the command line in
> NT/2000? What variable does it become? Thanks in advance.
perl perlscript.pl parameter
'parameter' becomes the first element of the special array @ARGV.
Do
perldoc perlvar
and search for @ARGV.
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Thu, 31 Oct 2002 07:31:30 -0600
From: "Jerry Preston" <g-preston1@ti.com>
Subject: perl error with oracle
Message-Id: <aprbbh$gvf$1@tilde.itg.ti.com>
Hi!
I just setup a new server with solaris 8 and installed perl5.6.1 and all
seems to be working great except that I get the following error:
DBD::Oracle initialisation failed: Can't locate auto/DBD/Oracle/ORA_OCI.al
in @INC (@INC contains:
/export/home/kthmgr/lib/perl5/site_perl/5.6.0/sun4-solaris
/usr/local/lib/perl5/5.6.1/sun4-solaris /usr/local/lib/perl5/5.6.1
/usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris
/usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl .) at
/usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/DBD/Oracle.pm line 48
at /var/apache/cgi-bin/DM4/fo_fails_only.cgi line 31
Any ideas what is wrong? How to fix?
Thanks,
Jerry
------------------------------
Date: Thu, 31 Oct 2002 11:08:48 +0100
From: =?ISO-8859-15?Q?S=E9bastien?= Cottalorda <spp@monaco377.com>
Subject: printing on Win32 Platform
Message-Id: <3dc10131$0$245$626a54ce@news.free.fr>
Hi all,
May be someone as a clue for me.
I need to print out some text file on the default printer on Win32 systems
(windows9X, Windows2000, windowsXP, WinNT Workstation).
The problem is that this default printer is not necessary the local one
(connected on LP).
I know how to use OLE link with Excel, but I didn't have Excel on some
computers.
How can I do?
Is someone know to use Notepad or Wordpad with Perl to use it for printing ?
Thanks in advance.
Sebastien
------------------------------
Date: Thu, 31 Oct 2002 12:30:33 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: printing on Win32 Platform
Message-Id: <3DC12269.1209FABB@bbsrc.ac.uk>
Sébastien Cottalorda wrote:
>
> Hi all,
>
> May be someone as a clue for me.
> I need to print out some text file on the default printer on Win32 systems
> (windows9X, Windows2000, windowsXP, WinNT Workstation).
If it's only text then try the Printer module on CPAN.
http://search.cpan.org/author/SRPATT/Printer-0.97/lib/Printer.pm
------------------------------
Date: Thu, 31 Oct 2002 14:54:25 +0100
From: "Phileas Fog" <phileasfog@hotmail.com>
Subject: Regex Pattern Evaluation
Message-Id: <aprcln$46gi6$1@ID-13188.news.dfncis.de>
Hello,
I'm sorry if my question is excessively stupid but I have limited Perl
experience (less than 1KLOC to date) and
I'm trying to find a way to do a an eval of the substitution pattern in a
regex in a simple way.
That is not
my %MACROS = (
"#macro", "<macro>$1</macro>"
);
my $data = "#macro(Hello World)"
$data =~ s/$macro\((.+?)\)/$MACROS{$macro}/og
As you can see I would like to get the pattern to do an eval of the
substitution before substituting...
As of now the result is <macro></macro> instead of <macro>hello
world</macro>
I'm thinking of a couple of things, so I will continue my homework.
Meanwhile if you have an answer to this I'd be glad to read it. I'm sure it
is excessively simple.
Thanks for your time.
------------------------------
Date: 31 Oct 2002 00:28:33 -0800
From: roger256shrubber@hotmail.com (Roger Shrubber)
Subject: Regexp to match a C-style string
Message-Id: <ccc09d98.0210310028.131c0d01@posting.google.com>
Hi all
I need to create a text file format which holds strings. The strings can
legally contain any ASCII character, so they must be encoded in some way.
C-style would be most convenient. Some example records might be:
ITEM foo="a string" bar="a string containing \"quotes\""
ITEM baz="a string ending with a slosh: \\"
ITEM qux="a string ending with a slosh and a quote: \\\""
Anyone know of a regexp that can find the limits of a string, and won't be
tripped up by combinations of escaped quotes and escaped sloshes?
My current effort is:
/".*?(?<!\\)(\\\\)*"/
The idea is to find the nearest quote which is preceded by an even number
of sloshes (including 0). Nice in theory, but unfortunately, it doesn't
seem to work.
Cheers
- rog
------------------------------
Date: Thu, 31 Oct 2002 11:08:56 +0100
From: Daniel Mueller <dmueller@fhtw-berlin.de>
Subject: sub procedure question
Message-Id: <apqvfo$43kg2$1@fu-berlin.de>
Hello,
i am new to perl and have to write a cgi-script that should parse data
of an big textfile and present it to the user in different ways.
I have a sub-procedure to parse the file, read line-wise, split it to an
array and to remove the quotes if there are some. The procedure takes
two arguments (1. - for the line, 2. - for the column.
My problem is that the procedure works once, but when using it a second
time, i get no data back(the size of the array seems okay, but it is
empty). I think the reinitialization of the array fails, but i don't
know why.
Here is the procedure, i know it is a little dirty and could be made
better with regular expressions, but i am really new to perl / re.
"
sub parse {
my ($datarecord, $column) = @_;
my $line = "";
my @text = (0);
my $counter = 0;
my $counter2;
my @output = (0);
sub readdata { # for removing the quotes
@text = split(";", $line);
$counter2 = 1;
foreach (@text) {
if ($counter2 == $column) {
if((substr($_, 0, 1) eq '"')
&& (substr($_, (length $_) - 1, 1)) eq '"') {
$_ = substr($_, 1, (length $_) - 2);
}
return $_;
}
$counter2++;
}
#last;
}
open(BR, '< TEST/BelegRaum_DozentAlles.txt')
or die "\nCould not open file!\n";
while($line=<BR>) { # parse linewise
if ($datensatz == 0) {
$output[$counter] = readdata();
$counter++;
}
else {
if (($.+1) == $datarecord) {
close(BR) or die "\nCould not close file!\n";
return readdata();
}
}
}
if ($datarecord == 0) {
close(BR) or die "\nCould not close file!\n";
return sort @output;
}
}
"
As i said it unfortunately only works once. I would be very happy about
a hint from you perl experts. THX a lot
CU Daniel Müller
------------------------------
Date: 31 Oct 2002 13:19:58 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: sub procedure question
Message-Id: <u9r8e6g2yp.fsf@wcl-l.bham.ac.uk>
Daniel Mueller <dmueller@fhtw-berlin.de> writes:
> Subject: Re: sub procedure question
By "sub procedure" you mean "nested subroutine". Perl does not
implement nexted subroutines in the way that, say, Pascal or GNU-C
does. Unfortunately it doesn't throw an error (only a warning) if you
try to use them.
> My problem is that the procedure works once, but when using it a
> second time, i get no data back(the size of the array seems okay, but
> it is empty).
Enable warnings, then read the explaintion of the warning that Perl
gives you.
It is demeaning for a human to be asked to do the work of a machine.
Please do not ask people to help you find problems in your code until
you have exhuasted the help that your computer can give you.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 31 Oct 2002 06:34:00 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: UTF-8 translation?
Message-Id: <s94w9.49351$wm6.9978@nwrddc01.gnilink.net>
Ed Kulis wrote:
> In perl, (and of course being perl it's not too hard at all) I'm
> writing a translator that will take multi-octet characters like an
> umlated-o and turn it into a safe corresponding character like
> plain-old-lower-case-o.
Oh, I see.
So you are simplifying the t and the i into an l, too, aren't you? After all
, it's the same character, just with an additional dash resp. an additional
dot on top.
There are a couple of options:
- Teach your Unix tools UTF-8
- Recode your file from UTF-8 to whatever your Unix tools understand (maybe
ISO-8895-1?). This is easy to do with Text::Iconv
- do not accept non-ASCII characters from your datasource, e.g. block
non-ASCII in the input field
> Question:
> Is there a module/reference that already maps all the UTF-8 codes to
> "safe" ASCII and vice-versa.?
This is by definition of the term "character" not possible.
> Question:
> Are there module/references that generally map one character coding
> scheme to another?
If you are talking about changing the encoding from X to Y then have a look
at Text::Iconv.
jue
------------------------------
Date: Thu, 31 Oct 2002 10:33:02 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: UTF-8 translation?
Message-Id: <3dc1031d.1321572310@news.cis.dfn.de>
On 31 Oct 2002 04:10:02 GMT, gorilla@elaine.furryape.com
(Alan Barclay) wrote:
>In article <B9E5B191.40C1%ekulis@apple.com>,
>Ed Kulis <ekulis@apple.com> wrote:
>>In perl, (and of course being perl it's not too hard at all) I'm writing a
>>translator that will take multi-octet characters like an umlated-o and turn
>>it into a safe corresponding character like plain-old-lower-case-o.
>
>Are you going to translate the 'u's to 'v's, the 'i's to 'j's and the
>'1's to 'l's too?
>
>Accented characters aren't 'plan-old' characters with extra ink. They
>are different letters. By removing the accent you are corrupting the
>word.
To a pedant, yes. In the real world, no. We Icelanders use
a lot of accented and special letters and we routinely
replace them with the plain ASCII equivalent when
corresponding with foreigners. To my certain knowledge,
Germans and Swedes do the same.
For example, I often use this to make Icelandic
text easier for non-Icelandic grokking applications
to handle:
sub icelandic_2_ascii
{
for (@_)
{
tr/ÁÐÉÍÓÚÝÖáðéíóúýö/ADEIOUYOadeiouyo/;
s/Þ/Th/;
s/Æ/Ae/;
s/þ/th/;
s/æ/ae/;
return $_;
}
}
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Thu, 31 Oct 2002 10:39:44 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: UTF-8 translation?
Message-Id: <slrnas21v6.rma.bernard.el-hagin@gdndev25.lido-tech>
In article <3dc1031d.1321572310@news.cis.dfn.de>, Helgi Briem wrote:
> On 31 Oct 2002 04:10:02 GMT, gorilla@elaine.furryape.com
> (Alan Barclay) wrote:
>
>>In article <B9E5B191.40C1%ekulis@apple.com>,
>>Ed Kulis <ekulis@apple.com> wrote:
>>>In perl, (and of course being perl it's not too hard at all) I'm writing a
>>>translator that will take multi-octet characters like an umlated-o and turn
>>>it into a safe corresponding character like plain-old-lower-case-o.
>>
>>Are you going to translate the 'u's to 'v's, the 'i's to 'j's and the
>>'1's to 'l's too?
>>
>>Accented characters aren't 'plan-old' characters with extra ink. They
>>are different letters. By removing the accent you are corrupting the
>>word.
>
> To a pedant, yes. In the real world, no. We Icelanders use
> a lot of accented and special letters and we routinely
> replace them with the plain ASCII equivalent when
> corresponding with foreigners. To my certain knowledge,
> Germans and Swedes do the same.
As do Poles.
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Thu, 31 Oct 2002 07:25:26 GMT
From: "El Senor" <ilovebritishbeef@yahoo.com>
Subject: Why is this an infine loop???
Message-Id: <GV4w9.5030$V15.499265@newsread2.prod.itd.earthlink.net>
The following code is supposed to get several HTML pages and crudely examine
which page has more HTML tags.
I have examined the code VERY carefully but I cannot understand why it
results in an infinite loop. For some reason the /g modifyer in the while
loop is not working - the regular expression matches the same html tag over
and over again, like it begins from the beginning each time.
Can anyone tell me why the /g is not working so that the code results in an
infinite loop?
Thanks,
-Mike
# q1.pl
# Given URLs specified on the command line, retrieves their web pages and
# displays the url of the web page with the most HTML tags. An HTML tag is
# defined as any text beginning with "<" and ending with ">". If no
websites
# are specified, defaults to comparing "www.google.com" and "www.yahoo.com".
use strict;
use LWP::Simple;
# Obtain the websites we want to compare from the user. If no websites
# specified, use yahoo and google.
my @websites;
if( @ARGV <= 0 ) {
push( @websites, { url => $_ } ) foreach
("http://www.google.com", "http://www.yahoo.com");
}
else {
push( @websites, { url => $_ } ) foreach @ARGV;
}
# Retrieve HTML for each web page using LWP::Simple's get(). HTML stored in
# the list of hashes under key {html}.
foreach my $current_website (@websites) {
$current_website->{html} = LWP::Simple::get( $current_website->{url} ) or
die("\nCould not retrieve requested website: $current_website->{url}\n");
}
# Count number of HTML tags for each web page. An HTML tag is defined as
the
# smallest possible block of text beginning with "<" and ending with ">".
my $num_tags;
foreach my $current_website (@websites) {
$num_tags = 0;
#######################################
# Here is the infinite while() loop: WHY??
# if I change it to $temp = $current_website->{html} and
# then use $temp in the while condition, it works perfectly.
# But what is wrong with the way I have it here?
###########################################
#
$num_tags++ while( $current_website->{html} =~ /<.*?>/gs );
$current_website->{num_tags} = $num_tags;
}
# Find the website with the most HTML tags and display it.
@websites = reverse sort { $a->{num_tags} <=> $b->{num_tags} }@websites;
print "\n$websites[0]->{url} has more tags than ",
join( ", ", map { $_->{url} } @websites[1..$#websites] ), ".\n";
------------------------------
Date: Thu, 31 Oct 2002 09:17:25 GMT
From: Derek Thomson <derek@wedgetail.com>
Subject: Re: Why is this an infine loop???
Message-Id: <Fy6w9.170$WL5.5518@news.optus.net.au>
El Senor wrote:
> The following code is supposed to get several HTML pages and crudely examine
> which page has more HTML tags.
>
> I have examined the code VERY carefully but I cannot understand why it
> results in an infinite loop.
Works fine for me on Perl 5.6.1 on Linux. Perhaps this is a bug that has
since been fixed. What version of Perl is this?
--
D.
------------------------------
Date: 31 Oct 2002 02:54:31 -0800
From: rich@jool.biz (dulux)
Subject: Windows File Attributes
Message-Id: <f81b11eb.0210310254.1c88ac62@posting.google.com>
Hi all,
I am a newbie and am struggling with the following -
I wish to write a perl program that emulates the Windows 2K function
that allows you to take the read-only attribute of a directory,
including all contents - no matter what the directory depth...
This will be used on Windows 98 and NT machines, and I can alter the
attributes
on the root folder but cannot workout how to go any further.
Any help is much appreciated.
Thanks
Dulux
------------------------------
Date: Thu, 31 Oct 2002 13:10:07 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Windows File Attributes
Message-Id: <3dc12ae0.1331752178@news.cis.dfn.de>
On 31 Oct 2002 02:54:31 -0800, rich@jool.biz (dulux) wrote:
>I wish to write a perl program that emulates the Windows 2K function
>that allows you to take the read-only attribute of a directory,
^^^^
>including all contents - no matter what the directory depth...
What do you mean 'take'? Set or read?
>This will be used on Windows 98 and NT machines, and I can alter the
>attributes on the root folder but cannot workout how to go any further.
You can use either the CACLS or ATTRIB commands.
I don't think CACLS exists on Win98.
For a more Perlish way, use the module Win32::Perms
http://www.roth.net/perl/perms/
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
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 4051
***************************************