[23169] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5390 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 19 15:52:57 2003

Date: Tue, 19 Aug 2003 11: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           Tue, 19 Aug 2003     Volume: 10 Number: 5390

Today's topics:
    Re: CGI is not so hard (Tad McClellan)
        defining services for SOAP::lite with WSDL from file? (bugbear)
    Re: Encrypting a superuser (Bill)
    Re: Encrypting a superuser <matthew.garrish@sympatico.ca>
    Re: excel to csv <REMOVEsdnCAPS@comcast.net>
    Re: excel to csv <josh@nospam.pixael.com>
    Re: excel to csv <josh@nospam.pixael.com>
    Re: excel to csv <g4rry.sh0rt@zw4llet.com>
        executing .exe on NT from remote Unix server (Oak Barrett)
        Filepaths inside array and size? (Math55)
    Re: Filepaths inside array and size? (Sam Holden)
        How to delimit string except when inside quotes? <mike@nospam.com>
    Re: How to delimit string except when inside quotes? (Tad McClellan)
    Re: How to delimit string except when inside quotes? <mike@nospam.com>
        Low-level way of fetching UDP datagram as a unit (John Ramsden)
    Re: Module::Build is yet more broken... <nospam-abuse@ilyaz.org>
    Re: Module::Build is yet more broken... <nospam-abuse@ilyaz.org>
    Re: perl hacking for fun and pleasure <REMOVEsdnCAPS@comcast.net>
    Re: Perl web developer wanted (London, UK) <murat.uenalan@gmx.de>
    Re: Quick removal of the begging of a file? <ekulis@apple.com>
    Re: Regular Expression Question (Awrigh01)
    Re: Testing whether a subroutine exists (symbolic ref) <usenet@expires082003.tinita.de>
    Re: Why a sudden taint error with change in ISP server' <usenet@expires082003.tinita.de>
    Re: Why a sudden taint error with change in ISP server' (Bill)
    Re: you *must* be able to shorten this... <ghee2ghee@yahoo.co.uk>
    Re: you *must* be able to shorten this... <uri@stemsystems.com>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 19 Aug 2003 08:00:17 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: CGI is not so hard
Message-Id: <slrnbk47r1.4e0.tadmc@magna.augustmail.com>

hudson <scripts_you_know_the_drill_@hudsonscripting.com> wrote:

> I'm still not 100% with you on CGI.pm. People around here seem very
> loyal to it, but I have read in a lot of different places that it is
> too large and slow, etc.


Large, slow and correct vs. small, fast and incorrect.

Choose one.


[ exaggerated to make a point ]

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 19 Aug 2003 09:15:56 -0700
From: pwomack@engage.com (bugbear)
Subject: defining services for SOAP::lite with WSDL from file?
Message-Id: <7435f6f0.0308190815.4f9c99e6@posting.google.com>

(note cross posting)
I'm just starting to mess around with SOAP,
and I may be missing the point royally.

I'm attempting to create a (java implemented)
SOAP server, with help from AXIS.

The axis stuff generates, amongst other useful
things, a file full of WSDL, describing the
services that will be published. The Axis
tools can then generate some nice java classes
which the Axis run-time libraries will serve up.

Other Axis tools will also take the (same) WSDL
file and generate type-correct Java classes that
client side code can build on.

I am attempting to perform a similar thing for a
perl client - I would like to synthesize some kind
of client-side module from the WSDL file, and then
tell the client which server will be providing this
service "today".

But...

Soap:Lite appears to want to always get the WSDL
from the server "on the fly", and then generate/populate
the client module from this module.

Am I trying to do the wrong thing, or am I trying
to do the right thing in the wrong way?

All information and guidance would be gratefully listened
to.

    BugBear


------------------------------

Date: 19 Aug 2003 06:36:14 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: Encrypting a superuser
Message-Id: <239ce42f.0308190536.30440315@posting.google.com>

"JJ \(UK\)" <gee@i.cant.think.why.you'd.want.my.email.address.com> wrote in message news:<u0l0b.883$tS2.747653@newsfep2-win.server.ntli.net>...
> > Can you not just set up a scheduled task for the script and let it run as
>  a
> > more powerful user?
> >
> > Matt
> 
> Nice idea, but no, there is a certain amount of manual checking and the name
> of the input file changes from month to month.

So run a script as superuser as a periodic service. The superuser
script checks for a flag file's existence (-e filename) and reads the
flag file, if it exists for an input file name and then does the task
on that named input file. It then deletes the flag file. Might be good
to use flock() and sleep() here.

The manual checking might still be a problem, but perhaps you can
extend the above to include two phases. I have something of the sort
running here. HTH.


------------------------------

Date: Tue, 19 Aug 2003 13:36:41 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Encrypting a superuser
Message-Id: <Zet0b.3580$HB4.457370@news20.bellglobal.com>


"JJ (UK)" <gee@i.cant.think.why.you'd.want.my.email.address.com> wrote in
message news:u0l0b.883$tS2.747653@newsfep2-win.server.ntli.net...
>
> Nice idea, but no, there is a certain amount of manual checking and the
name
> of the input file changes from month to month.
>

What exactly is it that this batch file does that requires a more privileged
user, then? Is there any way you can grant the privileges they need without
changing their group? Is there any way to rewrite the script so that it
doesn't require the users to be accessing restricted files/folders/whatever
it is you don't want them having access to?

Compiling to an executable, as noted by another poster, is not a
particularly safe way to hide your passwords, but if that is all you are
looking for check out perl2exe.

Matt




------------------------------

Date: Tue, 19 Aug 2003 05:16:01 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: excel to csv
Message-Id: <Xns93DC3FCC1FEB1sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Josh" <josh@nospam.pixael.com> wrote in
news:bhsoj9$2pg60$1@ID-203386.news.uni-berlin.de: 

>> >
>> > i need it for a php script
>>
>> What difference does it make what script you need it for?
> 
> in my php script i download the zipped excel from a server...
> then i extract the excel and save it on the server... now i can't read
> the excel... i need some tool that convert excel in csv

Why don't you explain what you're trying to do, in some detail, right from 
the start, rather than doling out hints one at a time?  Several people have 
already posted useful suggestions, and to each one, you give a one-sentence 
response along the lines of "That won't work, because x."

Explain your complete problem.  Now.  Or you're not going to get much more 
help from anyone.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP0H47mPeouIeTNHoEQJF1QCcD4aJFmVEywGOUkvdp0mwxn9P8D0AnjO/
9CW92/4KWDvPspArgsQ8Al91
=GQLu
-----END PGP SIGNATURE-----


------------------------------

Date: Tue, 19 Aug 2003 16:19:33 +0200
From: "Josh" <josh@nospam.pixael.com>
Subject: Re: excel to csv
Message-Id: <bhtbme$2qunr$1@ID-203386.news.uni-berlin.de>

"Garry Short" <g4rry.sh0rt@zw4llet.com> ha scritto nel messaggio
news:3f41f025$0$46005$65c69314@mercury.nildram.net...
> Josh wrote:
>
> > hi all
> >
> > anybody knows a script to save an excel in csv?
> >
> > i need it for a php script
> >
> > tnx
>
> Josh,
>
> *PLEASE* try reading the posting guidelines. It would have suggested
(among
> other things) doing a search on something like Google Groups ... if you
> had, you'd have found the following thread:
>
>
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=Xns93B49CBD9408Easu1cornelledu%40132.236.56.8&rnum=5&prev=/groups%3Fq%3Dexcel%2Bcsv%2Bgroup:comp.lang.perl.misc%26hl%3Den%26lr%3D%26ie%3DUTF-8%26as_drrb%3Db%26as_mind%3D12%26as_minm%3D5%26as_miny%3D2003%26as_maxd%3D19%26as_maxm%3D8%26as_maxy%3D2003%26selm%3DXns93B49CBD9408Easu1cornelledu%2540132.236.56.8%26rnum%3D5
>
> where I provided a sample script to do just this for Sara.

tnx but unfortunately i'm working on a linux server...




------------------------------

Date: Tue, 19 Aug 2003 16:24:58 +0200
From: "Josh" <josh@nospam.pixael.com>
Subject: Re: excel to csv
Message-Id: <bhtbsi$2tuc4$1@ID-203386.news.uni-berlin.de>

"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> ha scritto nel messaggio
news:Xns93DC3FCC1FEB1sdn.comcast@206.127.4.25...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> "Josh" <josh@nospam.pixael.com> wrote in
> news:bhsoj9$2pg60$1@ID-203386.news.uni-berlin.de:
>
> > in my php script i download the zipped excel from a server...
> > then i extract the excel and save it on the server... now i can't read
> > the excel... i need some tool that convert excel in csv
>
> Why don't you explain what you're trying to do, in some detail, right from
> the start, rather than doling out hints one at a time?  Several people
have
> already posted useful suggestions, and to each one, you give a
one-sentence
> response along the lines of "That won't work, because x."
>
> Explain your complete problem.  Now.  Or you're not going to get much more
> help from anyone.

ok... i need to parse an excel file that i downloaded automatically from a
remote server
i'm working on a linux server so i can't use some php's objects that run
only on windows systems
i can't use an odbc connection because my server don't support this
so i would convert this excel in a csv file to parse it with php... i can do
this calling a perl script (that convert a xls in csv) by my php script and
then parse the csv with php...




------------------------------

Date: Tue, 19 Aug 2003 16:26:46 +0000
From: Garry Short <g4rry.sh0rt@zw4llet.com>
Subject: Re: excel to csv
Message-Id: <3f4241d7$0$46015$65c69314@mercury.nildram.net>

Josh wrote:

<SNIP>
>> *PLEASE* try reading the posting guidelines. It would have suggested
> (among
>> other things) doing a search on something like Google Groups ... if you
>> had, you'd have found the following thread:
>>
>>
>
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=Xns93B49CBD9408Easu1cornelledu%40132.236.56.8&rnum=5&prev=/groups%3Fq%3Dexcel%2Bcsv%2Bgroup:comp.lang.perl.misc%26hl%3Den%26lr%3D%26ie%3DUTF-8%26as_drrb%3Db%26as_mind%3D12%26as_minm%3D5%26as_miny%3D2003%26as_maxd%3D19%26as_maxm%3D8%26as_maxy%3D2003%26selm%3DXns93B49CBD9408Easu1cornelledu%2540132.236.56.8%26rnum%3D5
>>
>> where I provided a sample script to do just this for Sara.
> 
> tnx but unfortunately i'm working on a linux server...

So what? So am I. 

This script was written on my laptop, which runs SuSE 8.1. One of the main
ideas behind Perl is that it's supposed to be *PORTABLE!*

In fact, I just went back and read the link I posted - it specifically says
I'm running Linux, and the OP specifically said in response that she was
running RedHat 8.

If you're going to ask for help, how about at least reading the information
you're pointed at?

Regards,

Garry




------------------------------

Date: 19 Aug 2003 10:42:43 -0700
From: oakbarrett@hotmail.com (Oak Barrett)
Subject: executing .exe on NT from remote Unix server
Message-Id: <e29c93e4.0308190942.62659822@posting.google.com>

hi all..

i have searched this group and cpan to no avail.

is there a module or a way for me to login to a remote windows server
from a perl script on a unix box, and execute a .exe on the windows
box?

thanks for any help


------------------------------

Date: 19 Aug 2003 04:02:56 -0700
From: magelord@t-online.de (Math55)
Subject: Filepaths inside array and size?
Message-Id: <a2b8188a.0308190302.6ae9694@posting.google.com>

hello, lets say i have an array with some elements like that:


/var/file1
/var/file1.2
/var/log/file2
/var/log/hallo/file3


how can i get the size of all the files in a very fast way? right now
i get it with -s, but this is very slow, if the array contains many
elements! can i do that with "du" on unix or something?

THANKS!!!:-)


------------------------------

Date: 19 Aug 2003 11:15:46 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Filepaths inside array and size?
Message-Id: <slrnbk41n2.k76.sholden@flexal.cs.usyd.edu.au>

On 19 Aug 2003 04:02:56 -0700, Math55 <magelord@t-online.de> wrote:
> hello, lets say i have an array with some elements like that:
> 
> 
> /var/file1
> /var/file1.2
> /var/log/file2
> /var/log/hallo/file3
> 
> 
> how can i get the size of all the files in a very fast way? right now
> i get it with -s, but this is very slow, if the array contains many
> elements! can i do that with "du" on unix or something?

du will do it, but it probably won't be significantly faster, chances are
the filesystem interface is the bottleneck, and everything has to go 
through that. If you have enough files that using -s is too slow, then
you'll have to run du multiple times which will slow it down further.

Hitting the disk is slow. It's just the way it is.

-- 
Sam Holden



------------------------------

Date: Tue, 19 Aug 2003 11:35:27 -0400
From: "Mike G." <mike@nospam.com>
Subject: How to delimit string except when inside quotes?
Message-Id: <3tr0b.3948$c6.3345@bos-service2.ext.raytheon.com>

I am trying to split a string using "|" as the record separator.  But I
don't want to delimit any records that may be enclosed in quotes.

I found this article in the Perl FAQ:
How can I split a [character] delimited string except when inside
[character]? (Comma-separated files)

http://www.perldoc.com/perl5.8.0/pod/perlfaq4.html#How-can-I-split-a-%5bcharacter%5d-delimited-string-except-when-inside%0a%5bcharacter%5d--(Comma-separated-files)

*****************************
 @new = ();
 push(@new, $+) while $line =~ m{
  "([^\"\\]*(?:\\.[^\"\\]*)*)",?  # groups the phrase inside the quotes
  | ([^,]+),?
  | ,
  }gx;
 push(@new, undef) if substr($line,-1,1) eq ',';
*****************************

I have two questions with this,  I am trying to convert this regular
expression so that it uses "|" (pipes) as the record separator.  And also
have this code recognize empty fields.

I'm not sure where to substitute the commas(",") for pipes ("|"), I tried
this bit of code, which seems to work, but it does not recognize empty
fields, it just skips over them.  (I'm using $recSep to hold the record
separator)

*****************************
$line = "F1|\"Hello|This is|Field2\"||Field4";
$recSep = "|";
 @new = ();
 push(@new, $+) while $line =~ m{
  "([^\"\\]*(?:\\.[^\"\\]*)*)",?  # groups the phrase inside the quotes
  | ([^$recSep]+),?
  | ,
  }gx;
 push(@new, undef) if substr($line,-1,1) eq $recSep;
foreach $var (@new) { print "$var\n"; }
*****************************

If you run this code, you can see that the empty field, which I would
consider the third field, does not get captured.

But if I change the $recSep and $line to:

$line = 'F1,"Hello,This is,Field2",,Field4';
$recSep = "|";

It does recognize the empty field. So when it prints out, you can see an
empty string where the third field is.

I'm not too familiar with complicated regular expressions, and the FAQ that
I got the code from does not explain what is going on.

Could someone help me.

Thanks,

-Mike
(I hope I explained this correctly)




------------------------------

Date: Tue, 19 Aug 2003 10:58:21 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to delimit string except when inside quotes?
Message-Id: <slrnbk4i8t.4rb.tadmc@magna.augustmail.com>

Mike G. <mike@nospam.com> wrote:

> I found this article in the Perl FAQ:
> How can I split a [character] delimited string except when inside
> [character]? (Comma-separated files)


Did you read it all the way until the end?


> I am trying to convert this regular
> expression


Why not use one of the other methods mentioned in the FAQ answer?


> Could someone help me.


--------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use Text::ParseWords;

my $line = "F1|\"Hello|This is|Field2\"||Field4";
my $recSep = '\|';

my @new = quotewords($recSep, 0, $line);

foreach my $var (@new) { print "$var\n"; }
--------------------------------


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 19 Aug 2003 11:38:14 -0400
From: "Mike G." <mike@nospam.com>
Subject: Re: How to delimit string except when inside quotes?
Message-Id: <Jvr0b.3949$c6.3324@bos-service2.ext.raytheon.com>

Sorry for the mix up, it should say this:
> But if I change the $recSep and $line to:
>
> $line = 'F1,"Hello,This is,Field2",,Field4';
> $recSep = ",";



"Mike G." <mike@nospam.com> wrote in message
news:3tr0b.3948$c6.3345@bos-service2.ext.raytheon.com...
> I am trying to split a string using "|" as the record separator.  But I
> don't want to delimit any records that may be enclosed in quotes.
>
> I found this article in the Perl FAQ:
> How can I split a [character] delimited string except when inside
> [character]? (Comma-separated files)
>
>
http://www.perldoc.com/perl5.8.0/pod/perlfaq4.html#How-can-I-split-a-%5bcharacter%5d-delimited-string-except-when-inside%0a%5bcharacter%5d--(Comma-separated-files)
>
> *****************************
>  @new = ();
>  push(@new, $+) while $line =~ m{
>   "([^\"\\]*(?:\\.[^\"\\]*)*)",?  # groups the phrase inside the quotes
>   | ([^,]+),?
>   | ,
>   }gx;
>  push(@new, undef) if substr($line,-1,1) eq ',';
> *****************************
>
> I have two questions with this,  I am trying to convert this regular
> expression so that it uses "|" (pipes) as the record separator.  And also
> have this code recognize empty fields.
>
> I'm not sure where to substitute the commas(",") for pipes ("|"), I tried
> this bit of code, which seems to work, but it does not recognize empty
> fields, it just skips over them.  (I'm using $recSep to hold the record
> separator)
>
> *****************************
> $line = "F1|\"Hello|This is|Field2\"||Field4";
> $recSep = "|";
>  @new = ();
>  push(@new, $+) while $line =~ m{
>   "([^\"\\]*(?:\\.[^\"\\]*)*)",?  # groups the phrase inside the quotes
>   | ([^$recSep]+),?
>   | ,
>   }gx;
>  push(@new, undef) if substr($line,-1,1) eq $recSep;
> foreach $var (@new) { print "$var\n"; }
> *****************************
>
> If you run this code, you can see that the empty field, which I would
> consider the third field, does not get captured.
>
> But if I change the $recSep and $line to:
>
> $line = 'F1,"Hello,This is,Field2",,Field4';
> $recSep = "|";
>
> It does recognize the empty field. So when it prints out, you can see an
> empty string where the third field is.
>
> I'm not too familiar with complicated regular expressions, and the FAQ
that
> I got the code from does not explain what is going on.
>
> Could someone help me.
>
> Thanks,
>
> -Mike
> (I hope I explained this correctly)
>
>




------------------------------

Date: 19 Aug 2003 09:17:42 -0700
From: john_ramsden@sagitta-ps.com (John Ramsden)
Subject: Low-level way of fetching UDP datagram as a unit
Message-Id: <d27434e.0308190817.2952a05b@posting.google.com>

I am writing an SNMP trap handler, using Graham Barr's Convert::BER
module (which looks excellent, from what I can see) to translate the
PDUs from binary to a manageable structure.

When reading raw traps from a socket connection, Convert::BER relies
on the datagram length which appears near the start of the raw trap
string.

But, as Barr points out in a source code comment, what is to stop a
hacker (or just an erroneous program) sending to an SNMP trap port
an SNMP trap datagram with a length longer than tha actual length
of the datagram, thus causing the trap handler to hang while it
waits for the rest of the datagram which may never appear?

Anyway, apart from using a timeout, I was wondering if there is some
lower-level Perl (or any) method of reading an UDP datagrams as a
unit, so that this problem cannot arise.

Also, I need solutions for Unix and Windows if possible, even if a
different approach must be used for each.


Cheers

John Ramsden (john_ramsden@sagitta-ps.com)


------------------------------

Date: Tue, 19 Aug 2003 15:53:06 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Module::Build is yet more broken...
Message-Id: <bhth52$90j$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Sam Holden
<sholden@cs.usyd.edu.au>], who wrote in article <slrnbk2j1t.dl5.sholden@flexal.cs.usyd.edu.au>:
> > Why do you think so?  `perl Build' being different from `perl
> > Build.PL' - this depends on the (undocumented and quite probably
> > subject to change soon) order of executable extensions for the Perl
> > scripts.  Moreover, who guaranties that there is no F<Build> on the
> > PATH before '.'?
> 
> I'm saying that if the module works so that executing Build.PL 
> creates a perl script called Build in the current directory (which is
> implied by the "./Build test" command you mentioned) then after running 
> perl Build.PL you can just run "perl Build test" instead of "./Build test".

What I was saying was that this is wrong.  Why do you think that given
both `Build' and `Build.PL' in the current directory the command `perl
Build' will prefer running `Build' vs. running Build.PL?

On the other hand, it may be that the executable extension logic is
triggered only with -S option; this would make my particular argument
moot - but again, note that this depends on a semi/undocumented feature.

> The only thing that matters with respect to the PATH and "perl Build test"
> is that "perl" is in the PATH, which is implied by the execution of
> "perl Build.PL" or even "perl Makefile.PL".

Without -S switch, my argument was wrong.  Thanks for pointing this out.

> The command "perl Build test" tells perl to run the script in the file
> "Build" in the current working directory and set @ARGV to be ('test').

> Is there *any* platform on which this is not true?

You mean "currently" or "in foreseeable future"?  I would not vouch in
the second case...

Ilya


------------------------------

Date: Tue, 19 Aug 2003 15:56:26 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Module::Build is yet more broken...
Message-Id: <bhthba$94r$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Ken Williams
<ken@mathforum.org>], who wrote in article <710171a3.0308181635.6d8fb155@posting.google.com>:
> > The beauty of Makefile.PL user interface (as opposed to the - faulty -
> > packager's interface) is that it was shell-, OS-, filesystem-,
> > etc-independent.  Now comes Build - and the invocation has the ./file
> > syntax, which is system-dependent!
> 
> Yes, but barely.  And I hope people will be able to surmount this
> obstacle and figure out how to run a perl script if they're installing
> perl modules.

Why do you think so?  E.g., they may be getting LWP just to use
`lwp-download'...

> In order to ease the transition module authors may make from MakeMaker
> to M::B, and in order to let people make distributions with both a
> Makefile.PL and a Build.PL (which happens quite a lot, and might be
> expected to happen basically forever), it is highly desirable that the
> config/build/test process is very similar to MakeMaker's.  Also, I
> considered lots of alternative ways to set things up when M::B was
> young, and I decided that many of MakeMaker's metaphors made a lot of
> sense, so I didn't change them.  This is one of the big ones I kept,
> and I think that's been a good decision.  It has, for example, enabled
> the creation of a pass-through Makefile.PL and Makefile, helping
> transitional compatibility with CPAN.pm

Do not see how.  Can you elaborate?

Yours,
Ilya




------------------------------

Date: Tue, 19 Aug 2003 10:30:14 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: perl hacking for fun and pleasure
Message-Id: <Xns93DC74FAF3366sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

cp <cpryce@pryce.net> wrote in news:180820031510377251%cpryce@pryce.net:

> In article <iv3ujv41n315ou09629gfh96aep93gf00n@4ax.com>, hudson
> <scripts_you_know_the_drill_@hudsonscripting.com> wrote:
> 
>> OK...let's forget about this and just talk about perl hacking for fun
>> and pleasure ;-)
>> 
>> much better........all this nonsense and bad karma is getting everyone
>> nowhere fast
> 
> Then start up rec.perl.hacking. And leave this news group to a
> professional discussion about Perl.

Bah.

> I make a living programming in
> Perl. Sometimes this news group is essential to getting that job done.

Me too.  Been that way for years; I wouldn't have it any other way.

 
> Some of the people who are trying to help you learn how to have fun
> with Perl make their living using Perl. Some of us have had to fight
> tooth and nail with project managers against misconception that Perl is
> not a "professional" programming language, and that Open Source
> projects are synonimous with "poor programming." 

Me too.  Irrelevant.


> When you post sloppy code "for fun and pleasure", you make my job
> harder.  The "bad Karma" you are experiencing is other programmers
> fighting to keep their craft professional.

You're assuming that hudson, or anyone else having fun, is going to post 
fun & pleasure code in a format that will appear to be an archive of 
useful and tested code.  Not necessarily true.


> Your poor code posting immediately becomes a part of an archive
> available to anyone with google and the sense to search the archives
> first for the answers to their questions.

But not enough sense to tell play code from production code?  Well, they 
can live and learn, I suppose.

Open source code, and the open source community, are *not* synonymous 
with "poor programming", but one must always keep Sturgeon's Law in mind.  

Lighten up.  For once (<wink>), hudson is right:  Perl *is* one of the 
most fun programming languages around.  hudson made a lot of enemies when 
he first came to c.l.p.m, because he was spreading his own bad karma 
around an didn't understand the culture.  However, he did have some good 
points sprinkled around here and there, despite his ignorance.  This 
time, I think he's right:  Perl is fun, let's all take a step back and 
relax, and perhaps have fun together.  That doesn't detract from Perl's 
or c.l.p.m's value to the professional developer.


My two cents' worth.
- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP0JCcWPeouIeTNHoEQL6oACgnxdBnqMpaByPfAoD/W1fjzGEdWgAoLrp
kYvXgOAWWJ6xa7Mq8JHjG9rO
=bH6C
-----END PGP SIGNATURE-----


------------------------------

Date: Tue, 19 Aug 2003 14:29:22 +0200
From: "Murat Ünalan" <murat.uenalan@gmx.de>
Subject: Re: Perl web developer wanted (London, UK)
Message-Id: <bht519$kui$06$1@news.t-online.com>

> Look forward to hearing from you.
>
> Branwell Moffat
>

Please use http://jobs.perl.org next time.

Greetings,
Murat




------------------------------

Date: Tue, 19 Aug 2003 10:05:17 -0700
From: Ed Kulis <ekulis@apple.com>
Subject: Re: Quick removal of the begging of a file?
Message-Id: <BB67A6DD.802E%ekulis@apple.com>

Thanks, Benjamin,

Great techniques in your response. See some of my comments.


On 8/18/03 7:54 PM, in article 3F419148.81D4E7FF@hotpop.com, "Benjamin
Goldberg" <ben.goldberg@hotpop.com> wrote:

> Ed Kulis wrote:
>> 
>> Hi,
>> 
>> I'd like to use perl to chop the head off a file in Unix that an
>> application is writing to without disturbing the file.  (Apps we use are
>> Oracle, PeopleSoft, Vantive, Unix scripting)
> 
> Not easily.  You can (if your filesystem supports this feature) use
> syscall(SYS_punch(), ...)  to free up the disk pages from the front of
> the file.  This releases them back to the filesystem, so that your file
> uses less space.  Note that the data still in the file will still appear
> to be at the same ofset as it had been, and the file will appear to
> still have the same length as it did before.  The only difference is
> that less disk space is used, and the fact that the leading bytes of the
> file will now appear to be filled with "\0" bytes.
> 
I was afraid that it wasn't easy.

>> We've got some immense trace files and I'd like to remove say the first
>> 50% of the lines of a 200 meg file while an has the file open and the
>> app is writing to it. That way we can manage the filesystem space while
>> retaining the recent interesting information.
> 
> If the app has the file open in append mode, and if you can temporarily
> force the app to stop writing, there's another way to do it.  By reading
> and seeking and writing, you can copy bytes from the latter 50% of the
> file to the front, and then call truncate() to make the file shorter.
> 
I'm trying to stay from the app.

> Something like this:
> 
>  open( FH, "<+", $filename ) or die horribly;
>  seek( FH, ((-s FH)/2), 0 ) or die horribly; # 50%
>  scalar(<FH>); # skip to the end of the line.
This is cool.

>  my $readfrom = tell FH;
>  my $writeto = 0;
>  my $n;
>  my $lastbytes = 0;
>  LOOP: while( 1 ) {
>     lseek( FH, $readfrom, 0 ) or die horribly;
>     my $buf;
>     while(1) {
>        $n = sysread( FH, $buf, 8192 ) and last;
>        unless( defined $n ) {
>           redo if $!{EINTR} or $!{EAGAIN};
>           die horribly;
>        }
>        last LOOP if $lastbytes;
>        $lastbytes = 1;
>        stop_other_app_from_writing();
>     } # end while(1)
>     lseek( FH, $writeto, 0 ) or die horribly;
>     TRYWRITE: {
>        my $m = syswrite( FH, $buf );
>        unless( $m ) {
>           redo TRYWRITE if $!{EINTR} or $!{EAGAIN};
>           die horribly;
>        }
>        substr( $buf, 0, $m ) = "";
>        $writeto += $m;
>        $n -= $m;
>        redo TRYWRITE if $n;
>     } # end TRYWRITE:
>  } # end LOOP: while(1)
>  truncate( FH, $writeto ) or die horribly;
>  allow_other_app_to_write();
>  close FH;
> 
> Isn't this ugly? :)
> 
> If you leave out the stop_other_app_from_writing and allow_other_app_to_
> _write, then there's a chance you'll some lines, due to a race
> condition.
That's what puts the "curse" in "recursive"
> 
> You might be better off rotating your log files every so often, then
> removing the oldest ones.  This is the standard technique for what you
> want.
> 
Yep. I was trying to be fancy so that a developer could always see the last
x% of a file. BUT! why don't I just write it to another file before I do the
cat /dev/null.

>> cat /dev/null > file
>>     sometimes works to zero the entire file while it's being written to
Always truncates but I've had some gremline reports from developers that the
app didn't like it and hung or crashed. I don't quite believe it and I think
is was the "Fallacy of the Last Change"

> 
> This should *always* truncate the file to 0 length.  Not "sometimes".
> 
> You could get the same effect by doing, in perl:
> 
>  truncate( "file", 0 );
> 
> Or:
> 
>  open( FILE, ">file" );
>  close(FILE);
Nice. perlish and not a qx{cat ...
> 
> However, for none of these do you retain any of your old data.
> 
>> because I think that the Unix inode stays the same so it won't make any
>> difference to the apps open state. I'm not clear on the details of the
>> file open states.
> 
> True -- the inode stays the same, so it doesn't make a difference to the
> app which is writing.
> 
Thanks for the confirm on this.


> But if you want to keep recent data, then it *does* make a difference.
>

Sounds like I can loop and post reads on the source log file and send the
lines to other files of a certain fixed size then truncate the source log
file from another process.

Might lose a line or two but that doesn't make much difference in a verbose
log.

I can then manage the chunks of the log files and eliminate older ones.

>> I don't want to do anything to the app configuration or startup. I'd
>> like to know if there are any Perl functions/techniques that could say
>> move the beginning of file pointer to the mid file some where.
> 
> The perl techniques for this aren't signifcantly different from the C
> techniques for it.
> 
>> Is there a clever way to get the size of a file and remove the beginning
>> of it?
> 
> The clever way of getting the size of a file is to use the -s operator,
> either on a filename or on a filehandle.
> 
> See:
>  perldoc -f -X



------------------------------

Date: 19 Aug 2003 11:04:31 -0700
From: awright@ymail.yu.edu (Awrigh01)
Subject: Re: Regular Expression Question
Message-Id: <cad8a63c.0308191004.5f255131@posting.google.com>

Sorry about not being clear.  I appreciate the help so far.  I am
searching through a text file read through line by line.

I want to be able to identify word patterns that occur consecutively
in the same line, such as: A Man Walks Down The Street. (including the
spaces)

This regular expression identifies this pattern:
[A-Z]\w*(\s+[A-Z]\w*)*.

However, there is another twist, sometimes the pattern will include a
comma, dash, hyphen, an "&", or a period, such as Johnson & Johnson
CauLife Ins. Co.

I can't figure out how to generally identify both "A Man Walks Down
The Street" and "Johnson & Johnson CauLife Ins. Co." in one regular
expression.

I hope this is clearer, and thanks again for any help.

Thanks.

Simon Taylor <simon@unisolve.com.au> wrote in message news:<bhsl32$ni6$1@otis.netspace.net.au>...
> Awrigh01 wrote:
> 
> > I have been working with regular expressions and was wondering if
> > anyone can help me tackle this problem.
> > 
> > I was wondering if anyone could help me with a regular expression to
> > strip the following two text patterns:
> > 
> > Bob Jones Comm'n College, Inc.,
> > Tufts University,
> > 
> > I believe that this pattern should strip words that begin with capital
> > letters:
> > [A-Z]\w*(\s+[A-Z]\w*)* 
> > 
> > Could someone help me with a pattern than would get both words that
> > begin with capital letters or a non-word character like a "," or "."
> 
> I think it would help if you were to refine the question a litle more.
> 
> Do I understand correctly that you want to strip away lines that begin 
> with text like:
> 
> Bob Jones Comm'n College, Inc.,
> Tufts University,
> 
> Put more generally, do you want to strip away lines that contain
> words that always begin with uppercase letters?
> 
> Do these kind of lines occur at the same place in each file?
> 
> What kind of data do you *not* want to strip away?
> 
> Hope this helps,
> 
> Look forward to seeing your follow up.
> 
> Simon Taylor


------------------------------

Date: 19 Aug 2003 15:21:37 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: Testing whether a subroutine exists (symbolic ref)
Message-Id: <bhtfa1$2vgvv$1@uni-berlin.de>

Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote:
> Tina Mueller <usenet@expires082003.tinita.de> wrote in news:bhqlv6$25j9g$1
> @ID-24002.news.uni-berlin.de:
> > print "$sub exists" if main->can( $sub );

> Oh, that is *bizarre*!

additionally, it should be main::->can( $sub ).
it generates a warning otherwise, i wonder why
i didn't see this. oh, wait, 5.6.1 generates a
warning, 5.8.0 does not. oh well =)

-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -


------------------------------

Date: 19 Aug 2003 12:14:34 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: Why a sudden taint error with change in ISP server's perl 5 version?
Message-Id: <bht4ba$2mahj$2@ID-24002.news.uni-berlin.de>

Bill wrote:

> Recently, apparently after a version upgrade on a server, the
> following taint code error message started occuring. Prior to the
> change, both of the above snippets worked without error--afterwards,
> only the second one did.

do you know which version was there before and which version
you have now?

> Could someone explain why EITHER might raise a taint error? 

> #!/usr/bin/perl -w -T
> use CGI;
> use strict;
> my $q = new CGI;
> my $tainted = $query->param("theirs");
                ^^
                  $q
> if($tainted && open(OUTFILE, ">filename") { print OUTFILE "data\n" }
                                          ^^
                                           )

this does not compile. please copy and paste next time.
anyway, i believe this is because (from perlsec):
|      The value of an expression containing tainted data will
|      itself be tainted, even if it is logically impossible for
|      the tainted data to affect the value.

so the $tainted is in the same expression as the open().

hth, tina
-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -


------------------------------

Date: 19 Aug 2003 06:38:11 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: Why a sudden taint error with change in ISP server's perl 5 version?
Message-Id: <239ce42f.0308190538.33d6742@posting.google.com>

oh, sorry, the line 

my $q = ...

should be 

my $query = 

in the example I gave...


------------------------------

Date: Tue, 19 Aug 2003 16:05:52 +0100
From: Ghee <ghee2ghee@yahoo.co.uk>
Subject: Re: you *must* be able to shorten this...
Message-Id: <3F423CD0.3040508@yahoo.co.uk>

Jeff 'japhy' Pinyan wrote:

> [posted & mailed]
> 
> On 28 Jul 2003, Ghee wrote:
> 
> 
>>I've written a short script to read in a form with HTML-style tags
>>(form is postscript, can be 0.5MB to 20MB+, tags are alphanumerical
>>wiht - or _ in), and substitute values into these tags from a separate
>>data file (pipe delimited, ie data|value), writing out the populated
>>form as a new file.
> 
> 
>>#!/usr/bin/perl
> 
> 
> I'd suggest
> 
>   use strict;
>   use warnings;
> 
> The 'strict' will require you to declare your variables.
> 
> 
>>#open output file, tag data, and the form
>>open (OUTPUT,">OUTPUT.ps") || die "can't open output file";
>>open (DATA,"DATA.PDF") || die "can't open data file";
> 
> 
> "PDF" is a common Adobe file suffix.  It's awfully misleading here.
> 
> 
>>open (FORM,"FORM1.ps") || die "can't open form file";
> 
> 
> It's helpful to include $! in your error messages; it explains why the
> system couldn't do what you asked.
> 
> 
>>#Read in pipe delimited file (PDF), put data in associative array
>>@data=<DATA>;
>>foreach $item (@data) {
> 
> 
> There is no reason to read a filehandle into an array, just to iterate
> over the array.  Use a while loop, like you did for FORM.
> 
> 
>>   @items=split /\|/,$item;
>>   $variable=$items[0];
>>   $value=$items[1];
> 
> 
> Why use @items?  Why not store the values directly into the variables you
> want to use?
> 
> 
>>   $$variable=$value; chop $value;
> 
> 
> EWW!  NO!  Not allowed.  Do not create a variable out of thin air like
> that.  If $foo is a string like "name", do NOT create $name by saying
> 
>   $$foo = "Jeff";
> 
> That is evil.  It's a symbolic reference.  You shouldn't use them.l
> 
> 
>>   $array{$variable}=$value;
> 
> 
> ... especially if you're going to store the relationship in a hash anyway!
> And %array is a rather poor name for a hash.
> 
> 
>>};
> 
> 
>   my %vars;
> 
>   while (<DATA>) {
>     chomp;  # remove the newline; chomp() is safer than chop()
>     my ($varname, $value) = split /\|/;
>     $vars{$varname} = $value;
>   }
> 
> 
>>#read through form line by line, identifying any tags and replacing
>>#values from associative array as neccesary
>>
>>while(<FORM>) {
>>   $stuff = $_;
> 
> 
> There's no reason not to use $_ in this loop.  And if you don't want to
> use $_, then why not say
> 
>   while (my $stuff = <FORM>) { ... }
> 
> 
>>   $done_stuff = "";
>>   while ($stuff =~ /<[0-9a-zA-Z-_]+>/) {
>>       $done_stuff = $done_stuff . $`;     #write out pre match
>>       $stuff = $';     #move post match to $stuff to loop again...
> 
> 
> Don't use $`, $&, and $'.  They're bad variables.  They slow things down,
> and there's almost always a way around them.  I have a feeling you want to
> use a substitution here.
> 
> 
>>       $tag_name = $&;
>>       $tag_name =~ s/<|>//g;    #take off < and >
>>       if (exists $array{$tag_name}) { #replace if exists in array
>>           $done_stuff = $done_stuff . $array{$tag_name};
>>       } else {
>>           $done_stuff = $done_stuff . "<$tag_name>";
>>       }
>>   }
>>   $done_stuff = $done_stuff . $stuff;
>>   print OUTPUT $done_stuff;
>>};
> 
> 
> Definitely.  You definitely want a substitution.
> 
>   while (<FORM>) {
>     s{
>       < ([-\w]+) >  # the ()'s capturing what they match to $1
>     }{
>       if (exists $vars{$1}) { return $vars{$1} }
>       else { return "<$1>" }
>     }xge;
>     # s{}{} is just another form of s///, and we're operating on $_
>     # the /x modifier means the regex has extra whitespace and comments
>     # the /g modifier means "do this globally for each match"
>     # the /e modifier means the replacement is a block of code to evaluate
> 
>     print OUTPUT;  # $_ is the default thing to print
>   }
> 
> 
>>close (FORM);
>>close (DATA);
>>close (OUTPUT);
> 
> 

Jeff,

Thanks for the suggestions - they sparked off two days of great 
discussion here (no-one knew about putting code in a regexp with the /e 
option).  Sorry for the delay in replying...

Ghee



------------------------------

Date: Tue, 19 Aug 2003 16:20:15 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: you *must* be able to shorten this...
Message-Id: <x71xvh1uww.fsf@mail.sysarch.com>

>>>>> "G" == Ghee  <ghee2ghee@yahoo.co.uk> writes:

<snip of massive quote>

at least you didn't top post but you should have edited out most/all of
the quote as you didn't comment directly on anything there.

  G> Thanks for the suggestions - they sparked off two days of great
  G> discussion here (no-one knew about putting code in a regexp with the
  G> /e option).  Sorry for the delay in replying...

that is putting code in the replacement side of s///. s/// is NOT a
regex but the substitution operator. the left part of it is a regex and
the right part is a double quotish string or code when using the /e
modifier. it helps to understand that properly when discussing it.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


------------------------------

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



------------------------------

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 5390
***************************************


home help back first fref pref prev next nref lref last post