[10179] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3772 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 21 03:07:12 1998

Date: Mon, 21 Sep 98 00:00:28 -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           Mon, 21 Sep 1998     Volume: 8 Number: 3772

Today's topics:
    Re: any way to encrypt my script? bitnut1@my-dejanews.com
    Re: any way to encrypt my script? <rra@stanford.edu>
        Boolean Searching... expoinfo@globalexpos.co.nz
    Re: Can GD.pm make 200 *ppi* gifs? (Tom Mornini)
    Re: Can GD.pm make 200 *ppi* gifs? (Anthony Boyd)
    Re: Can GD.pm make 200 *ppi* gifs? (Sam Holden)
    Re: Can you speed up this logfile report??? (Anthony Boyd)
        Each %HASH question <alby@iprolink.ch>
    Re: even/odd numbers (Leslie Mikesell)
    Re: even/odd numbers (Sam Holden)
        Help with perl hashes of hashes and arrays of hashes et <burry@nmt.edu>
    Re: Help with perl hashes of hashes and arrays of hashe <ajohnson@gpu.srv.ualberta.ca>
    Re: Help with perl hashes of hashes and arrays of hashe (Sam Holden)
    Re: Number Sort <fecund@fatnet.net>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Mon, 21 Sep 1998 04:48:46 GMT
From: bitnut1@my-dejanews.com
Subject: Re: any way to encrypt my script?
Message-Id: <6u4lrf$mr3$1@nnrp1.dejanews.com>


>--------------------------------------------
> Russ Allbery <rra@stanford.edu>:
> Patches to the compiler to improve it into what you want are most
> certainly welcome.  :)
>--------------------------------------------

I trust that you mean it, but many here are religiously opposed to any
kind of compilation and are willing to go to great lengths to prevent it.

Just look back at the beginning of this thread and you'll find 4 Perlers
trying to mislead a newbie that a Perl script cannot be obfuscated.

The officially approved "compiler" uses name strings instead of pointers.
This unusual design makes the executable larger and slower -- obviously
to make the compilation reversible -- and useless for most people.

I doubt it that this preaching through language design and deceit
will bring many converts to Perl.

B.N.

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


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

Date: 20 Sep 1998 22:08:17 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: any way to encrypt my script?
Message-Id: <yl1zp6jbni.fsf@windlord.stanford.edu>

bitnut1 <bitnut1@my-dejanews.com> writes:

> I trust that you mean it, but many here are religiously opposed to any
> kind of compilation and are willing to go to great lengths to prevent
> it.

> Just look back at the beginning of this thread and you'll find 4 Perlers
> trying to mislead a newbie that a Perl script cannot be obfuscated.

> The officially approved "compiler" uses name strings instead of
> pointers.  This unusual design makes the executable larger and slower --
> obviously to make the compilation reversible -- and useless for most
> people.

Um... I guess I can almost see where you got that idea from, in a twisted
sort of way, but believe me, the person who's actually writing the
compiler has no such concerns at the top of his mind.  The compiler isn't
implemented in the fashion in which it is to make compliation reversible;
it's implemented in the fashion in which it is because it's leveraging off
Perl's own internal parse structure and it's easier this way.

Obviously, with time and work, further optimization is possible and that
may well result in more speed.  The compiler is a major undertaking and
will doubtless take some years longer before it will be everything, or
even most things, people want it to be.

I don't think that *most* people really care about the reversibility of
the compile nearly so much as they care about the additional benefits that
compilation might bring (faster load time, making possible some global
optimizations that Perl can't do because it has to compile at run-time,
better profiling and debugging analysis of programs, and the like).

Oh, and note that the author of the compiler modules doesn't regularly
participate in threads like this.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Mon, 21 Sep 1998 04:57:20 GMT
From: expoinfo@globalexpos.co.nz
Subject: Boolean Searching...
Message-Id: <6u4mbg$nch$1@nnrp1.dejanews.com>

I have a search script were i need a boolean search.. here is some of it..
how do i get it to add the 'All Regions" to the $aera2 value to search for
either or the $area2 or 'All Regions'...

    $area = $area2 || 'All Regions';

Thanks

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


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

Date: Mon, 21 Sep 1998 05:06:44 GMT
From: tmornini@netcom.com (Tom Mornini)
Subject: Re: Can GD.pm make 200 *ppi* gifs?
Message-Id: <tmorniniEzMBJ8.A6y@netcom.com>

Anthony Boyd (anthony@outshine.com) wrote:

: So here is what you and the shop should agree to do: first, figure out how
: big the image will be on the shirt (let's say 8 inches wide); second,
: knowing that they want a 200ppi image, figure out how many pixels that
: would end up being (8 * 200 = 1600); third, have GD.pm make images just
: that wide (1600) without specifying any dpi/ppi setting; fourth, send the
: images to the shop and tell them you built the images oversized and if
: they'll change the setting in Photoshop to be 200ppi WITHOUT resampling --
: thereby causing the image to shrink down to 8 inches -- then they'll have
: exactly what they need to print the shirts.

I think this would be better off in comp.prepress. The advise given above
is spot-on however.

Only thing that I'd point out is that T-Shirts are typically 50-60 lpi, and
you need 2x dpi, so you should only be worrying about 100-120 dpi images, not
200.

Why don't you just save the darn thing as TIFF? It *definitely* contains
resolution information.

Go into "Image Size" dialog, turn off resampling, change the resolution, and
watch the dimensions decrease, but *not* the file size. Then select "Save As"
and change the format to TIFF. You're T-Shirt shop will be ecstatic.

To turn off resampling, I believe you check a box called "Constrain File Size"
in the "Image Size" dialog.

-- Tom Mornini
-- InfoMania


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

Date: Sun, 20 Sep 1998 23:51:29 -0800
From: anthony@outshine.com (Anthony Boyd)
Subject: Re: Can GD.pm make 200 *ppi* gifs?
Message-Id: <anthony-2009982351300001@oak-hiper1b-139-139.dialup.slip.net>

sholden@pgrad.cs.usyd.edu.au (Sam Holden) wrote:

> If you take an image and save it in photoshop at 100ppi, and then save
it again
> at 200ppi (and half the height and width I guess). Is there any difference
> between the two resulting files?

Not if you keep the same number of pixels.  If it's 400 pixels wide and 4
inches wide, that's 100dpi.  If you make it 2 inches wide at 200dpi, it's
still 400 pixels wide, so the "pixel integrity" is maintained.  However,
if you take that 2 inch picture, and size it back up to 4 inches wide AND
keep the 200dpi setting, well now it's supposed to be 800 pixels wide (4"
* 200).  So the image program you're using will use resampling technology
to add in pixels (it looks at the pixels and adds in extras that are an
average of the colors around it).

If you stay in RGB mode (24 bit, 16 million colors) while you do that
resampling, it can actually turn out okay, because there is a great
selection of color for super-accurate matching.  But with a GIF (8 bit,
256 colors) there just isn't a big color selection, and the image ends up
looking jagged.  I think Paint Shop Pro even disables resampling at 8 bit
-- they don't even want to try it at such restrictive levels.  Photoshop
will do it, I think.

-Tony


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

Date: 21 Sep 1998 06:52:27 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Can GD.pm make 200 *ppi* gifs?
Message-Id: <slrn70bttb.d8b.sholden@pgrad.cs.usyd.edu.au>

On Sun, 20 Sep 1998 23:51:29 -0800, Anthony Boyd <anthony@outshine.com> wrote:
>sholden@pgrad.cs.usyd.edu.au (Sam Holden) wrote:
>
>> If you take an image and save it in photoshop at 100ppi, and then save
>it again
>> at 200ppi (and half the height and width I guess). Is there any difference
>> between the two resulting files?
>
>Not if you keep the same number of pixels.  If it's 400 pixels wide and 4
>inches wide, that's 100dpi.  If you make it 2 inches wide at 200dpi, it's
>still 400 pixels wide, so the "pixel integrity" is maintained.  However,
>if you take that 2 inch picture, and size it back up to 4 inches wide AND
>keep the 200dpi setting, well now it's supposed to be 800 pixels wide (4"
>* 200).  So the image program you're using will use resampling technology
>to add in pixels (it looks at the pixels and adds in extras that are an
>average of the colors around it).

I know what it should do in theory I asked because I hoped the person who
asked the original question would make the deduction, that if they ended up 
being the same then ppi isn;t encoded in the file, and that if they are
different then that difference is going to be the ppi comment in that the
software might add...

-- 
Sam

Basically, avoid comments. If your code needs a comment to be
understood, it would be better to rewrite it so it's easier to
understand.	--Rob Pike


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

Date: Sun, 20 Sep 1998 23:35:57 -0800
From: anthony@outshine.com (Anthony Boyd)
Subject: Re: Can you speed up this logfile report???
Message-Id: <anthony-2009982335570001@oak-hiper1b-139-139.dialup.slip.net>

"Jim Woodgate" <jdw@dev.tivoli.com wrote:

> I saw Larry's note it was really good, but I wanted to make two quick
> comments:  >>SNIP<<

Yeah, Larry's post was great, and the followups, and yours too -- it
didn't occur to me that I was doubling-up on the array, but you're right,
I was.  Big waste.

And I NEVER KNEW that a foreach would load the whole damn thing into
memory, but a while statement would take it piece-by-piece.  I did know
that using /i on a match would slow things down, but I thought not enough
to notice.

Anyway, the bottom line is that I implemented every suggestion I could --
dropping the extra array, dropping the /i, using the while statment, etc. 
And then I re-ran it on the same exact 50MB file that had taken half an
hour on Friday.  This time it took ONE MINUTE.

And I learned a hell of a lot, too.  Thanks guys.

I picked up a copy of Advanced Perl Programming.  I hope it talks about
this kind of stuff in detail....

-Tony


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

Date: Mon, 21 Sep 1998 00:30:51 +0200
From: Millioud Martial <alby@iprolink.ch>
Subject: Each %HASH question
Message-Id: <3605821B.FBB47AA7@iprolink.ch>

Hello,

I've got some problems with this code :

while(($key,$value) = each %input) {
print "Yes" if $key eq 'True';
print "No" if $value eq 'False';
}

We assume that $Key = 'True' and $value = 'False'
It seems like the if doesn't work with $value. "Yes" is print but the
"No" is not print though $value does equal 'False'. Someone could
explain to me why ?
Thanks for your help.

Martial Millioud


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

Date: 21 Sep 1998 00:20:11 -0500
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: even/odd numbers
Message-Id: <6u4nmb$mn9$1@Mars.mcs.net>

In article <1dfo978.z9u47r1kmwglfN@roxboro0-058.dyn.interpath.net>,
>
>"modulus" is of course the easiest and most straightforward way of
>finding out, but it's hardly the only (although the most obvious way
>would much simplier if perl had a div command like pascal).

No, no...
 printf "Number $n is %s\n", $n & 1 ? "odd":"even" ;
is much easier and more straightforward, not to mention obvious.

  Les Mikesell
    les@mcs.com


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

Date: 21 Sep 1998 05:24:57 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: even/odd numbers
Message-Id: <slrn70bop9.8io.sholden@pgrad.cs.usyd.edu.au>

On 21 Sep 1998 00:20:11 -0500, Leslie Mikesell <les@MCS.COM> wrote:
>In article <1dfo978.z9u47r1kmwglfN@roxboro0-058.dyn.interpath.net>,
>>
>>"modulus" is of course the easiest and most straightforward way of
>>finding out, but it's hardly the only (although the most obvious way
>>would much simplier if perl had a div command like pascal).
>
>No, no...
> printf "Number $n is %s\n", $n & 1 ? "odd":"even" ;
>is much easier and more straightforward, not to mention obvious.

Only if you know that numbers are stored in binary. And no what & does which
is a lot less straightforward then the % and / solutions. In fact my
favourite was Tom Christiansen's $r=$n/2;$r=~/\.5$/... or words to that
effect.

-- 
Sam

Can you sum up plan 9 in layman's terms? It does everything Unix does
only less reliably.
	--Ken Thompson


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

Date: Sun, 20 Sep 1998 23:40:35 -0600
From: Brent Perschbacher <burry@nmt.edu>
Subject: Help with perl hashes of hashes and arrays of hashes etc
Message-Id: <Pine.SUN.3.96.980920232500.1734A-100000@rainbow>

Hello Everyone!
I am a lowly beginer and I am having a really funky problem with perl.
first I will give a little bit of background on my knowledge, I am
currently taking a course at NM Tech on perl so I am new to this language,
but I have been programing in c and c++ for 4-5 years, I've lost count, so
I know how to program and debug, but this has completely stumped me on
what is happening and why. somehwere along the line my array of
arrays(i've also tried it as array of hashes and hash of hashes) is losing
or overwriting with junk my data. I can input the data fine, and
imediately print it out, but if I go on to the next index in the "outter"
array it all goes bye-bye! I have been working for damn near 8 hours to
figure out why and how to fix this and I can't do either :( if anyone
could possibly explain to me why this doesn't work or what I'm doing wrong
to cause it to do this I would be very appreciative. If it helps I have
been using the book "Programming Perl" by Larry Wall, Tom Christiansen,
and Ronald L. Schwartz. the important parts of the code follow.

where I am declaring the array of arrays:

$database[$current][0] = $user;
$database[$current][1] = $first;
$database[$current][2] = $last;
$database[$current][3] = $age;
$database[$current][4] = $address;

this as far as I know is working because I can print out of this, but only
imediately after I declare it. All of the scalars are declared before this
point.

here is where I am printing. I have also tried a for, and a foreach loop
to do this implicitly, but I changed it trying to find the error.

 for $i (0 .. $#database){
  print "$i is i\n";
  print "User is:    $database[$i][0] \n";
  print "First is:   $database[$i][1] \n";
  print "last is:    $database[$i][2] \n";
  print "age is:     $database[$i][3] \n";
  print "address is: $database[$i][4] \n";
 }#end for      

like I said I have tried this with every type of * of *'s that I could
think of, but each one had the same "error" I copied most of the important
lines right out of my book and they still "died." 

anyhelp would be greatly appreciated.

thanx
Burry




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

Date: Mon, 21 Sep 1998 01:22:42 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Help with perl hashes of hashes and arrays of hashes etc
Message-Id: <3605F0B2.330FD22@gpu.srv.ualberta.ca>

Brent Perschbacher wrote:
!
[snip]
! been using the book "Programming Perl" by Larry Wall, Tom
! Christiansen, and Ronald L. Schwartz. the important parts of the code

well, at least you spelled 'Randal' with only one 'l' 
:-)

! like I said I have tried this with every type of * of *'s that I
! could think of, but each one had the same "error" I copied most of
! the important lines right out of my book and they still "died."

You would do better to tell us what 'error' is occuring, what you've
tried, and importantly, a small but complete snippet of code and data
that exhibits the actual problem.

regards
andrew


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

Date: 21 Sep 1998 06:36:17 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Help with perl hashes of hashes and arrays of hashes etc
Message-Id: <slrn70bsv0.blh.sholden@pgrad.cs.usyd.edu.au>

On Sun, 20 Sep 1998 23:40:35 -0600, Brent Perschbacher <burry@nmt.edu> wrote:
>Hello Everyone!
>I am a lowly beginer and I am having a really funky problem with perl.
>first I will give a little bit of background on my knowledge, I am
>currently taking a course at NM Tech on perl so I am new to this language,
>but I have been programing in c and c++ for 4-5 years, I've lost count, so
>I know how to program and debug, but this has completely stumped me on
>what is happening and why. somehwere along the line my array of
>arrays(i've also tried it as array of hashes and hash of hashes) is losing
>or overwriting with junk my data. I can input the data fine, and
>imediately print it out, but if I go on to the next index in the "outter"
>array it all goes bye-bye! I have been working for damn near 8 hours to
>figure out why and how to fix this and I can't do either :( if anyone
>could possibly explain to me why this doesn't work or what I'm doing wrong
>to cause it to do this I would be very appreciative. If it helps I have
>been using the book "Programming Perl" by Larry Wall, Tom Christiansen,
>and Ronald L. Schwartz. the important parts of the code follow.
>
>where I am declaring the array of arrays:
>
>$database[$current][0] = $user;
>$database[$current][1] = $first;
>$database[$current][2] = $last;
>$database[$current][3] = $age;
>$database[$current][4] = $address;
>
>this as far as I know is working because I can print out of this, but only
>imediately after I declare it. All of the scalars are declared before this
>point.
>
>here is where I am printing. I have also tried a for, and a foreach loop
>to do this implicitly, but I changed it trying to find the error.
>
> for $i (0 .. $#database){
>  print "$i is i\n";
>  print "User is:    $database[$i][0] \n";
>  print "First is:   $database[$i][1] \n";
>  print "last is:    $database[$i][2] \n";
>  print "age is:     $database[$i][3] \n";
>  print "address is: $database[$i][4] \n";
> }#end for      
>
>like I said I have tried this with every type of * of *'s that I could
>think of, but each one had the same "error" I copied most of the important
>lines right out of my book and they still "died." 
>
>anyhelp would be greatly appreciated.

What are "* of *'s"???

Post some code that demonstrates the problem and someone might be able to 
help.... The above code isn't much use since it doesn't fit the problem you
are having...

When I try :

$d[0][0] = 0;
$d[0][1] = 1;
$d[1][0] = 10;
$d[1][1] = 11;
$d[2][0] = 20; #what an aweful way to set up an array but I'll stick with 
$d[2][1] = 21; #but i'll stick with the poster's style...

for $i (0 .. $#d)
{
	print "$i\n";
	print "$d[$i][0] : $d[$i][1] \n";
}

I get :

0
0 : 1 
1
10 : 11 
2
20 : 21 

Which is what I would expect, so please give an example that shows the problem.

-- 
Sam

Can you sum up plan 9 in layman's terms? It does everything Unix does
only less reliably.
	--Ken Thompson


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

Date: Sun, 20 Sep 1998 21:40:15 -0700
From: Yary Hluchan <fecund@fatnet.net>
Subject: Re: Number Sort
Message-Id: <3605D8AF.678B@fatnet.net>

] How about trying that with the '-w' flag set?  You *do* use the '-w' 
] flag, don't you?  Doesn't everybody?  All the time???

A warning isn't an error. Once in a blue moon Perl warns you about
something that you really want to do. Why call split 28,000 times,
or write difficult-to-read mappings, when you can say:

{
  local $^W = 0;
  # Yes, I really want to use the numerical <=> operator on strings,
  # becuase each string begins with a number that I want to sort by.

  @ordered = sort {$a <=> $b} @stringilst;
}


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

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

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