[9926] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3519 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 23 21:01:27 1998

Date: Sun, 23 Aug 98 18:00:17 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 23 Aug 1998     Volume: 8 Number: 3519

Today's topics:
        [Q] getting ?name=value data from a URL through CGI.pm (Scott Cherkofsky)
    Re: [Q] getting ?name=value data from a URL through CGI <jon@jon-hodgson.com>
    Re: [Q] getting ?name=value data from a URL through CGI <dan@fearsome.net>
        Attention Webmasters!!! <investigators@iglobe.net>
        directory chmod <dan@fearsome.net>
        Help with IRIX 6.5 + perl5.005_02 (w/ GCC 2.8.1) <phil@bts.com>
    Re: Help with pattern matching... <danboo@negia.net>
        Help With Perl CGI Script <rockwood@tconl.com>
    Re: How to clear a filehandle? (Charles DeRykus)
        Needing bmp2gif converter spiegler@cs.uri.edu
    Re: Perl documentation <danboo@negia.net>
    Re: Perl documentation (Abigail)
    Re: Perl documentation (Abigail)
    Re: Perl FAR version 1.1.1 MAKE SURE YOU READ THIS BEFO (Steve Linberg)
    Re: Prime numbers [was Re: here's an implementation of  (Craig Berry)
    Re: Prime numbers [was Re: here's an implementation of  (Craig Berry)
    Re: Prime numbers [was Re: here's an implementation of  (Abigail)
        Simple question for doing a sort on a text file <gavinc@geko.net.au>
    Re: Simple question for doing a sort on a text file (Sam Holden)
    Re: Simple question for doing a sort on a text file (Sam Holden)
    Re: Size of a JPG file <founder@pege.org>
    Re: Size of a JPG file <jbc@west.net>
    Re: Size of a JPG file (Larry Rosler)
    Re: testing Text::GenderFromName <jbc@west.net>
    Re: Turn Perl program into binary <garry@NOSPAM.america.net>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 23 Aug 1998 17:21:57 -0400
From: crusader@bobo.shirenet.com (Scott Cherkofsky)
Subject: [Q] getting ?name=value data from a URL through CGI.pm
Message-Id: <6rq15l$h90@bobo.shirenet.com>


I've been using CGI.PM with great success to grab submitted form data from
an HTML page.  I've recently started trying to get data directly from a
URL in the form:

http://www.somesite.com/somepage.htm?Var1=Val1&Var2=Val2

For some reason, I can't get the name,value pairs to show up in my PERL
script using the same method that works for submitted (POSTed) forms:

use CGI qw(:standard);
$query = new CGI (\*STDIN);

$vName1 = $query->param('Var1');
$vName2 = $query->param('Var2');

I'm thinking this isn't working becuase no form is actually being POSTed.
IF that's the case, is there any way to get access to these variables?

Thanks for the help.

Scott
-- 
____________________________________________________________________________
  Scott   |   scottc1033 aol com  | Need Interenet access in Virginia?
Cherkofsky|crusader shirenet com  |  Try Shirenet <mailto:info@shirenet.com>
'Crusader'|HomePage:    http://www.shirenet.com/~crusader/html/Home.html


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

Date: 23 Aug 1998 21:59:45 GMT
From: "Jon C. Hodgson" <jon@jon-hodgson.com>
Subject: Re: [Q] getting ?name=value data from a URL through CGI.pm
Message-Id: <35E090D8.F47@jon-hodgson.com>

Just change 'POST' to 'GET'

- Jon


Scott Cherkofsky wrote:
> 
> I've been using CGI.PM with great success to grab submitted form data from
> an HTML page.  I've recently started trying to get data directly from a
> URL in the form:



> 
> http://www.somesite.com/somepage.htm?Var1=Val1&Var2=Val2
> 
> For some reason, I can't get the name,value pairs to show up in my PERL
> script using the same method that works for submitted (POSTed) forms:
> 
> use CGI qw(:standard);
> $query = new CGI (\*STDIN);
> 
> $vName1 = $query->param('Var1');
> $vName2 = $query->param('Var2');
> 
> I'm thinking this isn't working becuase no form is actually being POSTed.
> IF that's the case, is there any way to get access to these variables?
> 
> Thanks for the help.
> 
> Scott
> --
> ____________________________________________________________________________
>   Scott   |   scottc1033 aol com  | Need Interenet access in Virginia?
> Cherkofsky|crusader shirenet com  |  Try Shirenet <mailto:info@shirenet.com>
> 'Crusader'|HomePage:    http://www.shirenet.com/~crusader/html/Home.html


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

Date: Sun, 23 Aug 1998 23:43:46 +0100
From: "Daniel Adams" <dan@fearsome.net>
Subject: Re: [Q] getting ?name=value data from a URL through CGI.pm
Message-Id: <903912405.24069.0.nnrp-02.c2deb1c5@news.demon.co.uk>

I think maybe you might want to take a look at your sig. file - just a
friendly pubic service announcement

If you're going to advertise internet services, you should at least try
spelling it correctly. ;-) I, on the other hand, having no such commercial
interests in this ng, am free to make glaring spelling mistakes as above
with remarkably little consequence. It should be 'internet' and 'public'
respectively, in case anyone was wondering.

>Scott Cherkofsky wrote:

>   Scott   |   scottc1033 aol com  | Need Interenet access in Virginia?
> Cherkofsky|crusader shirenet com  |  Try Shirenet
<mailto:info@shirenet.com>
> 'Crusader'|HomePage:    http://www.shirenet.com/~crusader/html/Home.html




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

Date: Sun, 23 Aug 1998 22:00:31 +0100
From: "Host Investigator" <investigators@iglobe.net>
Subject: Attention Webmasters!!!
Message-Id: <35e0823e.0@news2.mcmail.com>






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

Date: Sun, 23 Aug 1998 23:16:09 +0100
From: "Daniel Adams" <dan@fearsome.net>
Subject: directory chmod
Message-Id: <903910620.15490.0.nnrp-06.c2deb1c5@news.demon.co.uk>

Hi,

I seem to be having little success writing directory permissions using
chmod, and was wondering if someone would be so kind as to take 5 seconds to
tell me which of the below is the correct syntax and why, puzzlingly, _none_
of the below seem to work: Surely I got lucky on at least one! I tried
checking various FAQs including the one at www.perl.com, but it didn't seem
to contain any info pertaining specifically to directory chmoding - I know
it must be almost identical to file permission chmoding, but it doens't seem
to be working for me. Is there something I'm forgetting??

chmod(0777, /foo/directory);
chmod 0777, '/foo/directory';
chmod(0777, /foo/directory/);
chmod 0777, '/foo/directory/';

--

Dan Adams
dan@fearsome.net

Psst: 0777 is just for the sake of amusement.




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

Date: 23 Aug 1998 19:11:36 -0400
From: Phil Eschallier <phil@bts.com>
Subject: Help with IRIX 6.5 + perl5.005_02 (w/ GCC 2.8.1)
Message-Id: <x6iujj47kn.fsf@bts.com>

Help;

I'm trying to compile that latest stable perl5 under IRIX.  The
environment is:

 - IRIX 6.5
 - GCC 2.8.1
 - PERL5.005_02

I'm reasonably sure that the GCC installation is Ok.  I've used GCC to 
reinstall itself (binary compary successful) and also GCC has been
used to install a number of other packages include TCL/TK, bison,
flex, pine, xemacs, ...

And I can successfully compile and install perl5.004_04 with this GCC
deployment.

Compiling perl5, the make process gets to the creation of 'miniperl'
 ... which is created ... the make performs:

 ./miniperl -w -Ilib -MExporter -e 0 || gmake minitest
 ./miniperl configpm tmp

the first line appears to complete successfully, but the second line
fails with:

Use of uninitialized value at configpm line 339, <GLOS> chunk 2.
Use of uninitialized value at configpm line 339, <GLOS> chunk 3.
Use of uninitialized value at configpm line 339, <GLOS> chunk 4.
Use of uninitialized value at configpm line 339, <GLOS> chunk 5.
Use of uninitialized value at configpm line 339, <GLOS> chunk 6.
Use of uninitialized value at configpm line 339, <GLOS> chunk 7.
Use of uninitialized value at configpm line 339, <GLOS> chunk 8.
Use of uninitialized value at configpm line 339, <GLOS> chunk 9.

thru the rest of the configpm file ... make then dies.

I've played a bit with the miniperl binary and have discovered that it
is having a problems with regular expressions.  This test program
(derived from what miniperl is doing at this stage of the product's
compilation):

#!./miniperl -w
 
$_ = "d_msgget (d_msgget.U):
        This variable conditionally defines the HAS_MSGGET symbol, which
        indicates to the C program that the msgget() routine is available.";
 
print "0 - $_\n";
s/\A(\w+)\s+\((\w+)\)//m || die "failed\n";
 
print "1 = $1\n";
print "2 = $2\n";
print "5 - $_\n";

Yields >> failed

But removing the second (\w+) in the pattern allows the program to
run.

This program will run as expected (setting $1 and $2) on Solaris 2.x
and Digital UNIX 4.x deployments of perl5.00502.

This problem also exists with perl5.005_51.

HELP!

-- 
Phil Eschallier    | Bux Technical Services | Systems, software, security
 inet phil@bts.com | 131 Wells Road         | and Inter-networking for
  tel 215 348 9721 | Doylestown, PA  18901  | your business!
  fax 215 348 2567 | http://www.bts.com     |


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

Date: Sun, 23 Aug 1998 18:26:48 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Help with pattern matching...
Message-Id: <35E09728.7500B348@negia.net>

kevin@zippy.tnet.com wrote:
> 
> Looking for a bit of help...
> 
> I've got strings coming at me like:
> 
> /usr/archives/muttusr/1998-08/000024: @436{54} changing...
> xxxxxxxxxxxxxx^^^^^^^x^^^^^^^x^^^^^^xxx^^^x^^xxx...
> 
> The above ^^^ areas are significant to me.  However the beginning of
> the line could change where it might look like:
> 
> /archives/fruits/red/apples/muttusr/1998-08/000024: @436{54} changing...
> 
> Where the path is longer but the significant parts are still there.  The
> following format for the significant stuff will always be there:
> 
>         list/archive/article: @position{length}
> 
> Just the beginning path may increase or decrease depending on where it
> is placed.
> 
[snip]
>
> I'm sure that this could all be done with one pattern match where the
> results would end up in $1 $2 $3 $4 but I'm not up to that point yet...

in fact it can be done with one pattern, and without using $1 et cetera
directly.

($list, $archive, $article, $position, $length) =
    $string =~ m|/([^/]+)/(\d{4}-\d{2})/(\d{6}): @(\d+){(\d+)}|;

print "($list, $archive, $article, $position, $length)";

i've made some assumptions about the character classes that might be
found in your data, but modifications to suit your actual needs
shouldn't be a big deal. specifically, i used '\d' (digit class) and
'[^/]+' (a string of non '/' characters) where you used '.' (any
character but "\n") to ward off false positives and enhance speed.

see the 'perlre' documentation for further explanation.

cheers,

-- 
Dan Boorstein   home: danboo@negia.net  work: danboo@y-dna.com

 "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
                         - Cosmic AC


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

Date: Sun, 23 Aug 1998 15:56:23 -0500
From: Bryan Rockwood <rockwood@tconl.com>
Subject: Help With Perl CGI Script
Message-Id: <35E081F6.DBBB0A54@tconl.com>

Hello all,

A two day old newbie here writing my first perl CGI script.  The script
is running on a Linux box and is on Apache 1.3.1 with PHP compiled in.
It goes out and pulls down a model forecast and translates it into a
view able forecast.  The address is at
http://tconl8038.tconl.com/cgi-bin/extended.cgi if you would like to see
what it does.  The way I get the data is to use LWP to pull it down into
a scalar, put that into a text file, and then put that text file into an
array so I can split it out into usable chunks.  The reason for the text
file is that I plan to have a caching feature in the near future to
speed up processing, since the file I get off of the gopher is updated
once a day.  My problem is this:  when the gopher file changes, and I go
with my web browser to update the page, the forecast is still from
yesterday.  When I go into the /tmp directory and look at the file, it
doesn't show as being updated from when I did the reload off of my web
browser.  If I put the script through the perl interpreter at the
command line, it updates the file and shows the correct forecast.  Now,
when I go to the web browser and pull up the script, it shows the
correct forecast as well.  I figured I would start in a perl news group
and see if it is something that possibly might be missing in my script
(I can post it, if needed).  If it sounds like something that should be
posted in the *.www.authoring.cgi group, please let me know.  Any input
would be most appreciated.  Thanks.

********************
Bryan Rockwood:  rockwood@tconl.com
System Administrator, Creighton University, Atmospheric Sciences
"I drank what?!" -- Socrates
********************



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

Date: Sun, 23 Aug 1998 23:26:22 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: How to clear a filehandle?
Message-Id: <Ey613y.214@news.boeing.com>

In article <6re5je$dld$1@news2.xs4all.nl>,
Hugo Benne <h.benne@library.uu.nl> wrote:
>
>Can anybody explain how to open a file, make a backup of it and clear the 
>original file before closing it?
>

Perhaps a one liner will suffice:

perl -ni.bak -e '' some_file

 
>From a program, you use special variable $^I. There's an
example of its use in the faqs somewhere.  Or if you're
worried about concurrency, check the docs for 'flock'
too.

HTH,
--
Charles DeRykus


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

Date: Sun, 23 Aug 1998 21:38:59 GMT
From: spiegler@cs.uri.edu
Subject: Needing bmp2gif converter
Message-Id: <6rq25j$pb3$1@nnrp1.dejanews.com>

Hi,

Any idea where I can find a program on the web that converts bmp2gif or
bmp2jpeg on the fly? I want to have a script or program on a web server that
converts incoming bmp images from a DB server to some www-supported graphical
format for display to a browser client.

Someone told me there are shareware apps or scripts out there that will do
this. I haven't found any yet. Can someone give me some direction? It would
be great if you could email me a response.

Thanks, Scott

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Sun, 23 Aug 1998 17:35:01 -0400
From: Dan Boorstein <danboo@negia.net>
Subject: Re: Perl documentation
Message-Id: <35E08B05.E0E023AB@negia.net>

David Hawker wrote:
> 
> I'm glad you're using proper sig markers! It's amazing, the majority of
> people I email don't have them.
> 
> --
> dhawker@bigfoot.com | ICQ 7222349
> http://dhawker.home.ml.org

i thought the .sig marker was "-- ". note the extra space. yours is
only "--".

cheers,

-- 
Dan Boorstein   home: danboo@negia.net  work: danboo@y-dna.com

 "THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
                         - Cosmic AC


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

Date: 23 Aug 1998 23:00:15 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl documentation
Message-Id: <6rq6tv$224$1@client3.news.psi.net>

David Hawker (dhawker@bigfoot.com) wrote on MDCCCXVIII September MCMXCIII
in <URL: news:35e14696.15795918@news.cableol.net>:
++ On 22 Aug 1998 16:46:18 GMT, Tom Christiansen <tchrist@mox.perl.com> felt
++ the need to post:
++ 
++ > [courtesy cc of this posting denied to cited author as a
++ >  penalty for address mutilation]
++ 
++ If I want to mutilate my address to foil spammers, that's what I'll do. A
++ lot of people do it. Surely it's not too much bother to remove the obvious
++ text or to see what went wrong in the undeliverable mail message? A lot
++ less bother than hunting down the documentation that isn't included in the
++ perl manual.


If you're that afraid of spam, don't post to Usenet.

Better weld your mailbox shut too.



Abigail
-- 
Spam bait: dhawker@bigfoot.com


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

Date: 23 Aug 1998 23:02:14 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl documentation
Message-Id: <6rq71m$224$2@client3.news.psi.net>

David Hawker (dhawker@bigfoot.com) wrote on MDCCCXVIII September MCMXCIII
in <URL: news:35e53e7f.14559031@news.cableol.net>:
++ On Sat, 22 Aug 1998 17:51:41 -0700, lr@hpl.hp.com (Larry Rosler) felt the
++ need to post:
++ 
++ >[Posted to comp.lang.perl.misc and copy mailed.]
++ >
++ >In article <6rnmno$8na$2@client3.news.psi.net> on 23 Aug 1998 00:11:36 
++ >GMT, Abigail <abigail@fnx.com> says...
++ >...
++ >> Uhm, what system comes without documentation for its system calls?
++ 
++ The one I'm using: MS-DOS and Windows95.

Then complain to the vendors for shipping a system without documentation.
Would you buy a TV without a manual too, and then complain the TV guide
doesn't have instructions on how to operate your TV?



Abigail
-- 
Spam bait: dhawker@bigfoot.com


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

Date: Sun, 23 Aug 1998 17:05:25 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Perl FAR version 1.1.1 MAKE SURE YOU READ THIS BEFORE POSTING
Message-Id: <linberg-2308981705250001@projdirc.literacy.upenn.edu>

In article <35DFD043.F5DDE52B@dead.end.com>, no.uce@dead.mailbox.com wrote:

> I don't remember having asked anything in my posting, or are you using a third
> person plural "you"?

You mean second person plural, I assume?  There is no third person plural
"you" (in English anyway) that I've ever heard reference to.  Third person
plural is "they."  But I'm sure you know this.

Your critique of people with short fuses is interesting, but sounds rather
short-fused itself.  Maybe we should all just go swimming and relax a bit.
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: 23 Aug 1998 22:22:02 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Prime numbers [was Re: here's an implementation of diff in perl]
Message-Id: <6rq4mb$s5s$1@marina.cinenet.net>

Martin Gregory (mgregory@asc.sps.mot.com) wrote:
: Daniel Grisinger <dgris@rand.dimensional.com> writes:
: > In article <r8zpcyvrju.fsf_-_@asc.sps.mot.com>
: > Martin Gregory <mgregory@asc.sps.mot.com> wrote:
: > >abigail@fnx.com (Abigail) writes:
: > >> -- 
: > >> perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
: > >
: > >Is this some well known trick for detecing prime numbers?
: > 
: > Yup, division, the best known trick for detecting prime
: > numbers.
: 
: Que?
: 
: 1) I don't see any division going on there.

It is; it's division based on whether you can fit N character substrings
of length M into a given string without any characters left over.  The
iteration over potential values of M and N is hidden by the regex
backtracking machinery, which is what makes this such a cool hack, even
through (as you imply below) it's not the most efficient way to find
primes in Perl.

: 2) Division seems to be a poor trick for detecting prime numbers: you
:    have to divide the number in question by evey number less than it.
:    Slow. This code does not do that: it has a one-shot hit to tell you
:    whether the number is prime.

The only way to detect prime-ness is to divide by all potential factors
and get a remainder on each.  The available optimization is to limit the
pool of potential factors; the easiest ones to elimate are:

* Any factor above sqrt(N) (since it must be paired with another factor
  below sqrt(N), which you can detect), and
* Any multiples of factors you've already tried (the Sieve of
  Eratosthenes).

This version does neither, making it a suboptimal prime-finder.  Its
intrinsic coolness more than makes up for this, however. :)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: 23 Aug 1998 22:24:29 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Prime numbers [was Re: here's an implementation of diff in perl]
Message-Id: <6rq4qt$s5s$2@marina.cinenet.net>

Martin Gregory (mgregory@asc.sps.mot.com) wrote:
: hex@voicenet.com (Matt Knecht) writes:
: > OUTER: for $number (1 .. 10) {
: >     INNER: for ($divisor = $number - 1; $divisor > 1; $divisor--) {
: >         next OUTER unless $number % $divisor;
: >     }
: >     print "prime: $number\n";
: > }
: > 
: > Hard to beleive that accomplishes the same thing!
: 
: I don't think that you can say that it does, at least at one level.
: 
: Specifically, it has to do (worst case) nearly N operations to
: determine whether N is prime, while the original only does one!

To make a fair comparison, you have to count the many backtrackings
performed by the regex engine in Abigail's version as 'operations'.  Work
done under the covers where you can't see it is still work. 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: 23 Aug 1998 23:05:59 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Prime numbers [was Re: here's an implementation of diff in perl]
Message-Id: <6rq78n$224$3@client3.news.psi.net>

Martin Gregory (mgregory@asc.sps.mot.com) wrote on MDCCCXVIII September
MCMXCIII in <URL: news:r8yasguvuu.fsf@asc.sps.mot.com>:
++ Daniel Grisinger <dgris@rand.dimensional.com> writes:
++ 
++ > [posted to comp.lang.perl.misc and mailed to the cited author]
++ > 
++ > In article <r8zpcyvrju.fsf_-_@asc.sps.mot.com>
++ > Martin Gregory <mgregory@asc.sps.mot.com> wrote:
++ > >
++ > >abigail@fnx.com (Abigail) writes:
++ > >> -- 
++ > >> perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
++ > >
++ > >Is this some well known trick for detecing prime numbers?
++ > 
++ > Yup, division, the best known trick for detecting prime
++ > numbers.
++ 
++ Que?
++ 
++ 1) I don't see any division going on there.
++ 2) Division seems to be a poor trick for detecting prime numbers: you
++    have to divide the number in question by evey number less than it.
++    Slow. This code does not do that: it has a one-shot hit to tell you
++    whether the number is prime.


If you think the regex is anywhere near efficient, you're sadly mistaken.

The regex is even worse than division. At least with division, it's one
operation. This is division by repeated addition.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: Mon, 24 Aug 1998 00:09:45 +0000
From: Gavin Cato <gavinc@geko.net.au>
Subject: Simple question for doing a sort on a text file
Message-Id: <35E0AF49.694B1BE5@geko.net.au>

Hiya Perl guru's

I'm having probs trying to do a very simple thing with a text file. 

I have a awk script that generates to STDOUT (or a file)  a listing that
looks like this,

user1	6555
user2	545
user3 	10885
user4	65757

etc..

I need to code a perl script that takes all these into a array then only
print out the ones that exceed the number 10000.

I'm quite a newbie with perl and just bought my "
Learning Perl 2nd edition" yesterday but ain't quite there yet :)

Any ideas? :) I'm sure it's only a 5-10 line piece of code but I can't
see my way through it (whilst I am reading this book)

thanks


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

Date: 24 Aug 1998 00:54:59 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Simple question for doing a sort on a text file
Message-Id: <slrn6u1ef9.l33.sholden@pgrad.cs.usyd.edu.au>

On Mon, 24 Aug 1998 00:09:45 +0000, Gavin Cato <gavinc@geko.net.au> wrote:
>Hiya Perl guru's
>
>I'm having probs trying to do a very simple thing with a text file. 
>
>I have a awk script that generates to STDOUT (or a file)  a listing that
>looks like this,
>
>user1	6555
>user2	545
>user3 	10885
>user4	65757
>
>etc..
>
>I need to code a perl script that takes all these into a array then only
>print out the ones that exceed the number 10000.
>
>I'm quite a newbie with perl and just bought my "
>Learning Perl 2nd edition" yesterday but ain't quite there yet :)
>
>Any ideas? :) I'm sure it's only a 5-10 line piece of code but I can't
>see my way through it (whilst I am reading this book)
>
>thanks

You coule always read the docs but I'm in a good mood today so :
perl -ane 'print $_ if $F[1]>10000'

might work...

Then again since the first script is in awk why not use awk to do it...
awk '{ if ($2 > 1000) print $0 }'

Both are a little less than 5-10 lines...

Sam



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

Date: 24 Aug 1998 00:57:50 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Simple question for doing a sort on a text file
Message-Id: <slrn6u1ekk.l33.sholden@pgrad.cs.usyd.edu.au>

On 24 Aug 1998 00:54:59 GMT, Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote:
>perl -ane 'print $_ if $F[1]>10000'

I should have left out the $_ I guess...

>
>might work...
>
>Then again since the first script is in awk why not use awk to do it...
>awk '{ if ($2 > 1000) print $0 }'

And that should be 10000 not 1000...

Sam



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

Date: Sun, 23 Aug 1998 21:02:40 +0200
From: "Mosl Roland" <founder@pege.org>
Subject: Re: Size of a JPG file
Message-Id: <6rq0ju$o15$1@orudios.magnet.at>

Mosl Roland <founder@pege.org> wrote in message
6rpg2p$pts$2@orudios.magnet.at...
>I would need for use in a Perlscript something like
>
>
>sub get_jpg_size
>(
>  my ( $filename ) = @_;
>
>
>
>  return ( $width, $height )
>}

Thanks, got answer per email, it is
    http://www.faqs.org/faqs/jpeg-faq/part1/section-22.html

Mosl Roland
http://pege.org/ clear targets for a confused civilization
http://salzburgs.com/ (did not find a slogan :-)




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

Date: Sun, 23 Aug 1998 15:35:41 -0700
From: John Callender <jbc@west.net>
Subject: Re: Size of a JPG file
Message-Id: <35E0993D.45AB983D@west.net>

Mosl Roland wrote:
> 
> Mosl Roland <founder@pege.org> wrote in message
> 6rpg2p$pts$2@orudios.magnet.at...
> >I would need for use in a Perlscript something like
> >
> >
> >sub get_jpg_size
> >(
> >  my ( $filename ) = @_;
> >
> >
> >
> >  return ( $width, $height )
> >}
> 
> Thanks, got answer per email, it is
>     http://www.faqs.org/faqs/jpeg-faq/part1/section-22.html

Also, the Image::Size module at CPAN does a good job on this type of
thing.

http://www.perl.com/CPAN/authors/id/RJRAY/Image-Size-2.7.tar.gz

--
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Sun, 23 Aug 1998 15:37:39 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Size of a JPG file
Message-Id: <MPG.104a398c405e650c9897e4@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <6rq0ju$o15$1@orudios.magnet.at> on Sun, 23 Aug 1998 21:02:40 
+0200, Mosl Roland <founder@pege.org> says...
> Mosl Roland <founder@pege.org> wrote in message
> 6rpg2p$pts$2@orudios.magnet.at...
 ...
> >sub get_jpg_size
> >(
> >  my ( $filename ) = @_;
 ...
> >  return ( $width, $height )
> >}
> 
> Thanks, got answer per email, it is
>     http://www.faqs.org/faqs/jpeg-faq/part1/section-22.html

The information is there, but you still have to write the code.  It is 
all done for you in a module available on CPAN called Image::Size.  You 
will find the code to extract the size from all the popular image 
formats.

-- 
(Yet Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sun, 23 Aug 1998 15:25:40 -0700
From: John Callender <jbc@west.net>
Subject: Re: testing Text::GenderFromName
Message-Id: <35E096E4.B442D586@west.net>

Andrew M. Langmead wrote:
> 
> It seems with the switch from "default to male" to "report if the name
> can't be determined" someone needs to create some rules to determine
> if the name seems to be male.

I think you've got a good point. The original code, as you said, seems
to have focused on identifying female names. Jon's laudable attempt to
"contribute to the destruction of the oppressive Patriarchy" by removing
the "default = male" behavior seems to have had the unanticipated effect
of crippling the module's effectiveness. There may be a lesson there for
those who incline towards unthinking political correctness (a group I am
sure does not include the esteemed Mr. Orwant, by the way)...

The module's overall success on the Social Security name list would have
been dramatically improved if all the 'unknowns' had been switched to
male:

Female names:

          Total names: 1655
  Believed to be male:  260 (15.7%)
Believed to be female: 1395 (84.3%)

Male names:

          Total names: 1195
  Believed to be male:  985 (82.4%)
Believed to be female:  210 (17.6%)

So, as much as I hate to advocate a symbolic slap in the face to the
Sisterhood, it probably makes sense to return the algorithm to its
roots, and have it default to male when none of the female rules fire.

Additionally, it struck me that it also might help to add a hash to the
module that associates all the uniquely male names from the Social
Security survey with 'male', and all the uniquely female names with
'female'. Then the existing routines that try to identify gender with
clever rules like "ends with 'een', ergo female" can be run on anything
that falls through the hash.

I don't know; such a brute-force approach would deprive the module of
some of its charm, though the 'tricksy' factor would be salvaged
somewhat by the knowledge that uncommon names were still being run
through the original code.

--
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Sun, 23 Aug 1998 21:18:01 GMT
From: Garry Williams <garry@NOSPAM.america.net>
Subject: Re: Turn Perl program into binary
Message-Id: <35E0873E.6AACBC34@NOSPAM.america.net>

Well, here's a suggestion: 

Why not place the password in a file that is owned by a trusted user
(perhaps yourself) without any permissions for others and turn the Perl
script into a setuid script?  You can open and read the file containing
the password and then give up the trusted uid before continuing as
before.  

A side-effect of this approach would be that the original script is now
taint checked.  This may mean un-tainting data that was not being
checked before.  

#!/opt/perl/bin/perl -w

# Scrub the environment

$ENV{PATH} = '/bin';
delete $ENV{IFS};
delete $ENV{ENV};

# Obtain the password
open(P, "/home/lily/secret") 
  || die "can't open /home/lily/secret, $!";
chomp($password = <P>);         # Read password
$> = $<;                        # Give up trusted uid

-- 
Garry Williams
garry@america.net

Lily Y. Fu wrote:
> 
> Hi,
> 
> I have a perl program having password information in clear text.
> I want people to run the program but don't want them to
> know the password. If I make the program not readable by
> the user, it won't run.
> 
> Is there a way to "compile" the program into binary
> so that the password is not in clear text at least?
> 
> Thanks,
> 
> --
> Lily Fu
> The Institute for Genomic Research
> Voice Mail: (301) 838-3557
> Email: lily@tigr.org


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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