[17918] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 78 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 17 09:05:39 2001

Date: Wed, 17 Jan 2001 06:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979740312-v10-i78@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 17 Jan 2001     Volume: 10 Number: 78

Today's topics:
        $foo{$bar}={x=>$x,y=>$y} v. $foo{$bar}{x}=$x etc? <visstmbl@reading.ac.uk>
    Re: $foo{$bar}={x=>$x,y=>$y} v. $foo{$bar}{x}=$x etc? (Abigail)
    Re: ApacheModulePerl.dll <johngros.NOSPAM@bigpond.net.au>
    Re: bidirectional communication using sockets <johngros.NOSPAM@bigpond.net.au>
        converting Internet Explorer 'favorites' to Netscape bo <nospam@ireland.com>
    Re: FAQ 8.8:   How do I get the screen size? <a.v.a@home.nl>
    Re: Finite Automata with Output using PerlRE? (Anno Siegel)
    Re: How to Create a Perl Shared Library (.so file) ? (Anno Siegel)
        Include file (Lorenzo Beccati)
    Re: Include file (Anno Siegel)
    Re: Installing Module (Helgi Briem)
    Re: Maximum array size? (Eric Bohlman)
    Re: Need help matching multiple if's.. <johngros.NOSPAM@bigpond.net.au>
    Re: newbie - hash value size limit? (Jason Goodrow)
    Re: Pattern Matching (Eric Bohlman)
    Re: Perl and AOL. How is this possible? (Eric Bohlman)
    Re: Perl and AOL. How is this possible? (Eric Bohlman)
    Re: Perl crashes on exit <alan@nospam.com>
    Re: Perl question (Softeng2001)
    Re: Perl question (Abigail)
    Re: Perl question (Anno Siegel)
    Re: Perl question (Anno Siegel)
    Re: Perl question (Bernard El-Hagin)
    Re: Perl question (Mike Stok)
        Problem with Upload to NT <sserena@freesurf.ch>
    Re: Problem with Upload to NT (Rafael Garcia-Suarez)
    Re: Putting text in an image? THANKS! <eric.kort@vai.org>
    Re: Random Numbers with a Twist <johngros.NOSPAM@bigpond.net.au>
    Re: Random text script, got one?:-) <sserena@freesurf.ch>
    Re: techniques for finding slow code? (Softeng2001)
    Re: TNEF For Perl. Need Help. Is this a Perl Script? <geoff-at-farmline-dot-com@127.0.0.1>
        UK PERL PROGRAMMER REQ <roadsweeperman@hotmail.com>
    Re: UK PERL PROGRAMMER REQ (Bernard El-Hagin)
    Re: What do you call the => operator? (Martien Verbruggen)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 17 Jan 2001 12:55:36 +0000
From: John Stumbles <visstmbl@reading.ac.uk>
Subject: $foo{$bar}={x=>$x,y=>$y} v. $foo{$bar}{x}=$x etc?
Message-Id: <Pine.WNT.4.30.0101171245330.163-100000@supc16.rdg.ac.uk>

Another pair of eyes please!

I had this:

(a)
     $ifTable{$ifIndex} = {
             Name            =>  $Name,
             Speed           =>  $Speed,
                 ...etc...
         } ;
(b)
     $ifTable{$ifIndex}{dot1d}{$MAC}    =   {
            mtime       =>  $MAC_mtime,
            nMACs       =>  $nMACs,
                 ...etc...
        }   ;

and I thought I should have a table of mtime, nMACs etc for each $MAC, but
I only get the record for the last $MAC I assign.

If I change (a) to this:
    $ifTable{$ifIndex}{Name}            =   $Name ;
    $ifTable{$ifIndex}{Speed}           =   $Speed ;
                 ...etc...

I get what I expect: a table for each $MAC.
In each case I get the table of Name, Speed etc for each $ifIndex.

Can anyone shed light on why the second arrangement works but the first
doesn't?

perl -V
This is perl, version 5.005_03 built for sun4-solaris


regards,

--
John Stumbles                                      j.d.stumbles@reading.ac.uk
I.T. Services Centre,   University of Reading  http://www.rdg.ac.uk/~visstmbl
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                            never generalise



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

Date: 17 Jan 2001 13:21:11 GMT
From: abigail@foad.org (Abigail)
Subject: Re: $foo{$bar}={x=>$x,y=>$y} v. $foo{$bar}{x}=$x etc?
Message-Id: <slrn96b727.9j6.abigail@tsathoggua.rlyeh.net>

John Stumbles (visstmbl@reading.ac.uk) wrote on MMDCXCVI September
MCMXCIII in <URL:news:Pine.WNT.4.30.0101171245330.163-100000@supc16.rdg.ac.uk>:
^^ Another pair of eyes please!
^^ 
^^ I had this:
^^ 
^^ (a)
^^      $ifTable{$ifIndex} = {
^^              Name            =>  $Name,
^^              Speed           =>  $Speed,
^^                  ...etc...
^^          } ;
^^ (b)
^^      $ifTable{$ifIndex}{dot1d}{$MAC}    =   {
^^             mtime       =>  $MAC_mtime,
^^             nMACs       =>  $nMACs,
^^                  ...etc...
^^         }   ;
^^ 
^^ and I thought I should have a table of mtime, nMACs etc for each $MAC, but
^^ I only get the record for the last $MAC I assign.

What do you mean "each $MAC"? There's no loop in the code.

Perhaps you have a loop, and just omitted that. I can think of several
errors you could make in the loop that causes this. But I won't guess.

^^ 
^^ If I change (a) to this:
^^     $ifTable{$ifIndex}{Name}            =   $Name ;
^^     $ifTable{$ifIndex}{Speed}           =   $Speed ;
^^                  ...etc...
^^ 
^^ I get what I expect: a table for each $MAC.
^^ In each case I get the table of Name, Speed etc for each $ifIndex.
^^ 
^^ Can anyone shed light on why the second arrangement works but the first
^^ doesn't?


Show more code.



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: Wed, 17 Jan 2001 12:33:51 GMT
From: "John Boy Walton" <johngros.NOSPAM@bigpond.net.au>
Subject: Re: ApacheModulePerl.dll
Message-Id: <Pig96.66971$xW4.522992@news-server.bigpond.net.au>


"Rob" <a565a87@my-deja.com> wrote in message
news:9414ed$8aj$1@nnrp1.deja.com...
> I nmade 5.6.0 from the CPAN source distribution, and the root sits on
> my C drive.  I'm using the very latest Win32 1.3.14 binary distr. of
> Apache.  The Apache root is R:\Program Files\Apache Group\Apache
>
> ---
> Here's my Autoexec.bat:
>
> @ECHO Off
> PATH C:\
> VERIFY OFF
>
> C:\ATAPI\MSCDEX /V /D:CDMKE /L:E /M:10
> SET PATH=C:/MSVC/BIN;c:/perl/5.6.0/bin;c:/perl/5.6.0/bin/MSWin32-x86;%
> PATH%
> SET INCLUDE=C:/MSVC/INCLUDE;C:/MSVC/MFC/INCLUDE;%INCLUDE%
> SET LIB=C:/MSVC/LIB;C:/MSVC/MFC/LIB;%LIB%
> SET INIT=C:/MSVC;%INIT%
>
> ---
> The httpd.conf DSO line reads:
>      LoadModule perl_module modules/ApacheModulePerl.dll
>
> ---
> Running Apache from the console, not a service.  I get the following:
>
>      R:\Program Files\Apache Group\Apache>apache
>      Syntax error on line 205 of r:/program files/apache
>      group/apache/http.conf:
Looks like your http.conf needs an edit.




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

Date: Wed, 17 Jan 2001 09:29:03 GMT
From: "John Boy Walton" <johngros.NOSPAM@bigpond.net.au>
Subject: Re: bidirectional communication using sockets
Message-Id: <zBd96.66611$xW4.520418@news-server.bigpond.net.au>


"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:ois96tcmqhvk1feg02bp6usenh2j353rl6@4ax.com...
> John Boy Walton wrote:
>
> >>    I am trying to write a PERL program using sockets. One side ( which
> >> we call client ) is communicating with the listener ( which we call
> >> server)
> >The server serves and the client 'listens', you have them around the
wrong
> >way.
>
> Really? Hmmm... the client is the one that initiates communication, a
> server is the one that responds to it.
Gunned down by Bad Bart again!
I guess I find a new way to be wrong every day.
Hopefully some day I will run out of ways ;-)




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

Date: Wed, 17 Jan 2001 12:32:20 +0000
From: rob <nospam@ireland.com>
Subject: converting Internet Explorer 'favorites' to Netscape bookmark file
Message-Id: <3A6590D4.74363A72@ireland.com>

Hi
I'm trying to import the favourites I've created in IE to Netscape.  IE
uses a .url file for the actual link, so in my favourites, I can click
"MSN" which uses information from the file below.

Netscape uses an HTML file to store its equivalent, a bookmark file.
The bookmark file has additional fields, such as last time visited, etc.
which are not important to me.  There are also directories aka folders
in the Favorites directory and I'll want to import the hierarchy under
these too.  Am interested in doing moving bookmarks from Netscape to IE
too.

I have used some Perl scripting in the past, but nothing really from
scratch.  I've been watching the NG and trying to use some of the best
practices but I'm stuck.
Any help available?
Thanks
-rob-



C:\WINNT\PROFILES\robrien\Favorites>type MSN.url
[InternetShortcut]
URL=http://www.microsoft.com/isapi/redir.dll?prd=ie&pver=5.0&ar=IStart
Modified=705677D1B316C00198

$ perl $prog/fav2book.pl
Use of uninitialized value in concatenation (.) or string at
/users/robrien/programming/perl/fav2book.pl line 10.
favdir is
Use of uninitialized value in concatenation (.) or string at
/users/robrien/programming/perl/fav2book.pl line 11.
bookmark is
Cannot overwrite myfile
Please use a different Main::bookmark file name

administrator@IE00671 /cygdrive/c/winnt/profiles/robrien/Favorites
$ emacs $prog/fav2book.pl



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

use strict;

$Main::debug = 1;

$Main::favdir = $ARGV[0];
$Main::bookmark = $ARGV[1];

if ( $Main::debug ) {print "favdir is $Main::favdir\n"; }
if ( $Main::debug ) {print "bookmark is $Main::bookmark\n"; }

$Main::bookmark = "myfile";
if ( -e $Main::bookmark )
{
    print "Cannot overwrite $Main::bookmark\n";
    print "Please use a different Main::bookmark file name\n";
    exit(1);
}

opendir( FAV, $Main::favdir ) || die "cannot open directory
$Main::favdir\n";

#open( BOOKMARK, ">$Main::bookmark" );

foreach $Main::filename ( sort readdir( $Main::favdir ))
{
    open( FN, $Main::filename ) || die " Cannot read file
$Main::filename";
    while( ($Main::url = <FN>) )
    {
 $Main::url = chomp( $Main::url );
 if( $Main::url =~ /^URL/ )      # This is the line we want
 {
      print "<DT><A HREF=\"" . $Main::url . "\" $Main::filename </A>
</DT>\n";
 }
    }
    close( FN );
}


close( FAV );
#close( BOOKMARK );




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

Date: Wed, 17 Jan 2001 12:38:05 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: FAQ 8.8:   How do I get the screen size?
Message-Id: <3A6593D0.BB7C3229@home.nl>


--------------95403B60CE342952B4FE7B69
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

>
>
>         use Term::ReadKey;
>         ($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize();
>
>

This is a nice module and comes very close to what i need.
I making a website with a window filling background.
And because not everyone uses the same resolution, a module like this comes in
handy.

Is there a similar module to capture a webbrowsers height and width in pixels?


--
AvA
irc.xchat.org #perl



--------------95403B60CE342952B4FE7B69
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>

<blockquote TYPE=CITE>&nbsp;
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; use Term::ReadKey;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ($wchar, $hchar, $wpixels,
$hpixels) = GetTerminalSize();
<p>&nbsp;</blockquote>
This is a nice module and comes very close to what i need.
<br>I making a website with a window filling background.
<br>And because not everyone uses the same resolution, a module like this
comes in handy.
<p>Is there a similar module to capture a webbrowsers height and width
in pixels?
<br>&nbsp;
<pre>--&nbsp;
AvA
irc.xchat.org #perl</pre>
&nbsp;</html>

--------------95403B60CE342952B4FE7B69--



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

Date: 17 Jan 2001 13:04:32 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Finite Automata with Output using PerlRE?
Message-Id: <944590$epq$1@mamenchi.zrz.TU-Berlin.DE>

Paul Cody Johnston  <pcj@Stanford.EDU> wrote in comp.lang.perl.misc:
>I'd like to be able to automata with output, like a lexer might.
>Therefore in a regular expression having several alternatives ( '|' ), I'd
>like to be able to know which alternative was successful.  I'd also like
>to be able to associate an identifier (or a number) with each alternative
>in the definition of the regex.
>
>This would involve extending the regular expression syntax and possibly
>the addition of another special variable.
>
>For example if I have the regular expression:
>
>  $animal =~ m/ cat | dog | mouse /x;
>
>I want to know what kind of animal it is. Preferably, I would have
>something like:
>
>  my $DOG = 10;
>  my $CAT = 20;
>  my $MOUSE = 30;
>
>  $animal = m/ (?~$DOG dog ) | (?~$CAT cat ) | (?~$MOUSE mouse ) /x;
>  use English;
>  my $animal_id = $MATCH_OUTPUT; 
>
>So in this example I made up some hypothetical new regex syntax where the
>(?~ ) group means "Associate the value after the tilde with the enclosing
>alternative.  If the alternative is successfully matched, set the special
>variable "MATCH_OUTPUT" to that value".
>
>Finally, I have two questions:
>
>(1) can I do this now in Perl?

The syntax is already in place: the (?{ code }) construct can be
used to identify which part of a regex actually matched, like so:

  /dog(?{ $hit_num = 1})|cat(?{ $hit_num = 2})|mouse(?{ $hit_num = 3})/

See perlre for details.  Unfortunately the construct is still
experimental and can't be recommended for production code yet.

Anno


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

Date: 17 Jan 2001 14:03:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to Create a Perl Shared Library (.so file) ?
Message-Id: <9448mu$h91$1@mamenchi.zrz.TU-Berlin.DE>

 <hmug@my-deja.com> wrote in comp.lang.perl.misc:
>Hi
>
>I would like to create a shared library (.so file) from a prel script
>which I would like to use inn my PL/SQL procedure.
>
>Can someone educate me on how I can go about creating the .so file
>given the perl script. Do I need to add anything in the perl script to
>make creation of the shared library feasible?

Can't be done.  You need a language that compiles to native machine
code to make a shared library.  Perl isn't one of those languages.

It may be possible to embed perl in another language to finally
arrive at a shared library that *behaves* as if it defined Perl
functions for other programs to use, but that would be, umm,
adventurous.

Anno


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

Date: Wed, 17 Jan 2001 10:01:55 GMT
From: lorenzobeccati@mail.omnitel.it (Lorenzo Beccati)
Subject: Include file
Message-Id: <3a656c95.6064139@news.interbusiness.it>

Is it possible to include a file where I've declared some variables
from PL files ?

In this way I can declare variables in this file and have them in all
the PL files that I need.

Thanks.
Lorenzo Beccati



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

Date: 17 Jan 2001 10:37:36 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Include file
Message-Id: <943slg$58m$4@mamenchi.zrz.TU-Berlin.DE>

Lorenzo Beccati <lorenzobeccati@mail.omnitel.it> wrote in comp.lang.perl.misc:
>Is it possible to include a file where I've declared some variables
>from PL files ?
>
>In this way I can declare variables in this file and have them in all
>the PL files that I need.

It is possible, though the term isn't "include file" in Perl.  See
perldoc perlmod for a start.

Anno



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

Date: Wed, 17 Jan 2001 10:50:32 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: Installing Module
Message-Id: <3a6577a5.681379221@news.itn.is>

On Tue, 16 Jan 2001 14:19:18 GMT, "Waarddebon"
<Waarddebon@chello.nl> wrote:

>Can anyone tell me how I can install modules on hypermart ?
>I would like to install the Time::Local module, but I've got no clue how to
>do this.
>
What in the name of all that is Perl
is a hypermart?

Time::Local is a built-in module,  part of 
any standard Perl distribution and you
should not need to install it yourself.
If you do, your perl setup is broken.

Test this from the command line with
perl -e 'use Time::Local;'
If you don't get an error, you're OK.

For more info on using the module, see
perldoc -X Time::Local

Regards,
Helgi Briem


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

Date: 17 Jan 2001 12:06:45 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Maximum array size?
Message-Id: <9441sl$s79$4@bob.news.rcn.net>

Eric <eric.kort@vai.org> wrote:
> I am pushing data onto an array from an image.  When I get to about 4MB of
> data pushed, the script freezes, despite the fact that more memory is
> available.

> Why is that?

Impossible to answer without looking at your code.  Do bear in mind,
though, that Perl variables can have a quite substantial memory overhead,
so storing 4MB of data may use a *lot* more than 4MB of memory (if the 4MB
consisted of 400 strings that were each 10K long, the memory overhead
would be trivial compared to the data.  If it consisted of 400,000 string
that were each 10 bytes long, the overhead would be several times larger
than the data).



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

Date: Wed, 17 Jan 2001 11:43:51 GMT
From: "John Boy Walton" <johngros.NOSPAM@bigpond.net.au>
Subject: Re: Need help matching multiple if's..
Message-Id: <Xzf96.66884$xW4.522726@news-server.bigpond.net.au>


"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn95k0cb.2a1.tadmc@tadmc26.august.net...
> Roger Hinson <hinson@home.com> wrote:
> What if   $y = 3;   ?
>
> Clause 1 is then false. Can't stop, have to evaluate Clause 2.
>
> Clause 2 is true, do the if() skip the else().
> >then it doesn't ever drop down to the else.  Could someone explain what
> >am I doing wrong, or what I should do to make it right?

> Use && ("and") instead of ||.
That hurts my brain trying to follow if ( ($y != 3) && ($y != 7)) {
I think if ( ($y == 3) || ($y == 7)) { and reversing the order of the
blocks, is easier to understand.
Mind you a lot of the code examples here are hard for me to follow. ;-)




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

Date: 17 Jan 2001 06:43:37 -0500
From: episonic@panix.com (Jason Goodrow)
Subject: Re: newbie - hash value size limit?
Message-Id: <9440h9$daj$1@panix3.panix.com>

In <EpW86.17$Le4.1877@vic.nntp.telstra.net> "Wyzelli" <wyzelli@yahoo.com> writes:
>>
>> I've got a hash with lots of keys - Values have one or more element
>> (saving as a ':'delimited string)
>>
>> How large is too large for the string? I mean, a hash with
>> a six charicter key and 50k value?
>>
>> Any info?
>>

>How much RAM do you have?

>How many other users are sharing the resources of the system?

It's a dialup shell account, BSD. I'll ask the sysadmin
Wondering if there's a general guideline.

thanks

goodrow@opencity.com



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

Date: 17 Jan 2001 11:17:32 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Pattern Matching
Message-Id: <943v0c$s79$1@bob.news.rcn.net>

[mildly off-topic]
Mike McPherson <hafateltec@hotmail.com> wrote:
> Ok I have somwhat figured it out.  The match below chacks for a
                                                     ^^^^^^
If I remember Psych 101 correctly, the "word" "chack" was used in a number
of early studies of the perceptual phenomenon called "set," which is
basically the tendency of the mind to perceive what it's expecting to see
even if what's there isn't actually what it's expecting (this is, of
course, the mental property that makes Douglas Adams' SEP Field work with
so little consumption of energy, and is also of major interest to
programmers, as it makes debugging difficult).

The studies found that if "chack" appeared in a text about farming, people
would tend to read it as "chick" but if it appeared in a text about
banking, people would read it as "check."

My favorite personal story about psychological set involves a piece of
80x86 assembler code that was part of an MSDOS screen-reading program for
blind users (Tinytalk).  Tinytalk had a number of configuration options
for things like what parts of the screen to monitor for changes, and it
could dynamically change those options based on what program was running
at the time.  Since many DOS programs had a "shell out" option, it was
necessary to keep a stack of program names, DOS itself not exposing the
information in any usable manner.  For a couple weeks, the feature wasn't
working; when the user shelled out to another program, the new
configuration got loaded, but when he exited the sub-shell, the
previous configuration didn't get reloaded.  I was tearing my hair out
trying to find the problem, as it was holding up a new release.  Finally,
I found it: I was pushing the stack but not popping it.  How could I have
made such a dumb mistake?  Because I knew so well that stack operations
come in pairs, I was seeing the pop even though it wasn't there.

Gerald Weinberg discusses set extensively in his classic _The Psychology
of Computer Programming_ which, IMHO, every serious programmer should
read.



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

Date: 17 Jan 2001 11:26:50 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Perl and AOL. How is this possible?
Message-Id: <943vhq$s79$2@bob.news.rcn.net>

Tad McClellan <tadmc@augustmail.com> wrote:
> Roman Stawski <roman.stawski@fr.adp.com> wrote:
>>Tad McClellan wrote:
>>> 
>>> Perl does not operate "under a browser" in ANY circumstance.
>>
>>Err, ActiveState _do_ have this thing called PerlScript 


> But that is not Perl. That is PerlScript.

Oh, it is *Perl*.  It's just not *perl*.  It's a bunch of "glue" code that
sticks a Microsoft ActiveX Scripting interface on perl and adds a built-in
variable or two.


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

Date: 17 Jan 2001 11:30:48 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Perl and AOL. How is this possible?
Message-Id: <943vp8$s79$3@bob.news.rcn.net>

Uri Guttman <uri@sysarch.com> wrote:
> abigail may be curt but many newbies need that. and she is almost always
> correct, knows plenty of perl and computer stuff and you can actually
> converse with her.

One of the great benefits of following the standard advice to read at
least a month's worth of posts to a newsgroup before making one's first
post is that you don't get unpleasantly surprised by anyone's style of
communication.



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

Date: Wed, 17 Jan 2001 08:51:51 GMT
From: Alan Pettigrew <alan@nospam.com>
Subject: Re: Perl crashes on exit
Message-Id: <VA.00000008.001c92c0@fox-europe.com>

In article <t5utgj6uj7dj82@corp.supernews.com>, Chris Stith wrote:
> From: Chris Stith <mischief@velma.motion.net>
> Newsgroups: comp.lang.perl.misc
> Subject: Re: Perl crashes on exit
> Date: Fri, 12 Jan 2001 21:24:35 -0000
> 
To reply to part of your answer:
> > The book says basename (fullname [, suffixlist]).
> 
> Please say the book gives a description of what should be in
> suffixlist. It could be that it needs to be a "list" of values,
> but not given in Perl's list context (for example, a scalar, a
> comma-separated list of multiple scalars, or a scalar containing
> comma-separated values).
> 
That is what Perl in a Nutshell says for File::Basename
Under fileparse it says:
   ($name, $path, $suffix) = fileparse($fullname, @suffixlist)
so I reckon my attempt:
> >    my @suff = ('.xml','.csv','.ini');
> >    $work = basename($file, @suff);
looks valid.

For other posters, the excerpt below is not the full code.  I do tidy up 
properly at the end of the program, but this does not stop the crash.
The crash seems related to ODBC code, but the cause seems to be the 
basename.

As things are working at present, I don't wish to mess about too much, 
but I would feel happier if I knew what caused the problem.

Is the code valid for basename, or have I made a mistake?  If so, why 
should it crash the program?  Perl is normally resilient.

Anyone got any ideas on this?

Alan

> Alan Pettigrew <alan@nospam.com> wrote:
> > Further investigation seems to point to the basename function.
> 
> > If I use:
> >    my @suff = ('.xml','.csv','.ini');
> >    $work = basename($file, @suff);
> > then the program crashes on exit.
> > If instead I use:
> >    $work = basename($file, '.xml');
> >    $work = basename($work, '.csv');
> >    $work = basename($work, '.ini');
> > then there is no crash.
> 
> What is the syntax internal to the suffixlist? Must the values
> there be separated by commas? Must it be a scalar? Perhaps
> maybe it could be a scalar with mulitple values, separated by
> spaces?
> 
> I'm not familiar with the tools you are using, but these could
> be issues leading to your crash if they are important to the
> package.
> 
> > Is the syntax of the basename wrong, or is there some bug?
> > The book says basename (fullname [, suffixlist]).
> 
> Please say the book gives a description of what should be in
> suffixlist. It could be that it needs to be a "list" of values,
> but not given in Perl's list context (for example, a scalar, a
> comma-separated list of multiple scalars, or a scalar containing
> comma-separated values).
> 
> See if any of these work for basename:
> 
>     $work = basename($file, '.xml', '.csv', '.ini');
> 
>     my @suff = ('.xml', '.csv', '.ini');
>     $work = basename($file, join(',', @suff) );
> 
>     my $suffixes = ('.xml', '.csv', '.ini');
>     $work = basename($file, $suffixes);
> 
> > Is this merely moving where fields occur in memory, and masking the 
> > crash, or can I assume this is a workaround?
> 
> I have very rarely found a case in which Perl had a problem with
> memory alignment causing a crash or saving me from one. As a matter
> of fact, I'm not sure I've ever found a problem caused by this that
> didn't already have severe errors in my code. When I say severe, I
> mean really hideous things that only get done in the dawning hours
> after all the coffee is gone. Perl, being handled by a system
> somewhere between pure interpretation and pure compilation but not
> quite "jit", protects you from a lot of the intricacies of memory
> problems. A high-level language should. (If you consider C high-level,
> then you should realize that I make the previous statement considering
> C to be mid-level. I don't think anythign breaks cleanly into two
> parts, especially high-level vs. low-level languages.)
> 
> 
> I'm not sure what you are doing is a workaround. It may be simply
> more correct for the tools you are using. It may be a working
> workaround that is no more technically correct. It may not even
> be a complete workaround, as under stress or in production many
> "workarounds" fail to work around things. My bet is, though, that
> you've found one of possibly many ways to not just alleviate your
> problem, but to eradicate it. There may be other ways which work
> as well, but maybe not. I wish I knew more about your particular
> dilemma so I could offer advice that is more helpful.
> 
> Chris
>




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

Date: 17 Jan 2001 08:48:20 GMT
From: softeng2001@aol.com (Softeng2001)
Subject: Re: Perl question
Message-Id: <20010117034820.16364.00000872@ng-cp1.aol.com>

I would do this in this way:

$file = 'somefilename';
open(F, "<$file.txt") or die "Error";
open(F2, ">$file.pl") or die "Error";

while($line = <F>)
{
  $line =~ /(.*?)\&/;
    savetotable($1);
  $line =~ s/****.*//;
  $line =~ s/arrays/hash/ig;
  print F2 $line;
}

close F;
close F2;


Thanks,
Valeriy.


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

Date: 17 Jan 2001 09:03:40 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Perl question
Message-Id: <slrn96anvc.8ot.abigail@tsathoggua.rlyeh.net>

BionicMan (bionic@engineer.com) wrote on MMDCXCVI September MCMXCIII in
<URL:news:3A6510AE.5077DE9B@engineer.com>:
'' Hi:
'' What is the quickest way to parse a file that has the following
'' characteristics:
'' -I need to be able to search for character "&" and whatever is in front
'' of needs to be saved in a table.
'' -Replacing all the words "arrays" with the word "hash"
'' -Remove all the comments which in 100% of the cases start with ****
'' -Direct  all the results of the above in a *.pl file

The quickest way is most likely sed.


Abigail
-- 
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
          q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'


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

Date: 17 Jan 2001 10:17:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl question
Message-Id: <943rf1$58m$1@mamenchi.zrz.TU-Berlin.DE>

Dave <david.obrien@ssmb.com.au> wrote in comp.lang.perl.misc:
>>         $line =~ s/****//g;
>
>Sorry this is totally wrong.  Not reading your post I guess.  Need to strip 
>the rest of the line.

This doesn't compile (you need to escape '*' in a regex if you mean
it literally).  So you posted code, found an apparent error in it and
posted again, never bothering to run it through Perl even once.

Test your code before posting.  If you can't for some reason (no such
reason here), then say that it's untested.  There's no excuse for
posting code with syntax errors.

Anno


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

Date: 17 Jan 2001 10:30:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl question
Message-Id: <943s8f$58m$2@mamenchi.zrz.TU-Berlin.DE>

Softeng2001 <softeng2001@aol.com> wrote in comp.lang.perl.misc:
>I would do this in this way:
>
>$file = 'somefilename';
>open(F, "<$file.txt") or die "Error";
>open(F2, ">$file.pl") or die "Error";
>
>while($line = <F>)
>{
>  $line =~ /(.*?)\&/;
>    savetotable($1);
>  $line =~ s/****.*//;

This is the third time this nonsensical regex is posted to this thread,
by two different posters if headers aren't misleading.  Conspiracy?

Anno


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

Date: Wed, 17 Jan 2001 10:34:55 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Perl question
Message-Id: <slrn96atab.2q0.bernard.el-hagin@gdndev25.lido-tech>

On 17 Jan 2001 10:30:39 GMT, Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de> wrote:
>Softeng2001 <softeng2001@aol.com> wrote in comp.lang.perl.misc:
>>I would do this in this way:
>>
>>$file = 'somefilename';
>>open(F, "<$file.txt") or die "Error";
>>open(F2, ">$file.pl") or die "Error";
>>
>>while($line = <F>)
>>{
>>  $line =~ /(.*?)\&/;
>>    savetotable($1);
>>  $line =~ s/****.*//;
>
>This is the third time this nonsensical regex is posted to this thread,
>by two different posters if headers aren't misleading.  Conspiracy?

It makes perfect sense to me. It simply means "zero or more of zero or
more of zero or more of zero or more followed by zero or more of
anything". :)

Cheers,
Bernard
--
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'


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

Date: Wed, 17 Jan 2001 12:41:08 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Perl question
Message-Id: <Epg96.4213$Le2.135296@typhoon.austin.rr.com>

In article <Xns902C9E8AC8511davidobrienssmbcomau@169.191.103.140>,
Dave <david.obrien@ssmb.com.au> wrote:
>BionicMan <bionic@engineer.com> wrote in <3A6510AE.5077DE9B@engineer.com>:
>
>>Hi:
>>What is the quickest way to parse a file that has the following
>>characteristics:
>>-I need to be able to search for character "&" and whatever is in front
>>of needs to be saved in a table.
>>-Replacing all the words "arrays" with the word "hash"
>>-Remove all the comments which in 100% of the cases start with ****
>>-Direct  all the results of the above in a *.pl file

[...]

>Regular expressions.
>
>Sorry a bit obvious I know
>
>open (OUT_FILE,">$outfile") or die "can not open $outfile output file";
>open (FILE_HANDLE,$input_file) or die "Can not open $input_file input 
>file";
>@file_lines=<FILE_HANDLE>;
>foreach $line (@file_lines)
>    	{
>    	$line =~ s/****//g;

[...]

You might want to think about what s/****//g would do, the * is a 
metacharacter in perl regexes.

If the input file is large then you might not want to slurp it all into 
memory at once, a more idiomatic approach might be something *like*:

  [...]

  while (<FILE_HANDLE>) {	# stashes line in $_ - see I/O Operators
				# in perlop man page

    if (/(.*)&/) {		# matches against $_ 
      # stash $1 somewhere
    }

    s/\*\*\*\*.*//;		# One way to do it, modifies $_ if regex
				# matches, there are other ways to write 
				# regex which may be prettier to you

    # other transformations & work on the content of $_

    print OUT_FILE;		# prints $_ to OUT_FILE, usually
				# if the output causes an error the close
				# will indicate it.
  }

  unless (close(OUT_FILE)) {
    die "$0: error closing $outfile\n";
  }

The perlop manual page gives examples of the use of m// and s/// to match 
and perform substitutions on the contents of variables, and the perlre 
manual page plumbs the details of the regular expressions as implemented 
in perl.

The documentation should be on-line in any reasonable perl distribution, 
on my system at home I's use

  perldoc perlop

to read the perlop manual page.  Perldoc can also search perl's 
documentation, use

  perldoc perldoc

to get started.

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |
GPG PGP Key 1024D/059913DA         | Fingerprint      0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work)      |                  75D2 9EC4 C1C0 0599 13DA


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

Date: Wed, 17 Jan 2001 12:35:22 +0100
From: "Stefan Serena" <sserena@freesurf.ch>
Subject: Problem with Upload to NT
Message-Id: <943vv5$jo4$1@bw107zhb.bluewin.ch>

I made a procedure which uploads a file from the Harddisc to a NT-Server.
The line in the HTML-document looks like that:
<input type="file" name="file" enctype="multipart/form-data">

Then, the code in the perl-file:
open (OUTFILE, ">$basedir/$fileName");
while ($bytesread = read($file, $buffer, 1024))

 print OUTFILE $buffer;
}
close (OUTFILE);

All that works good if I upload any file to an unix (linux)-server, it also
works if I upload a ascii-file to a NT-Server, but it doesn't work properly
if I want to upload a binary-file to a NT-Server.
I've seen that there's a special character which is interpreted by perl like
a \n. So it makes a linefeed quite often which is the cause that the file
(eg *.mpg) can't be played correctly or not at all. I've tryed to substitute
it (s///), but it didn't work neither.

Thanx

Stefan




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

Date: Wed, 17 Jan 2001 12:57:23 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Problem with Upload to NT
Message-Id: <slrn96b5m7.fpj.rgarciasuarez@rafael.kazibao.net>

Stefan Serena wrote in comp.lang.perl.misc:
> I made a procedure which uploads a file from the Harddisc to a NT-Server.
> The line in the HTML-document looks like that:
> <input type="file" name="file" enctype="multipart/form-data">
> 
> Then, the code in the perl-file:
> open (OUTFILE, ">$basedir/$fileName");
> while ($bytesread = read($file, $buffer, 1024))
> 
>  print OUTFILE $buffer;
> }
> close (OUTFILE);
> 
> All that works good if I upload any file to an unix (linux)-server, it also
> works if I upload a ascii-file to a NT-Server, but it doesn't work properly
> if I want to upload a binary-file to a NT-Server.

I think you should look up the binmode function in perlfunc :
  perldoc -f binmode

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 17 Jan 2001 08:31:47 -0500
From: "Eric" <eric.kort@vai.org>
Subject: Re: Putting text in an image? THANKS!
Message-Id: <9446ip$sec$1@msunews.cl.msu.edu>


"Eric" <eric.kort@vai.org> wrote in message
news:93nb9c$1udb$1@msunews.cl.msu.edu...
> Is there a perl module to help with placing text on an image?  For
example,
> I am writing a program to generate a histogram of an image (thus creating
a
> tiff), and I would like to be able to put numbers on the x axis scale.
Must
> I draw the numbers pixel by pixel, or is there a simpler way?
>
> Thanks,
> Eric
>
>
Thanks for all the options.  I will check it out, and try to pick one!

Eric




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

Date: Wed, 17 Jan 2001 09:47:24 GMT
From: "John Boy Walton" <johngros.NOSPAM@bigpond.net.au>
Subject: Re: Random Numbers with a Twist
Message-Id: <MSd96.66638$xW4.520330@news-server.bigpond.net.au>


"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m366jfxfye.fsf@mumonkan.sunstarsys.com...
> Indeed, and it would essentially reproduce the correct solution
> that Craig submitted a while ago.  For reasons that are unclear
> to me, the topic of this thread has now become the domain of
> applicability of his code, since noone has offered any alternative.
> Bizarre.
>
> If ifs and buts were candy and nuts, we'd all have a merry Christmas.
 Sorry Joe I read the first four posts in this thread and thought it was too
esoteric to help. So I submitted my post then read the rest and yes Craigs
solution is much better than mine. I have to try and adapt my minesweeper to
use his hash idea. I don't have the problem of no bombs being adjacent to
others so it would speed up my code and avoid the problem Abigail and Garry
pointed out.




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

Date: Wed, 17 Jan 2001 12:34:53 +0100
From: "Stefan Serena" <sserena@freesurf.ch>
Subject: Re: Random text script, got one?:-)
Message-Id: <943vu7$jnv$1@bw107zhb.bluewin.ch>

Hi

It's always a good idea to go to www.cgi-resources.com

Stefan

<johnstarr2001@my-deja.com> schrieb im Newsbeitrag
news:9435qs$1im$1@nnrp1.deja.com...
> Hi I looking for a random text script if someone has already have made.
> Thanks.
>
>
> Sent via Deja.com
> http://www.deja.com/




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

Date: 17 Jan 2001 09:02:46 GMT
From: softeng2001@aol.com (Softeng2001)
Subject: Re: techniques for finding slow code?
Message-Id: <20010117040246.16364.00000873@ng-cp1.aol.com>

use Benchmark;

$start_time = new Benchmark;
#some loop here
$end_time = new Benchmark;
print "time = ".timediff($start_time, $end_time);

or smth like this. Look at the Benchmark module documentation, I do not
remember all functions.

Thanks,
Valeriy.


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

Date: Wed, 17 Jan 2001 10:51:46 -0000
From: "Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1>
Subject: Re: TNEF For Perl. Need Help. Is this a Perl Script?
Message-Id: <943td2$4a6$1@soap.pipex.net>

<metacomputer1239@my-deja.com> wrote in message
news:9425ed$4om$1@nnrp1.deja.com...
: Hello,
:     I am try to setup a program called AMAVIS email virus scanner.
: The Linux box is using RED HAT 6.0, when I try to install the AMAVIS it
: gives me a message that I need TNEF. I can't find TNEF for REDHAT 6.0
: RPM. Does anyone no where it can be found?
:      Is TNEF a Perl module, or program? Can a newer version of TNEF be
: re-compiled, for Red HAt 6.0.

It's all in the README for amavis.

Geoff




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

Date: Wed, 17 Jan 2001 10:54:31 +0000
From: "roadsweeperman@hotmail.com" <roadsweeperman@hotmail.com>
Subject: UK PERL PROGRAMMER REQ
Message-Id: <3A6579E7.38F121DC@hotmail.com>

Hi

We are a mobile phone mail order company  looking for a reliable
freelance perl specialist to adapt off the shelf e-commerce scripts to
our needs.

Also other projects in the pipeline.

Must be UK based.



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

Date: Wed, 17 Jan 2001 11:00:58 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: UK PERL PROGRAMMER REQ
Message-Id: <slrn96aur8.2q0.bernard.el-hagin@gdndev25.lido-tech>

On Wed, 17 Jan 2001 10:54:31 +0000, roadsweeperman@hotmail.com
<roadsweeperman@hotmail.com> wrote:
>Hi
>
>We are a mobile phone mail order company  looking for a reliable
>freelance perl specialist to adapt off the shelf e-commerce scripts to
>our needs.

Good for you. So what's your Perl question?

>Also other projects in the pipeline.

Well, you'd better get them out of there. Nothing more annoying than a
clogged pipe.

Cheers,
Bernard
--
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'


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

Date: Wed, 17 Jan 2001 19:15:33 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: What do you call the => operator?
Message-Id: <slrn96al55.fu5.mgjv@martien.heliotrope.home>

On Tue, 16 Jan 2001 15:55:22 -0800,
	Matt Schalit <mschalit@pacbell.net> wrote:
> In article <slrn966d6p.cvd.tadmc@tadmc26.august.net>, tadmc@augustmail.com says...
> 
>  
>> What is your point?
>> 
>> We want to know what it is called.
>> 
>> Your Camel quote above does not provide a name for it.
>> 
>> Do you know what the word "digraph" means? It doesn't sound like it...
> 
> 
> I don't know who you are or what you represent.
> This is the first post I've read from you, and you sound like
> an asshole.  I wonder how many other people think the same?

Hmmm.. Find the posts in this group with the title 'Statistics for
comp.lang.perl.misc', and just see how often Tad posts here. If you
can't remember having seen any posts of him before, you either have a
killfile entry for him, a lousy newsfeed, dyslexia, a bad memory, or
you've only been reading this group for less than 3 minutes.

On the other hand.... Who are you, anyway? According to deja, you have
posted 3 posts to this group. This probably explains why I never saw
your name before, as far as I can recall.

> Btw, when someone puts something inside quotes, the result is
> called a quotation, dumbass.

Name calling, again. It looks like you're going for a personal entry in
a bunch of killfiles this way. 

You are really showing a severe lack of understanding of Usenet, this
group in particular, and manners, not to speak of common sense. With a
tiny little bit of research [1], you could have found out that Tad is a
well respected poster here, who has been around a bit longer than you
have. It is never a good idea to attack, for whatever reason, a well
respected member of a group, especially not if you have the delusional
idea that the other members of the group are going to think that you are
doing the right thing. You will be disappointed. 

And name calling is about the silliest thing you can do.

You have just ensured that the most clueful people probably won't see
your posts anymore, next time you can't get your perl to compile, or you
have a real problem with Perl. 

Not clever. Not clever at all. You need a LART.

Martien

[1] Even without knowing his other email address that has a longer
history here.
-- 
Martien Verbruggen              | 
Interactive Media Division      | Can't say that it is, 'cause it
Commercial Dynamics Pty. Ltd.   | ain't.
NSW, Australia                  | 


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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


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


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