[8465] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2082 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 12 11:07:47 1998

Date: Thu, 12 Mar 98 08:00:38 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 12 Mar 1998     Volume: 8 Number: 2082

Today's topics:
    Re: A to lower case. (Tor Iver Wilhelmsen)
    Re: c.l.p.mod and TPI <merlyn@stonehenge.com>
        Debugger messages <smithr@lexma.meitech.com>
    Re: EEEEEK, trying to work with perl and Microsoft!! <bw@pindar.com>
    Re: Examples of REGEXP ? mgscheue@io.com
    Re: help with hash <jdf@pobox.com>
        How to read whole HTML content from Web pages? (Guy St-Amant)
    Re: Is there a way to dynamically link subroutines? (Andrew M. Langmead)
        libwww WIN32 MODULE <krisvg@netit.be>
        lower case fails on strings with newlines?? kevin@cmhcsys.com
        mkdir() and umask <object01@cc.gatech.edu>
    Re: mkdir() and umask <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: mkdir() and umask <object01@cc.gatech.edu>
    Re: mkdir() and umask <object01@cc.gatech.edu>
        MsgBox <mike.battaglia@pricer.com>
    Re: Problem with "goto" in Perl (Tor Iver Wilhelmsen)
    Re: Q about FAQ answer - Random line from file (David Wall)
    Re: QUIZ: answer and hash slice tutorial <barnett@houston.Geco-Prakla.slb.com>
        read() vs sysread() in Socket Library (Peter Caffin)
    Re: replacing/removing a escape secquence <min.shin@rw.sni.de>
    Re: Speed of sort routine vs. one-by-one compare   (123 (Matija Grabnar)
    Re: splitting by one or more spaces <barnett@houston.Geco-Prakla.slb.com>
    Re: system(command) = fork + exec(command)? kill parent <borisg@ml.com>
        Weak references? <jll@skynet.be>
    Re: What is PERL? Learn JAVA instead? (I R A Aggie)
    Re: Where can I get the PERL for Windows NT and 95? <ludlow@us.ibm.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 12 Mar 1998 14:52:39 GMT
From: toriw@online.no (Tor Iver Wilhelmsen)
Subject: Re: A to lower case.
Message-Id: <3510f452.17277475@news.eunet.no>

On Tue, 10 Mar 1998 20:54:40 +0100, Mario Soares
<mario_soares@hotmail.com> uttered:

>make the conversion ~ /[A-Z]/ to ~ /[a-z]/ in all submited query, 
>but not for this kind of characters.

For ISO-Latin-1 (and possibly others), lowercase versions are the
value of the uppercase letter plus 0x20 (32).

-- 
"Between our dreams and actions lies this world."
   - Bruce Springsteen, "Dead Man Walking"
Tor Iver Wilhelmsen       toriw@online.no


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

Date: 12 Mar 1998 08:07:41 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: c.l.p.mod and TPI
Message-Id: <8cen08kkw2.fsf@gadget.cscaper.com>

>>>>> "Ronald" == Ronald J Kimball <rjk@coos.dartmouth.edu> writes:

Ronald> Okay, so why must someone who wants to post an ad pass it
Ronald> through TPI?  Why does TPI get exclusive say on which ads can
Ronald> be posted to c.l.p.mod and which ones can't?

Because it makes sense.  TPI is the Larry-sanctioned non-profit body
that supports Perl by providing glue.  As a non-profit, TPI board
members must abstain on actions for which they have a commercial
interest.  Therefore, it's reasonably safe as a co-moderator for CLPA.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 173 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Thu, 12 Mar 1998 10:56:29 -0500
From: "Ray Smith" <smithr@lexma.meitech.com>
Subject: Debugger messages
Message-Id: <6e90bk$bg7$1@client2.news.psi.net>

While debugging a script I get the following error message.  I can't find
"Can't upgrade ..." any where in *.pl, *.pm files in the Perl distribution
files.  The script appears to work ok when not under debugging (-d).  Any
ideas?

Captured (partial) Session:

s:/crs/r105to11[137] sdflog -e -lshort2.sdl
Loading DB routines from perl5db.pl version 1
Emacs support available.
Enter h or `h h' for help.
main::(m:/p267-006/tools/sdflog.ksh:14):
14:     eval 'exec perl -d -w -S ${0}.ksh ${1+"$@"}'
15:     if 0;
  DB<1> c
Can't upgrade that kind of scalar at d:\perl5_402\lib/perl5db.pl line 1131.
        Tk::Widget::AUTOLOAD('Tk::Frame=HASH(0xc66318)', '-text', 'File',
'-unde
rline', 0) called at m:/p267-006/tools/SdfLogEd.pm line 44
        SdfLogEd::edit('SdfLog=SCALAR(0xa85220)', 'short2.sdl') called at
m:/p26
7-006/tools/sdflog.ksh line 344
        main::edit_log('SdfLog=SCALAR(0xa85220)', 'short2.sdl') called at
m:/p26
7-006/tools/sdflog.ksh line 236
DB::fake::(d:\perl5_402\lib/perl5db.pl:2084):
2084:     "Debugged program terminated.  Use `q' to quit or `R' to
restart.";
  DB<1>
 which I can't find in any *.pl, *.pm file in the distribution.  I




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

Date: Thu, 12 Mar 1998 13:25:37 -0000
From: "Bob Wilkinson" <bw@pindar.com>
Subject: Re: EEEEEK, trying to work with perl and Microsoft!!
Message-Id: <3507e376.0@nnrp1.news.uk.psi.net>


Jason Hazzard wrote in message ...

>I have written some scripts in PERL, they are actually CGI scripts which
>use DBM to create and read database files.  I have used them sucessfully
>on various systems with NDBM GDBM etc....  But all these systems were
>UNIX servers.
>
>My question is, can these scripts run on a Microsoft IIS server?  Are DBM
>routines installed with perl, or are they native to UNIX only?  They
>didnt seem to want to work for me!  And how do I find out what packages I
>can use... GDBM seems to be the most highly recommended.
>

Go look at ftp://ftp.roth.net/pub/ntperl/gdbm_file/

>
>Thanks, Jay

Bob




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

Date: Thu, 12 Mar 1998 09:35:38 -0600
From: mgscheue@io.com
Subject: Re: Examples of REGEXP ?
Message-Id: <6e8v9v$hdm$1@nnrp1.dejanews.com>

In article <6e8a8m$2jo$1@nnrp1.dejanews.com>,
  myself@technologist.com wrote:
>
> Seems like regexp *is* rocket science in fact... well, it feels like it when
> one get started with it.Looks also that one could only learn from example
> as every book or explanation I've read on the topic was confusing at best.
> Any place with many examples of regexp ?Thanks!

I (and many others here) like Jeffrey E. F. Friedl's _Mastering Regular
Expressions_, from O'Reilly.  Many clear, concise examples.

See http://www.oreilly.com/catalog/regex/

Mark

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 12 Mar 1998 10:00:30 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: help with hash
Message-Id: <yaygrm29.fsf@news.concentric.net>

jimmyp@marimba.com writes:

>  %Acl = (
>     bart => {
>         password => "simpson",
>         products => [
>             {prod_name1 => ["build1" , "build2", "build3"]},
>             {prod_name2 => ["build3"]},
>             {prod_name3 => ["build5", "build2"]},
>         ],
>      },

You're adding an unnecessary level of indirection by making the
products key resolve to an anonymous list.  Why not just have it be a
hash?

  %Acl = (
     bart => {
         password => "simpson",
         products => {
             prod_name1 => ["build1" , "build2", "build3"],
             prod_name2 => ["build3"],
             prod_name3 => ["build5", "build2"],
         },
      },
      etc.

You'd get the various products with

   %products =  %{$Acl->{bart}->{products}}

and the builds with

   @builds = @{$Acl->{bart}->{products}->{prod_name1}};

Perhaps you'll be able to understand you own code better if you
maintain separate hashes for each category, like:

   my (%password, %products);
   $password{bart} = 'simpson';
   $products{bart} = { prod_name1 =>  etc.

> I have looked at perlref and perllol, and perldsc, but they get pretty steep
> quickly and I don't really understand them.

Well, have you read _Learning Perl_?  I'm afraid that until you do
understand those manpages, you'll have a hard time finishing and
maintaining the project you're working on.  I hope this helps.  Be
patient, and keep reading.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Thu, 12 Mar 1998 15:42:14 GMT
From: gstamant@cedep.com (Guy St-Amant)
Subject: How to read whole HTML content from Web pages?
Message-Id: <3507fe4a.7748986@news.cedep.com>

Hi,

I would like my script to read the content of various Web pages.
How can I do that?

I'm not talking about submiting a form here, I mean, how to grab the
content of any page from the Web?

Thanks.

Guy.


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

Date: Thu, 12 Mar 1998 14:30:15 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Is there a way to dynamically link subroutines?
Message-Id: <EppMyG.LD4@world.std.com>

Oliver Schoenwald <oliver.schoenwald@fernuni-hagen.de> writes:

>Gene A Brock wrote:

>> I am working on a program that loads in many Perl variables, and it
>> would be great if I could include the data as a subroutine after
>> saving it in Perl syntax.  The problem is, I don't know the name of
>> the file to require beforehand. 

>Gene, I think you shouldn't "require" the file, as this will be loaded at
>startup-time.
>You should load the file during run-time into a scalar $var and make an eval
>$var to run it.

Actually, require doesn't work until runtime. (Have you every noticed
that you can't break on a subroutine in a "required" library until you
pass the statement that loads it?)

require accepts a variable as an argument. require basically performs
the same action as loading the file into a scalar and calling
"eval". (except for it also keeps track of which files it has called
and will not "require" the same file twice.)

I don't see any advantage in using eval here.

-- 
Andrew Langmead


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

Date: Thu, 12 Mar 1998 16:41:50 +0100
From: Kris Van Gompel <krisvg@netit.be>
Subject: libwww WIN32 MODULE
Message-Id: <3508023E.F270AD8D@netit.be>

Hi,

I tried to install the Win32 module, but it doesn't work.

I got the whole time :

No perl script found in input ... Does anybody know what the problem is?

I installed the version 5.004 like they said, then I set the PATH
variable and then I typed install.bat, but then I got the error.

Perl is installed under NT... Can anybody help me please?

Thanks in advance

Kris

--
Kris Van Gompel
System Manager Net it be
Posthoflei 3
2600  BERCHEM
-------------------------------------
tel     :       03/286.04.34
fax     :       03/286.04.70
email   :       krisvg@netit.be
url     :       http://www.netit.be
-------------------------------------




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

Date: Thu, 12 Mar 1998 09:31:55 -0600
From: kevin@cmhcsys.com
Subject: lower case fails on strings with newlines??
Message-Id: <6e8v2l$hcu$1@nnrp1.dejanews.com>

my problem is that i've got a code snippet that makes an input string be
lowercase, e.g.

$string = lc($string);

typically, $string contains something like "ATYPICAL CHEST PAIN", and
everything words just fine.

now, i'm reading in my data with $/ = "" and a line like $string = <INFILE>. 
my problems start when i read in something that's more than one line long. 
in such a case, $string might contain something like

1.   ATYPICAL CHEST PAIN
2.  RULE OUT ESOPHAGEAL SPASM

or, it might contain a straightforward paragraph-like thing, such as

Serum coffee was triple the legal state limit at 3.4 meq/liter.  Chest x-ray
was normal, with no infiltrate, cardiomegaly, or missing lungs.  There was a
cylindrical object in the region of the second through fifth left ribs,
consist with a lead pencil that was not removed from a pocket before
radiography.

in either of these cases where i've got multiline data, lc returns zip.  it's
not that it doesn't do lower-casing--- rather, $string now holds "".

any thoughts?  all that the blue camel says about the argument to lc is that
"lc EXPR....returns a version of EXPR (or $_ if omitted)...."  there's no
stated requirement that EXPR not contain multiple lines.

kevin

"If we suppose for the moment that a pizza is a syntactical structure...." 
--Nigel Chapman

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Thu, 12 Mar 1998 08:31:17 -0600
From: Jeff Stewart <object01@cc.gatech.edu>
Subject: mkdir() and umask
Message-Id: <3507F1B5.4DAC@cc.gatech.edu>

Perl's mkdir() function requires a directory name and a "mode," which
the manual says is modified with the umask() function.  The mans for
umask() just say, "Sets the umask for the process and returns the old
one. If EXPR is omitted, merely returns current umask."

So what's a umask?  What process?

I tried executing mkdir (testing, 777) and got a testing directory with
or gx wx permissions set.

???

I tried executing print umask(); and got 18.

???

Please forgive my ignorance, but what are the man pages leaving out?

--
Jeff S.


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

Date: 12 Mar 1998 16:18:36 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
To: object01@cc.gatech.edu
Subject: Re: mkdir() and umask
Message-Id: <7x4t140wfn.fsf@beavis.vcpc.univie.ac.at>

Re: mkdir() and umask, Jeff <object01@cc.gatech.edu> said:

Jeff> "Sets the umask for the process and returns the old
Jeff> one. If EXPR is omitted, merely returns current
Jeff> umask."

Jeff> So what's a umask?  What process?

It's *this* process, the one that is calling umask().

A umask is a bit-mask which protects access modes on files.

See the man pages intro(2), umask(2).


Basically, think octal.  Each access field (user, group,
world) has 3 bits (rwx).  2^3 = 8 which is why we use octal
for it, e.g.

umask == 027

means user  = do nothing       (rwx = 000 binary = 000 octal)
      group = protect `w' bit  (rwx = 010 binary = 002 octal)
      world = protect all bits (rwx = 111 binary = 007 octal)

Jeff> I tried executing mkdir (testing, 777) and got a
Jeff> testing directory with or gx wx permissions set.

?

Jeff> I tried executing print umask(); and got 18.

Think octal -- 18 decimal == 022 octal

Try this little script to see what happens:

    #! /usr/bin/perl -w
    # get mode from cmd line, make sure it's octal
    my $mode = oct shift;
    printf("0%o\n", $mode & ~umask());

Giving this script the argument 777 produces 0755.  Note the
unary not `~', the umask tells us which bits to switch *off*.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,      | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/

"Everything I am, I learned on the back of cereal boxes" ~ RJ, "Over the Hedge"


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

Date: Thu, 12 Mar 1998 09:29:03 -0600
From: Jeff Stewart <object01@cc.gatech.edu>
Subject: Re: mkdir() and umask
Message-Id: <3507FF3F.7A14@cc.gatech.edu>

> Jeff> I tried executing mkdir (testing, 777) and got a
> Jeff> testing directory with or gx wx permissions set.
> 
> ?

If the question mark is referring to or gx wx, I was referring to:

dr----x--x

Those are the permissions that 777 set.  Now, I would have read those
permissions 411.  That doesn't even figure into the octal logic, does
it?  The man pages say think octal, and they always use 4 digits (0777
or 0411), but still, that doesn't seem to convert.

--
Jeff S.


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

Date: Thu, 12 Mar 1998 09:36:44 -0600
From: Jeff Stewart <object01@cc.gatech.edu>
Subject: Re: mkdir() and umask
Message-Id: <3508010C.51D@cc.gatech.edu>

Now I tried both mkdir (testing, 0777) and mkdir (testing, 0755).  Both
produced the same permissions:

drwxr-xr-x

Why did that happen?

--
Jeff S.


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

Date: Thu, 12 Mar 1998 09:07:13 -0600
From: "Michael A. Battaglia" <mike.battaglia@pricer.com>
Subject: MsgBox
Message-Id: <3507FA21.591B8834@pricer.com>

I have built perl 5.004_04 for windows from the source code (obtained
from CPAN).  I have added libwin32-0.09 and Win32API-registry-0.12.  All
of my perl scripts fail looking for auto/win32/MsgBox.al.  I think this
comes from an old, unsupported module.  Does anyone know of a
replacement?  All it does is display a windows message box with an OK
button.  I see that Win32API does have some window functions, but I
can't find the archive.

Any help would be appreciated.

Thanks
Mike Battaglia
Pricer Inc.
mike.battaglia@pricer.com




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

Date: Thu, 12 Mar 1998 14:52:37 GMT
From: toriw@online.no (Tor Iver Wilhelmsen)
Subject: Re: Problem with "goto" in Perl
Message-Id: <350ff280.16811584@news.eunet.no>

On 11 Mar 1998 22:52:00 GMT, Zenin <zenin@best.com> uttered:

>	Yes.  As I've stated, this is a special case in Perl, and I don't
>	really count it as a normal form of goto.  It really deserves it's
>	own keyword, IMHO to make this point more clear.

It's a pity Larry didn't "reserve" extra words, like the Java
developers did, for future (possible) use:

sub number {
   if ($number_one->dead()) {
      # I am not a number!
      become &free_man; # The Keyword Formerly Known As Goto
   }
}

sub free_man {
}

:-)

-- 
"Between our dreams and actions lies this world."
   - Bruce Springsteen, "Dead Man Walking"
Tor Iver Wilhelmsen       toriw@online.no


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

Date: Thu, 12 Mar 1998 15:27:37 GMT
From: dkw0@cdc.gov (David Wall)
Subject: Re: Q about FAQ answer - Random line from file
Message-Id: <6e8v6t$2nc3@cdc4.cdc.gov>

In article <pvjsvhzo.fsf@news.concentric.net>, Jonathan Feinberg <jdf@pobox.com> wrote:
>dkw0@cdc.gov (David Wall) writes:
>
>Do you have the blue Camel, or the pink?  You need the blue.

Blue.  Bought it about a year ago, and read the first few chapters, just 
enough to do the first simple things I wanted.  (It's the only computer 
book I've ever chuckled at as I read it.)  Recently I got more interested 
and bought most of the other books recommended here in c.l.p.m:  the Llama, 
Panther, Mouse, Owls, and just to be sure I didn't miss anything, the 
Gecko.  (I'm a PoB at work :-( )  Now if I can ever work my way through 
them....  :-)

[excellent detailed explanation snipped]
>So, to rewrite the thing somewhat less pithily, hoping this helps,
>
>   while (defined ($_=<FOO>)) {
>      if (rand($.) < 1) {
>         $line = $_;
>      }
>   }
>

Ah, yes, that helps much!  At first glance, though, it looks as if it's 
biased toward lines at the beginning of the file, but a bit of calculation 
(plus a simulation just for fun) confirms that each line has an equal 
chance of being selected.

In case you're interested, here's the calculation I did on the probability 
of a line being selected:

Let N = the number of lines in a file

P(line n is selected) = P( Uniform(0,n)   < 1 ) and
                        P( Uniform(0,n+1) > 1 ) and
                        P( Uniform(0,n+2) > 1 ) and
                        ...
                        P( Uniform(0,N)   > 1 )
     = (1/n)[ n/(n+1) ][(n+1)/(n+2)]...[ (N-2)/(N-1) ][ (N-1)/N ]
     = 1/N

Neat!  Now if only there were a way to determine the number of lines 
beforehand, we wouldn't have to read the whole file, and could just quit 
when a line was selected.  :-)  Still, this uses considerably less memory 
than 

@lines=<FILE>;
$line=@lines[ int(rand(@lines)) ];

which was what I came up with at first.

David Wall


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

Date: Thu, 12 Mar 1998 08:16:42 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: QUIZ: answer and hash slice tutorial
Message-Id: <3507EE4A.5E4BA7F3@houston.Geco-Prakla.slb.com>

Larry Rosler wrote:
> 
> I was impressed by the submission made by Uri Guttman on March 3 about
> hash slices.  In particular, I was pleased by the notational
> convenience, and thought that there might also be a performance benefit
> if the hash requires complex addressing.
> 
> To my surprise, I found a consistent small performance degradation,
> which
> I am having trouble understanding.  My very simple test program and
> benchmark
> results are given below.  This is perl, version 5.004_01 on HP-UX 10.20.
> 
> ******************************************************************
<snip>

> Benchmark: timing 16384 iterations of HashList, HashSlice, RefList,
> RefSlice...
>   HashList:  2 secs ( 1.80 usr  0.01 sys =  1.81 cpu)
>  HashSlice:  2 secs ( 2.00 usr  0.01 sys =  2.01 cpu)
>    RefList:  2 secs ( 1.91 usr  0.00 sys =  1.91 cpu)
>   RefSlice:  3 secs ( 2.10 usr  0.01 sys =  2.11 cpu)
> 
> ******************************************************************
> 
Interesting.  I cut & pasted your code, and ran it on Sun Solaris 2.5.1,
perl 5.004_01, and got the following benchmark data:

Benchmark: timing 16384 iterations of HashList, HashSlice, RefList,
RefSlice...
  HashList:  2 secs ( 1.67 usr  0.00 sys =  1.67 cpu)
 HashSlice:  2 secs ( 2.01 usr  0.00 sys =  2.01 cpu)
   RefList:  2 secs ( 1.97 usr  0.00 sys =  1.97 cpu)
  RefSlice:  2 secs ( 2.10 usr  0.00 sys =  2.10 cpu)


Don't know why this is, really, but I found it interesting enough to
post this reply.  

> Why does code that intuitively should run faster behave this way?  In
> his submission, Uri stated that a script could "use hash slices to
> improve its efficiency, clarity and elegance."  I agree about clarity
> and elegance, but am troubled about efficiency.
> 
> Larry Rosler
> Hewlett-Packard Laboratories
> lr@hpl.hp.com

Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

Date: Tue, 10 Mar 1998 21:44:43 GMT
From: UCE-trap_synic@omen.net.au (Peter Caffin)
Subject: read() vs sysread() in Socket Library
Message-Id: <3507b297.2753708@news.omen.net.au>

Hi. Reading the Pelican Book, it suggested that to read data from a socket
connection, you should use sysread() rather than read().

However, when I used sysread, no matter the number of bytes I requested, the
maximum I'd receive would be 1460 bytes, no matter what number I requested or
what webpage I asked for. Once I changed my script to use read(), I got the
correct result.

I was just curious to know if anyone else had found this (ie, is it a bug?)
and if anyone knew why it happened.

I include the program (it's quite short).

--
#!/usr/bin/perl -w
#
# Testing basic socket communication
# using HTTP and the Perl Socket module.

use Socket;

socket(F, PF_INET, SOCK_STREAM, (getprotobyname('tcp'))[2]) || die $!;

my $sin = sockaddr_in (80,inet_aton('www.omen.net.au'));
connect(F,$sin) || die $!;

select(F);
$|=1;
print F "GET /~synic/ HTTP/1.0\n\n";
$|=1;
read(F, $buffer, 100000);

open FILE, '>/home/webclients/synic/cgi-bin/text';
print FILE "$buffer";
close (FILE);

close(F);

--:     _         ___  _    _ _ 
 _oo__ |_|_ |__  _ |  |  _ |_|_' _   synic at omen dot net dot a u
//`'\_ | (/_|(/_| .|. |_(_|| | || |  http://www.omen.net.au/~synic
/ 


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

Date: Thu, 12 Mar 1998 16:41:01 +0100
From: Hyeon-Min Shin <min.shin@rw.sni.de>
To: Peter Shankey <shankeyp@charlestoncounty.org>
Subject: Re: replacing/removing a escape secquence
Message-Id: <3508020D.1F2DB1E8@rw.sni.de>

When you transfer this file to the UNIX-System you do it binary. If you do
it in ASCII you won't have this problem in future.

Try it with WS_FTP, there you can choose if you want do it binary or ASCII.
Min

Peter Shankey schrieb:

> I have a file which has been moved to a unix system from a dos system.
> The file contains a ^M  or I should say a "ESC M".  I know it a escape
> sequence because I see it in vi but not with a cat command.
>
> to get rid of it I have tried the follow with no success:
>
> stuff
> while (<CU>) {
> s/^[M//;
> print CUtemp $_;
> }
> stuff
>
> I have tried a few variations of the regular expression with no success.
>
> any idea would be helpful
>
> thanks
> pete





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

Date: 12 Mar 1998 14:05:11 GMT
From: matija@rzenik.arnes.si (Matija Grabnar)
Subject: Re: Speed of sort routine vs. one-by-one compare   (123)
Message-Id: <6e8q2n$ogj$1@kanja.arnes.si>

In article <Pine.SUN.3.96.980311174435.10375C-100000@coyote.rain.org>,
Nick Halloway  <snowe@rain.org> wrote:
>Yes, the database gets used between updates and needs to be kept 
>sorted.  It's updated one record at a time.
>The records are about 25 bytes long.  
>The file would be sorted by length of the first record, i.e. how many
>characters before the first space.
>One record at a time has to be inserted, but I'm keeping the program
>that uses the database waiting until the database is updated, with 
>lockfiles.  

I think you would be best off using DB_file. It will keep the file sorted 
for you (or it will keep an index, which is just as good). 

You can find the use decribed on page 391 of the new Camel, but basicaly,
you do a 

use DB_File;

tie %h, 'DB_File' , "tree" O_RDWR,O_CREAT,0644, $DB_BTREE;

You can change the comparison function by assigning it to 
$DB_BTREE, as in 
$DB_BTREE->{compare}='Compare';

a normal while (key=each %h) loop will then return elements in 
sorted order...
-- 
"My name is Not Important. Not to friends. 
    But you can call me mr. Important"  - Not J. Important 
Matija.Grabnar@arnes.si


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

Date: Thu, 12 Mar 1998 08:09:17 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: splitting by one or more spaces
Message-Id: <3507EC8D.60EEE905@houston.Geco-Prakla.slb.com>

Oosterom wrote:
> 
> Hi,
> 
> I am trying to extract the date from the localtime value. I have to split
> this value, but if the daynumber is smaller than 10, there are two spaces
> before this number in the localtime value. This means I have to split by
> one or more spaces. The codes below don't work:
> 
> ($day, $month, $daynr, $time, $year) = split (/*\s/, localtime);
> 
Are you using perl -w on your #! line???

When I ran the above, I got the error message:
/*\s/: ?+*{} follows nothing in regexp at junk50 line 4.

Perl is telling you that the * follows nothing, and is, therefore,
unintelligable to it.

Is there some reason why you need the things from localtime in this
manner?

The suggested idiom for getting localtime data is:
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

This gives you the numeric equivalent data.  $mday = 0 means Sunday, 6
means Saturday, etc.

$year = calendar year - 1900

Depending on your requirements, this may be a better way to go...

Just a thought.  (info above from Blue Camel, pg 185).

> Any suggestions anyone? Thanks.
> 
> Thijs.
HTH.

Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
* Schlumberger Geco-Prakla   (281) 596-1434 (Office Number)            *
* 1325 S. Dairy Ashford      (281) 596-1807 (Fax)                      *
* Houston, TX 77077                                                    *
------------------------------------------------------------------------


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

Date: Thu, 12 Mar 1998 08:48:11 -0500
From: Boris Goldberg <borisg@ml.com>
Subject: Re: system(command) = fork + exec(command)? kill parent, children?
Message-Id: <3507E79B.38D8@ml.com>

Jorge Daza wrote:
> 
> Barninga Z! wrote:
> 
>      >If system(command) = fork + exec(command),
>      >then how can I get the PID of exec(command), not the
>      >PID of the system(command) which is the parent of
>      >the "command".
> 
> Hi there, I just wanted to say that "system()" it's NOT equal to
> "fork() + exec()".
> system() returns control to the point after it was called.
> exec() does NOT return.
> 


Actually, system() calls vfork() instead of fork().


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

Date: Thu, 12 Mar 1998 15:02:09 +0100
From: Jean-Louis Leroy <jll@skynet.be>
Subject: Weak references?
Message-Id: <VA.0000007a.013c4843@jll>

Hello,

I'm working on a persistence layer. Given the ID of an object, I need 
to find out whether it is already present in memory. This is to 
ensure object unicity:

    $id = read_id($storage);
    return $objects{$id} if exists $objects{$id};
    $obj = instantiate($class);
    read_data($obj, $storage);
    $objects{$id} = $obj;

If I use a global hash, however, the object will never be freed, 
because its reference count will always be at least 1 (the reference 
from the hash). Weak references would do fine, alas Perl doesn't have 
them.

So what's the solution?

I've thought of maintaining my own refcount inside in the object, and 
returning a tied scalar that would manage my refcount.

I also considered converting references into strings and storing *that* 
in the hash (it would contains pairs like 23 => 'SCALAR(0x123456)'). 
This would not prevent freeing the object, but is there a way to 
convert the string back to a reference?

Or does anybody have another hack (using typeglobs or whatever) or 
solution?

jl



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

Date: Thu, 12 Mar 1998 10:51:22 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <fl_aggie-1203981051220001@aggie.coaps.fsu.edu>

In article <6e7fcg$q3n$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com
(Tom Christiansen) wrote:

+ Aber auf Deutsch sagt Mann la misma cosa (o sea, "ja") que dice en el
+ Swedish, n'est-ce pas?  How se sabe si es aleman oder sueco dort?  :-)

Oh, for crying out loud, why don't you people speak perl?

James - add :)'s as necessary... :)

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>


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

Date: Thu, 12 Mar 1998 07:37:58 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Where can I get the PERL for Windows NT and 95?
Message-Id: <3507E536.987E4600@us.ibm.com>

Husky wrote:
> 
> If I want to test my perl scripts in IIS on NT or PWS on Win95.
> Where can I get the perl software for these OS?
> Thanks...

Go to any web search engine, type in "perl windows".  Research complete.

--
James Ludlow (ludlow@us.ibm.com)
This isn't tech support and all opinions are my own.


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

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

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