[6279] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 901 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 5 17:37:19 1997

Date: Wed, 5 Feb 97 14:00:19 -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           Wed, 5 Feb 1997     Volume: 7 Number: 901

Today's topics:
     Advice: Fastest ASCII hash tree dump (Todd Lehman)
     Re: C-Routines from Perl <rootbeer@teleport.com>
     Re: Calling Perlscript from web-root <rootbeer@teleport.com>
     Re: Color coding perl (Larry W. Virden)
     Compiling strings at runtime (bill davidsen)
     Re: Compiling strings at runtime (Mike Stok)
     Re: controlling case sensitivity <tchrist@mox.perl.com>
     Re: Decrementing a field in a flat data-base?????????? (Nathan V. Patwardhan)
     Re: Empty contents of a file without deleting it (Nathan V. Patwardhan)
     Re: filehandles in recursive calls <jander@jander.com>
     Re: Help With Perl Mail <qwan@ctp.com>
     How do child processes talk to each other? [Q] (Eric J Peers)
     Re: How to do this using perl? (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)
     Re: Looking for an oneliner perl script <osborri@mail.northgrum.com>
     Re: Maximum to size of string? <jander@jander.com>
     Re: More probs with pattern matching.. <jesse@ginger.sig.bsh.com>
     non-blocking file IO in perl (Chris Ochs)
     Re: Perl 5.003 causes segmentation fault on SGI Irix <wessel@mat075207.student.utwente.nl>
     Re: Perl on Microsoft IIS, NT Server 4.0 (Duncan Harris)
     Re: Q: opening a file RW without deleting it. <merlyn@stonehenge.com>
     Re: Shouldn't HTML2PS output binary? (Mark Daku)
     Re: UNIX-based perl: backgrounding and file descriptors <merlyn@stonehenge.com>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 5 Feb 1997 20:41:57 GMT
From: lehman@visi.com (Todd Lehman)
Subject: Advice: Fastest ASCII hash tree dump
Message-Id: <5daral$q1t@darla.visi.com>

I'm reading and writing a nested hash data structure from/to a plain ASCII
text file and I want to do it as fast as possible in Perl.  I'm storing
some web data this way and interacting with it using Perl/CGI scripts.

Taking a suggestion from the Camel book (p.274, 2nd Ed), I'm letting Perl
parse my incoming data for me.  This seems to work pretty darn fast, and
all is good in the world.  :)  The challenge I still have, however, is to
dump that data back out to a file as quickly as possible.  I've written two
versions of a hash dump subroutine, one which prettyprints the output
and another which dumps the output all on one super-compacted line.

I've done everything I could think of so far to optimize the code,
short of unrolling the recursion (I guess I might try that as a final
last-gasp step).  Any other possibilities?

Code is below.  I guess the limiting factor is traversing the tree,
or maybe the regex substitution to conver ' to \' ?

I guess right now I'm getting about 10,000 final string objects per
second on my target machine, which is good enough for me from a practical
standpoint.  But still, from a programming standpoint, that seems
awfully slow...

--Todd Lehman


--------------------begin dump.in--------------------
{
   'a' => 'b',
   'c' => {
      'd' => 'e',
      'f' => 'g',
      'h' => {
         'i' => 'j',
      },
      'k' => {
         'l' => 'm',
         'n' => 'o',
         'p' => {
           'q' => 'r',
           's' => 't',
         },
      },
      'u' => 'v',
   },
   'w' => {
      'x' => {
         'y' => 'z',
      },
   },
}
--------------------end dump.in--------------------


--------------------begin dump.pl--------------------
#!/bin/perl
use strict;

my $data;


sub SlurpData   #---READ INPUT FILE
{
   my ($varname, $filename) = @_;
   my $slurp;

   open(SLURP, "<$filename") || die "Cannot open data file '$filename'!";
   while (<SLURP>)  { $slurp .= $_; }
   close(SLURP);

   eval $varname . " = " . $slurp . ";";
}


sub PrettyDump   #---WRITE OUTPUT FILE, PRETTYPRINTED
{
   if (ref($_[0]) eq "")
   {
      $_[0] =~ s/'/\\'/gs;
      print OUT "'", $_[0], "'";
   }
   elsif (ref($_[0]) eq "HASH")
   {
      my $level = $_[1];
      my $key;

      print OUT "{\n";

      foreach $key (keys %{$_[0]})
      {
         $key =~ s/'/\\'/gs;
         print OUT $level, "  '", $key, "' => ";
         PrettyDump($_[0]->{$key}, $level . "  ");
         print OUT ",\n";
      }

      print OUT $level, "}";
   }
}


sub TinyDump   #---WRITE OUTPUT FILE, SUPER-COMPACTED
{
   if (ref($_[0]) eq "")
   {
      $_[0] =~ s/'/\\'/gs;
      print OUT "'", $_[0], "'";
   }
   elsif (ref($_[0]) eq "HASH")
   {
      my $key;

      print OUT "{";

      foreach $key (keys %{$_[0]})
      {
         $key =~ s/'/\\'/gs;
         print OUT "'", $key, "'=>";
         TinyDump($_[0]->{$key});
         print OUT ",";
      }

      print OUT "}";
   }
}


#---TEST CODE

my $i;

if ($ARGV[0] eq "-s")
{
   for ($i = 0; $i < 1000; $i++) { SlurpData('$data', 'dump.in'); }
}
else
{
   open(OUT, ">dump.out") || die "Cannot open output file!";
   SlurpData('$data', 'dump.in');

   if ($ARGV[0] eq "-p")
   {
      for ($i = 0; $i < 1000; $i++) { PrettyDump($data, ""); }
   }
   elsif ($ARGV[0] eq "-t")
   {
      for ($i = 0; $i < 1000; $i++) { TinyDump($data, ""); }
   }
   else
   {
      PrettyDump($data, ""); print OUT "\n";
   }

   close(OUT);
}
--------------------end dump.pl--------------------


Running times on two different UNIX boxes:

SYSTEM #1
---------
% time dump.pl -s
1.58u 0.42s 0:08.41 23.7%
% time dump.pl -p
1.31u 0.05s 0:03.39 40.1%
% time dump.pl -t
1.20u 0.03s 0:05.04 24.4%


SYSTEM #2
---------
% time dump.pl -s
3.90u 1.03s 0:10.70 46.0%
% time dump.pl -p
3.96u 0.12s 0:05.56 73.3%
% time dump.pl -t
3.36u 0.15s 0:04.46 78.6%


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

Date: Tue, 4 Feb 1997 07:48:24 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Oliver Belikan <ob@online.neurotec.de>
Subject: Re: C-Routines from Perl
Message-Id: <Pine.GSO.3.95.970204074410.832F-100000@linda.teleport.com>

On 4 Feb 1997, Oliver Belikan wrote:

> Is it possible to call C-functions from Perl ?
> How ?

It's in the docs; the perl(1) man page lists this, or something like it.

         perlxs      Perl XS application programming interface
         perlxstut   Perl XS tutorial
         perlguts    Perl internal functions for those doing extensions

Once you've read those and their references, if you have further
questions, please ask again. Good luck!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Tue, 4 Feb 1997 07:42:03 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Arne Unneland <arne@digital-hverdag.no>
Subject: Re: Calling Perlscript from web-root
Message-Id: <Pine.GSO.3.95.970204074027.832E-100000@linda.teleport.com>

On 3 Feb 1997, Arne Unneland wrote:

> If you have a url like this:
> 
> http://www.somecorp.com/
> 
> Can you call a perl-script from this location without using any
> redirect/location methods. Can you set the webserver to do this
> automatically?

This should be explained in the documentation for your server. If you
can't find the answer there, see about a server newsgroup, or its FAQ,
since this isn't a Perl question. (You can tell it's not a Perl question
because the answer would be the same if the script were written in tcsh,
for example.)

Good luck!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 5 Feb 1997 14:35:09 -0500
From: lwv26@cas.org (Larry W. Virden)
Subject: Re: Color coding perl
Message-Id: <5dandd$7pf@csa21s4m.cas.org>


I believe CRISP comes with a set of macros for color coding Perl code.
-- 
Larry W. Virden                 INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.


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

Date: 5 Feb 1997 19:15:06 GMT
From: davidsen@tmr.com (bill davidsen)
Subject: Compiling strings at runtime
Message-Id: <5dam7q$1f0k@usenet1y.prodigy.net>

I have a program which reads in rather a lot of strings and uses
them to search some text. This is being rather painfully slow, and
I'd like to speed it. However, I don't see a good way to do the
equivalent of /str/o using a string read in at runtime. I can't
practically have a copy of the program for each set of match
strings, nor do I want the confusion of having a program write
another program and then run it.

Is there a way I'm missing which will do the compile at runtime,
like regcomp, and save the pattern?
--
	-bill davidsen (davidsen@tmr.com)
"As a software development model, Anarchy does not scale well."
		-Dave Welch


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

Date: 5 Feb 1997 20:32:19 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Compiling strings at runtime
Message-Id: <5daqoj$t01@news-central.tiac.net>

In article <5dam7q$1f0k@usenet1y.prodigy.net>,
bill davidsen <davidsen@tmr.com> wrote:
>I have a program which reads in rather a lot of strings and uses
>them to search some text. This is being rather painfully slow, and
>I'd like to speed it. However, I don't see a good way to do the
>equivalent of /str/o using a string read in at runtime. I can't
>practically have a copy of the program for each set of match
>strings, nor do I want the confusion of having a program write
>another program and then run it.
>
>Is there a way I'm missing which will do the compile at runtime,
>like regcomp, and save the pattern?

You can build a string and eval it.  This is pretty much what Tom
describes in match_any at the bottom of CPAN/doc/FMTEYEWTK/regexps.html on
a cpan site.  You can get ot this through www.perl.com/perl, go into
the Documentation link of Perl Software and look in Expert Information
FMTYEWTK bit at What Makes Perl's Regular Expressions Dynamite.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 5 Feb 1997 21:14:28 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: controlling case sensitivity
Message-Id: <5dat7k$5em$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, mheins@prairienet.org (Mike Heins) writes:
:Dan Lipofsky (danlip@proton.cyc.com) wrote:
:: if ($sensitive) {
:: 	if ( m/$word/ ) { ... }
:: }
:: else {
:: 	if ( m/$word/i ) { ... }
:: }
:: 
:I suggest using the new embedded modifier capability in
:Perl 5:
:
:	$_ = 'Foo';
:	$word = '(?i)foo';
:		print "Matched $_ case-insensitive with $word\n" if /$word/;

Please: Every time someone asks about /$word/, please mention that it's
10-15x *SLOWER* than using /word/ without the variable interpolation.
Lamentably, the speedy alternatives involve superclever eval and/or
closure tricks that You Are Not Expected To Understand, like this:

    sub _bm_build {
	my $condition = shift;
	my @regex = @_;  # this MUST not be local(); need my()
	my $expr = join $condition => map { "m/\$regex[$_]/o" } (0..$#regex);
	my $match_func = eval "sub { $expr }"; 
	die if $@;  # propagate @_; this shouldn't happen!
	return $match_func; 

    } 

    sub bm_and { _bm_build('&&', @_) }
    sub bm_or  { _bm_build('||', @_) }

    $f1 = bm_and qw{ 
	    xterm 
	    (?i)window 
    };

    $f2 = bm_or qw{ 
	    \b[Ff]ree\b
	    \bBSD\B
	    (?i)sys(tem)?\s*[V5]\b 
    };

    # feed me /etc/termcap, prolly
    while ( <> ) {
	print "1: $_" if &$f1;
	print "2: $_" if &$f2;
    } 

##############################################################
# For a really fun time, explain why this also works: :-)
##############################################################

    *f1 = bm_and qw{ 
	    xterm 
	    (?i)window 
    };

    *f2 = bm_or qw{ 
	    \b[Ff]ree\b
	    \bBSD\B
	    (?i)sys(tem)?\s*[V5]\b 
    };

    # feed me /etc/termcap, prolly
    while ( <> ) {
	print "1: $_" if f1();
	print "2: $_" if f2();
    } 

##############################################################
# Hm... this doesn't find syntax errors until you call it!!
# Maybe it should be either
#	return scalar (&$match_func, $match_func); 
# or
#	return eval { &$match_func, 1 } && $match_func; 
# or
#	return eval { &$match_func, 1 } ? $match_func : die;
# depending on how spectacular a failure one wants, and when
##############################################################


__END__
-- 
Tom Christiansen      Perl Consultant, Gamer, Hiker      tchrist@mox.perl.com


You are unlucky enough to bump into all my rough edges.  --Andrew Hume


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

Date: 5 Feb 1997 18:42:20 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Decrementing a field in a flat data-base??????????
Message-Id: <5dakac$m82@fridge-nf0.shore.net>

Paul J Tomsic (ptomsic@kta.com) wrote:
: I'm wondering if anyone has any suggestions as to how one would go about
: decrementing a field in a flat_db.txt file that has it's fields delimited with

You might try Sprite.pm, which handles flat-file database files in a sql-like
fashion!  Available at a CPAN near you!

--
Nathan V. Patwardhan
nvp@shore.net
"Outshined outshined outshined!"
	--Chris Cornell from Soundgarden


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

Date: 5 Feb 1997 18:41:22 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Empty contents of a file without deleting it
Message-Id: <5dak8i$m82@fridge-nf0.shore.net>

Chris Schoenfeld (chris@ixlabs.com) wrote:
: What's the most desirable method of emptying a file's contents without
: deleting it (e.g. system(cp /dev/null file)) in Perl?

If you wish to remove the contents of a file with out deleting it,
you might reopen the file in write/create mode.

Ex:

open(CLEARME, ">filename.txt")
    || die("No:$!\n");
close(CLEARME);

HTH!

--
Nathan V. Patwardhan
nvp@shore.net
"Outshined outshined outshined!"
	--Chris Cornell from Soundgarden


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

Date: 05 Feb 1997 15:28:04 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: filehandles in recursive calls
Message-Id: <3evb3smj.fsf@jander.com>

"Samir Grover" <sgrover@elizacorp.com> writes:

> 
> Hello all, please look at this.
> 
> #BEGIN
> $inName = "foo.cmd"
> &doCommandFile($inName);
> print "I am done\n";
> 
> sub doCommandFile {
> 	local($fname);
> 	$fname = $_[0];
> 	open(COMFILE, "$fname") or die "Can't open '$fname'\n";
> 	while ($x = <COMFILE>) 
> 	{
> 		if ($something)
> 		{
> 			...
> 		} elsif ($x = $something)
> 		{
> 			@data = split(" ", $x);
> 			&doCommandFile($data[1]);
> 		} elsif ($something)
> 		{
> 			...
> 		}
> 	}
> } # End of Routine

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

my $inName = "perl.h";
doCommandFile($inName);
print "I am done\n";

sub doCommandFile {
  my $fname = shift;
  my $path;

  warn ("$fname\n"), return unless -T $fname;
  print "+++ $fname +++\n";
  open $fname, $fname  or die "Can't open '$fname'\n";
  while (<$fname>) {
    next unless /^\s*#include\s+([<"])(\w+)/;
    print "$fname: $_";
    $path = ($1 eq '"') ? "./$2.h" : "/usr/include/$2.h";
    doCommandFile($path);
  }
  close $fname;
  print "--- $fname ---\n";
}
================================================================

When run from the perl source tree, the above produces:

================================================================
 ./Bletch.h
/usr/include/sys.h
/usr/include/stdarg.h
/usr/include/sys.h
/usr/include/stdarg.h
/usr/include/sfio.h
/usr/include/objc.h
/usr/include/appkit.h
/usr/include/sys.h
/usr/include/sys.h
/usr/include/sys.h
/usr/include/sys.h
/usr/include/sys.h
/usr/include/linux.h
/usr/include/sys.h
/usr/include/sys.h
/usr/include/linux.h
+++ perl.h +++
perl.h: #include "config.h"
+++ ./config.h +++
 ./config.h: #include "Bletch: How does this C preprocessor catenate tokens?"
--- ./config.h ---
perl.h: #include "embed.h"
+++ ./embed.h +++
--- ./embed.h ---
perl.h: #include "perlio.h"
+++ ./perlio.h +++
 ./perlio.h: #include "perlsdio.h"
+++ ./perlsdio.h +++
 ./perlsdio.h: #include <stdio.h>
+++ /usr/include/stdio.h +++
/usr/include/stdio.h: #include <features.h>
+++ /usr/include/features.h +++
/usr/include/features.h: #include <sys/cdefs.h>
--- /usr/include/features.h ---
/usr/include/stdio.h: #include <libio.h>
+++ /usr/include/libio.h +++
/usr/include/libio.h: #include <_G_config.h>
+++ /usr/include/_G_config.h +++
--- /usr/include/_G_config.h ---
/usr/include/libio.h: #include <stdarg.h>
/usr/include/libio.h: #include <sys/cdefs.h>
/usr/include/libio.h: #include <stdarg.h>
--- /usr/include/libio.h ---
--- /usr/include/stdio.h ---
 ./perlsdio.h: #include "nostdio.h"
+++ ./nostdio.h +++
--- ./nostdio.h ---
 ./perlsdio.h: #include "nostdio.h"
+++ ./nostdio.h +++
--- ./nostdio.h ---
--- ./perlsdio.h ---
 ./perlio.h: #include "perlsfio.h"
+++ ./perlsfio.h +++
 ./perlsfio.h: #include <sfio.h>
--- ./perlsfio.h ---
--- ./perlio.h ---
perl.h: #include <objc/NXCType.h>
perl.h: #include <appkit/NXCType.h>
perl.h: #include <ctype.h>
+++ /usr/include/ctype.h +++
/usr/include/ctype.h: #include <features.h>
+++ /usr/include/features.h +++
/usr/include/features.h: #include <sys/cdefs.h>
--- /usr/include/features.h ---
/usr/include/ctype.h: #include <endian.h>
+++ /usr/include/endian.h +++
/usr/include/endian.h: #include <features.h>
+++ /usr/include/features.h +++
================================================================

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: Wed, 05 Feb 1997 11:06:55 -0800
From: "Qiang \"Ching\" Wan" <qwan@ctp.com>
Subject: Re: Help With Perl Mail
Message-Id: <32F8DA4F.2780@ctp.com>

Romualdo Ortiz wrote:
> 
> How I Can send a email with a subject and a from through a Telnet
> Section?
> 
> Subject: (I WANT TO BE ABLE TO PUT SOMETHING HERE)
>   Date:
>       Wed, 5 Feb 1997 12:35:32 -0500 (EST)
>   From:
>       Super-User <root> (I WANT TO BE ABLE TO PUT WHAT EVER I WANT)
> 
> >From : Romualdo
> Subject : Claro
> 
> Thing of Life
> 
> Bla, Blas
> _____________________________________________________________
> 
> Thanks,
> Rom
> 
> rom_ortiz@icepr.com

You might not be able to fake "sent-from", but you can surely set
"reply-to". Here's the Perl script (assuming you are using Unix):

$recipient = 'someone@somewhere';
$return_addr = 'someone_else@somewhere_else';
$subject = 'This is my subject';
 ...

open (OUT, "| /usr/lib/sendmail $recipient");
print OUT "Reply-to: $return_addr\n";
print OUT "Subject: $subject\n";
print OUT "Message:\n";
print OUT ...; # print your messages
close(OUT);

Check out "man sendmail" for more details.


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

Date: 5 Feb 1997 20:51:37 GMT
From: peers@rintintin.Colorado.EDU (Eric J Peers)
Subject: How do child processes talk to each other? [Q]
Message-Id: <5darsp$et6@lace.colorado.edu>

How can I get two child processes to talk to each other/
pass strings back and forth. I'm using the simple
client/server code as detailed in the perl book and I'd like
to be able to pass a string from one forked process in the
server to another forked process...

Thanks!
	--Eric
-- 
+----------------------------------------------------------------------------+
| If God had meant for us to use the metric system, we wouldn't have feet... |
|                          peers@rintintin.colorado.edu                      | 
+------------- http://rintintin.colorado.edu/~peers/Home.html ---------------+ 


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

Date: Wed, 05 Feb 1997 19:35:16 +0100
From: lassehp@imv.aau.dk (Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen)
Subject: Re: How to do this using perl?
Message-Id: <lassehp-ya023180000502971935160001@imv.aau.dk>

In article <gsq8d5.vo.ln@localhost>, tadmc@flash.net (Tad McClellan) wrote:

>[ emailed, posted ]
>
>
>Tom Christiansen (tchrist@mox.perl.com) wrote:
>:  [courtesy cc of this posting sent to cited author via email]
>
>: In comp.lang.perl.misc, 
>:     "Samir Grover" <sgrover@elizacorp.com> writes:
>: :@data = split("\", "c:\speech\work");
>: :
>: :I want to split "c:\speech\work" into array of "c:", "speech" and "work".
>: :
>: :"\" is creating a problem for perl compiler.
>   ^^^^^^^^^^^^^^^^^^^^^^^^^
>: And likewise for awk, C, C++, Tcl, Python, or Java -- or in fact any
>: language reasonable or otherwise.  It's a stoopid microsoft megablunder.
>                                                    ^^^^^^^^^^^^^^^^^^^^^
>
>I thought it was a CP/M megablunder, wasn't it?
>
>(or should that be CP\M megablunder ;-)
>
>Even back then, backward compatability was important to M$, which
>may be why they are still viewed as 'backward' by some (present
>company included ;-). It may also be why they are rich as sin...
>
>
>: Just use real slashes like God and Dennis intended.
>                        ^^^^^^^^^^^^^^^^^^^
>
>But, apparently, not like Gary (Kildall) intended ;-)

I don't recall backslash being part of either CP/M 2.2 or CP/M 3, nor of
Concurrent CP/M-86, which I believe was the last CP/M (I only had a brief
encounter with this in highschool, where it was the OS used on the Danish
produced Regnecentralen RC-Piccoline computers.) Back then, there were
"user areas", identified by numbers. CP/M, as far as I remember, never had
hierarchical directory structures. So I doubt it's fair to blame Kildall
here. (Blame him for not talking to IBM when it mattered: Bill Gates
wouldn't have been the devil he is now.)

If I recall correctly, even the first DOS didn't have hierarchical
directory structures. Why backslash was chosen I don't know.

What I do know, since I went straight from CP/M to Macintosh back in 1989,
is that relying on the Unix way of doing things is just as biased as
relying on the MicroSSoft way of doing things. I agree that choosing colon
as separator and CR as line separator was unfortunate for the Macintosh.
But at least it doesn't use backslash.

However, I do believe that noone should write code depending on / in paths
or '\012' as line separator and yet call their code truly portable. If I
remember correctly, even assuming that '\n' and '\012' are the same is
wrong for ANSI C. In fact, I think this is a part of Perl where there are
things to clean up. (read: too many things in Perl are Unix-biased to some
extent.)

And I don't care much about what God or Dennis intended, although I do
agree that Microsoft is stoopid.

--
Lasse Hillerxe Petersen     ! "Business as usual is
Systems Administrator       !  no longer acceptable"
Information & Media Science !         -Gilbert F. Amelio
Aarhus University, DENMARK  !          Apple CEO and chairman


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

Date: 5 Feb 1997 19:34:56 GMT
From: "Rick Osborne" <osborri@mail.northgrum.com>
Subject: Re: Looking for an oneliner perl script
Message-Id: <01bc139b$9e2402b0$1f7fe484@mlbweb>

Thierry DELATTRE <th@euro-checkpoint.com> wrote in article
<32f8bff7.1850979@news2.skynet.be>...
>I'm looking for a free oneliner perl script. Do you ever saw one
>somewhere ?

Sure:

  print 'Hello World!';

There you go.
_________ o s b o r n e @ g a t e w a y . g r u m m a n . c o m _________
Pinky, are you pondering what I'm pondering?
Uh, I think so, Brain, but balancing a family and a career... oooh, it's
all too much for me. 


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

Date: 05 Feb 1997 14:21:08 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: Maximum to size of string?
Message-Id: <4tfr3vq3.fsf@jander.com>

boekhold@elektron.et.tudelft.nl (M.Boekhold) writes:

> 
> Hi,
> 
> Is there a limit to the size of a string in Perl5? I have a
> cgi-0script that

Practically speaking, no. I believe the length is held in an int, so
if in int on your architecture is 32 bits...

> now chokes. It uses *really* large strings (I put an entire HTML-table
> into a string, which makes it easy for me to work with template-files
> for the html-output). It looks to me as if mytable just doesn't fit
> into the string anymore, it is broken of somewhere right in the middle.
> 
> It also may have something to do with the regex-stuff, since I do something
> like: $line =~ s/TABLE/$table/, or even with print (print $line).

Well, since we've established it's almost certainly not a perl size
limitation, we'd need a peek at the code to go much further...

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: 05 Feb 1997 15:54:36 -0500
From: Jesse Glick <jesse@ginger.sig.bsh.com>
Subject: Re: More probs with pattern matching..
Message-Id: <4ok9ongeib.fsf@ginger.sig.bsh.com>

Mr Matty <hayes@coventry.ac.uk> writes:

> blah blah THIS IS my code
> 
> i want to only replace the "THIS IS" bit so it reads :-
> 
> blah blah <HTML TAG>THIS IS</HTML TAG>

s!([A-Z][A-Z\s]*)!<HTML TAG>$1</HTML TAG>!g;

-- 
Jesse "Da Juice" Glick
mailto:jglick@sig.bsh.com
617-867-1017


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

Date: 5 Feb 1997 19:54:49 GMT
From: root@web1.valley-internet.com (Chris Ochs)
Subject: non-blocking file IO in perl
Message-Id: <5daoi9$a0n$1@falcon.ns.net>

Is there a good source of information somewhere on how to do non blocking file
IO in perl?  Specifically I am trying to do serial communications.  

With my limited understanding of serial comm, It is my understanding that
data cannot be sent and received simultaneously.  If this is true, what handles
the negotiation so that simultaneous transmissions from both ends of the 
connection do not happen at the same time?  If I am completely lost here I would greatly appreciate some pointers to more information on serial communications.


I would also like to get some price quotes on anyone who would be interested
in doing the programming for me if this turns out to be something that would
take too much time on my part to learn, as it needs to be done within 2 weeks.

If anyone wants more info on exactly what I need done, you can post here or 
email me at admin@valleynet.net.

Chris



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

Date: Wed, 05 Feb 1997 16:58:54 +0100
From: Wessel de Roode <wessel@mat075207.student.utwente.nl>
To: jeff@alexr.com
Subject: Re: Perl 5.003 causes segmentation fault on SGI Irix
Message-Id: <32F8AE3E.2781@mat075207.student.utwente.nl>

Jeff Ferguson wrote:
> 
> Hello: I have been running perl 5.001 for some time now on my SGI Irix
> machine without any problems. I recently upgraded (compiling the source
> distribution) to 5.003 and since have had strange things happen to
> existing programs. Certain scripts written some time ago, which operated
> without a problem, are now causing segmentation faults on the system and
> dumping core. The strange thing about it is that sometimes they run
> fine, and sometimes they crash. There doesn't seem to be any rhyme or
> reason to it. Anyone have any thoughts?
I have the same problems with perl5.003. I'm now running 5.002 without
problems. It's probaly the buggy-linker. I'll have a compiling run with
gcc and the old linker see wat this brings.

Wessel

-- 
---
There can be no rainbows around the soul until 
      there are first tears in the eyes.

	  -- Frances Firebrace --


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

Date: 5 Feb 1997 19:28:54 GMT
From: duncan@sapio.co.uk (Duncan Harris)
Subject: Re: Perl on Microsoft IIS, NT Server 4.0
Message-Id: <memo.970205192825.125A@sapio.compulink.co.uk>

In article <32F8797F.4171@powersim.no>, stemo@powersim.no (Steinar Moen) 
wrote:

> Perl doesn't work on my Server.
> 
> I have installed Perl5 on my Windows NT Server 4.0, running MS IIS 3.0.
> I've also enabled the Execute permission on my cgi-bin directory. (This
> is a virtual directory)
> Is there anything else I have to do? (Enabling Perl etc...?)

Yes, enable the ScriptMap in the registry:

Load REGEDT32.
Select:

HKEY_LOCAL_MACHINE
\System
\CurrentControlSet
\Services
\W3SVC
\Parameters
\ScriptMap

>From the Edit menu select Add Value

in the Add Value dialog add .pl with a data type of REG_SZ, in the string
editor enter the String Value of <full path>\perl.exe %s

--
Duncan Harris, Sapio Design Ltd, Manchester, U.K.
~~~~~~~~~~~ mailto:duncan@sapio.co.uk ~~~~~~~~~~~
Web on CD-ROM?  Check out http://www.sapio.co.uk/


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

Date: 03 Feb 1997 08:11:53 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: mike@stok.co.uk
Subject: Re: Q: opening a file RW without deleting it.
Message-Id: <8cybd5udom.fsf@gadget.cscaper.com>

>>>>> "Mike" == Mike Stok <mike@stok.co.uk> writes:

Mike> In article <8clo96hlup.fsf@gadget.cscaper.com>,
Mike> Randal Schwartz  <merlyn@stonehenge.com> wrote:
>>>>>>> "Mike" == Mike Stok <mike@stok.co.uk> writes:
>> 
Mike> scalar <FILE>;

>> What are those "scalars" doing in there?
>> Works just fine without them.  It's misleading this way.

Mike> In what way is it misleading, not necessary, ugly, verbose, untidy I can
Mike> live with, but misleading?

It's misleading in that a newbie will look at that and say "hey, an
expert wrote this, and he *put them in*, so *they must be necessary*".
And then she'll see code later that doesn't have it there and WONDER
why the scalar is *missing*.

You introduce a noise word.  Newbies will take it as gospel.  If
you're going to preach, at least preach the streamlined forms!

Just like (from one of my books, bleh):

	open HANDLE, "$filename";

Why are those quotes there?!?  (In reality, because I had originally
written "<$filename", but then realized that the "<" was mostly
redundant.)  This is yes, technically correct, but extrapolates to
mostly bad behavior. Just like your "scalar".

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 575 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@ora.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: 05 Feb 1997 16:02:54 -0500
From: daku@nortel.ca (Mark Daku)
Subject: Re: Shouldn't HTML2PS output binary?
Message-Id: <esqohdzq83l.fsf@nortel.ca>


> Hi,
> 
> I'm using html2ps on an HP-UX machine, with perl already pre-installed.
> But, when I operate on an HTML document, I get a file with a whole bunch
> of cryptic text output (supposedly postscript, but NOT in the expected
> binary).  When I then print this resultant file, I just get a dump of
> the text.

Postscript is text.  Postscript has never been binary.

> 
> Anybody know what's wrong here?  I'm sure it's not my printer (which
> does postscript), and I'm sure it's not the way I'm printing (using the
> 'lp -dPRINTER FILE' unix command).
> 

Well geuss what it is your print command.  You have to tell you
printer that you are about to send postscript.  lp on most systems
does not do that.  lp stands for LinePrint(er).  However most lpr
implementations set up so that they detect for the postscript header
and thus switch the mode of the printer to postscript.

Thus try lpr instead of lp.  Actually I never use lp anymore, it is
often sends stuff throught some silly text processing macro or such.
Sys admins love "fixing" lp to use these silly macros.

Make sure that the first bit of the file looks like this or something
like it.  %!PS-Adobe-3.0

> Thanks in advance for any help.
> Vik.


Mark Daku
daku@nortel.ca


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

Date: 04 Feb 1997 07:02:50 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Christopher M Wolff <christopher.wolff@nb.rockwell.com>
Subject: Re: UNIX-based perl: backgrounding and file descriptors
Message-Id: <8craiw3bzp.fsf@gadget.cscaper.com>

>>>>> "Christopher" == Christopher M Wolff <christopher.wolff@nb.rockwell.com> writes:

Christopher> Two UNIX-based perl questions:
Christopher> 1) Can a background process be launched from within perl?

Yes, similar to how you would do it in C:

	defined $kidpid = fork or die "Cannot fork: $!";
	unless ($kidpid) { # child does this:
		exec "whatever I want";
		die "Cannot exec whatever: $!";
	}
	waitpid($kidpid); # omit this if you don't want to wait

Christopher> 2) How can I write to a file descriptor specified by number alone?
Christopher> I tried using syswrite, but it doesn't seem to work like the C "write"
Christopher> function. I need to do this because a parent process has setup the
Christopher> file descriptors 3 and 4 for communication.

	open HANDLE_TO_THREE, ">&=3" or die "fd 3 wasn't open: $!";

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 574 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@ora.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: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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 V7 Issue 901
*************************************

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