[25727] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7967 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 12 09:05:33 2005

Date: Tue, 12 Apr 2005 06:05:19 -0700 (PDT)
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, 12 Apr 2005     Volume: 10 Number: 7967

Today's topics:
        [perl-python] Python documentation moronicities (contin <xah@xahlee.org>
    Re: [perl-python] Python documentation moronicities (co <cam.ac.uk@mh391.invalid>
    Re: [perl-python] Python documentation moronicities (co <joe@inwap.com>
    Re: [perl-python] Python documentation moronicities (co <rbt@athop1.ath.vt.edu>
        Basic question about web programming <tamir.yehuda@gmail.com>
    Re: Basic question about web programming <josef.moellers@fujitsu-siemens.com>
    Re: Basic question about web programming <noreply@gunnar.cc>
    Re: Basic question about web programming <spamtrap@dot-app.org>
    Re: Basic question about web programming <nospam@bigpond.com>
        Beginner Question #1 soup_or_power@yahoo.com
    Re: Beginner Question #1 <postmaster@castleamber.com>
    Re: Beginner Question #1 <1usa@llenroc.ude.invalid>
        Client socket programming eating up CPU/memory <stryder22204@gmail.com>
    Re: Comparing Regular Expressions <shirsch@adelphia.net>
    Re: FAQ 4.49 How do I process/modify each element of an <hendrik_maryns@despammed.com>
    Re: New Perl installation can't find module <jon.m.landenburger@verizon.com>
    Re: Perl function for negative integers using the 2's c <joe@inwap.com>
    Re: Simple Encryption Script <joe@inwap.com>
    Re: Simple Encryption Script <joe@inwap.com>
    Re: Simple Encryption Script <tassilo.von.parseval@rwth-aachen.de>
    Re: Simple Encryption Script <someone@example.com>
    Re: Simple Encryption Script <hackeras@gmail.com>
    Re: Simple Encryption Script <hackeras@gmail.com>
    Re: Simple Encryption Script (Anno Siegel)
    Re: Simple Encryption Script <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 12 Apr 2005 03:25:33 -0700
From: "Xah Lee" <xah@xahlee.org>
Subject: [perl-python] Python documentation moronicities (continued)
Message-Id: <1113301533.054410.203710@z14g2000cwz.googlegroups.com>

http://python.org/doc/2.4.1/lib/module-re.html
http://python.org/doc/2.4.1/lib/node114.html

---------
QUOTE
The module defines several functions, constants, and an exception. Some
of the functions are simplified versions of the full featured methods
for compiled regular expressions. Most non-trivial applications always
use the compiled form
UNQUOTE


What does a programer who wants to use regex gets out from this piece
of motherfucking irrevalent drivel?

----------
QUOTE
compile(
pattern[, flags])

Compile a regular expression pattern into a regular expression  object,
which can be used for matching using its match() and  search() methods,
described below.

The expression's behaviour can be modified by specifying a  flags
value. Values can be any of the following variables,  combined using
bitwise OR (the | operator).
UNQUOTE


What exactly is it fucking saying?

I wanted to use regex to find & replace on text. I've read in a file.
Trying to reading this fucking doc is a pain in the ass. What are these
"flags"? Do i do

re.compile(r'mypat','M') or
re.compile(r'mypat',M)
or perhaps
re.compile(r'mypat',re.M)

The M isn't a fucking variable. Why does the doc incompetently use that
term?
And what the fuck is it unclearly meant by "OR" operator with the
mother fucking bitwise jargon?

All a person reading regex really wanted is to see how to use a string
pattern and replace it with another. The fucking doc cannot be possibly
fucking worsely written.

Fuck the mother fucking coders in the IT industry.

So, is
re.compile(r'mypat','M')
re.compile(r'mypat','MULTILINE')
equivalent?

and, by that fucking bitwise shit is it meant to say like
re.compile(r'mypat','M'|'U')
?

why cannot this piece of shit writing give a single example of usage?
and motherfucking confusedly organized, with fucking variable terms the
writer don't fucking understand, and meanwhile always trying to sound
big asshole and don't stop at masturbation by mention a regex book and
not hesitate to mention another language Perl. Fucking morons.

for a exposition of IT's fucking stupid docs and their fuckhead coders,
see:
http://xahlee.org/Periodic_dosage_dir/t2/xlali_skami_cukta.html

a cleaned up account of this post will be appended to the above
exposition.

--------

One final piece of advice here to sober up the fuckheads who are
currently offended and defiant: you want to ask yourself this question:
Can a seasoned programer, who is expert at least 2 languages, who is
also a expert at Perl and knew regex well, and who has also read the
official Python tutorial and has written at least 10 simple python
programs over a span of a month, can such a person, who have not yet
used regex in Python but now wants to use regex in Python and have just
read the doc, must he, resort to many trial and error to see exactly
what the doc is talking about?

But, can this doc be (re-)written effectively and easily so that any
programers needn't do trial'n'error post-reading?

The answer to the questions are resounding yeses, you fucking asses.

paypal me a hundred dollars and i'll rewrite the whole re doc in a few
hours.

Fuck you the standard IT morons. Excuse me for i didn't have time to
write a more coherent and detailed analysis of the stupidities of the
re doc.

 Xah
 xah@xahlee.org
=E2=88=91 http://xahlee.org/PageTwo_dir/more.html =E2=98=84



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

Date: Tue, 12 Apr 2005 11:46:29 +0100
From: Michael Hoffman <cam.ac.uk@mh391.invalid>
Subject: Re: [perl-python] Python documentation moronicities (continued)
Message-Id: <d3g8u8$9pi$1@gemini.csx.cam.ac.uk>

I've had enough.

*PLONK*
-- 
Michael Hoffman


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

Date: Tue, 12 Apr 2005 04:02:20 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: [perl-python] Python documentation moronicities (continued)
Message-Id: <F4CdnYojx8MiN8bfRVn-2w@comcast.com>

Xah Lee wrote:

> of motherf***ing irrevalent drivel?

I am greatly amused.
A troll impersonating Xah Lee has made xah look like a total moron.
LOL


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

Date: Tue, 12 Apr 2005 09:00:41 -0400
From: rbt <rbt@athop1.ath.vt.edu>
Subject: Re: [perl-python] Python documentation moronicities (continued)
Message-Id: <d3ggpp$9fu$1@solaris.cc.vt.edu>

Xah Lee wrote:

> What does a programer who wants to use regex gets out from this piece
> of motherf**king irrevalent drivel?

Any resume that ever crosses my desk that includes 'Xah Lee' anywhere in 
the name will be automatically trashed.


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

Date: 12 Apr 2005 03:38:18 -0700
From: "tamiry" <tamir.yehuda@gmail.com>
Subject: Basic question about web programming
Message-Id: <1113302298.630577.245540@g14g2000cwa.googlegroups.com>


I'd like to erite a simple perl script that will accept a URL
as input, will go to that web site, look for pdf files that are
referenced there and will download them.
What I don't have a clue about is the first part, how to access the
remote URL, and read the html text.
I'm kinda sure it shouldn't be complicated with perl.
Please can any one direct me to an online book or article ?
I tried looking for "web programming" but it gave me web server
applications. Maybe I just don't know what I'm looking for ?

lot's of thanks.



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

Date: Tue, 12 Apr 2005 12:45:24 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Basic question about web programming
Message-Id: <d3g91a$4iu$1@nntp.fujitsu-siemens.com>

tamiry wrote:
> I'd like to erite a simple perl script that will accept a URL
> as input, will go to that web site, look for pdf files that are
> referenced there and will download them.
> What I don't have a clue about is the first part, how to access the
> remote URL, and read the html text.
> I'm kinda sure it shouldn't be complicated with perl.
> Please can any one direct me to an online book or article ?
> I tried looking for "web programming" but it gave me web server
> applications. Maybe I just don't know what I'm looking for ?
>=20
> lot's of thanks.
>=20

Look at LWP::Simple

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Tue, 12 Apr 2005 12:52:29 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Basic question about web programming
Message-Id: <3c1ni7F6jc68tU1@individual.net>

tamiry wrote:
> I'd like to erite a simple perl script that will accept a URL
> as input, will go to that web site, look for pdf files that are
> referenced there and will download them.
> What I don't have a clue about is the first part, how to access the
> remote URL, and read the html text.
> I'm kinda sure it shouldn't be complicated with perl.
> Please can any one direct me to an online book or article ?

How about the Perl documentation?

http://search.cpan.org/perldoc?LWP%3A%3ASimple

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Tue, 12 Apr 2005 07:11:46 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Basic question about web programming
Message-Id: <GPqdnaNfYMNuMcbfRVn-uQ@adelphia.com>

tamiry wrote:

> I'd like to erite a simple perl script that will accept a URL
> as input, will go to that web site, look for pdf files that are
> referenced there and will download them.
> What I don't have a clue about is the first part, how to access the
> remote URL, and read the html text.
> I'm kinda sure it shouldn't be complicated with perl.
> Please can any one direct me to an online book or article ?

Have a look at these modules:
     WWW::Mechanize
     LWP

You can read about them at CPAN:
     <http://search.cpan.org>

> I tried looking for "web programming" but it gave me web server
> applications. Maybe I just don't know what I'm looking for ?

You should narrow the search by googling for "Perl web client 
programming" - you want to write a client app, after all, and you want 
to do it in Perl.

That will get you a fairly focused set of hits. Most of them will be 
examples and tutorials concerning the above two modules.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Tue, 12 Apr 2005 22:05:20 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Basic question about web programming
Message-Id: <425bba46@x-privat.org>

tamiry wrote:

> 
> I'd like to erite a simple perl script that will accept a URL
> as input, will go to that web site, look for pdf files that are
> referenced there and will download them.
> What I don't have a clue about is the first part, how to access the
> remote URL, and read the html text.
> I'm kinda sure it shouldn't be complicated with perl.
> Please can any one direct me to an online book or article ?
> I tried looking for "web programming" but it gave me web server
> applications. Maybe I just don't know what I'm looking for ?
> 
> lot's of thanks.

You can probably accomplish this without Perl.

See if you have wget installed
http://www.gnu.org/software/wget/wget.html

gtoomey


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

Date: 12 Apr 2005 05:27:56 -0700
From: soup_or_power@yahoo.com
Subject: Beginner Question #1
Message-Id: <1113308876.545262.133900@l41g2000cwc.googlegroups.com>

Consider the following code. Is there any workaround to calling sub b
from sub a without using the $type. Thanks for your help.

package my::package

sub new ()
{
      return self;
}

sub a ()
{
  my($type)=shift;
  my $par1
  &b($type, $par1);
}

sub b()
{
   my($type, $param)=@_;
}



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

Date: 12 Apr 2005 12:36:57 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Beginner Question #1
Message-Id: <Xns96364D65CC754castleamber@130.133.1.4>

 wrote:

> Consider the following

subject: "beginner question #1" and think, how many beginner question #1s 
are posted here today.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Tue, 12 Apr 2005 12:43:22 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Beginner Question #1
Message-Id: <Xns963658A9DCC67asu1cornelledu@127.0.0.1>

soup_or_power@yahoo.com wrote in news:1113308876.545262.133900
@l41g2000cwc.googlegroups.com:

> Consider the following code. Is there any workaround to calling sub b
> from sub a without using the $type. Thanks for your help.
> 
> package my::package

Please post real code.

In addition to the syntax error above, my is probably going to be 
confusing.

Other than with pragmas, it use customary to capitalize the first letter 
of each component in a package identifier.

So:

package My::Package;

use strict;
use warnings;

missing.

> sub new ()

Why the prototype?

> {
>       return self;
> }

What is self?

Bareword "self" not allowed while "strict subs" in use at t.pl line 9
 
> sub a ()

Why the prototype?

> {
>   my($type)=shift;
>   my $par1

Syntax error.

>   &b($type, $par1);
> }
> 
> sub b()
> {
>    my($type, $param)=@_;
> }

You need a good book, and make an effort to help others help you.

Please read the posting guidelines for this group.

I have no idea what you are trying to do here.

#! /usr/bin/perl

use strict;
use warnings;

sub a { print "This is a\n"; }

sub b { 
    print "This is b\nCalling a ...\n";
    a();
}

b();

__END__



-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

Date: 12 Apr 2005 05:31:59 -0700
From: "Stryder" <stryder22204@gmail.com>
Subject: Client socket programming eating up CPU/memory
Message-Id: <1113309119.624804.111290@z14g2000cwz.googlegroups.com>

I'm trying to write a client program that when called upon will create
a socket, connect to a remote server, send a request and get back data,
then close the socket.

I'm able to do all of this but each subsequent socket I create causes
the program to eat up more memory and CPU cycles.  I've copied the
examples directly from the Camel book and other places, and this always
happens.  I've encountered this on both Solaris and Linux with both
IO::Socket and IO::Socket::INET modules.

Here's some code that is causing this to happen.  I'll follow it with
some "top" readings that show the memory and CPU usage increasing.

========================= CODE ==============================
use IO::Socket;
use IO::Handle;

############## irrelevant code populating @unaps here

my $paddr = sockaddr_in(9000, inet_aton('127.0.0.1')) || die
"sockaddr_in error: $!";
my $buff;

foreach $unap ( @unaps ) {
    $remote = IO::Socket::INET->new(
        Proto     => "tcp",
        PeerAddr  => '127.0.0.1',
        PeerPort  => 9000,
    );
    unless ($remote) { die "cannot connect to http daemon on $host" }
    $remote->autoflush(1);

    print $remote "$unap\x0d\x0a";
    $buff = <$remote>;
    while (<$remote>) {}
    close $remote;
    print "$buff\n";
}

========================= END CODE ==============================

Here's the "top" readout.  Each of these readings is just a few seconds
apart.

 20001 gatekeep   1  10    0   27M   27M cpu/1    0:06 11.93% perl
 20001 gatekeep   1  30    0   30M   29M run      0:07 13.25% perl
 20001 gatekeep   1  10    0   32M   32M cpu/2    0:08 14.21% perl
 20001 gatekeep   1  30    0   34M   34M cpu/2    0:08 15.01% perl
 20001 gatekeep   1  20    0   36M   35M run      0:09 15.89% perl
 20001 gatekeep   1  30    0   38M   38M cpu/1    0:10 16.94% perl
 20001 gatekeep   1  30    0   40M   39M run      0:11 17.79% perl
 20001 gatekeep   1  10    0   42M   42M sleep    0:12 18.64% perl
 20001 gatekeep   1   0    0   44M   43M run      0:13 19.38% perl
 20001 gatekeep   1  30    0   46M   45M run      0:14 20.42% perl
 20001 gatekeep   1  10    0   47M   47M run      0:14 21.07% perl
 20001 gatekeep   1   0    0   49M   49M cpu/1    0:15 21.69% perl
 20001 gatekeep   1  40    0   51M   51M cpu/2    0:16 22.49% perl
 20001 gatekeep   1  30    0   52M   52M cpu/1    0:17 22.67% perl
 20001 gatekeep   1  10    0   54M   54M cpu/1    0:17 23.12% perl
 20001 gatekeep   1  50    0   56M   56M sleep    0:18 23.62% perl
 20001 gatekeep   1  30    0   59M   59M sleep    0:20 24.30% perl
 20001 gatekeep   1  50    0   65M   65M cpu/2    0:23 25.59% perl
 20001 gatekeep   1  30    0   67M   66M cpu/1    0:23 26.17% perl
 20001 gatekeep   1   0    0   68M   68M cpu/2    0:24 26.62% perl
 20001 gatekeep   1  40    0   70M   70M cpu/1    0:25 27.38% perl
 20001 gatekeep   1  20    0   72M   72M cpu/2    0:27 28.04% perl
 20001 gatekeep   1  10    0   74M   73M sleep    0:27 28.24% perl
 20001 gatekeep   1   0    0   75M   75M cpu/2    0:28 28.58% perl
 20001 gatekeep   1  10    0   77M   77M cpu/1    0:29 29.10% perl
 20001 gatekeep   1   0    0   79M   78M cpu/1    0:30 29.31% perl

I'm hoping this is just something dumb I'm not understanding about
this.  Any help would be VERY appreciated.

Thanks.

Ralph



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

Date: Tue, 12 Apr 2005 07:59:24 -0400
From: "Steven N. Hirsch" <shirsch@adelphia.net>
Subject: Re: Comparing Regular Expressions
Message-Id: <uPCdnfqjx7uBJcbfRVn-vg@adelphia.com>

Robert Inder wrote:
> I'm interested in comparing the "coverage" of regular expressions.  
> 
> In particular, if I have two regular expressions, I want to know
> whether it is possible to construct a string that will match
> both, or indeed that will match one and not the other.
> 
> So, for instance, suppose I believe that if an object has a
> descripiton string matching regexp R1, it is of type A.
> Someone now tells me that an object with a
> descripiton string matching regexp R2 is of type B.  What can I tell
> about (the sets of things of type) A and B by looking at R1 and R2? 
> 
> So if R1= "^a.*$" and R2 = "^b.*$", I know that A and B are disjoint.
> 
> Whereas if R1= "foo" and R2 = "foobar", I know that B is a subset of A.
> 
> But how do I formalise (i.e. program) this comparison process?
> 
> This strikes me as a very general problem/issue and there 
> just has to be some work on formalising and solving it.  But I don't
> know how to find it: Google searches for things like "regular
> expression comparison" are swamped by algorithms for matching regexps
> against strings and so forth, which isn't what I want. 
> 
> Can anyone point me in the right direction?  

There's a wonderful treatment of the subject in "Higher Order Perl", 
written by Mark Jason Dominus.  This is easily one of the most 
thought-provoking books on Perl to date (IMHO) and a highly-recommended 
read.


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

Date: Tue, 12 Apr 2005 13:50:26 +0200
From: Hendrik Maryns <hendrik_maryns@despammed.com>
Subject: Re: FAQ 4.49 How do I process/modify each element of an array?
Message-Id: <1113306643.836619@seven.kulnet.kuleuven.ac.be>

PerlFAQ Server schreef:
> This message is one of several periodic postings to comp.lang.perl.misc
> intended to make it easier for perl programmers to find answers to
> common questions. The core of this message represents an excerpt
> from the documentation provided with Perl.
> 
> --------------------------------------------------------------------
> 
> 4.49: How do I process/modify each element of an array?
> 
>     Use "for"/"foreach":
> 
>         for (@lines) {
>             s/foo/bar/;     # change that word
>             y/XZ/ZX/;       # swap those letters
>         }

Quote from perlop:
"For sed devotees, y is provided as a synonym for tr. "
so wouldn't it be more instructive to use tr/// here?

0.02c

H.

-- 
Hendrik Maryns

Interesting websites:
www.lieverleven.be	(I cooperate)
www.eu04.com		European Referendum Campaign
aouw.org		The Art Of Urban Warfare


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

Date: 12 Apr 2005 05:01:11 -0700
From: "JONL" <jon.m.landenburger@verizon.com>
Subject: Re: New Perl installation can't find module
Message-Id: <1113307271.491574.103600@o13g2000cwo.googlegroups.com>

JONL wrote:
>I guess this thread has more than run its course. Though I will say
that the file I get from CPAN is ReadKey.pm which is less than what I
need since I need to compile an so file.  Yes I did see the thing about
getting cpan to do the work for me and in fact was working last nite on
that .  I got stopped when it demanded I load lynx which I started but
lynx had some problems with our curses configuration.  These are
problems which can be resolved but will take time.  I thank everyone
who offered advice.
JonL



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

Date: Tue, 12 Apr 2005 03:54:14 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Perl function for negative integers using the 2's complement in hex?
Message-Id: <mvOdnW-Nqr1FNcbfRVn-3g@comcast.com>

stylechief wrote:
> That works like a charm when one can explicitly pass a hex number like
> the above example.  However, for whatever reason, when one attempts to
> read from a binary file and use unpack() to deliver the hex numbers,
> one gets:
> Argument "ffbe8e" isn't numeric in pack at E:\Test\bif.plx line 5.
> 
> code:
> open (BINARYFILE, "<000332") || die "Cant open: $!\n";
> while(read(BINARYFILE, $data, 3)){
>   $data= unpack 'H*',$data;
>   print unpack 'i',pack 'i',$data;
>   print "\n";
> }
> close (BINARYFILE) || die"Cant close: $!\n";
> 
> It *is* unpacking to a 24 bit hex number,


No, it is unpacking to a six-character string of hexadecimal digits.
The phrase "24 bit hex number" is meaningless, what you've got is
a 24-bit number expressed as a string of hexadecimal digits.

> but fails to see this number as numeric.  It gets "stringified" somehow.

Using 'H' with unpack() returns a string, not a number.
The string of hexadecimal digits needs to go through the hex() function
in order to be numeric.

    $hexdata = unpack 'H*',$data;
    $integer = hex $hexdata;
    print unpack 'i', pack 'i',$integer;

or

    read(BINARYFILE, $three_bytes, 3);
    $four_bytes = '\x00' . $three_bytes;
    $integer = unpack 'i',$four_bytes;

or

    $sign_extend = ($three_bytes & "\x80\x00\x00") ? "\xff" : "\x00";
    $four_bytes = $sign_extend . $three_bytes;

(Obviously, little-endian machines and big-endian ones need to
handle those last two differently.)

	-Joe


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

Date: Tue, 12 Apr 2005 03:09:52 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Simple Encryption Script
Message-Id: <sLudnQGDkanpA8bfRVn-sA@comcast.com>

Nikos wrote:

> Until now i thoughs that if we ommited the doubles quotes in a print it 
> would be tha same as haveing it, meaning that the $variable or @array 
> would still be interpolated.
> 
> But why is that difference?

It was deliberately designed that way.
The perl special variable $" was created for that difference.

perl -le '@a=qw(a b c); $" = q{_*_}; print @a; print "@a"'
abc
a_*_b_*_c

	-Joe


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

Date: Tue, 12 Apr 2005 03:18:13 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Simple Encryption Script
Message-Id: <kaCdnf4zodj3PcbfRVn-uA@comcast.com>

Nikos wrote:

>>$toBeEncrypted =~ tr/a-zA-Z/b-zA-Za/;
> 
> a-z transletes to b-z
> A-Z msut to B-Z why you say A-Za ?

If you use tr/A-Z/B-Z/ then Y translates to Z, but the character
that Z translates to is not specified.  So either
	tr/A-Z/B-ZA/
or
	tr/A-Z/B-Z[/
is appropriate.

Your program should explicitly document what it does to
characters that are outside of the A-Z range.
	-Joe


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

Date: Tue, 12 Apr 2005 12:21:01 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: Simple Encryption Script
Message-Id: <slrnd5n88d.1vm.tassilo.von.parseval@localhost.localdomain>

Also sprach Sherm Pendley:

> John W. Krahn wrote:
>
>> That is because we are using operators which don't require parentheses 
>> instead of functions which do.  (The operators 'chr', '+' and 'ord' to be 
>> specific.)
>
> Um... Did I miss something? chr() and ord() are both listed in perlfunc. 
> And functions in general often don't require parentheses.

Perl is one of the few languages which blurs the distinction between
operators and functions. In most languages, a function is syntactically
different from an operator in that it requires parentheses. Therefore,
in C++ 'new' and 'delete' are operators. Also, operators very often are
in infix notation whereas a function is prefix with respect to its
arguments.

In Perl, the parentheses-rule-of-thumb does not exist. 

Tassilo
-- 
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);


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

Date: Tue, 12 Apr 2005 10:33:03 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Simple Encryption Script
Message-Id: <ztN6e.21540$yV3.19708@clgrps12>

Sherm Pendley wrote:
> John W. Krahn wrote:
> 
>> That is because we are using operators which don't require parentheses 
>> instead of functions which do.  (The operators 'chr', '+' and 'ord' to 
>> be specific.)
> 
> Um... Did I miss something? chr() and ord() are both listed in perlfunc. 
> And functions in general often don't require parentheses.

Functions without parentheses ARE operators.

perldoc perlfunc
[snip]
        Any function in the list below may be used either with or without
        parentheses around its arguments.  (The syntax descriptions omit the
        parentheses.)  If you use the parentheses, the simple (but occasionally
        surprising) rule is this: It looks like a function, therefore it is a
        function, and precedence doesn't matter.  Otherwise it's a list
        operator or unary operator, and precedence does matter.


perldoc perlop
[snip]
        Terms and List Operators (Leftward)

        A TERM has the highest precedence in Perl.  They include variables,
        quote and quote-like operators, any expression in parentheses, and any
        function whose arguments are parenthesized.  Actually, there aren't
        really functions in this sense, just list operators and unary operators
        behaving as functions because you put parentheses around the arguments.
        These are all documented in perlfunc.

        If any list operator (print(), etc.) or any unary operator (chdir(),
        etc.)  is followed by a left parenthesis as the next token, the
        operator and arguments within parentheses are taken to be of highest
        precedence, just like a normal function call.

        In the absence of parentheses, the precedence of list operators such as
        "print", "sort", or "chmod" is either very high or very low depending
        on whether you are looking at the left side or the right side of the
        operator.


cat Changes5.000
[snip]
     All functions have been turned into list operators or unary operators,
     meaning the parens are optional.  Even subroutines may be called as
     list operators if they've already been declared.


You are probably thinking of Perl4 where functions actually were functions.

:-)

John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 12 Apr 2005 14:13:44 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: Simple Encryption Script
Message-Id: <d3gah5$igr$1@nic.grnet.gr>

Joe Smith wrote:

> perl -le '@a=qw(a b c); $" = q{_*_}; print @a; print "@a"'
> abc
> a_*_b_*_c
> 
>     -Joe

I see. But how is this helpfull?
I cant think of a reason other that seperate the values of the @array 
when it comes to print "@array";


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

Date: Tue, 12 Apr 2005 14:21:44 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: Simple Encryption Script
Message-Id: <d3gb05$j01$1@nic.grnet.gr>

Joe Smith wrote:
> Nikos wrote:
> 
>>> $toBeEncrypted =~ tr/a-zA-Z/b-zA-Za/;
>>
>>
>> a-z transletes to b-z
>> A-Z msut to B-Z why you say A-Za ?
> 
> 
> If you use tr/A-Z/B-Z/ then Y translates to Z, but the character
> that Z translates to is not specified.  So either
>     tr/A-Z/B-ZA/
> or
>     tr/A-Z/B-Z[/
> is appropriate.

> Your program should explicitly document what it does to
> characters that are outside of the A-Z range.

Yes, now i think i understand. So the 'A' in tr/A-Z/B-ZA/ means that 
every other character outside the A-Z range should be changes to A

and to the 2nd example with [ ?


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

Date: 12 Apr 2005 11:24:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Simple Encryption Script
Message-Id: <d3gb69$lh9$4@mamenchi.zrz.TU-Berlin.DE>

Joe Smith  <joe@inwap.com> wrote in comp.lang.perl.misc:
> Nikos wrote:
> 
> >>$toBeEncrypted =~ tr/a-zA-Z/b-zA-Za/;
> > 
> > a-z transletes to b-z
> > A-Z msut to B-Z why you say A-Za ?
> 
> If you use tr/A-Z/B-Z/ then Y translates to Z, but the character
> that Z translates to is not specified.  So either

Ah but it is, just not explicitly:

               Otherwise, if the REPLACEMENTLIST is shorter than
               the SEARCHLIST, the final character is replicated
               till it is long enough.  If the REPLACEMENTLIST is

So "Z" is translated to "Z".

Anno


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

Date: Tue, 12 Apr 2005 11:54:22 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Simple Encryption Script
Message-Id: <Xns9636505B0697Dasu1cornelledu@127.0.0.1>

Nikos <hackeras@gmail.com> wrote in news:d3gah5$igr$1@nic.grnet.gr:

> Joe Smith wrote:
> 
>> perl -le '@a=qw(a b c); $" = q{_*_}; print @a; print "@a"'
>> abc
>> a_*_b_*_c
>> 
>>     -Joe
> 
> I see. But how is this helpfull?

If you need to ask that, then you do not see.

#! /usr/bin/perl

use strict;
use warnings;

my $data = [ [ Chicago => 1000 ], [ Tulsa => 2000 ] ];
output_sep_values($data, sepchar => "\t");
output_sep_values($data);


sub output_sep_values {
    my $data_ref = shift;
    my %args = (
        sepchar => ',',
        @_,
    );
    {
        local $" = $args{sepchar};
        for my $row (@{ $data }) {
            print "@{ $row }\n";
        }
    }
}   


__END__

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html


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

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


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 7967
***************************************


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