[6382] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 24 21:17:57 1997

Date: Mon, 24 Feb 97 18:00:22 -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           Mon, 24 Feb 1997     Volume: 8 Number: 7

Today's topics:
     Re: @DynaLoader::ISA ERROR message under win32 <Webmaster@tarrcity.demon.co.uk>
     Re: Choosing the best method for finding an item on a l <dwatson@infoscape.com>
     Re: compiling Perl on HPUX 9.x <gary@www.rdss.com>
     Re: compiling perl <tchrist@mox.perl.com>
     Re: floating point -> hex ?? (Mike Stok)
     Re: futur de perl et java-script <csc80@amdahl.com>
     Generating a randomly sorted list of integers (Stephen Frost)
     Re: getDate??? (Dave Thomas)
     Re: Help with Perl and Window95 <sandj@worldnet.att.net>
     Re: help: syntax error for "}" (Tad McClellan)
     Re: How to spam - legitimately <rpsavage@ozemail.com.au>
     Re: How to spam - legitimately <99borns@ionaprep.pvt.k12.ny.us>
     Re: How to spam - legitimately <markusg@burrow.muc.de>
     how to write a Perl shell? <ltong@helios.phy.ohiou.edu>
     Re: incremented scalar names, is it possible? (Dave Thomas)
     newbie problem with pipes (Gerd Schering)
     Perl Munitions T-Shirt <nicholas@binary9.net>
     Re: split() matches, but returns no values (Pythagoras Watson)
     SSI Random Image Displayer <Shadow@r56h108.res.gatech.edu>
     Re: Strange output with open function <jander@ml.com>
     Re: Trying to understand regex's <jander@ml.com>
     uc without explicit argument inside map. Bug? <dave@nuance.com>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: Mon, 24 Feb 1997 21:11:45 +0000
From: Webmaster <Webmaster@tarrcity.demon.co.uk>
Subject: Re: @DynaLoader::ISA ERROR message under win32
Message-Id: <E7YuxMARQgEzEwXK@tarrcity.demon.co.uk>

In article <330F13E9.2121@worldaccess.nl>, Rene Vendrig
<achterom@worldaccess.nl> writes

>Hello, i'm using perl win32 5.003 (beta) with Win95 and WebSite and the
>following errormessage
>was generated by perl
>
>Can't locate package AutoLoader for @DynaLoader::ISA at printdatasup.pl
>line 3.
>
>what does it mean and what is a possible solution.

<snip script>

I think your problem is with the SDBM_File which I had some initial
problems with under Win32.  Try something along the lines of the
(untested) ff:

#######################
use SDBM_File;

# set modes as Fcntl doesn't appear to work w Win32
sub O_CREAT { 0x0100 }
sub O_BIN { 0x8000 }
sub O_RDWR { 0x0002 }

# this'll create the file if it does't exist, otherwise open it in
# read/write mode.  I understand the "binary" is needed for SDBM under
# Win32
tie( %db, "SDBM_File", 'purple', O_RDWR | O_CREAT | O_BIN, 0666 )
        || die( "purple tie died" );

# add a rec with key "goo" and val "gaa"
$db{"goo"}="gaa";

# Print it out (the camel book says use each() on large DBM files)
while (($key,$val)=each(%db)) {
        print $key, " = ", $val, "\n";
}

# delete the record created above
delete($db{"goo"});

untie( %db); 

#######################

HTH

PS I'm on Win95 and 5.001 so as I understand things this ought to work
for 5.003

-- 
Wm ...


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

Date: Mon, 24 Feb 1997 16:57:52 -0800
From: Dennis Watson <dwatson@infoscape.com>
Subject: Re: Choosing the best method for finding an item on a list.
Message-Id: <33123910.6F66@infoscape.com>

Alexandre Bento Freire wrote:
> 
>  Many times, I just want to know, if the string is there, without
>  caring is index on the list.

Seems to me that if you just need to know *if* the item is on the list
and not *where* on the list the item is then:

@list = ... ; # Some huge list
$item = ... ; # An item to search for
if ( grep(/$item/, @list) ) {
   print "$item is in \@list";
}

This keeps the search loop in compiled C code rather than in Perl as it
would be in your #1 "for () if" example.  Also it avoids the overhead of
converting the list into an associative array which doesn't seem
necassary if you just need to know if an item is in a list and not where
or what it is.

Of course, only profiling would tell for sure.  Anyone...

The other issue I can see with my code is that I am relying on a side
effect.  The list returned by grep is converted to a scaler, the length
of the returned list, and acted upon by if().  This would be considered
bad form by some.

-- 
Dennis Watson    dwatson@infoscape.com
Developer / Systems Administrator


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

Date: Tue, 25 Feb 1997 00:21:27 +0000
From: Gary Ebert <gary@www.rdss.com>
To: Ben Pressnall <"ben "@fshelby.chem.uidaho.edu>
Subject: Re: compiling Perl on HPUX 9.x
Message-Id: <33123087.11A2@www.rdss.com>

Ben Pressnall wrote:
> 
> can anyone help me compile Perl on a HPUX 9.X system?
> 
> Thanks,
> 
> --
> Ben Pressnall
> University of Idaho
> Chemistry Dept.
> (208)885-7093  pressnal@uidaho.edu

Check out the HPUX public-domain (HPPD) web site at
http://hpux.cae.wisc.edu/pubdomain/contents.html
-- 
Gary Ebert
Mobile Datacom Corporation
22300 Comsat Drive, Clarksburg, MD 20871
Phone: 301-428-2115 Fax: 301-428-1004


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

Date: 24 Feb 1997 23:08:07 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: compiling perl
Message-Id: <5et70n$66k$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    nieder@princeton.edu (Hanspeter Niederstrasser '98) writes:
:Is there a way to compile (not interpret) a perl script into a win32 .exe?  I 
:don't need to know about perl5 from Activeware<sic>  I got it and runs fine, 
:I'm just looking for a way to make scripts that were called from my server run 
:a little faster and cleaner than having the whole perl.exe run each time.
:
:About 6 months ago I saw someone post a similar question here, and got a 

Even using Malcolm's perl-to-C compiler on Unix seldom makes it run
significantly faster.  Usually a little faster, but not all that much.

Here's a very rough draft of part of the new FAQ I'm writing:

    =head2 How can I make my Perl programs run faster?

    The best way to do this is to come up with a better algorithm.
    This can often make a dramatic difference.  Chapter 8 in the Camel
    has some efficiency tips in it you might want to look at.

    Other approaches include autoloading of seldom-used Perl code.
    See the AutoSplit and AutoLoader modules in the standard distribution
    for that.  Or you could find out the bottle neck and think about
    writing just that part in C, the way we used to take bottlenecks in
    C code and write them in assembler.

    In some cases, it may be worth it to use the backend compiler to
    save off just the byte code (and spare compilation time) or compile
    into C, which will certainly save compilation time and sometimes a
    small amount (but not much) execution time.  See the question the
    compiling your Perl programs.

    If you're currently linking your perl executable to a shared libc.so,
    you can often gain a 10-25% performance benefit by rebuilding it
    to link with a static libc.a instead.  This will make a bigger perl
    executable, but your Perl programs (and programmers) may thank you
    for it.

    =head2 How can I make my Perl programs take less memory?

    When it comes to time-space tradeoffs, Perl nearly always prefers
    to throw memory at a problem.  Scalars in Perl use more memory
    than strings in C, arrays take more that, and hashes use even more.
    Recent releases have been addressing these issues, but there's still
    a lot to be done.  For example, as of 5.004, duplicate hash keys are
    all shared amongst all hashes using them, so require no reallocation.

    In some cases, using substr() or vec() to simulate arrays can be
    highly beneficial.  For example, an array of a thousand booleans
    will take at least 20,000 bytes of space, but it can be turned
    into one 125-byte bit vector for a tremendous memory savings.
    The standard Tie:SubstrHash module can also help for certain types
    a data structure.

    Another thing to try is see whether your Perl was compiled with
    the system malloc or Perl's built-in malloc.  Whichever one it is,
    try using the other one and see whether it makes a difference.

    =head2 How can I free an array or hash so my program shrinks?

    You can't.  Memory the system once allocates to a problem will never
    be returned to the system.  That's why long-running programs sometimes
    re-exec themselves.

    However, judicious use of my() on your variables will help make sure
    that when they go out of scope, Perl frees up their storage for use
    in other parts of your program.  (Lexicals also execute about 10%
    faster than globals.)  A global variable, on the other hand, you can't
    do this with, although undef()ing it will achieve the same effect.
    In general, memory allocation and de-allocation isn't something you
    can or should be worrying about much in Perl.

    =head2 How can I make my CGI script more efficient?

    Beyond the normal measures described to make general Perl programs
    faster or smaller, a CGI program has additional issues.  It may be
    run several times per second.  Given that each time it runs it will
    need to be re-compiled and will often allocate a megabyte or more of
    system memory, this can be a killer.  And compiling into C B<isn't
    going to help you> because the process start-up overhead is where
    the bottleneck is.

    What you should look into in this case is running with either the
    Fast::CGI module to create permanent CGI daemon processes, or else
    using mod_perl in Apache to run with an embedded Perl interpreter
    that pre-compiles your script and then runs it within the same
    address space without forking.

    =head2 How can I hide the source for my Perl program?

    Delete it. :-) Seriously, in most cases, this isn't going to win
    you any friends, and won't do what you think it will anyway.

    First of all, you can't take away read permission, because the source
    code has to be readable in order to be compiled and interpreted.
    (That doesn't mean that a CGI script's source is readable by people
    on the web, though.)  So you have to leave the permissions at the
    socially friendly 0755 level.

    If you're thinking this is a security problem, then what you're
    talking about is security through obscurity, which is provably
    false and probably dangerous as well.  Real security has to do with
    authentication and authorization, not relying upon people not knowing
    about back doors.

    If it's a matter of people profitting from your code, then there
    really isn't any protection beyond a legal one.  License your software
    and pepper it with threatening statements like "This is unpublished
    proprietary software of XYZ Corp.  Your access to it does not give
    you permission to use it blah blah blah".

    You can try using encryption via source filters
    http://www.perl.com/CPAN/modules/by-module/Filter.  But they might
    be able to decrypt it.  You can try using the byte-code compiler and
    interpreter described below, but they might be able to de-compile it.
    You can try using the native-code compiler described below, but they
    might be able to disassemble it it.

    The bottom line is that nothing else but a restrictive licence is
    really going to work here.  Why do you think laptops bootup with
    the flash message "DISASSEMBLY PROHIBITED"?

    =head2 How can I compile my Perl programs into byte-code or C?

    Malcolm Beattie has written a multifunction backend compiler,
    available from http://www.perl.com/CPAN/authors/id/MICB/, that can do
    both these things.  It is as of this writing in late alpha release,
    which means it's fun to play with if you're a programmer but not
    really for people looking for turn-key solutions.

    I<Please> understand that merely compiling into C does not in
    and of itself guarantee that your code will run very much faster.
    That's because except for lucky cases where a lot of native type
    inferencing is possible, the normal Perl run time system is still
    present and thus will still take just as long to run and be just
    as big.  Most programs save little more than compilation time,
    leaving execution no more than 10-30% faster.  A few rare programs
    actually benefit significantly (like several times faster), but this
    takes some tweaking of your code.

    Malcolm will be in charge of the 5.005 release of Perl itself to
    try to unify and merge his compiler and multithreading work into
    the main release.

    You'll probably be astonished to learn that the current version of the
    compiler generates a compiled form of your script whose executable
    is just as big as the original perl executable, and then some.
    That's because as currently written, all programs are prepared for
    a full eval() statement.  You can tremendously reduce this cost by
    building a shared libperl.so library and linking against that.  See
    the F<INSTALL.pod> file in the perl source distribution for details.
    If you link your main perl binary with this, it will make it minicule.
    For example, on my system, /usr/bin/perl is only 11k in size!

As I said, this is very rough, but it should give you some ideas.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
The correct way of pronouncing (well, spelling) the name of LA is
"La Ciudad de nuestra Sen~ora la Reina de los A'ngeles de Porciu'ncula".
                    Good luck. :-)


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

Date: 25 Feb 1997 01:39:29 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: floating point -> hex ??
Message-Id: <5etfsh$e55@news-central.tiac.net>

In article <5esifb$cjo@news-central.tiac.net>,
Steve Smith  <ssmith@nine.com> wrote:
>I would like to represent a single precision floating-point value as
>a hexidecimal number (ie 8-bit hex), but I'm not having any luck.
>
>I've tried 
> 1)  sprintf ("%x", $num)
> 2)  various tries with unpack 
>
>Is there a trick to using unpack?  It's yielding unexpected results....
>Also, it only yields a 1-bit hex number for some reason....

Possibly something like:

  $hexString = unpack ('H*', pack ('f', $num));

would do what you want.

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: Mon, 24 Feb 1997 23:47:06 GMT
From: "Carol C. Kankelborg" <csc80@amdahl.com>
Subject: Re: futur de perl et java-script
Message-Id: <3312287A.41C67EA6@amdahl.com>

Abigail wrote:
> 
> On 23 Feb 1997 02:24:43 GMT, Nathan V. Patwardhan wrote in comp.lang.perl.misc:
> ++ Abigail (abigail@ny.fnx.com) wrote:
> ++
> ++ : I've always seen Usenet as being a international medium. Too bad there
> ++ : are still arrogant people who think it's a US-only thingy.
> ++
> ++ I agree that Usenet is international, but I also thought that language-
> ++ specific groups existed, like fr, de, etc.
> ++
> 
> Like en.comp.lang.perl.misc? I don't know about fr and de, I never read
> there, but nl.* is not for postings in Dutch, but for subjects related
> to the Netherlands. Of course, the language use most will be Dutch,
> but postings in another language are welcome too.
> 
> Are you suggesting we should copy all groups and make language specific
> groups with the same subject? Build barriers while the rest of the
> world tries to remove them? Why should someone who isn't able to write
> good English denied the right to post a question to comp.lang.perl.misc?
> There might be someone - oh horror - in this groups who is able to read
> French, or whatever language the poster posts in, and give an answer.
> I thought that was one of the purposes of this group - sorry for being
> mistaken.
> 
> Abigail

I agree with what Abigail is saying here.  I, too, always thought the
fr, de, nl, etc. groups were country-related, not language-related,
just as ba is for the (SF) Bay Area region.  Sure, the majority
language of the internet and this newsgroup is English, but as its 
use grows outside the US and Commonwealth, I would hope that there 
would be more non-English communication.  If you don't understand
the language of a post, just skip over it. Surely the community
of a newsgroup as large as c.l.p.m is large enough that there are
some who are trilingual (Perl, English, some other language).
I commend Nathan for dusting off his high school French and
attempting to respond to Dominique.  I tried to provide an
English translation for my replies to Dominique as a courtesy
to the non-French speakers in the group.  I welcomed the chance
to dust off my French as well.

If, however, everyone who attempts to post in a non-English
language gets run off with "Go away, we only speak English here,"
then is it any wonder you don't find more non-English posts?

The Internet should make the world smaller, so we all can expand our
horizons more easily.

**********************************************************************
*** Carol C. Kankelborg                 csc80@amdahl.com           ***
*** Amdahl Corporation       The above opinions are uniquely mine. ***
**********************************************************************


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

Date: 24 Feb 1997 23:48:53 GMT
From: frostbyt@shell01.ozemail.com.au (Stephen Frost)
Subject: Generating a randomly sorted list of integers
Message-Id: <5et9d5$fbn@reader1.reader.news.ozemail.net>

Hi all,

I needed to write some code to produce a randomly sorted list of
integers (between "1" and "n").  This I have done, but I am not
at all happy with the amount of code that was required, nor with
the performance implications of the way I've gone about it.  It
works just dandy (and fast enough) with 1->99 or thereabouts, but
if I were to use it with 1->999 or 1->9999 it would probably die
a horrible death.

Perhaps someone might suggest an alternative approach to mine?  I
set up an array containing a "0" for each integer required, and then
set it to "1" as each number in the range is used, pushing the
new number onto my list as I go.  Here's the code (ugly as it is):


sub GenerateRandomList {
   #
   # Generates a random list of numbers between "1" and "n"
   #
   $high = $_[0];
   $list = '';
   $USED = '';
   $random = srand(time);
   for ($x = 1; $x < ($high + 1); $x++) {
      $USED{"$x"} = '0';
   }
   for ($x = 1; $x < ($high + 1); $x++) {
      while (1 == 1) {
         $y = GenerateRandomNumber();
         if ($USED{"$y"} eq '0') {
            $USED{"$y"} = '1';
            push @list, $y;
            last;
         }
      }
   }
   return @list;
}


sub GenerateRandomNumber {
   $number = int(rand($random) * $high) + 1;
   if ($number > $high) {
      $number = $high;
   }
   return $number;
}


Would be very interested in alternative approaches ... but go easy
on me won't you?  I am, after all, merely a born-again COBOL
programmer...    8^)

Steve


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

Date: 25 Feb 1997 00:02:06 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: getDate???
Message-Id: <slrn5h4aqv.auk.dave@fast.thomases.com>

On 24 Feb 1997 15:04:45 GMT, Sebastien Lambert <slambert@avenor.com> wrote:
> How can I change a string like '02/06/97' or any others strings dates
> to the number of seconds since 00h00.00 January 1, 1970.

Have a look at the various Date:: modules on CPAN. Date::Parse should do
what you want.

Dave


-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Mon, 24 Feb 1997 19:25:04 -0500
From: sean <sandj@worldnet.att.net>
To: "Nathan V. Patwardhan" <nvp@shore.net>
Subject: Re: Help with Perl and Window95
Message-Id: <33123160.4F50@worldnet.att.net>

u can always get another phone line!!

;-)

sean


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

Date: Mon, 24 Feb 1997 18:56:45 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: help: syntax error for "}"
Message-Id: <dcdte5.6p.ln@localhost>

Keith Warner Colvin (colvin@aloha.net) wrote:
: Aloha from Hawai'i,

: I am trying to run a .cgi, and I get these error messages, 
: I have tried a number of things, what is the advice of you who know more?


My advice would be to let you know that it is near impossible to
troubleshoot a syntax error without seeing the syntax...

Where's the code?


: # Unmatched right bracket, at end of line

But, I would guess that you have an unmatched right bracket ...


:  Line 140
: # syntax error, near "}"
:  Line 140
: # aborted due to compilation errors.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 25 Feb 1997 10:53:45 +1000
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: How to spam - legitimately
Message-Id: <33123819.5D98@ozemail.com.au>

William R. Somsky wrote:
> [snip]
> By the by, does anyone know if there are established terms for the[snip]

Collective noun: noun singular in form but denoting a number of individuals.

What's in common usage already?
a. I got email today regarding...
b. I got some email today regarding...
c. I got an email today regarding...
Prohibition is too late...


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

Date: Mon, 24 Feb 1997 19:35:40 -0800
From: "!Stephen!" <99borns@ionaprep.pvt.k12.ny.us>
To: "William R. Somsky" <somsky@dirac.phys.washington.edu>
Subject: Re: How to spam - legitimately
Message-Id: <33125E0C.F94@ionaprep.pvt.k12.ny.us>

William,

> I usually say things like "I receives some email" or "I received
> an email message" or just "I received email", and avoid completely
> the notion of _an_ email.

	Or you can get around the whole issue and just say "I have some new
e-mail." BTW, while we are on the subject is it spelled email or e-mail?
I've seen it both ways.

> 
> By the by, does anyone know if there are established terms for the
> two different types/usages of nouns I'm referring to here as
> "substansive" and "objective"?  Ie, nouns/noun usages that specify
> a substance that doesn't come in any discrete units, eg, "water",
> "air" (atoms/molecules don't count here), things where you don't
> say "I had 23 waters" (hmm... ordering "a water" meaning "a glass of
> water" in a restaraunt would be a separate usage) versus nouns/noun
> usages that specify discrete items that can be identified and
> counted, things where you do say, "I see 3 cars"?
	I believe the term you are fishing for is a collective noun. A
collective noun is a noun that is used in the singular form, but is
plural in meaning. i.e. water, food. You do *not* say "I had a food. I
had a water. etc." 

-- 
!Stephen!
Maintainer of the Punk and Metal Midi Archives
	http://www.geocities.com/SiliconValley/4063/index.html
"I thought I could leave this school crap in school!"


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

Date: Mon, 24 Feb 1997 23:59:16 GMT
From: Markus Gloede <markusg@burrow.muc.de>
To: somsky@dirac.phys.washington.edu (William R. Somsky)
Subject: Re: How to spam - legitimately
Message-Id: <7xlo8dzrfv.fsf@burrow.muc.de>

>>>>> "WRS" == William R Somsky <somsky@dirac.phys.washington.edu> writes:

    WRS> By the by, does anyone know if there are established terms
    WRS> for the two different types/usages of nouns I'm referring to
    WRS> here as "substansive" and "objective"?  Ie, nouns/noun usages
    WRS> that specify a substance that doesn't come in any discrete
    WRS> units, eg, "water"

Well, as far as I can recall my English lessons it's called
'uncountable noun"

Markus G


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

Date: Mon, 24 Feb 1997 21:13:22 GMT
From: Lu TONG <ltong@helios.phy.ohiou.edu>
Subject: how to write a Perl shell?
Message-Id: <33120472.6A51@helios.phy.ohiou.edu>

Is there anyone know how to write a shell interpretor by Perl which can
be invoked in a script file. like this:
-------
#!/home/ttt/hello
p  'this is a file'.
-------
where hello is the interpretor by Perl. Thanks!

tong


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

Date: 25 Feb 1997 00:14:30 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: incremented scalar names, is it possible?
Message-Id: <slrn5h4bi5.auk.dave@fast.thomases.com>

On Mon, 24 Feb 1997 21:51:16 GMT, Tim Allison <tja2f@dayhoff.med.Virginia.EDU> wrote:
> 
> I've looked through my new Camel book but to no avail...

Look at the references chapter.

> so that I don't have to assign 500*30 scalars, I'd like to use scalar
> names of the form:  ##name## where the first ## is the ## of the file
> and the second ## is the relative # of the grepped line.  [For example,
> 23name13 would be the 13th grepped line from the 23rd file.]  I am
> absolutely flexible on this; but is this even possible?  How can I :

You might want to use soft references:


# -- untested --

$fileNo = 1;

for $file (@files) {

   < grep them lines >
   
   my $grepNo = "01";
   
   for (@greppedLines) {
      ${"V${fileNo}name$grepNo"} = $_;        # assign to V01name00...
      $grepNo++;            # and increment 00 part
   }
   
   $fileNo++;
}

Of course, you'd probably want to assign at the time you do the grep, but
this shows the principle.

Dave

-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: 25 Feb 1997 00:20:46 GMT
From: gerd4000@mailszrz.zrz.TU-Berlin.DE (Gerd Schering)
Subject: newbie problem with pipes
Message-Id: <5etb8u$2el@hermes.uhland.de>

-- 
Hello,
I try to use a named pipe to pipe data to another programm, i. e. gnuplot.
The fifo gets created but after opening it, the whole process hangs.
What's wrong?

######################################################################
#!/usr/bin/perl -d

require "timelocal.pl";

$infile = 'somefile';
open (IN, "<$infile") || die "Can't open $infile for reading: $!\n";

$FIFO = 'plotfifo';
if (-p $FIFO) {unlink $FIFO;}

system ('mkfifo', $FIFO);

open (COMMAND, "|/usr/bin/gnuplot");
print COMMAND "plot $FIFO with lines\n";

open(DATA, ">$FIFO") || die "Can't open $FIFO for writing: $!\n";

# never got after here!

while (<IN>) {

	... process data ...

}
close DATA;
sleep (10);
close COMMAND;
#######################################################################

If you think the problem is not of general interest, please reply via email.

Gerd

PS.: Send replies (if any) to the address below. The address in the header 
might be misleading or not availabe!
-----------------------------------------------------------------------------
-- Gerd Schering                          email: Schering@zrz.TU-Berlin.DE --
-- TU Berlin, Zentraleinrichtung Rechenzentrum                             --
-- Sekretariat E-N 50, Einsteinufer 17, 10587 Berlin                       --
-- X400: S=Schering OU=zrz P=TU-Berlin A=d400 C=de   fax: +49 30 314 21060 --
----------------------------------------------------------------------------- 


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

Date: Mon, 24 Feb 1997 15:25:15 -0500
From: "Nicholas J. Leon" <nicholas@binary9.net>
Subject: Perl Munitions T-Shirt
Message-Id: <Pine.LNX.3.95.970224152240.396A-100000@neko.binary9.net>


I hope this question is MISC enough for here. But could anyone point me
in the direction of a vendor that sells the Perl Munitions T-shirt? I'm in
the US, so export restrictions aren't a factor here.

TIA,
 
 
N!
------------------------------------------------------------------------------
Nicholas J. Leon                                          nicholas@binary9.net
"Elegance through Simplicity"                  http://www.binary9.net/nicholas
 
                "Adrenaline takes you, to the next level, you're
                  dancing the dance with the digital devil."




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

Date: 25 Feb 1997 00:46:35 GMT
From: py@ecst.csuchico.edu (Pythagoras Watson)
Subject: Re: split() matches, but returns no values
Message-Id: <5etcpb$6f1@charnel.ecst.csuchico.edu>

[ Posted and CC'd to dmacks@netspace.org ]

According to Daniel Macks <dmacks@netspace.org>:
:Say I've got a string that is a colon-delimited set of fields in a
:database (relax...this is *not* a sort() question:) I want to split up a
:line into its component fields, so I figured I'd use split(), but the
:(external non-modifiable) program that generates the strings passes a set
:of all null fields, the result of split() is a 0-item list.
:
:Example (perl 5.002)
:  @foo = split( ':', 'this:one:seems:normal' ));
:  @bar = split( ':', ':::fine' ));
:  @ack = split( ':', ':::' ));

Note that all of the above have an extra closing parenthesis, so they most
likely all give syntax errors.

:gives
:  @foo = ( 'this', 'one', 'seems', 'normal' );
:  @bar = ( undef, undef, undef, 'fine' );

Actually, it gives:
   @bar = ( '', '', '', 'fine' );

Try:
   perl -lwe '@bar = split( ":", ":::fine" );
              print defined($bar[0]) ? "not undef" : "undef"'

as compared to:
   perl -lwe '@bar = split( ":", "" );
              print defined($bar[0]) ? "not undef" : "undef"'

:  @ack = ();
:Why doesn't @ack=(undef,undef,undef,undef)?
:
:The number of fields varies (and could be zero) so I can't think of a
:simple way to just define an all-undef array of the correct length.
:
:Any elegant ways to get all the undefs?

Why not use:
  @ack = split( ':', ':::', -1 ));

As the split entry in the perlfunc man page indicates:
  If LIMIT is negative, it is treated as if an arbitrarily large LIMIT had
  been specified.

This won't give you an array of undefs, but you don't get those in the
"bar" example either.  Instead, it gives you null fields, but that should
be just as good.

-- 
Py -- 3.141592653589793238462643383279502884197169399375105...
Pythagoras Watson -- "Live long and may all your kernels pop."
INET: py@ecst.csuchico.edu ============ COMPUSERVE: 72162,2676


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

Date: 24 Feb 1997 23:55:35 GMT
From: "Shadow" <Shadow@r56h108.res.gatech.edu>
Subject: SSI Random Image Displayer
Message-Id: <01bc19df$3e6d8ea0$0f02000a@shadow>

I just got a cgi that inserts the tags and path to random images, but I
don't know how to make it so that when the HTML is opened it opens the cgi
to insert the script, is it <!--- exec cgi= ---> or something cause I tried
that and it didn't work. maybe I did it wrong ?
Any help would be appreciated.
my email is at the bottom .

-- 
shadow@full-moon.com 
http://128.61.56.108/~shadow/


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

Date: 24 Feb 1997 18:25:03 -0500
From: Jim Anderson <jander@ml.com>
Subject: Re: Strange output with open function
Message-Id: <wkbhgj1u6r4.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

Cedar Milazzo <cedar.w.milazzo@boeing.com> writes:

> I am trying to override the open function to prepend a path to any file
> opened.  I am getting very strange output though.  
> When I run the code below I get:
> 
> FILEHANDLE=TEST
> EXPR=Can't locate object method "open" via package "Filehandle at
> topen.pl line 17.
> 
> Code used is:
> 
> use subs 'open';
> 
> open(TEST,testfile);
> print (TEST "testing" );
> close(TEST);
> 
> sub open {
>   my($FILEHANDLE,$EXPR)=@_;
>   print("\n FILEHANDLE=");
>   print($FILEHANDLE);
>   if ($EXPR){
>   print("\n EXPR=");
>      print($EXPR);
>   }
>   CORE:open TEST testfile;

Well, offhand and w/o testing, I'd say you've got an error in the
above line. Try rewritung it as:

CORE::open TEST, testfile;
    ^^         ^

and see if that helps. BTW, don't forget to check for success/failure
of the command.

>   print(TEST "\n\nThats all.\n");
>   close(TEST);
>   return 1;
> }
> 
> Any suggestions would be greatly appreciated.


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

Date: 24 Feb 1997 18:17:22 -0500
From: Jim Anderson <jander@ml.com>
Subject: Re: Trying to understand regex's
Message-Id: <wkblo8du73x.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

posenj@lancet.co.za (Kevin Posen) writes:

> Hi.
> 
> I'm taking a course in Perl and am currently learning regex's. My book gave me this expression:
> 
> 	($first, $middle, $last) = (/\b(\w+)\b\s+\b(.*)\b\s?\b(\w+)\b/);

Looks to me like most (and probably all) of those word breaks (\b) are
completely unnecessary. Just what book are you using, anyway? It may
be time to get a better one.

> This is meant to put the words into their respective variables (first word into $first etc.). But it
> doesn't work when using only one word because it can't find a last word and so no variables get
> initialised. It is meant ot work (I can see this from the context of the program), and it comes out
> of a published book (which should be checked). Is their a problem with my version of Perl (for DOS)
> or is the book wrong?.

Of course the easiest way to "put words into variables" is probably
with the split operator. This also eliminates the problem you mention
below. For example:

(@words) = split;

> I derived this expression to do the task:
> 
> 	($first, $excess, $middle, $last) = (/\b(\w+)\b(\s?\b(.*)\b\s+\b(\w+)\b)?/);
> 
> The problem is that it has to introduce a fourth variable (which I could happily do without). Is
> there a way to rewrite it using only my original three variables?
> 
> Any help is greatly appreciated!!!
> Thanks.
> Kevin Posen


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

Date: 24 Feb 1997 17:24:08 -0800
From: Dave Peters <dave@nuance.com>
Subject: uc without explicit argument inside map. Bug?
Message-Id: <7ek9nxhe4n.fsf_-_@nuance.com>


Running perl5.003. Platform doesn't seem to be relevant: the behaviour
is the same on the six platforms I tried.

---
% perl -le 'print join "_",map { uc } split "-","this-is-a-string"'
Not enough arguments for upper case at -e line 1, near "uc }"
Execution of -e aborted due to compilation errors.
---
but:
---
% perl -le 'print join "_",map { uc $_ } split "-","this-is-a-string"'
THIS_IS_A_STRING
---
I'd have hoped that uc would behave like most of the other functions,
and employ $_ as its default argument! Is this fixed in the current
version?

Cheers,
 d
PS: Did a cursory check of DejaNews; no mention of this 'problem' that 
I could find.



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

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 V8 Issue 7
***********************************

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