[11615] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5216 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 24 13:07:22 1999

Date: Wed, 24 Mar 99 10:01:31 -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           Wed, 24 Mar 1999     Volume: 8 Number: 5216

Today's topics:
    Re: Perl Detecting Browser Version (Abigail)
    Re: Perl not working with PWS (Jonathan Stowe)
    Re: perl version 4 (Bart Lateur)
        print on win32? (GEMINI)
    Re: protecting perl scripts (Tad McClellan)
        randomizing an array order <dwatanab@uci.edu>
        RegExp problem, can't see wood for trees (I.J. Garlick)
    Re: RegExp problem, can't see wood for trees <jglascoe@giss.nasa.gov>
    Re: RegExp problem, can't see wood for trees <jdf@pobox.com>
    Re: return codes in Win32 Perl <dennis.kowalsk@daytonoh.ncr.com>
    Re: Sendmail return address help (Jonathan Stowe)
    Re: Shipping Cost Script (Mark P.)
    Re: Simple Program <ruedas@geophysik.uni-frankfurt.de>
        Why does Mail::Mailer do this?! <choganNOSPAM@NOSPAMprimenet.com>
    Re: Why don't wildcards expand on cmd line- win32 v5.00 <mpmcgill@bellatlantic.net>
    Re: why my sub returns nothing? <aqumsieh@matrox.com>
    Re: Win32 file size limitations? <cassell@mail.cor.epa.gov>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 24 Mar 1999 16:17:28 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl Detecting Browser Version
Message-Id: <7db36o$7b5$2@client2.news.psi.net>

David Walford (davewal@corp.sgi.com) wrote on MMXXXI September MCMXCIII
in <URL:news:36F830F9.84143BFA@corp.sgi.com>:
"" Is there a way that PERL could detect the version of a users browser in
"" a cgi script?

No.

Browsers *may* send a string indicating what brand and version they are,
but it's well known that many browsers are lying because of boneheadness
of document authors. (There are more than 2 browsers...)

"" If so, how?

How isn't Perl specific. Read the manual of your server whether it passes
this information on to programs it calls. If you're lucky, it uses a well
known protocol. Either ask your question in a group related to such a 
protocol, or in a group appropriate for your server.

"" Or is this only capable with javascript?

What if the browser doesn't run javascript?



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


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

Date: Wed, 24 Mar 1999 17:03:32 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: Perl not working with PWS
Message-Id: <36f91aae.29480658@news.dircon.co.uk>

On Wed, 24 Mar 1999 21:37:31 +0800, Simon Ng <simon_ng@pacific.net.sg>
wrote:

>Hi , can anybody out there help me. I can't seem to get my perl to work
>on PWS 4.0. I've already tried inserting the Script Map in the registry
>".pl => c:\perl\bin\perl.exe %s %s" but still cannot work.
>

Almost certainly this is a sxerver configuration problem but as you
have not described the symptons I dont think anyone is going to be
able to help you ...

/J\


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

Date: Wed, 24 Mar 1999 16:07:57 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: perl version 4
Message-Id: <36f90d0f.476529@news.skynet.be>

Samson Chiao wrote:

>Does anyone know the syntax for the PUSH operation on an Associative
>Array in Perl version 4?

Same as for Perl5.

> I'm having problems with the version 5 syntax:
>"push @{$monster{$patch_num}}, "$target";"

It's not the push, it's the  @{...} construct that is new in Perl5. This
uses an array reference/anonymous array.

Best you can do is upgrade, but in on Perl4, you might get something to
work using:

	$monster{$path_num} .= "$target\000";

and retrieve the array as

	split /\000/,$monster{$path_num};

   HTH,
   Bart.


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

Date: 24 Mar 1999 16:26:06 GMT
From: dennis@info4.csie.nctu.edu.tw (GEMINI)
Subject: print on win32?
Message-Id: <7db3mu$9ve$1@netnews.csie.NCTU.edu.tw>

is there any module that can provide
print function on win32?
my perl program will generate a GIF
image and I'd like to print it from
printer directly by program. Maybe I can
launch an application to load the image
and print it, but the user has to close the application.
Is there any other solution?


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

Date: Wed, 24 Mar 1999 06:18:46 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: protecting perl scripts
Message-Id: <mmhad7.1v2.ln@magna.metronet.com>

Mr.unix (Mr.unix@mail.excite.com) wrote:
: Is there anyway to protect my scripts from being copied, such as compiling
: to an executable form for distribution?

: I have worked hard on a socket program here at work that will allow real
                                         ^^^^^^^^^^^^

   That sounds like a "work for hire". If so, then the code belongs
   to your employer.

   I would not allow the source for code that I owned to be made
   inaccessible...


: time information to be passed from our mainframe to a Unix or wintel system.
: Now that some have caught wind of its future potential, they want to use it,
: forgetting about who made it all possible in the first place. They want to
: take credit for the entire endeavor, not just the glossy candy coat they may
: have applied to the surface.


   Office politics are off-topic for the Perl newsgroup.


: I guess this is my "Welcome to the Business World".


   Well, here is a "Welcome to the Usenet World" then:


   You are expected to check for your question in the list of
   Frequently Asked Questions (FAQ) for a newsgroup *before*
   posting to that newsgroup.

   I guess you missed this one from the Perl FAQ, part 3:

      "How can I hide the source for my Perl program?"


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 24 Mar 1999 09:47:15 -0800
From: =?iso-8859-1?Q?d=E1na?= watanabe <dwatanab@uci.edu>
Subject: randomizing an array order
Message-Id: <36F92469.86D974E2@uci.edu>

A simple task and i have a relatively simple solution but wonder
if there are any simpler ones

the task is basically to deal a shuffled deck of cards

(i'm actually dealing a random card in the deck from an unshuffled deck
of cards, 
if i could shuffle the deck, i could just pop the cards, which would be preferred)

my solution:

foreach $suit (qw(H S D C)) {
        for ('A',2..10,'J','Q','K') {
                push(@cards,"$suit$_");
        }
}

while (@cards) {
        for (qw (player1 player2 player3 player4)) {
                my $card;
                ($card,@cards)=deal_card(@cards) if @cards;
                push (@{$hands{$_}},$card);
        }
}

sub deal_card {
        my (@cards) = @_;

        $card_no=int(rand $#cards+1);
        $card=$cards[$card_no];
        $card[$card_no]=$card[0];
        shift(@cards);

        return ($card,@cards);
}


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

Date: Wed, 24 Mar 1999 16:44:50 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: RegExp problem, can't see wood for trees
Message-Id: <F93yIq.45u@csc.liv.ac.uk>

Hi Perl Gurus

I am bashing my head against a brick wall, this reg exp should be easy but
can't for the life of me get it right.

Any way here goes, have tried the following

	$name =~ /name="?([^"]+)/i;
	$fn   = $1;

and

	($fn = $name) =~ /^.*name="?(.+)"?.*$/$1/i;

with the first I get a " on the end of $1 sometimes, but not others.
The second one works sometimes as well if I put a ? mark after the + but
otherwise just gives a single character (yes I can see why, but I was
getting desperate)


What I am after is the file name between the optional double quotes. What
makes it difficult is that it can be at the end of a line (with or without
a \n) and could have a ; after the second double quote. It could also be
in the middle of a line, in which case the ; would no longer be optional.

Probably some examples would help

any old stuff; name="file.doc"
any old stuff; name=file.xls
any old stuff; name="file.exe";
any old stuff; name=file;

The last 2 may also be followed by more unwanted characters as well.

Any help would be greatly appreciated, and please don't tell me I missed
it in perlfaq6 or I'll cwt nad cwy.

PS if you want to send an email as well as posting an answer feel free to.
(shows how desperate I am I suppose)

Thanks in advance.

-- 
Ian J. Garlick
ijg@csc.liv.ac.uk

Truly great madness can not be achieved without significant
intelligence.
                -- Henrik Tikkanen



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

Date: Wed, 24 Mar 1999 12:16:14 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: "I.J. Garlick" <ijg@csc.liv.ac.uk>
Subject: Re: RegExp problem, can't see wood for trees
Message-Id: <36F91DDE.926BC6EA@giss.nasa.gov>

[courtesy copy of post sent to cited author]

"I.J. Garlick" wrote:
> 
> Probably some examples would help
> 
> any old stuff; name="file.doc"
> any old stuff; name=file.xls
> any old stuff; name="file.exe";
> any old stuff; name=file;

how about:

my ($name) = ($line =~ /name=[^\w.]*([\w.]+)/i);

	Jay Glascoe
-- 
> Truly great madness can not be achieved without significant
> intelligence.
>                 -- Henrik Tikkanen


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

Date: 24 Mar 1999 12:52:25 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: RegExp problem, can't see wood for trees
Message-Id: <m3oglird0m.fsf@joshua.panix.com>

ijg@csc.liv.ac.uk (I.J. Garlick) writes:

> 	$name =~ /name="?([^"]+)/i;

> with the first I get a " on the end of $1 sometimes

If you can provide a brief sample script, with data, which exhibits
this behavior, I'll eat my bitbucket.

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


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

Date: Wed, 24 Mar 1999 11:32:52 -0500
From: "Dennis Kowalski" <dennis.kowalsk@daytonoh.ncr.com>
Subject: Re: return codes in Win32 Perl
Message-Id: <#itpKNhd#GA.188@rpc1285.daytonoh.ncr.com>

FYI

I did a test to see what the exit status of del was.
If the delete works it is 0 no matter how many files are deleted.

haakon.alstadheim@sds.no wrote in message ...
>Phil Mak <pmak@iname.com> writes:
>
 My
>guess is you deleted 1 file, so del returned 1.
>
>The other value, 65280, means del returned 256, which if you interpret
>as a signed character is -1, this may be a special code indicating
>error.
>





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

Date: Wed, 24 Mar 1999 17:05:44 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: Sendmail return address help
Message-Id: <36f91b3f.29625664@news.dircon.co.uk>

On Wed, 24 Mar 1999 05:11:51 -0600, David <snuffy@execpc.com> wrote:

>I want the return address in my massmailer to 
>be my own rather than that of the host.
>
>The line that opens up my mailer is:
>$mailprog = "/usr/sbin/sendmail:;    (perl)
>

sendmail manpage ...

/J\


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

Date: Wed, 24 Mar 1999 17:47:35 GMT
From: mag@imchat.com (Mark P.)
Subject: Re: Shipping Cost Script
Message-Id: <36f924e0.21783402@news.ionet.net>

	UPS has a script you can use that does this already. Its
posted on their site and its in word format, but its there. Its kinda
hard to find also.

On Tue, 23 Mar 1999 17:23:43 -0800, Erik Boles
<erik@rockymountainwebtech.com> wrote:

>Sorry if this is off topic for this NG but could not find any more
>appropriate.
>
>I am looking for a script to run in a CGI environment that will take
>information from a shopping cart program, and, based on on product
>weight and the destination zip code, will formulate UPS ground shipping
>costs.  Can anyone point me in the right direction if there is even such
>a thing?
>
>Any help is greatly appreciated.
>
>erik
>
>



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

Date: Wed, 24 Mar 1999 16:47:19 +0100
From: Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de>
To: Ophir Marko <ophir@saifun.com>
Subject: Re: Simple Program
Message-Id: <36F90907.3F54@geophysik.uni-frankfurt.de>

>What's wrong?
Additionally to the mistakes mentioned by others:
 i++;
should be
 ++$i;

$index=$index+$#_+1;
the $#_+1 also looks strange to me.
-- 
--------------------------------------------
Thomas Ruedas
Institute of Meteorology and Geophysics, 
J.W. Goethe University Frankfurt/Main
Feldbergstrasse 47			D-60323 Frankfurt/Main, Germany
Phone:+49-(0)69-798-24949		Fax:+49-(0)69-798-23280
e-mail: ruedas@geophysik.uni-frankfurt.de
http://www.geophysik.uni-frankfurt.de/~ruedas/
--------------------------------------------


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

Date: 24 Mar 1999 16:51:23 GMT
From: Craig Hogan <choganNOSPAM@NOSPAMprimenet.com>
Subject: Why does Mail::Mailer do this?!
Message-Id: <7db56b$5co$1@nnrp03.primenet.com>

Hey,

After getting The Perl Cookbook, I was interested in using the
Mail::Mailer module as they descibe.  But it does something strange to
my CGI script.  Was this module not made for CGI?

Every time I send something with the module, it reloads my script
(generating my "Mail Sent" page twice).  I have tried all manner of
kludges to not get it to load twice but I am unable to do so since any
flags I create don't have persistence.  So rather than write a flag
out to a file (yuck!), I threw my hands up and thought I'd ask for some
help here.  Anybody had a similar experience?

thanks,

Craig

-- 
 .....................................................................
[ Craig Hogan          !   Cure TAB archive, live Cure recordings:    ]
[ chogan@primenet.com  !  http://www.primenet.com/~chogan/index.html  ]
[ Software Engineer    !       "Smear this man across the wall"       ]
 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::



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

Date: Wed, 24 Mar 1999 11:42:01 -0500
From: Michael P McGill <mpmcgill@bellatlantic.net>
Subject: Re: Why don't wildcards expand on cmd line- win32 v5.005_02
Message-Id: <36F915D9.F53F717A@bellatlantic.net>

I finally found the solution myself-- it was at a CPAN site:
Apparently they intentionally left out wildcard expansion as a potential
incompatibility!
The solution for this is found at the following link
ftp://csociety-ftp.ecn.purdue.edu/pub/CPAN//ports/win32/Standard/x86/perl5.005_02.patch.gz
Under the heading:
! =item Command-line Wildcard Expansion

I have tried their solution and it works well.

Michael P McGill wrote:
> 
> Why do I get the message:
> "Can't open *.log: No such file or directory"
> 
> from the following command line:
> "C:\Data>perl chk_log.pl *.log"
> 
> When I do the same thing with 5.003_07 on another Windows98 machine with
> an identical configuration
> (as far as the environment goes anyway), it works fine and processes all
> the files with and extension of ".log"
> 
> I have 5.005_02 ActiveState port on a system running Windows98. If I
> specify all the files I want to process on the command line, my program
> works great, but I don't think this is how it is supposed to be.
> 
> Your help is appreciated,
> Michael


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

Date: Wed, 24 Mar 1999 10:14:48 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: why my sub returns nothing?
Message-Id: <x3yg16u7wd4.fsf@tigre.matrox.com>


dizhao@my-dejanews.com writes:

> Look at the code below, in the sub t, I predefined $index, but when returned
> from the foreach loop, it returns nothing(it supposed to return 0). I think
> it has something to do with foreach scenario. Can someone give me a
> explanation? I am using perl5.005_2. Thanks. #!/usr/bin/perl $i = t(0); print
> "i is: $i\n"; $i = t(1); print "i is: $i\n"; sub t {  my ($ii) = @_;  my
> $index = 1;  if ($ii)  {  foreach $index (0..10)  {  return $index;  }	} 
> $index = 2;  return $index; }

Well on my version (5.004_04), the results are:

i is: 2
i is: 0

what exactly are your results?



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

Date: Wed, 24 Mar 1999 09:59:20 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Win32 file size limitations?
Message-Id: <36F927F8.B8DEB798@mail.cor.epa.gov>

Jared Westlund wrote:
> I'm using ActivePerl's Win32 port v.5.005 on an NTsvr machine.  I'm fairly
> new to Perl, and I'm having a problem with file size limitations.
> 
> Here's what I'm doing:
> 
> - a batch file loops through a list of files...
> - for each file, it executes my Perl script with the file parameter from the
> batch and three other filenames.  <file1> <file2> <...>
> - the script reads each line of <file1>, and depending on various criteria,
> it outputs the line to file2,3, or 4.
> - each time the script is run, it opens files 2-4 for appending.
> - however, the script stops writing at about 9.5 gig -- it still continues
> to execute, but it doesn't write to the output files.
> 
> The input files total 60 gigs collectively, and so should the output files
> upon completion.  However, the output never exceeds 9.x gigs.
> 
> Is there a known filesize limitation within Perl for Win32?  Any help would
> be appreciated.

There could be a variety of limits, depending on how your code is constructed.
On the perl-win32-users listserv (through ActiveState in case you're interested)
there was a recent thread about file size limits.  How are you tracking the
ends of your files?  As I understand it, ActivePerl uses a 4-byte unsigned
integer
in some places, and it might be overflowing.  Are you using stat or -s to get
the current size of the file?  Could be a problem there.  Are you using `dir`?
That might work, but it's a kludge.

But you could check out the Win32API module.  In Win32, M$ defines two fields
nFileSizeHigh and nFileSizeLow which together give you the 64-bit file size.
You might consider using Win32API to get the file size and then using
Math::BigInt to store it in a value that won't overflow.  Or someone else
might give you a *really* good idea...

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

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

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