[16665] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4077 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 21 06:10:45 2000

Date: Mon, 21 Aug 2000 03:10:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <966852618-v9-i4077@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 21 Aug 2000     Volume: 9 Number: 4077

Today's topics:
    Re: Passing argument to Perl script <gellyfish@gellyfish.com>
    Re: Perl cgi-wrap issues and security problems <gellyfish@gellyfish.com>
    Re: Perl code help involving tabs <gellyfish@gellyfish.com>
        PERL file handling srikdvs@my-deja.com
    Re: PERL file handling <elephant@squirrelgroup.com>
        Pretty-printer - why not? (Peter Seebach)
    Re: Replace array element <gellyfish@gellyfish.com>
    Re: Serial port ??? (David Efflandt)
    Re: Sorting is very slow <jpl@research.att.com>
    Re: system() and error handling <roman.stawski@fr.adp.com>
        Thank you!!  (rookie question) <NIXSPAMdrh@engineer.com>
    Re: Wildcards in DOS 'dir' command (fvw)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 20 Aug 2000 10:17:42 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Passing argument to Perl script
Message-Id: <8no7nm$j6a$1@orpheus.gellyfish.com>

On Sat, 19 Aug 2000 16:16:19 +0200 Lary wrote:
> "Jonathan Stowe" <gellyfish@gellyfish.com> wrote in message
> news:8nlmu2$f54$1@orpheus.gellyfish.com...
>> On Sat, 19 Aug 2000 11:51:43 +1000 Minh Le wrote:
>> > Hi,
>> > I'm trying to pass 3 different arguments to my simple perl script
>> > without any success.  I did try GetOption ... but they are all
>> > failed.  What I need is during execute my script, I need to pass
>> > 3 different arguments to the program and depend on which argument
>> > has been provided, a particular sub-routine or task will be called.
>> > Example:  myperl -a x  -b x -c x where x can be 0 or 1.  if there
>> > is no option or argument provided, it will print out a help message,
>> > say " Please run myperl -help"
>>
>>
>> You will probably want to use the module Getopt::Std to do this - in your
>> case you will have something similar to :
>>
>>
>> #!/usr/bin/perl -w
>>
>> use Getopt::Std;
>> use strict;
>>
>> my %opts;
>>
>> getopts('a:b:c:',\%opts) || die "Invalid argument\n";
>>
>> unless(exists $opts{a} &&
>>        exists $opts{b} &&
>>        exists $opts{c} )
>> {
>>   die "You must supply all of the arguments\n";
>> }
>>
>>
> 
> user the -s command line option (or on unix invoke perl with the -s option:
> #!/usr/local/perl -s  ).
> If you write on the command line:
> 
> perl -s myprogram.pl -a=5 -b=6 -c=7
> 
> you will get in the program the variables $a $b $c with the values from the
> command line
> 

Except that it is necessary to declare the variables using 'our' or
'use vars' under 'use strict' and it would be necessary to test for
the existence of unwanted switches with some nasty symbol table hacks -
it also does not warn against a missing value for the switch defaulting
instead the value of the variable to '1' which might be useful or annoying
depending on how you look at it.  There is a reason why this facility is
described as 'rudimentary' in the perlrun manpage.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: 21 Aug 2000 07:37:55 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl cgi-wrap issues and security problems
Message-Id: <8nqio3$m02$1@orpheus.gellyfish.com>

On Fri, 18 Aug 2000 13:33:07 GMT Rafael Garcia-Suarez wrote:
> Sandra wrote in comp.lang.perl.misc:
>>
>>Questions:
>>1. CGI-wrap is the only solution? 
>>2. We would like to have a modified version of Perl
>>with exec() disabled, system() disabled, eval disabled,
>>and most server/disk access disabled  etc, etc.  
>>is this possible?  
> 
> You can hack the perl source code to remove those functions.

Alternatively the Opcode module allows  you to disable groups of functions
this could be turned on in a small wrapper if necessary.

In the end however minimizing the risk associated with allowing people to
run arbitrary CGI programs on your servers is down to good administration.
You might want to ask in a group that discusses web server administration
issues about the methods that people use to reduce the risk of damage
being done to your or someone elses machine by user code.

/J\

-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: 21 Aug 2000 08:18:29 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl code help involving tabs
Message-Id: <8nql45$m57$1@orpheus.gellyfish.com>

On Thu, 17 Aug 2000 21:25:51 -0700 Jordan Zommick wrote:
> Suppose I have an ascii document that has some marked up tags identifing
> tabs. The example here shows a paragraph with tabs set to 3in and 5in in the
> document. The marked up text
> would look like:
> 
> <P><TABS:3in, 5in>This is text<TAB>More text<TAB>Last Text</P>
> 
> 
> Simply converting <TAB> to 5 spaces would end up like
> This is text     More text     Last Text
> 
> However, that's not what I'm after. I need the middle set of text to start
> at 3 inches and the last set of text to start at 5 inches.  So I guess I'd
> have to use a fixed font and count the length of string 1 and pad enough
> spaces to reach 3inches. Then, count string 1 + padding + string 2 and pad
> enough spaces to reach 5 inches.  Does this all sound correct?  Now, how the
> heck would I do that in perl?
> 
> 

It completely depends on your output device.  I would be tempted to cause
the program to output the appropriate troff codes to do this and then
post-process this for printing.  There is also a Font::AFM module that you
might find useful if you want to use a variable width font.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Mon, 21 Aug 2000 06:04:55 GMT
From: srikdvs@my-deja.com
Subject: PERL file handling
Message-Id: <8nqgq0$dhl$1@nnrp1.deja.com>

I am using a PERL script to split an input file.What is the maximum
file size that PERL can handle?When I used a 3.6GB file the script
failed.What is the alternative for handling such big files??


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 21 Aug 2000 09:08:55 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: PERL file handling
Message-Id: <MPG.140b8f19f1e988a59896d3@localhost>

srikdvs@my-deja.com <srikdvs@my-deja.com> wrote ..
>I am using a PERL script to split an input file.What is the maximum
>file size that PERL can handle?When I used a 3.6GB file the script
>failed.What is the alternative for handling such big files??

how are you handling this input file ? .. and how is it failing ? .. I'm 
no expert but I wouldn't have thought that the size taken by the 
FILEHANDLE was related in any way to the size of the file that you're 
opening .. meaning that any size of input file could be processed as 
long as it was processed a line at a time (or X lines at a time)

show us some code

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 21 Aug 2000 04:44:09 GMT
From: seebs@plethora.net (Peter Seebach)
Subject: Pretty-printer - why not?
Message-Id: <39a0b398$0$72520$3c090ad1@news.plethora.net>

I know you're supposed to "just write it right in the first place", but as
someone who gets called in to *fix* 5,000 line perl programs with, uhm,
"sporadic" indentation, I really wish this would get done.

No, I'm not volunteering, just griping, and reminding everyone that you don't
always *get* to write the code right the first time, because it may not be
your code.

I just have to share this example:

if ($a{'b'} eq "c") {
   $a{'d'} =~ s/\s+/\|/g; }

Note the careful alignment of braces.

-s
-- 
Copyright 2000, All rights reserved.  Peter Seebach / seebs@plethora.net
C/Unix wizard, Pro-commerce radical, Spam fighter.  Boycott Spamazon!
Consulting & Computers: http://www.plethora.net/


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

Date: 21 Aug 2000 07:11:55 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Replace array element
Message-Id: <8nqh7b$lu3$1@orpheus.gellyfish.com>

On Sat, 19 Aug 2000 15:36:56 -0700 Larry Rosler wrote:
> In article <8nmijn$8ji$1@nnrp1.deja.com>, marxjkj123@my-deja.com says...
>> Hello all.  I need an item within a string to be replaced.
> 
> Why does your Subject refer to an 'array element'?  Perl strings aren't 
> arrays.
>  
>> Here is the situation.
>> 
>> $Line = "e:\dir1\environment\EJB\";
> 
> Others have pointed out the syntax errors in that statement, but haven't 
> bothered to let you in on the Big Secret.  Forward slashes work just 
> fine, and are far easier to manage. 
> 

That does all rather depend on the context of course - the OP doesnt show
whatever it is that he intends to do with that string and whilst it is true
that forward slashes will work with Perl functions that take filenames
it might be that the string is going to be passed to something that might
not be so sensible (The DOS command interpreter for instance).

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Mon, 21 Aug 2000 04:35:10 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Serial port ???
Message-Id: <slrn8q1cbs.9ae.efflandt@efflandt.xnet.com>

On Sun, 20 Aug 2000 22:58:57 +0200, Denis Bucher <dbucher@horus.ch> wrote:
>
>Hello !
>
>How to read the serial port under Windows f.e. COM1 ???

Win32::SerialPort module

Or that has been ported to Unix (Linux) as Device::SerialPort

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Mon, 21 Aug 2000 09:37:39 GMT
From: "John P. Linderman" <jpl@research.att.com>
Subject: Re: Sorting is very slow
Message-Id: <39A0F863.71A12362@research.att.com>

Abigail wrote:

> John P. Linderman (jpl@research.att.com) wrote on MMDXLVI September
> MCMXCIII in <URL:news:39A029D0.93E86D41@research.att.com>:
>
> \\ Peter McIlroy has written a particularly nice mergesort
> \\ implementation.  It takes advantage of pre-existing order
> \\ in the input, so it looks essentially order N on sorted,
> \\ reversed, or organpipe data, but it expends very few
> \\ extra comparisons detecting it, so it remains solidly
> \\ order NlogN on random input.  I rewrote most of
> \\ his implementation for Perl, but I'm too much of a
> \\ newbie to allocate those extra N pointers.  If any guru
> \\ would like to lend a hand, I'll be happy to share the
> \\ source, and we can see how it compares with the
> \\ current qsort-based implementation.
>
> Unfortunally, since Perl is much slower than C, even an O (N log N)
> sorting method in Perl is unlikely to beat qsort in C, even if that
> goes quadratic. By the time the N log N beats the N^2, you enter the
> area where you start swapping, which then becomes the dominant factor.
> And by the time the swapping time gets dominated by the N log N, you
> run out of memory anyway.... ;-)
>
> Now, a merge- (or heap- (!)) sort for perl (as opposed to Perl) would
> be cool. But I doubt it would ever go in.

Sorry, I meant perl, not Perl.  I'm not comfortable enough with
perlguts to allocate and deallocate the extra pointers.  Short of
that, I think it's close to being drop-in-able.

Heap sort isn't likely to win over merge sort for two reasons.
As elements sift down the (logN depth) heap, there are 2
comparisons at each node, one to find the lesser subnode,
the other to compare it with the sift-down element.
That results in roughly twice as many comparisons
as merge-sort.   Furthermore, the typical heap layout
is a bit of a cache-buster.  As you sift down the heap,
you're all over memory.  Merge sort and qsort are much
kinder to caches.

If you don't do something to stop me, I'll mail you the
merge-based sort for perl.  Maybe it will never go in,
but it ABSOLUTELY won't go in if it's never tried.

John P. Linderman  jpl@research.att.com



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

Date: Mon, 21 Aug 2000 09:00:23 +0200
From: Roman Stawski <roman.stawski@fr.adp.com>
Subject: Re: system() and error handling
Message-Id: <39A0D387.44EC375D@fr.adp.com>

nobull@mail.com wrote:
> 
> Roman Stawski <roman.stawski@fr.adp.com> writes:
> 
> > Unfortunately, for me -1 is a real exit status for a 3rd party
> > program.
> 
> You you maybe, but not for Unix-like OS.  Unix exit stati are in the
> range 0..255.
> 
> What OS are you using?
> 

I've reproduced the problem on Windows (Perl 5.5 and 5.6) and 
Solaris (Perl 5.5).

The OS doesn't _apparently_ mind a -ve exit status when running the 
program from the command-line. There just seems to be a mix up when
running it from a Perl script using the system() function.

-- 
Roman Stawski - ADPgsi


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

Date: Mon, 21 Aug 2000 02:34:06 -0700
From: David <NIXSPAMdrh@engineer.com>
Subject: Thank you!!  (rookie question)
Message-Id: <djt1qsop8v27embfo6irccc6hvm0sr6vs9@4ax.com>

Thank you very much for your replies to my question.  As I work in the world of proprietary
intellectual ideas and safeguarded process, it is stunning and refreshing to watch the support and
exchange of ideas that take place in the open source community.  I look forward to being able to
contribute as well.

As for the solutions posted here, it will take me a few days to implement them, but I will certainly
post the results.

Thanks again,

David Huska


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

Date: Mon, 21 Aug 2000 04:54:29 GMT
From: fvw+usenet@var.cx (fvw)
Subject: Re: Wildcards in DOS 'dir' command
Message-Id: <966833971IOZ.fvw@var.cx>

<39a09fe8@news.victoria.tc.ca> (yf110@vtn1.victoria.tc.ca):
>jblatz2@my-deja.com wrote:
>: I'm using ActivePerl on a Windows NT 4.0 platform.  I'm trying to use
>: the 'dir' command with the '*' wildcard and it won't work.  I'm trying
>: something like:
>
>: @dirlist=`dir /b ..\*.log`;
>
>
>In addition to other points someone else made, I wonder if `dir` can run
>at all.
>
>
>It's possible you need `cmd /c dir`.

Under unix backticks and system() runs the string with /bin/sh, so I'd
assume cmd would be run under nt...

-- 

                        Frank v Waveren
                        fvw@var.cx
                        ICQ# 10074100


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4077
**************************************


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