[11664] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5264 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 31 00:04:14 1999

Date: Tue, 30 Mar 99 21:00:21 -0800
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, 30 Mar 1999     Volume: 8 Number: 5264

Today's topics:
    Re: "Taint-free" relative paths (Andrew M. Langmead)
        ANNOUNCE: boston.pm technical meeting april 5, 7pm <uri@home.sysarch.com>
        ARRGG...Control-C in DOS? <horizon@internetexpress.com.au>
    Re: Blank browser window <rick.delaney@home.com>
    Re: changing to numeric month (Abigail)
    Re: changing to numeric month (Larry Rosler)
    Re: Comment controls <jdf@pobox.com>
    Re: foreach loop works, for loop not (David Efflandt)
    Re: HELP: Overwriting data within a file <rick.delaney@home.com>
    Re: HELP: Overwriting data within a file (Chris Tremblay)
    Re: how to find local system IP address in Perl <Savage.Ron.RS@bhp.com.au>
    Re: How to use set uid in Perl? (David Efflandt)
    Re: including perl scripts in Server Side Includes (SHT (David Efflandt)
        Looking for Top Sites script <sangiro@dropzone.com>
    Re: LWP..to use or not? <jdf@pobox.com>
        More newbe confusion... <rayj00@ameritech.net>
        New Perl Web Site Stats Package for Apache/Win32 (Craig Vitter)
    Re: one liner to remove nth occurrence of a character (Abigail)
        Opening >2Gb files on AIX <rong@prth.tensor.pgs.com>
        Reference to built-in function <thelma@alpha2.csd.uwm.edu>
    Re: Suppressing output from an externally run program.. senthilr@my-dejanews.com
    Re: system ('myproc &'); (Andrew M. Langmead)
    Re: timeout on user input? <rick.delaney@home.com>
    Re: Tk800.013 Won't work on my RH 5.2 system <lusol@Pandora.CC.Lehigh.EDU>
    Re: Tricky regex Problem <Tony.Irvine@env.qld.gov.au>
    Re: Tricky regex Problem <rick.delaney@home.com>
    Re: Win32::Internet FTP question <rick.delaney@home.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 31 Mar 1999 03:56:27 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: "Taint-free" relative paths
Message-Id: <F9FxM4.4x0@world.std.com>

Dale Henderson <dhenders@cpsgroup.com> writes:

>So, is there a safer way to derive the $prefix varialble. If not, is
>there a way to turn of taint checking in this instance only.

Use the methods explained in the perlsec man page to check if the
tainted variable contains what you think it does and extract the
proper untainted data from it.

-- 
Andrew Langmead


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

Date: 30 Mar 1999 23:45:30 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: ANNOUNCE: boston.pm technical meeting april 5, 7pm
Message-Id: <x74sn2w9lh.fsf@home.sysarch.com>


[this is being posted and mailed to boston.pm]

the next technical meeting of boston.pm is on monday april 5, from 7-10 pm.

boston.pm holds a technical meeting on the first monday night of the
month. at these meetings we try to discuss perlish stuff. sometimes we
have a theme, sometimes we have chaos. we always have fun and sometimes
we learn or teach something. we intend to have guest speakers too
(anyone interested?). this is not a replacement but an adjunct for our
monthly social meetings which are always chaotic and fun but rarely
educational.

email me or boston-pm@darkridge.com for directions or more info. i will
be off the net until sunday :-( so emailing the list is probably better.
when i get back i will email directions for those who request it.

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Wed, 31 Mar 1999 13:26:05 +1000
From: Mick <horizon@internetexpress.com.au>
Subject: ARRGG...Control-C in DOS?
Message-Id: <370195CD.BBC85CAD@internetexpress.com.au>

Hi....
Thanks to the previous replies!!
I was testing my previous attempt under DOS, with no success. I tried it
under Linux and it works!
Ok...this code works perfectly under Linux for catching control-c's, why
doesn't it work under DOS?

#!C:\PERL\5.00502\BIN\MSWin32-x86-object\perl

use Config;

    defined $Config{sig_name} || die "No sigs?";

    foreach $name (split(' ', $Config{sig_name})) {

        $signo{$name} = $i;

        $signame[$i] = $name;

        $i++;

   #Print out all sig names for interest sake..

   print "SIG names are $name\n";
    }

   print STDOUT "Please enter text: "; #Thanks Bart!
        $SIG{INT} = \&catch_zap;
        while(<STDIN>){
                print;
        }
        print "Done.\n";
        print "$shucks zaps caught.\n" if $shucks;

        sub catch_zap {
                my $signame = shift;
                $shucks++;
                warn "Somebody sent me a SIG$signame";
                # not "die"!
        }

This code refuses to catch a control-c in a DOS window - Why?????

Thanks again for all the previous replies!
Mick

--




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

Date: Wed, 31 Mar 1999 03:24:09 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Blank browser window
Message-Id: <37019757.AACC55BE@home.com>

Rob Annandale wrote:
> 
> Hello people,
> 
> I am experiencing a problem with the PERL script below.
> 
> #!/usr/local/bin/perl -w
> $ENV{A_TERM} = 'vt100';
> @args = ("runcbl", "-f", "thankyou.acu");
> print "Content-type: text/html\n\n";
> system(@args);
> 
> I receive a blank screen in my IE browser window when
> 'thankyou.acu' is supposed to be executed.

And what happens when you run it from a shell?  If it works there then
your problem is a CGI FAQ, not a Perl problem.  One possible answer is
buffering.  Add $|++ to the top of your program.

If it still doesn't work, then you should be able to figure out why by
testing the success of system.

perldoc -f system

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 31 Mar 1999 03:41:11 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: changing to numeric month
Message-Id: <7ds5gn$9qq$1@client2.news.psi.net>

Larry Rosler (lr@hpl.hp.com) wrote on MMXXXVIII September MCMXCIII in
<URL:news:MPG.116b25487b2ce29897f6@nntp.hpl.hp.com>:
[] 
[] True.  From John Stanley's post on, the answers started to come out 0 to 
[] 11.  To fix my 'index' solution, one simply changes
[] 
[]   $months = 'JanFebMarAprMayJunJulAugSepOctNovDec';
[] 
[] to
[] 
[]   $months = '123JanFebMarAprMayJunJulAugSepOctNovDec';

The drawback of the 'index' solution is that it only works because all
the abbreviations are 3 characters.

[] + Or:
[] + 
[] + $i = 0;
[] + %months = map {$_ => ++ $i}
[] +           qw /Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
[] + 
[] + print "month number is $months{$gmonth}\n";
[] 
[] Congratulations on the slowest hash initialization yet.  Only about 67 
[] times slower than the hash access itself.


I don't care much about the initialization time. The lookup is fast,
and it works regardless how long the month names are. In fact, it works
for all mappings of strings to their index in a list.

Besides, the main reason for suggesting this was to show that there
are different ways to tackle to problem, not to enter in yet another
Benchmark contest.



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: Tue, 30 Mar 1999 20:26:35 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: changing to numeric month
Message-Id: <MPG.116b43d59ab7a6ae9897f7@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <x7bthawg5f.fsf@home.sysarch.com> on 30 Mar 1999 21:23:56 -
0500, Uri Guttman <uri@home.sysarch.com >says...
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
 ...
>   LR> None of the benchmarks tests for failure.  That was noted in my original 
>   LR> post.
> 
> but you test index and for with foo!

I tested them with 'foo' to show that the failure cases took the 
longest.  The hash cases are all essentially identical time and I didn't 
bother to test.

>   LR> #!/usr/local/bin/perl -w
>   LR> use Benchmark;
> 
>   LR> $months = 'JanFebMarAprMayJunJulAugSepOctNovDec';
>   LR> @months = $months =~ /(...)/g;
> 
> cute!

I thought so too.  :-)
 
>   LR> @months{@months} = 0 .. 11;
> 
> i like $#months (or @months for 1 based) better. it also is correct for
> dynamically created arrays so it is a good idiom to teach. and the hash
> should be named like i did month2num or something like that.

But I wanted to have $months, @months, $months[...], %months, 
@months{...}, and $months{...} all together, side by each.  More fun!

 ...
>   LR> ...  But it's the hash initialization that really kills.
> 
> true. i wonder if there is a way to speed up initializing of hashes? i
> think you can assign to keys %hash and preallocate n buckets. i may look
> into that but i have no time right now. i have to rush out and buy some
> good ol' thick kosher wine for my charoset that i am making for the
> seder tomorrow night in NJ.

Have a happy one!

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com


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

Date: 30 Mar 1999 22:46:13 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Andy Cantrell <cantrela@agcs.com>
Subject: Re: Comment controls
Message-Id: <m3u2v2nwxm.fsf@joshua.panix.com>

Andy Cantrell <cantrela@agcs.com> writes:

> I haven't poured over the camel book looking for this.
> The index has a few things to say about #'s but I guess
> they didn't hit the right note with me and so I turned
> here.  Any feedback?

[jdf@joshua jdf]$ perlindex '# line'
1  0.795 lib/perl5/5.00502/Text/ParseWords.pm
2  0.761 lib/perl5/5.00502/pod/perlsyn.pod
3  0.663 lib/perl5/5.00502/pod/perlfaq6.pod

perlsyn looks like a good bet.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 31 Mar 1999 03:43:41 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: foreach loop works, for loop not
Message-Id: <slrn7g36d2.k8.efflandt@efflandt.xnet.com>

On Tue, 30 Mar 1999 18:08:30 -0500, Bill Mooney <wmooney@voicenet.com> wrote:
>
>
>On 30 Mar 1999, David Efflandt wrote:
>
>> Someone was trying to use a perl script I have to test if a bunch of
>> webservers were online.  The subroutine works.  The part giving trouble 
>> was trying to iterate through a bunch of IP URL's with a 'for' loop.  I
>> haven't figured out why the script hangs after the first iteration.  I
>> even tried a different intermediate variable in case the $i was being
>> affected by its use in string context, but that did not work either.
>> Using a list with a 'foreach' instead works fine.
>>  
>> Following is just a brief example.
>> 
>> Anyone know why this hangs after the first iteration?  Subroutine is being
>> executed once, but then something hangs and the second $url never prints:
>>     
>> for ($i=1; $i<=3; $i++) {
>>     $url = 'http://192.168.1.' . $i;
>>     print "$url\n";
>>     &wwwtest($url);
>> ) 
>
>Could it be that your closing your for loop for a paren instead of a
>bracket?
>
>-Bill

No, just a typo in this msg.  Note that the author that was trying to loop
my script actually used the variable $iterator instead of $i and the
long variable certainly was not used in the subroutine.  I also did not
use $url elsewhere in the script, the sub grabbed it from ($_) = @_ and
used pattern expansion into other variable names from there.  The foreach
loop using a list, used the same variable name and subroutine call, so why
that worked and the 'for' did not is a mystery.

-- 
David Efflandt    efflandt@xnet.com
http://www.xnet.com/~efflandt/


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

Date: Wed, 31 Mar 1999 03:02:04 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: HELP: Overwriting data within a file
Message-Id: <3701922A.F27687A3@home.com>

[posted & mailed]

Mario D'Alessio wrote:
> 
> I'm attempting to write a script which will overwrite
> data within a file. Here's a simplified code example:
> 
>     # Open file for read-write
>     open ( FILEHANDLE, "+< $file" ) or die "cannot open $file";
 
[snip]
 
> I threw in some "tell FILEHANDLE" to watch the current file
> position. It SEEKs correctly to the proper position, but the print
> statement always appends rather then writing at the current file
> position.

Are you sure you opened the file like that and not as "+>>$file"?  What
OS are you on?  Can you create a complete (but small) program that
exhibits this behaviour?  I have used open/seek/print many times and
have never had this problem.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Wed, 31 Mar 1999 03:04:15 GMT
From: anne@storm.ca (Chris Tremblay)
Subject: Re: HELP: Overwriting data within a file
Message-Id: <37019054.212497@news.storm.ca>

Also sent courtesy email

I think (I may be wrong) in the following line:
open ( FILEHANDLE, "+< $file" ) or die "cannot open $file";

it should be:
open ( FILEHANDLE, "< $file" ) or die "cannot open $file";



On 31 Mar 99 00:08:38 GMT, dalessio@manatee.cig.mot.com (Mario
D'Alessio) wrote:

>
>I'm attempting to write a script which will overwrite
>data within a file. Here's a simplified code example:
>
>    # Open file for read-write
>    open ( FILEHANDLE, "+< $file" ) or die "cannot open $file";
>
>    # Seek to a position within the file
>    seek ( FILEHANDLE, $filesize - $tag_indicator_length - $tag_length, 0 );
>
>    # Overwrite the existing data with new data
>    print FILEHANDLE, $new_data;
>
>    close FILEHANDLE
>
>I threw in some "tell FILEHANDLE" to watch the current file
>position. It SEEKs correctly to the proper position, but the print
>statement always appends rather then writing at the current file
>position.
>
>The Programming Perl book states "Note that the opposite of read
>is simply a print...", so I assumed that if I can read from the
>newly SEEKed position, I can write there.  If I remember correctly,
>the op system keeps a separate read file pointer and a write file
>pointer, right? So, how do I get Perl to move the write file pointer?
>
>Any help appreciated. Thanks.
>
>Mario
>
>
>PS: You'll notice that I use the file size in my "seek" call above,
>    instead of doing something like this:
>
>       seek( FILEHANDLE, $tag_indicator_length + $tag_length, 2 );
>
>    Seeking to the WHENCE of 2 doesn't work for me. Any ideas?
>
>
>**********************************************************
>*                                 ____    ____    ___    *
>*  __/\__  Mario D'Alessio       ((oo))  //oo\\  /o o\   *
>*  \RUSH/  dalessio@cig.mot.com   \__/    \__/   \_O_/   *
>*   |/\|   Work: (847) 632-2323    Moe   Larry   Curly   *
>*          9am to 6pm Central Time                       *
>*                                                        *
>**********************************************************



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

Date: Wed, 31 Mar 1999 14:05:42 +1000
From: "Ron Savage" <Savage.Ron.RS@bhp.com.au>
Subject: Re: how to find local system IP address in Perl
Message-Id: <7ds6u8$16v2@atbhp.corpmel.bhp.com.au>

This 2 liner works under Windows95 and Unix (IRIX).
use Sys::Hostname;
print join '.', unpack 'C4', gethostbyname hostname;


--
Ron Savage
Office (preferred): Savage.Ron.RS@bhp.com.au
Home: rpsavage@ozemail.com.au
http://www.ozemail.com.au/~rpsavage
Ken Bauman wrote in message <922825471.502.45@news.remarQ.com>...
>This is probably only marginally a Perl question.  How can you find your
own
>machine's IP address in a Perl script?
>
>The closest things I have found are hostname() from Sys:Hostname and
>gethostby*() from Socket,  But I think these assume some kind of server
>(host) is running on the system.
>
>Thanks,
>Ken Bauman
>
>




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

Date: 31 Mar 1999 03:59:16 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: How to use set uid in Perl?
Message-Id: <slrn7g37a9.k8.efflandt@efflandt.xnet.com>

On Tue, 30 Mar 1999 18:38:49 -0500, Fu Chin Liu
<fuchin@mail.nwos.lucent.com> wrote:
>Does anyone know how to set uid in Perl?
>e.g. How can I set the user id to root while the perl process is ran by
>other uid and get the permission to change the permission of the files
>which are owned by root.
>Then uid can be changed back to continue running the rest of the script?
>
>Thanks

You probably need a C wrapper since most systems ignore suid on scripts
for security reasons.  It used to be in the old O'Reilly "Learning perl"
(perl4) book, but is not in "Learning Perl" (Perl5).  Maybe it is on CPAN.

Basically what the suidwrap script does is hide the script by putting a
dot in front of the scriptname and writes out a C wrapper with the
original scriptname and permissions (like 4755).  The C wrapper has a hard
full path to the script so it needs to be redone if the script is moved.

-- 
David Efflandt    efflandt@xnet.com
http://www.xnet.com/~efflandt/


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

Date: 31 Mar 1999 04:04:26 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: including perl scripts in Server Side Includes (SHTML)
Message-Id: <slrn7g37ju.k8.efflandt@efflandt.xnet.com>

On 30 Mar 1999 21:50:16 GMT, Lars Plessmann <larsplessmann@gmx.de> wrote:
>How can I include perlscripts with the #include tag to a shtml file?
>That is right, isn't it?
>
>     <!--include file="file.pl"-->
>
>When I include it in windows ist works. But in Linux there happens
>nothing. Even on a webserver in the internet it doesn't work (there even
>is an error message)!
>What have I done wrong?
>Please help me, it's very important!
>Thx,
>
>     Lars

Unless the CGI script is in a ScriptAlias directory (like cgi-bin set up
by your ISP) the scriptname usually needs to end with '.cgi' as in
'file.cgi' whether it is used standalone or as SSI.  Or course there could
be any number of other problems.  Make sure the script runs in the shell
(./file.cgi) without errors before trying it on the web.  You will get
more detailed error messages.

-- 
David Efflandt    efflandt@xnet.com
http://www.xnet.com/~efflandt/


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

Date: Tue, 30 Mar 1999 20:35:56 -0800
From: "sangiro" <sangiro@dropzone.com>
Subject: Looking for Top Sites script
Message-Id: <3701a747$0$209@nntp1.ba.best.com>

Heya all,

I've spent a load of time on the web looking for a real Top Sites script but
to no avail.  Free is best but I'm willing to pay for it - can anybody help?

Here's what I DON'T want:
I don't want a jazzed up top referrer script where the hits on the top sites
list accumulates every time somebody clicks on a graphic/link on your site.

Here's what I DO want:
I'm looking for a script that actually counts the hits a member site
receives WITHOUT someone having to click on a graphic.  This is
traditionally done by adding a link to a graphic on my server on the members
pages and counting the amount of times the specific ID requests the graphic
from my server.

Any help?

Safe swoops
Sangiro

www.dropzone.com





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

Date: 30 Mar 1999 22:48:17 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Mick <horizon@internetexpress.com.au>
Subject: Re: LWP..to use or not?
Message-Id: <m3r9q6nwu6.fsf@joshua.panix.com>

Mick <horizon@internetexpress.com.au> writes:

> @data_files = grep { /\.data$/ } readdir(DIR);

> But how do I go about this with remotely located files?

Check out Net::FTP .

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Tue, 30 Mar 1999 22:41:09 -0800
From: Raymond Jender <rayj00@ameritech.net>
Subject: More newbe confusion...
Message-Id: <3701C385.36690468@ameritech.net>

 ...and I do have Learning Perl and Perl by Example.

What am I missing here? I have a form with a scrolling
menu, a couple of checkboxes and 3 radio buttons.
Either one or the other check box an be selected.
How do I detrmine this in the CGI script?

I can parse the input ok and split the pairs by the
following:

# Resolve and unencode name/value pairs into %in
    foreach (split('&', $in)) {
        s/\+/ /g ;
        ($name, $value)= split('=', $_, 2) ;
        $name=~ s/%(..)/chr(hex($1))/ge ;
        $value=~ s/%(..)/chr(hex($1))/ge ;
        $in{$name}.= "\0" if defined($in{$name}) ;  # concatenate
multiple vars
        $in{$name}.= $value ;
    }
@tmp = %in; # Copy the hash into an array

    return %in ;

After returning from the above, I can look at $tmp[0], $tmp[1], etc.
but $tmp[0] may not always be the same because of the optional
checkboxes.
There are a maximum 4 pairs that could be input and 3 pair minimum.

I am now doing something like:

$micro="n";
$macro="n";
if ($tmp[0] eq "Macronut"){$macro = "y";}
	elsif ($tmp[0] eq "Micronut") {$micro = "y";}
		elsif ($tmp[2] eq "Macronut") {$macro = "y";}
			elsif ($tmp[2] eq "Micronut") {$micro = "y";}

As you can see, if $tmp[0] equals Macronut, I never check for Micronut!
There are more possibilities!! I need to know the values of the above
in order to perform certain calculations.

I hope you can understand the problem. Do I make sense?
My head hurts from banging it!!!


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

Date: Wed, 31 Mar 1999 04:50:57 GMT
From: craig@vitter.com (Craig Vitter)
Subject: New Perl Web Site Stats Package for Apache/Win32
Message-Id: <7ds61o$n7r@dfw-ixnews10.ix.netcom.com>

Hello,

I just completed a Web site stats package for Win32 users running Apache 
1.3.4+. The package consists of four Perl scripts and some html docs. The 
scripts are designed to be run by a scheduling util like AT on NT nightly and 
they generate several pages of stats on visitors, page views, browsers, etc.

I developed these scripts for my own Apache development servers and thought 
that others might like to play with them on theirs. If you are interested you 
can download the package in one small (51K) zip file from my site 
www.vitter.com/logcv.htm.

I plan on adding a lot of new features over the next couple of weeks so any 
feedback on the scripts would be appreciated (and of course you would get 
complete credit for any help).

take care,
Craig


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

Date: 31 Mar 1999 04:00:26 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: one liner to remove nth occurrence of a character
Message-Id: <7ds6kq$a18$1@client2.news.psi.net>

Tad McClellan (tadmc@metronet.com) wrote on MMXXXVII September MCMXCIII
in <URL:news:nmuqd7.9t.ln@magna.metronet.com>:
?? dboude@my-dejanews.com wrote:
?? : Hi all. I need a little help with the appropriate line that will remove the
?? : 3rd occurrence of a double quote from each line of a file. I'm somewhat
?? : familiar with Perl, being more successful at making Franken-scripts from
?? : others input than making my own from scratch. If anyone could help me out
?? : with this, I would appreciate it greatly.
?? 
?? 
??    Please do not post the same question multiple times in
??    different threads.
?? 
?? 
??       s/([^"]*"[^"]*"[^"]*)"/$1/;  # delete the third double quote char


That's a lot of typing if you want to scale that to removing the 30th
double quote char.  It can also be expensive if there isn't a third quote
char; even more expensive if you want to delete the 30th, and there are
29 quote chars. Anchoring the regex makes it fail faster.

         s/^((?:[^"]*"){2}[^"]*)"/$1/;

Alternatively, you could use:

         $i = 0;
         s/"/++ $i == 3 ? '' : '"'/ge;


For both approaches, you probably can construct sentences where they
beat the other.




Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: Wed, 31 Mar 1999 11:19:33 +0800
From: Ron Grunwald <rong@prth.tensor.pgs.com>
Subject: Opening >2Gb files on AIX
Message-Id: <Pine.SOL.3.96.990331105834.3464I-100000@swan>

Hi all,

I've recently come across a problem where my Perl script attempts
to open a file of around 2.2Gb in size. It couldn't do it.
Files below 2Gb in size do open successfully. I've used the open ()
and sysopen () Perl functions for this.

The operating system that the script runs on is AIX 4.2.1, which 
does support file sizes of > 2Gb. The Perl release that I'm using
is 5.004.

My question then is: Does Perl provide a facility whereby files
of size greater than 2Gb can be processed successfully ?


Any help would be greatly appreciated.


Regards, Ron.

--------------------------------------------------------------------------
Ron Grunwald               | Usual E-mail         rong@prth.pgs.com
UNIX Programming Section   | Alternate E-mail     r.grunwald@usa.net 
PGS Tensor Pty. Ltd.       | Work Tel.            011 618 9320 9029
 Petroleum Exploration and | IBM Centre, Perth
   Seismic Processing.     |             Western Australia
--------------------------------------------------------------------------



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

Date: 31 Mar 1999 04:19:03 GMT
From: Thelma Lubkin <thelma@alpha2.csd.uwm.edu>
Subject: Reference to built-in function
Message-Id: <7ds7nn$i0i$1@uwm.edu>

How can I get this to work?  It tells me push is an undefined
subroutine (&main::push), which of course it is--but is there a way
I can tell it I mean perl's push?

                      thanks.  --thelma

#!/usr/bin/perl -w

use strict;

sub newelem;

###I want these to be references to system built in functions
my ($pushref,$shiftref) = (\&push,\&unshift);

my @aray = ( "here", "i", "am");

newelem \@aray,$pushref,"PUSHED";
newelem \@aray,$shiftref,"FIRST";
print "@aray"; print "\n";

sub newelem
{ @aray = @{$_[0]};    
  my $action = $_[1];  ####Reference to a built in function
  my $newmem = $_[2];

  &$action(@aray), $newmem;
}  






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

Date: Wed, 31 Mar 1999 02:46:10 GMT
From: senthilr@my-dejanews.com
Subject: Re: Suppressing output from an externally run program...
Message-Id: <7ds29g$ojp$1@nnrp1.dejanews.com>



> I was wondering if there was a way of making a system call (that is to
> say, run a shell program) in perl and suppressing all output that that
> system call (shell program) produces.

$cmd = "command";

@cmdout = qx[$cmd 2>&1];

Now everything that comes out from the command is in the array
@cmdout. Nothing will appear on the screen.

Hope it helps,
 ..Senthil.



-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 31 Mar 1999 03:52:21 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: system ('myproc &');
Message-Id: <F9FxFA.2F9@world.std.com>

sstarre@my-dejanews.com writes:

>When started from CGI, the browser waits until the background process
>finishes. This is an expected result. Is there a way to run the process
>detached and to not have the parent wait for it to complete?

In another article, you mention reading the sections in the camel book
on exec() system() and fork(). Thats a great start, but unfortunately
you need to be looking is in the CGI process model.

I guess the first thing that I would suggest in caes like this is to
run the script directly, instead using a web browser to tell the web
server to call the script on your behalf. Maybe even run it under the
perl debugger. If you do that, you will probably notice that the
system() function does indeed return very quickly and the first
program can end while the second program still executes.

This means that it perl is fine letting the other program run, it must
be the web server that has a problem with it.

Now from the CGI standard documentation, or your server's
documentation, find out how the server knows that the CGI script is
done. It does so by determining when the child processes standard
output stream is closed. Since the program being called from system()
is inheriting a copy of the parent's filehandles, it is keeping a pipe
to the server open. Since the server doesn't sees the pipe to the CGI
script close, it doesn't think that the CGI script is done.
-- 
Andrew Langmead


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

Date: Wed, 31 Mar 1999 03:27:16 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: timeout on user input?
Message-Id: <37019813.6D856C62@home.com>

[posted & mailed]

Lee Ramirez wrote:
> 
> Is there anyway I can set a timeout on the input?

perldoc perlfaq8

    How do I timeout a slow event? 

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 31 Mar 1999 02:32:50 GMT
From: "Stephen O. Lidie" <lusol@Pandora.CC.Lehigh.EDU>
Subject: Re: Tk800.013 Won't work on my RH 5.2 system
Message-Id: <7ds1gi$1hbk@fidoii.cc.Lehigh.EDU>

John Daschbach <d3h486@wd19518.emsl.pnl.gov> wrote:

> I have been using PerlTk for a few years on older Linux systems, using
> the Tk4 series of PerlTk.  I upgraded to RH 5.2 on one machine and
> grabbed the Tk800.013 tarball.  PerlTk compiled fine, and ran the
> tests (make test) with one exception (I don't have DataDumper
> installed presently).

> But PerlTk does not run.  I consistently get the following error
> message.  This is from running the demos, but the same result obtains
> with my PerlTk scripts that have run for years.

> [d3h486@wd19518 demos]$ perl browse
> Goto undefined subroutine &main::-1 at /usr/lib/perl5/site_perl/Tk/Widget.pm line 324.
> [d3h486@wd19518 demos]$ perl color_editor 
> Assuming 'require Tk::Frame;' at color_editor line 13
> Goto undefined subroutine &main::-1 at /usr/lib/perl5/site_perl/Tk/Widget.pm line 324.
> [d3h486@wd19518 demos]$ perl composite 
> Assuming 'require Tk::Entry;' at /usr/lib/perl5/site_perl/Tk/LabEntry.pm line 23
> Goto undefined subroutine &main::-1 at /usr/lib/perl5/site_perl/Tk/Widget.pm line 324.
>  at /usr/lib/perl5/site_perl/Tk/LabEntry.pm line 23
> [d3h486@wd19518 demos]$ 


> Line 324 is the end of the AUTOLOAD routine.  

> Can someone help with what's going on?  This is the first time I can
> remember installing a Perl package which passed all the tests and had
> it fail.

Answered a million times in comp.lang.perl.tk!

1) Upgrade perl to 5.005_02
2) install Tk800.013

QED


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

Date: Wed, 31 Mar 1999 13:50:15 +1000
From: Tony Irvine <Tony.Irvine@env.qld.gov.au>
Subject: Re: Tricky regex Problem
Message-Id: <37019B77.181E8E4A@env.qld.gov.au>

Rick Delaney wrote:
> > $lhs = '([\w ]{1})' x @order; 
> Why the {1}?

Ahhh.... yes true :-)

 
> You could replace this with
> $rhs = join '.', map { "\${$_}" } @order; 

Fantastic. Thanks, I think I will spend a bit of time aquatinting myself
with map now.


> Or you could leave everything as you have it and just change the
> preceding line to: 
>    s/$lhs/"\"$rhs\""/eeg;

Ok if you have a moment could you tell me why that fixes it?

Anyway thanks for your help it is much appreciated.

Tony
-- 
Tony Irvine
Information Support Officer
Environmental Protection Agency
Tel:(07)3227-7991  Fax:(07)3227-6534
E-Mail: Tony.Irvine@env.qld.gov.au
---------------------------------------------
Visit us online at http://www.env.qld.gov.au
---------------------------------------------


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

Date: Wed, 31 Mar 1999 04:54:16 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Tricky regex Problem
Message-Id: <3701AC75.A9787010@home.com>

[posted & mailed]

Tony Irvine wrote:
> 
> Rick Delaney wrote:

> >    s/$lhs/"\"$rhs\""/eeg;
> 
> Ok if you have a moment could you tell me why that fixes it?

Okay, here goes.

$rhs eq '${$order[0]}${$order[1]}${$order[2]}${$order[3]}' so

    s/$lhs/$rhs/g;

would substitute the pattern in $lhs with the string,
'${$order[0]}${$order[1]}${$order[2]}${$order[3]}'. 

But you want those variables to be interpolated so you try

    s/$lhs/$rhs/eg;

However, since /e causes the replacement part to be treated as an
expression, the normal interpolation is not done.  Instead you get
whatever the expression: 

   $rhs;

returns or

    ${$order[0]}${$order[1]}${$order[2]}${$order[3]}

again.

To get at the values of these variables, you must eval again.  But you
can't just say

    s/$lhs/$rhs/eeg;

because that would try to give you the result of the expression

    ${$order[0]}${$order[1]}${$order[2]}${$order[3]}

and that's not a valid perl expression.  The expression you want is

    "${$order[0]}${$order[1]}${$order[2]}${$order[3]}"

so you try

    s/$lhs/"$rhs"/eeg;

But that won't work either, because the first /e will return the result
of the expression

    "$rhs"

which is

    ${$order[0]}${$order[1]}${$order[2]}${$order[3]}

again which is an invalid expression to give to the second /e.  What you
want is to get the first /e to result in

    "${$order[0]}${$order[1]}${$order[2]}${$order[3]}"

One such expression is

    "\"$rhs\""

so you finally end up with

    s/$lhs/"\"$rhs\""/eeg;

HTH.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Wed, 31 Mar 1999 03:15:23 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Win32::Internet FTP question
Message-Id: <37019548.FA41E348@home.com>

[posted & mailed]

Andy Watts wrote:
> 
> use Win32::Internet();

I don't know anything about this module but I think I see something
wrong.

> 
> $Bytes = 0;
> $File = "c:\\temp\\map.txt";  # Drive path and file on local system
> $Filename = "map.txt";
> $Destination = "v:\\dr\\virtual_html\\incoming";  # Drive path on remote
> system

You shouldn't need to specify your paths like that.

    $File = "c:/temp/map.txt";  

should work fine.

> $DestFile = "$Destination$Filename";

That can't be right.  I think you want

    $DestFile = "$Destination/$Filename";

> $INET = new Win32::Internet();

You should probably check the success of this method and most of the
others you are using.

-- 
Rick Delaney
rick.delaney@home.com


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5264
**************************************

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