[9406] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3001 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 27 11:18:27 1998

Date: Sat, 27 Jun 98 07:02:04 -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           Sat, 27 Jun 1998     Volume: 8 Number: 3001

Today's topics:
    Re: [Q] split ///, $variable (Michael J Gebis)
    Re: [Q] split ///, $variable (Larry Rosler)
    Re: [Q] split ///, $variable (Dan Boorstein)
    Re: A kind of TAR with perl <davidc@selectst.com>
    Re: Array Elements (GILLY)
    Re: chroot without super user privilage? <rootbeer@teleport.com>
    Re: creating unique session id w/ perl (Plamen Petkov)
    Re: Ctrl+D not working; stuck in STDIN (Plamen Petkov)
        Doublequoting philosophy (Robert Friberg)
    Re: Doublequoting philosophy (Larry Rosler)
        Download file to browser via application/x-compress (RHooD)
        Download file to browser via application/x-compress (RHooD)
    Re: Field Sort without modules? (Bob Trieger)
    Re: Field Sort without modules? <ajohnson@gpu.srv.ualberta.ca>
        Finding the beginning of a loop (Abigail)
    Re: first language - last language (Bart Lateur)
    Re: first language - last language (M.J.T. Guy)
    Re: Flames.... (Franz Kaufmann)
    Re: growing array size:  Is this a bug? (Gabor)
    Re: growing array size:  Is this a bug? (Kevin Reid)
    Re: How to check variables exists in a string <ljz@asfast.com>
        HTML pages with Perl <jaap.prins@mail.which.net>
    Re: HTML pages with Perl (Abigail)
    Re: javascript and perl <kosenko@netwood.net>
    Re: Linked list and a code challenge (M.J.T. Guy)
    Re: LWP::Simple on NT with a proxy / fire wall <davidc@selectst.com>
    Re: LWP::Simple on NT with a proxy / fire wall <davidc@selectst.com>
        matching case-insensitive 8-bit characters (Plamen Petkov)
    Re: matching case-insensitive 8-bit characters (Honza Pazdziora)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 27 Jun 1998 05:41:31 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: [Q] split ///, $variable
Message-Id: <6n20mb$3h3@mozo.cc.purdue.edu>

Ryan Snowden <ryan@steelplan.com.au> writes:
}I have a nice filename fully pathed like:
}    /u1/s/blah/path/tothe/wonderful/pathname//filename.zip

}So, in order to strip everything down and get the filename

#You're right: a regexp is probably easier than split.
#Untested code, so cut me some slack.  It's close, though.
$foo='/some/funky/path';

#Suck up everything at the end of a string that's not a slash:
$foo =~ m</([^/])+)>;
print "The file is $1\n";

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Sat, 27 Jun 1998 06:28:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: [Q] split ///, $variable
Message-Id: <MPG.ffe93387c2b65119896f8@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <6n20mb$3h3@mozo.cc.purdue.edu>, Michael J Gebis 
<gebis@albrecht.ecn.purdue.edu> says...
 ...
> #Suck up everything at the end of a string that's not a slash:
> $foo =~ m</([^/])+)>;

  $foo =~ m<([^/])+)$>;

You need the anchor to avoid snagging the *first* path segment.  This 
regex also handles when there are *no* slashes (which was not the problem 
statement, I know, but it's also one character shorter :-).

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


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

Date: Sat, 27 Jun 1998 13:56:38 GMT
From: danboo@negia.net (Dan Boorstein)
Subject: Re: [Q] split ///, $variable
Message-Id: <3594f923.170055235@snews.negia.net>

On 27 Jun 1998 05:16:58 GMT, cberry@cinenet.net (Craig Berry) wrote:

>Russ Allbery (rra@stanford.edu) wrote:
>: Ryan Snowden <ryan@steelplan.com.au> writes:
>: 
>: > I have a nice filename fully pathed like:
>: 
>: >     /u1/s/blah/path/tothe/wonderful/pathname//filename.zip
>: 
>: > So, in order to strip everything down and get the filename
>: > (filename.zip), I figured I'd split it up, save it into an array, and
>: > then get value number [9]..  i think... anyway, /// won't do it
>: > obviously.  How do I make the / in the middle of the / / be the split
>: > character.
>: 
>: @path = split (/\/+/, $filename);
>: 
>: should do it.  (I'm not sure if you can use the m%/+% syntax in the regex
>: that split uses, to avoid leaning toothpick syndrome.)
>
>And then use $path[-1] to get the last element, which is the part you're
>interested in.

and if you don't need the rest of the path info, you could combine
them and just use:

$file = (split '/', $filename)[-1];

cheers,

dan boorstein


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

Date: Sat, 27 Jun 1998 21:25:45 +1000
From: David Coldrick <davidc@selectst.com>
Subject: Re: A kind of TAR with perl
Message-Id: <3594D6B9.B0612A9@selectst.com>

Could it be that Jean-Paul is not on a UNIX system? 

Regards,
David

Abigail wrote:
> 
> Jean-Paul SALIOU (saliou@bsboulot) wrote on MDCCLIX September MCMXCIII in
> <URL: news:6mt4b3$o2i@btmpjg.god.bel.alcatel.be>:
> ++
> ++ Hello,
> ++
> ++ I'm looking for a script in perl which has the
> ++ same effect than the unix tar.
> 
> There is of course a module on CPAN, but what is wrong with
> 
>       system "tar", @options; ?
> 
> Abigail
> --
> perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")\n-> define ("foldoc", "perl")) [0] -> print'


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

Date: Sat, 27 Jun 1998 12:09:15 GMT
From: mingtian@hanmail.net (GILLY)
Subject: Re: Array Elements
Message-Id: <3594dc79.14954536@usenet.kornet21.net>

Tom Phoenix <rootbeer@teleport.com> wrote:

>    sub col_counts {
>	# Given a reference to an array of (references to) arrays,
>	# this returns an array giving the sizes of the referenced
>	# arrays. 
>	map { scalar @$_ } @{ +shift };
>    }
 ..

what's the meaning of "+" before "shift"?
where can i find the man page about that?
perlop?


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

Date: Sat, 27 Jun 1998 07:22:22 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: chroot without super user privilage?
Message-Id: <Pine.GSO.3.96.980627001820.20167V-100000@user2.teleport.com>

On Sat, 27 Jun 1998, Andrew Chang wrote:

> Newsgroups: comp.lang.perl, comp.lang.perl.misc

If your news administrator still carries comp.lang.perl, please let him
or her know that that newsgroup has not existed since 1995. If you
have such an outdated newsgroup listing, you are probably missing out
on many other valid newsgroups as well. You'll be doing yourself and
many others a favor to use only comp.lang.perl.misc (and other valid
Perl newsgroups) instead.

> I would like to assign a subdirectory to be the root for those
> operations in my shell (same as what chroot does) so that user programs
> compiled and executed within the shell cannot have access to anything
> outside of the designated root. 

If your system doesn't let non-root users access the chroot system call,
there's no way for Perl to do it. But perhaps you can convince your system
administrator to let you make a chroot "wrapper" for you to use. This
would be a small program which would be setuid to root so that it could
chroot and launch another program. 

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 27 Jun 1998 11:10:27 GMT
From: plamendp@techno.link.com (Plamen Petkov)
Subject: Re: creating unique session id w/ perl
Message-Id: <3597ce45.77765083@news.techno-link.com>

On Fri, 26 Jun 1998 17:52:40 -0400, Kyle Poquette <poquk@ils.unc.edu>
wrote:

>
>I am trying to create a unique session id to be assigned to each user of
>my web site.  Now, I realize that I can create a unique identifier using a
>combination of the time function and the process ID.  However, I plan to
>later user this session id to reference confidential information about the
>user of the session in a database, and I don't want the session id to be
>guessed easily.
>
>Is there a way to create a session id (using perl, of course) which cannot
>easily be guessed, and which will generate a unique string for each
>invocation of the cgi script (which could possibly be running multiple
>times per second)?  How do the larger shopping cart sites like amazon.com
>create their session ids?

Use  <random-generated-string> as a session ID plus the current
process ID (_$$). Use it as a file name. Keep track (on disk) of cart
ID's generated.

This is a code from Selena Sol's Web Store (under GNU General Public
License) [selena@eff.org, http://www.eff.org/~erict]  generating an
unique cart ID.


###
    srand (time|$$);
    $cart_id = int(rand(10000000));
    $cart_id .= "_$$";
    $sc_cart_path = "${cart_id}.cart";
###

You have to check if there is already a cart with the same ID recorded
earlier. If YES, "rand" again,  If NO, record the ID; don't forget to
"expire" the carts recorded (i.e. delete old card ID's after some
expire period).

plamen.


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

Date: Sat, 27 Jun 1998 10:35:57 GMT
From: plamendp@techno.link.com (Plamen Petkov)
Subject: Re: Ctrl+D not working; stuck in STDIN
Message-Id: <3594be4f.73678429@news.techno-link.com>

On 27 Jun 1998 03:10:30 GMT, wings <xuchu@iscs.nus.edu.sg> wrote:

>
>what i mean is that on Windows 95, say the input is as follows:
>aa
>bb
>cc
>the output is supposed to be:
>cc    ---> this line lost in Windows95!
>bb
>aa
>
>however, as above, the last line of input is lost in win95! 
>what's the problem?


Hmm... this sample works fine for me: here is perl 5.004_2 for W95. 
Nothing is lost, every line I enter is displayed (reversed of course).
However, I finish the input with ^Z not ^D. ^D doesn't work at ALL.

BTW, if   while-condition is w/o angles, i.e.

while (@strings) {
 ...

as Larry suggested, I DO lose the last input line too(the first to be
printed out). WITH angles, everything is OK. Can't figure out why ?!





See the following examples (nevermind what is your input; watch out
the OUTPUT). Here is perl 5.004_2 Win32. ^Z used for end of input.

###  ex 1
@strings=<STDIN>;
print "Hello!\n";
### I got NO OUTPUT at ALL

### ex 2 
### note the  FIRST  '\n'   in Hello string !!!!
@strings=<STDIN>;
print "\nHello!\n";
### I got what I expected, i.e.  "Hello!"


### ex 3
### now 'strings' is NOT an array
### note the MISSING  '\n', i.e. may be we will get no output
$strings=<STDIN>;
print "Hello!\n";
### hmm.., I got what I want, i.e.  "Hello!"


This is kind of 'flushing' problem I think... 

regards
plamen.

A Perl Newbie.


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

Date: Sat, 27 Jun 1998 11:51:45 GMT
From: robban@insult.com (Robert Friberg)
Subject: Doublequoting philosophy
Message-Id: <3594d7c9.13453427@news.appman.com>


Many perl hackers use double quotes when they don't have to.

The documentation is full of stuff like:

   print "Password: ";
   "ab" =~ /a(.*)b/;
   die "/etc/games is no good";
   die "/etc/games is no good, stopped";
   require "ioctl.ph";

Isn't there a penalty of at least one scan on those strings?
Please don't tell me the penalty is so insignificant that it 
doesn't matter because that's not the point. I might suggest
you start using, for ex:

   print reverse reverse "Password: ";
   
   :)

^~v^~v^~v^~v^~v^~v^~v^~v^~v^~v^~v^~v^~v^~v
*
*   Robert Friberg
*   robban@insult.com =~ s/i/it-ko/;
*   C/Perl/Delphi/SQL developer
*


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

Date: Sat, 27 Jun 1998 06:42:04 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Doublequoting philosophy
Message-Id: <MPG.ffe968aa7785f9896f9@nntp.hpl.hp.com>

In article <3594d7c9.13453427@news.appman.com>, Robert Friberg 
<robban@insult.com> says...
> 
> Many perl hackers use double quotes when they don't have to.
> 
> The documentation is full of stuff like:
> 
>    print "Password: ";
>    "ab" =~ /a(.*)b/;
>    die "/etc/games is no good";
>    die "/etc/games is no good, stopped";
>    require "ioctl.ph";
> 
> Isn't there a penalty of at least one scan on those strings?
> Please don't tell me the penalty is so insignificant that it 
> doesn't matter because that's not the point.

You're right.  That's not the point.

A good point is that using '...' consistently when there is no 
interpolation immediately draws attention to "..." when there *is* 
(should be) interpolation (or interpretation of escape sequences other 
than \\ or \').

I've switched my null strings from '' to "" though, because it's too easy 
to eyeball '' as ".

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


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

Date: Sat, 27 Jun 1998 13:33:43 GMT
From: chat-world@gmx.net (RHooD)
Subject: Download file to browser via application/x-compress
Message-Id: <3594f336.9759974@news.infopool.com>

Hi !

I have a big problem !!!

I have written a script who download a file from a remote server,
but when i click in a browser on the href, in the savebox ,
the name of the perlscript are standing !!!!

how can i tell the browser that the filename is xxx.zip ?????

please answer fast !!! THX

My ICQ - UIN is 385902 !!!


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

Date: Sat, 27 Jun 1998 13:37:17 GMT
From: chat-world@gmx.net (RHooD)
Subject: Download file to browser via application/x-compress
Message-Id: <3596f585.10350993@news.infopool.com>

Hi !

I have a big problem !!!

I have written a script who download a file from a remote server,
but when i click in a browser on the href, in the savebox ,
the name of the perlscript are standing !!!!

how can i tell the browser that the filename is xxx.zip ?????

please answer fast !!! THX

My ICQ - UIN is 385902 !!!


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

Date: Sat, 27 Jun 1998 12:35:53 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Field Sort without modules?
Message-Id: <6n2p30$9a1$1@ligarius.ultra.net>

[ posted and mailed ]

Trent Hare <trent@jps.net> wrote:
-> Abigail wrote:
-> > ++ Looking for field sorting without modules installed...
-> > ++ (ie)
-> > ++ an comma separated ascii file , sorted by field[2] (after the split)
-> > ++ Clues anyone?
-> > 
-> > Yes. It's called FAQ
-> > 
-> > Abigail
-> > --
-> > perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
-> 
-> 
-> Oh, I'm sorry to have disturbed you Abigail. I've been reluctant to post
-> a message (question) just for this reason. I have been reading FAQ's and
-> tutorials for 3 days trying to find an answer to this question.
-> 
-> Several very kind people (David Black, and Dean Inada) have sent
-> examples to me via e-mail, and thank God for "spider"! Very appreciated!


If those others sent sent you the answer but didn't tell you it was in the 
FAQs then they helped you a lot less than Abigail did. That fish thing.

-> If you would be so kind to tell me *which Perl FAQ you are referring to
-> I'd appreciate it. I'm only a little stupid.... maybe I'll be able to
-> find it with a small clue.

If you have perl on your system, you have the documentation including the 
FAQs. 
look in      pathtoperl/lib/Pod
or if html   pathtoperl/html/lib

-> Hoping someday to be as smart as you,

Don't be so fast to jump on somebody because they tell you to check the FAQs 
or documentation. They are trying to help you help yourself.

HTH

Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-286-0591
  and let the jerk that answers know that his
  toll free number was sent as spam. "


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

Date: Sat, 27 Jun 1998 07:20:46 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Field Sort without modules?
Message-Id: <3594E39E.13C7317F@gpu.srv.ualberta.ca>

Trent Hare wrote:
!
! Abigail wrote:
! > ++ Looking for field sorting without modules installed...
! > ++ (ie)
! > ++ an comma separated ascii file , sorted by field[2] (after the split)
! > ++ Clues anyone?
! >
! > Yes. It's called FAQ
! >
[snip] 
! 
! Oh, I'm sorry to have disturbed you Abigail. I've been reluctant
! to post a message (question) just for this reason. I have been
! reading FAQ's and tutorials for 3 days trying to find an answer
! to this question.
[snip] 
! If you would be so kind to tell me *which Perl FAQ you are
! referring to I'd appreciate it. I'm only a little stupid....
! maybe I'll be able to find it with a small clue.

perlfaq4.pod:=head2 How do I sort an array by (anything)?

of course, it won't necessarily tell you how to sort your
particular ascii file by field[2] ... but it most certainly gives
you the tools to do so.

regards
andrew


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

Date: 27 Jun 1998 10:57:43 GMT
From: abigail@fnx.com (Abigail)
Subject: Finding the beginning of a loop
Message-Id: <6n2j77$rn0$1@client3.news.psi.net>



Snowhare (snowhare@devilbunnies.org) wrote:
++ Ah. Here is a code challenge for everyone:
++
++ Given a finite linked list similiar the one I drew above, determine
++ if a *loop* exists in the linked list with the smallest possible  
++ use of memory (scratch variables) and CPU (in other words the
++ lowest order computational complexity). You should return the
++ list element where the loop occurs ('b' in the example above) or
++ null if no loop is present. The linked list is in the form
++ of a hash ($hsh{'1022'} => '3421'; $hsh{'3421'} => '54532';, and
++ so on). The loop may be any size up to and including the entire
++ linked list or as small as 2 elements linked together at the tail.
     
  
As readers to rec.puzzles will know, there are 2 algorithms with minimal
overhead that determine whether a linked list contains a loop. The first
algorithm uses pointer swapping; the list is traversed, and while traversing,
the pointers are reversed. There is a loop in the list, iff you terminate
at the beginning of the list.

The second algorithm is the 'chasing pointers' algorithm. It will leave
the list intact. The idea is to have 2 pointers walking the list, with
one pointer advancing one node per iteration, the other advancing two
nodes per iteration. If there is a loop, the fast one will overtake the
slow one - and if there is no loop, the fast one will hit the end of the
list.

The requirement to determine the beginning of the loop is an interesting
twist. I have not been able to modify either of the described algorithms
such that they will report the beginning of the list. However, if we
combine both algorithms, we can find the answer - and still have minimal
overhead.


Consider the following linked list with a loop:

                B
  H *-->*-->*-->*-->*-->*-->*-->*
                ^               |
                |               v
                *<--*<--*<--*<--*
                            M

The goal is to find B - and we can find B if we know how many nodes away
it is from H, the head of the list.

If we start at the head with the chasing pointers, the pointer will
eventually meet at some point in the loop, say point M; assume M != B. We
can know easily determine the length of the loop M -> B -> M. Call this
lenght l.  We can now also determine how far away M is from H. Call the
length of the path H -> B -> M m.

Now we perform the other algorithm, and switch pointers. Since the
list between H and B will be traversed twice, those pointers will end
up in the same direction:

                B
  H *-->*-->*-->*<--*<--*<--*<--*
                |               ^
                v               |
                *-->*-->*-->*-->*
                            M

Now we can again determine the length H -> B -> M (which is a different
path). Call this length k.

The length L of the path H -> B can now be found by the relationship

    2 * L = k + m - l.

Given L, it is only a matter of counting from H to find B.

The case M == B can be determined while switching the pointers. While
switching pointers, all nodes on the path H -> B will be visited twice,
including H and B, and all other nodes only once. Since we know M is
in the loop, we can keep track how often we visit M. If we visit M twice,
M has to be equal to B and we have found the answer.


The algoritm below uses 6 scratch variables: 4 scalars as list pointers,
one scalar to keep track of k + m - l, and one to count how often we've
visited M during the pointer switching. The latter could have been
avoided by increasing the code (it will only have 3 possible states).

The running time is clearly bounded by O (n) (with n nodes in the list).
It is not hard to see that each node is visited at most 6 times, and
I believe careful analysis will show at most 5 n + c visited nodes,    
for some c > 0.


#!/usr/local/bin/perl -w

use strict;


# Assume $hash {0} gives the beginning of the list, and 'undef'
# signals the end (if there is no loop).
# Also assume all labels are numerical.
my %hash = (
    0  =>  1,
    1  =>  2,
    2  =>  3,
    3  =>  4,
    4  =>  5,
    5  =>  6,
    6  =>  7,
    7  =>  3     # Change to undef for no loop.
);

# Assume the list terminates with a value of undef, and the start
# of the list is found at $hash {0};

# Two scalars overhead.
my $fast = my $slow = $hash {0};

# First, determine a point in the list, if any.
while (defined $fast) {# Advance pointers.
    $fast = $hash {$fast}; last if !defined $fast || $fast == $slow;
    $fast = $hash {$fast}; last if !defined $fast || $fast == $slow;
    $slow = $hash {$slow}
}

do {print "No loop found\n"; exit} unless defined $fast;

# Now, find the length of the loop.
my $l = 0;
do {$l --; $fast = $hash {$fast}} while $fast != $slow;

# Now, find the length of the list till the point the pointers met.
$fast = 0;
while ($fast != $slow) {$l ++; $fast = $hash {$fast}}

# Reverse the list.
$fast    = 0;
my $prev = undef;
my $tmp  = 0;

while (defined $fast) {
    if ($fast == $slow && ++ $tmp > 1) {
        # B == M.
        print "Loop starts at $fast\n";
        exit;
    }
    my $next = $hash {$fast};
    $hash {$fast} = $prev;
    $prev = $fast;
    $fast = $next;
}

# Walk to the meeting point again.
$fast = 0;
while ($fast != $slow) {$l ++; $fast = $hash {$fast}}


# Now we know how far from the beginning the loop starts.
$l /= 2;

$fast = 0;
$fast = $hash {$fast} while $l --;

print "Loop starts at $fast\n";


__END__
-- 
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: Sat, 27 Jun 1998 11:10:36 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: first language - last language
Message-Id: <3597d1d3.9899627@news.tornado.be>

birgitt@my-dejanews.com wrote:

>  What is the *last* language all you experts would ever want to
>  deal with ? Don't say there isn't one.

Cobol, ADA, C. Popular for some mysterious reason taht escapes me
completely. I'd prefer Smalltalk, Lisp, FORTH, Modula, APL, ... any
time, although I've not done any real work using these.

And I just can't grasp Prolog.

	Bart.


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

Date: 27 Jun 1998 11:34:37 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: first language - last language
Message-Id: <6n2lcd$7mo$1@pegasus.csx.cam.ac.uk>

In article <6mrfv3$2p7$1@nnrp1.dejanews.com>,  <birgitt@my-dejanews.com> wrote:
>
>  What is the *last* language all you experts would ever want to
>  deal with ? Don't say there isn't one.

If you mean "most obscure" or "most difficult to program in", it'd
be difficult to beat the original program input form for the Manchester
Mark I.

Programs were written in binary (of course).   But they were coded
by taking the bits in fives and writing the character with that bit
pattern.    Oh, and the binary numbers were written least significant
bit first.

And people complain that Perl looks like line noise.


Mike Guy


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

Date: Sat, 27 Jun 98 14:28:05 gmt
From: ws97-868@wsrz1.wiso.uni-erlangen.de (Franz Kaufmann)
Subject: Re: Flames....
Message-Id: <6n2ogm$e0$1@rznews.rrze.uni-erlangen.de>

On 20 Jun 1998 19:09:04 GMT, Tom Christiansen says...
>
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc, 
>    gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
>:The faq is big.  The docset for perl is big.  
>
>grep.  man -k.  less.  find.  whatever.
>
>If you haven't figured out how to search for things,
>turn off your computer until you can buy yourself
>a pet trainer.
>
>--tom
>-- 
>A woman needs a little more weird today than normal.  --Andrew Hume

>From someone that seems to be so proficient with perl,it could be 
expected to be a little more patient.

Of course there are FAQ4s a.s.o but the amount of text,as useful it may 
be for every aspect of perl programming,is often too comprehensive.
Apart from this,Mr Christiansen seems to have more fundamental problems:

A tone of voice like he uses is impolite ,brazen and totally unnecessary.
It seems as if he is continually in stupor because of being enchanted by 
his own brilliance.Why the heck is he replying ,only to say "I wont tell 
you anything look for yourself".The answer is,he is replying,because he 
want4s to show off.



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

Date: 27 Jun 1998 11:26:50 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: growing array size:  Is this a bug?
Message-Id: <slrn6p9lr2.3do.gabor@localhost.vmunix.com>

In comp.lang.perl.misc, Tom Phoenix <rootbeer@teleport.com> wrote :
# On 26 Jun 1998, unknown wrote:
# 
# > My perl version is
# >   This is perl, version 5.001
# >  
# >           Unofficial patchlevel 1m.
# 
# If you think you have found a bug in a version of Perl which is older than
# the Spice Girls, you should probably try upgrading to a newer version. :-)
# 
# Good luck!

That's the best comeback I've seen in a long time. :)


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

Date: Sat, 27 Jun 1998 09:43:34 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: growing array size:  Is this a bug?
Message-Id: <1db8q0d.re2lvr12up6j2N@slip166-72-108-46.ny.us.ibm.net>

unknown <kesey@globe.ece.utexas.edu> wrote:

> I found what I think may be a bug in perl.  I wrote this simple
> program to demonstrate the situtation:
> 
<snip>
> 
> On my system, this generates the output:
> 
> 0 LAST ELEM 1
> 1 LAST ELEM 1
> 2 LAST ELEM 1
> 3 LAST ELEM 1
> 4 LAST ELEM 9
> 5 LAST ELEM 9
> 
> The problem is that the size of the list grows due to the function call
> 
>   &someSub (3, $arr[9]);
> 
> I thought that referring to an list element past the end of the list
> does not increase the size of the list.  Notice that using the same
> parameters with the built-in function 'reverse' does not grow the
> list.  Also, putting the undefined list element first in the parameter
> list does not grow the list.
> 
> An unrelated problem I found is that the 'sort' using the undefined
> list element causes a segmentation fault on my system.
> 
> My perl version is
>   This is perl, version 5.001
>  
>           Unofficial patchlevel 1m.

In my system, it prints:

0 LAST ELEM 1
1 LAST ELEM 1
2 LAST ELEM 1
3 LAST ELEM 1
4 LAST ELEM 1
5 LAST ELEM 1

and does not cause any error.

perl -v:


This is perl, version 5.004

Copyright 1987-1997, Larry Wall
Macintosh port Copyright 1991-1998, Matthias Neeracher


-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: 27 Jun 1998 09:41:12 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: How to check variables exists in a string
Message-Id: <ltogvfotc7.fsf@asfast.com>

Tom Phoenix <rootbeer@teleport.com> writes:

> On Fri, 26 Jun 1998, Tony Edwardson wrote:
> 
> > Anyone got any ideas how to check that perl variables embeded in a
> > string are defined?
> 
> That's what the defined() function tests.
> 
> > I want to expand the embeded perl veriables with their values in some
> > way such that I can check that each variable is defined
> 
>     if (grep !defined($_), $group, $book, $yy, $mmm) {
> 	warn "Oops, at least one of them isn't defined.\n";
>     } else {
> 	$scalar="/home/user/$group/$book/$yy$mmm$yy";
>     }

I'm not sure whether this is what you (Tony Edwardson) are thinking
of, but perhaps you're wondering if there's a way in Perl to make use
of something similar to the following sh/bash/ksh construct:

  xxx="Result: ${var:-UNDEFINED}"

In case something like this is what you're looking for in Perl, one way
to accomplish something similar is ...

  $xxx = "Result: ${\eval{defined($var)?$var:'UNDEFINED'}}";  

This can be made a bit more compact if you've defined the following
function:

  sub d {
    my $var = shift;
    return (defined($var) ? $var : shift);
  }

Then, you could do it this way:

  $xxx = "Result: ${\d($var,'UNDEFINED')}";  

And I'm confident that there are other variations on this general,
interpolation-based approach which also would work.

This is verbose enough (and in the case of my first example,
Byzantine-looking enough) to encourage most people to stay away in
droves and use an `if' construct (such as Tom's, above) or certain
other approaches that don't rely on this aspect of interpolation.  But
then again, if you have lots of embedded variables in a single string,
and each would need to be handled in this manner, then perhaps you
might actually find this approach to be useful.

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: Fri, 26 Jun 1998 19:18:33 +0100
From: Jaap Prins <jaap.prins@mail.which.net>
Subject: HTML pages with Perl
Message-Id: <3593E5F9.3848F1DF@mail.which.net>

Hello,
Is it possible to produce an HTML page with a CGI-Perl programme
using Perl 5.003(!)? If so, How?
Thanks in advance
Jaap Prins



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

Date: 27 Jun 1998 11:26:44 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: HTML pages with Perl
Message-Id: <6n2ktk$s50$3@client3.news.psi.net>

Jaap Prins (jaap.prins@mail.which.net) wrote on MDCCLX September MCMXCIII
in <URL: news:3593E5F9.3848F1DF@mail.which.net>:
++ Hello,
++ Is it possible to produce an HTML page with a CGI-Perl programme
++ using Perl 5.003(!)? If so, How?

Yes.

perldoc -f print



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Sat, 27 Jun 1998 00:31:25 -0700
From: Peter Kosenko <kosenko@netwood.net>
To: Inge Soetens <soetensi@se.bel.alcatel.be>
Subject: Re: javascript and perl
Message-Id: <35949FCB.1B00@netwood.net>

I don't see why not.  You can submit a URL with JavaScript; and you can
attach a query string to it.  So, if you wanted to call a Perl script,
you would set:

	window.location.href =
"/cgi-bin/whatever.pl?name1=value1&name2=value2";

I presume that this is what you are asking, since it is clear that you
can call a Perl script directly from a form.

Peter Kosenko

Inge Soetens wrote:
> 
> Hi,
> 
> Can anyone tell me....
> Is it possible to call a perl procedure from a javascript function ?
> 
> Thanks

-- 
     |===============================================================|
     | Peter Kosenko, Editor    Email: mailto:kosenko@netwood.net    |
     | 1448-1/2 12th St.        URL: http://www.netwood.net/~kosenko |
     | Santa Monica, CA 90401   Phone: (310) 451-7208                |
     | Netwood Design Center    URL: http://ndc.netwood.net/         |
     |===============================================================|

"Man is a rational animal.  He can think up a reason for anything he
wants to believe."--Benjamin Franklin


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

Date: 27 Jun 1998 11:23:48 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Linked list and a code challenge
Message-Id: <6n2ko4$795$1@pegasus.csx.cam.ac.uk>

Snowhare <snowhare@devilbunnies.org> wrote:
>Given a finite linked list similiar the one I drew above, determine
>if a *loop* exists in the linked list with the smallest possible
>use of memory (scratch variables) and CPU (in other words the
>lowest order computational complexity). You should return the
>list element where the loop occurs ('b' in the example above) or
>null if no loop is present. The linked list is in the form
>of a hash ($hsh{'1022'} => '3421'; $hsh{'3421'} => '54532';, and
>so on). The loop may be any size up to and including the entire
>linked list or as small as 2 elements linked together at the tail.

The standard algorithm to find whether or not there is a loop is O(1)
space and O(N) time, which is clearly best possible:

     Set p1 and p2 pointing to the start of the list.
     At each step, advance p1 by one step, and p2 by two.
     If we fall off the end, there is no loop.
     If we find p1 = p2 at any stage, we have a loop.

But that doesn't identify the start of the loop.   We need to be a bit
more elaborate:

     When p1 = p2, step p2 until it is again equal to p1.
     Then the number of steps x is the size of the loop.
     Now set p1 to the start of the list and p2 x steps along.
     Step p1 and p2 together until they are equal.   This is the
     first element of the loop.  (Note p1 and p2 may be equal
     initially, if the list is all loop.)

That's still O(1) space and O(N) time.


Mike Guy


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

Date: Sat, 27 Jun 1998 20:46:01 +1000
From: David Coldrick <davidc@selectst.com>
Subject: Re: LWP::Simple on NT with a proxy / fire wall
Message-Id: <3594CD69.B272389C@selectst.com>

Thanks, Gisle. I'll try it.

Gisle Aas wrote:
> 
> I think you need 'http://n.n.n.n:80' (and the ':80' is redundant).
> 
> --
> Gisle Aas


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

Date: Sat, 27 Jun 1998 22:58:15 +1000
From: David Coldrick <davidc@selectst.com>
Subject: Re: LWP::Simple on NT with a proxy / fire wall
Message-Id: <3594EC67.7304D1CB@selectst.com>

Gisle,

Well spotted. 'http://' did it (without the port).

Thanks,
David

Gisle Aas wrote:
> 
> David Coldrick <davidc@selectst.com> writes:
> 
> > What I'd really like confirmed is that a proxy spec of 'n.n.n.n:80' should
> > work.
> 
> I think you need 'http://n.n.n.n:80' (and the ':80' is redundant).
> 
> --
> Gisle Aas


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

Date: Sat, 27 Jun 1998 10:35:59 GMT
From: plamendp@techno.link.com (Plamen Petkov)
Subject: matching case-insensitive 8-bit characters
Message-Id: <3595c87a.76281193@news.techno-link.com>

Hi,

How to  match case-insens. 8-bit characters in RE?? 

plamen.


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

Date: Sat, 27 Jun 1998 11:53:30 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: matching case-insensitive 8-bit characters
Message-Id: <adelton.898948410@nemesis>

plamendp@techno.link.com (Plamen Petkov) writes:

> Hi,
> 
> How to  match case-insens. 8-bit characters in RE?? 

Check man perllocale(1).

Hope this helps,

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
Sorry if this email reaches you late/after deadline, I've been gone for 4 days


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

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

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