[16945] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4357 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 18 11:06:10 2000

Date: Mon, 18 Sep 2000 08:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <969289509-v9-i4357@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 18 Sep 2000     Volume: 9 Number: 4357

Today's topics:
    Re: [Q] Two Questions <pap@sotonians.org.uk>
    Re: [Q] Two Questions (Gwyn Judd)
        Can I dynamically create hashes? (Bryce Pursley)
    Re: can i run a cgi script within javascript tag? <pbyrne@ie.oracle.com>
        Compiling PERL Modules marshala@my-deja.com
    Re: Finding the width and height of a GIF (Martien Verbruggen)
        How to sort a comma delimited file on the Nth field? <akelingos@petrosys-usa.com>
    Re: How? Read a file from another server? (Csaba Raduly)
    Re: intermittent glob error (Martien Verbruggen)
    Re: Just Cant Get The File Upload Thing <ubl@schaffhausen.de>
    Re: Just curious.. <ren.maddox@tivoli.com>
        New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
        perlcc : *NOT* the DynaLoader problem sauloon_2000@my-deja.com
        Running a perl program as a daemon? <Damien_Dove@bigpond.com>
    Re: Serial port and threads (Rafael Garcia-Suarez)
    Re: Shortest code for Fibonacci? <pdcawley@bofh.org.uk>
    Re: single line regex and multi-line regex without rese (Eric Smith)
    Re: sprintf() rounding problem mexicanmeatballs@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 18 Sep 2000 14:05:03 +0000
From: "Paul Taylor" <pap@sotonians.org.uk>
Subject: Re: [Q] Two Questions
Message-Id: <Rtox5.142$gm6.7539@nnrp4.clara.net>

Hi,

> 	1- What will happen if I specify a number like 0.123 or
>            00.123. As far as I understand, the numbers that start with
> 	   0 in Perl are treated as octal numbers whereas these
> 	   numbers are floating point decimal format numbers.
> 

In the case of 0.123, Perl will treat your value as a standard float.

It's a leading (superfluous-looking) zero that 
Perl looks out for in octal numbers.

Your second example 00.123, gets reported as 
123.0000 when printed as a decimal float.

Off-hand, I don't know why this happens.  Perhaps some of the experts
can enlighten us.

> 	2- In Perl, varibales can be represented as $x or ${x}. What
> 	   is the significance or reason for exitance of the second
>         notation? 

This is a load easier.  Assume you have a variable called $prefix, and
want to combine it with something else to make, say, a hash key.

$hash{"$prefix_value"};

In this example, Perl will assume that you want to use the 
variable $prefix_value to dereference the hash.

You can explicitly determine the variable you wish to use
by using the braces notation :-

$hash{"${prefix}_value"};

Now, Perl knows that it has to use a variable called $prefix,
which is what you really wanted.

P.


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

Date: Mon, 18 Sep 2000 13:12:00 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: [Q] Two Questions
Message-Id: <slrn8sc54t.hr9.tjla@thislove.dyndns.org>

I was shocked! How could Farooq Azam <azam@birch.ee.vt.edu>
say such a terrible thing:
>Hello,
>
>I have two questions for which I could not find an answer to from the
>books I have. 
>
>	1- What will happen if I specify a number like 0.123 or
>           00.123. As far as I understand, the numbers that start with
>	   0 in Perl are treated as octal numbers whereas these
>	   numbers are floating point decimal format numbers.

Did you try?

[gwyn@thislove:~]$ perl -w
$dec = 0.0123;
$oct = 0123;
print "\$dec = $dec\n";
print "\$oct = $oct\n";
__END__
$dec = 0.0123
$oct = 83

Sometimes it's quicker to just try and see what happens :)

>	2- In Perl, varibales can be represented as $x or ${x}. What
>	   is the significance or reason for exitance of the second
>	   notation? 

The two versions mean basically the same thing. The parenthesised form
is useful in a double-quoted string:

$text = "abcdef${varname}ghijkl";

when you don't really mean:

$text = "abcdef$varnameghijkl";

and you can't seperate them with whitespace:

$text = "abcdef$varname ghijkl";

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
"I know not with what weapons World War III will be fought, but
World War IV will be fought with sticks and stones."
		-- Albert Einstein


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

Date: Mon, 18 Sep 2000 14:43:44 GMT
From: hbpursle@duke-energy.com (Bryce Pursley)
Subject: Can I dynamically create hashes?
Message-Id: <39c60958.1119702557@news.infoave.net>

I'm reading a history file which is a comma delimited file.  I'm
pulling out records that are "ALARM" records from the "SIMCST"
equipment.

What I want to do is to create a separate hash for each unit that is
named by the $tid  variable.  The code below doesn't seem to be
working.  I think all it is doing is creating one hash called %tid
rather than substituting the variable name for the hash name.  How do
I do what I am wanting?




while (defined ($filename = glob ($histfilelist0)) ) { # Begin Block 1
 open (HISTFILE, $filename) || die "can't open $filename: $!";
 while (defined <HISTFILE>) { # Begin Block 1A
  foreach (<HISTFILE>) { # Begin Block 1B
   @tmp = split (/,/);
   if (($tmp[5] =~ (/^SIMCST/)) && ($tmp[7] =~ (/^ALARM|^Alarm/))) {
    $tid = ($tmp[2]);
    $timestamp = $tmp[0];
    $tid{$timestamp} = [ @tmp ];
   }
  } # end Block 1B
 } # end Block 1A
} # end Block 1


Bryce


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

Date: Mon, 18 Sep 2000 14:38:26 +0100
From: Pascal Byrne <pbyrne@ie.oracle.com>
Subject: Re: can i run a cgi script within javascript tag?
Message-Id: <39C61AD2.38CE814C@ie.oracle.com>

This is a multi-part message in MIME format.
--------------E6F6677C01227AEAAE3D5738
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I'm not sure if this is what you want. Nothing after the javascript will be processed:

<script language="javascript">
  location.replace("http://myserver.com/cgi/script.pl");
</script>

> klidge wrote:
> >
> > I would like to ask you if it's possible for a cgi script written in perl
> > to run from within a javascript script
> > example:
> > Html source:
> > <script language="javascript">
> > --the code i need here---
> > </script>
> > In order for the "result" after accessing the page would be the same as the
> > htm source was:
> > <script language="javascript">
> > document.write('this line has been generated from a cgi perl script');
> > </script>
> >
> > thank you in advance
>
> Sortof.
>
> You could declare an ILAYER inside a DIV , then if IE is detected
> overwrite the contents of the DIV with an IFRAME.
>
> Now you can create a request in the IFRAME/ILAYER that represents
> a request to your server side javascript , which would in turn , output
> javascript to update the interaction
>
> --
> --=<> Dr. Clue (A.K.A. Ian A. Storms) <>=--
> --=<[]>=- http://www.drclue.net
> --=<[]>=- C++ HTML JavaScript DHTML CGI TCP/IP SQL JAVA VRML NSAPI
> --=<[]>=- http://www.drclue.net/F1.cgi/HTML/HTML.html (My famous
> HTML/CGI guide.)

--------------E6F6677C01227AEAAE3D5738
Content-Type: text/x-vcard; charset=us-ascii;
 name="pbyrne.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Pascal Byrne
Content-Disposition: attachment;
 filename="pbyrne.vcf"

begin:vcard 
n:Byrne;Pascal
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:pbyrne@ie.oracle.com
title:WPTG Engineering
end:vcard

--------------E6F6677C01227AEAAE3D5738--



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

Date: Mon, 18 Sep 2000 13:53:17 GMT
From: marshala@my-deja.com
Subject: Compiling PERL Modules
Message-Id: <8q56o4$de8$1@nnrp1.deja.com>

I am learning PERL in a Win32 environment, looking at scripts that were
written on UNIX boxes.  We have a version of PERL which runs quite
happily under Windows NT.  However, I am having a lot of difficulty
trying to use modules.

I downloaded a module called 'Net::FTP' from CPAN today.  I looked at
the README, which said I should type the command 'PERL makefile.pl'.  I
did this, it processed for a while, and then I got an error message,
saying that it couldn't find my 'configuration' file.

I tried using a module called Date::Time the other day.  when I
downloaded that file, I received a 'C' filr and an 'H' file.  The
documentation indicated that it most be useful to have a 'C' compiler
handy.

Is there something special about downloading modules, installing
modules or compiling modules that I have missed out?  Can I compile
these modules under a Win32 environment or does it have to be in a UNIX
environment?

Any help much appreciated...

Regards

Andy Marshall


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 19 Sep 2000 00:29:17 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Finding the width and height of a GIF
Message-Id: <slrn8sc65c.ntr.mgjv@martien.heliotrope.home>

On Mon, 18 Sep 2000 12:45:50 GMT,
	Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
> I was shocked! How could Martien Verbruggen <mgjv@tradingpost.com.au>
> say such a terrible thing:
> >On Mon, 18 Sep 2000 09:14:04 GMT,
> >	Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
> >> Image::Info
> >
> >Slightly immature code, I believe? And it doesn't actually support GIF
> >(yet?).
> 
> Well my copy says it supports GIF (this is version 0.4 I believe).

Hmmm... Interesting.

$ perl -MCPAN -e shell
cpan> readme Image::Info
[snip]
This Perl extention allows you to extract information from various
image files.  In this alpha release we only support JPEG (plain JFIF
and Exif) and PNG.  Usage is something like this:
[snip]
cpan> i Image::Info
Module id = Image::Info
    CPAN_USERID  GAAS (Gisle Aas <gisle@aas.no>)
    CPAN_VERSION 0.05
    CPAN_FILE    G/GA/GAAS/Image-Info-0.05.tar.gz
    INST_FILE    (not installed)

www.cpan.org only lists 0.04 and 0.05. Maybe you have 0.04?

Anyway, the README for either states that there are only two supported
formats. But again: maybe that's bogus information.

I never bothered downloading it, because it simply looks too immature :)

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd.   | reflects this.
NSW, Australia                  | 


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

Date: Mon, 18 Sep 2000 09:11:32 -0500
From: "Alec Kelingos" <akelingos@petrosys-usa.com>
Subject: How to sort a comma delimited file on the Nth field?
Message-Id: <ssc8d79th3t24@corp.supernews.com>

I have a comma delimited file.  e.g.

"alec","10001","42159","michigan"
"bob","801","42002","ohio"
"fred","55891","42159","oklahoma"

How can I sort this file using the 3rd column and write out to a new file?
I can create a hash using the 3rd column as keys and the entire record as
the value, then sort the keys and write each element to a new file . is that
the best way or is there some other way?

Thanks in advance,
Alec





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

Date: 13 Sep 2000 10:31:49 GMT
From: real.email@signature.this.is.invalid (Csaba Raduly)
Subject: Re: How? Read a file from another server?
Message-Id: <8FAE77E90quuxi@194.203.134.135>

A million monkeys weren't enough! It took webmaster@cobnet.com
(leonardz) on 07 Sep 2000 to produce <8p8vcd$i9c$1@nnrp1.deja.com>: 

[snip]
>open (DATAFILE, "<$FileName");
>
>??
>
>>> Don't do unchecked opens.
>
>This is my file, I know what is in it, however it is located on
>another server for space saving reasons. I am guessing you are
>suggesting I check it in case someone has tampered with it?
>

The point is that you should *ALWAYS* check the result of open, like 
this:

open (DATAFILE, "<$FileName") or die "Couldn't open file: $!";

There are many reasons why open could fail: the file might have been 
deleted by the Grim File Reaper, the disk might have gone bust, lpr on 
fire :-) 

There's not much point in reading DATAFILE if you couldn't open it 
successfully in the first place.

Remember C's fopen() ? It returns a FILE*, or NULL on error. Not 
checking its return value is a sure way to get a protection fault 
sooner rather than later.

HTH,
-- 
Csaba Raduly, Software Developer (OS/2), Sophos Anti-Virus
mailto:csaba.raduly@sophos.com      http://www.sophos.com/
US Support +1 888 SOPHOS 9      UK Support +44 1235 559933
Life is complex, with real and imaginary parts.


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

Date: Tue, 19 Sep 2000 00:37:40 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: intermittent glob error
Message-Id: <slrn8sc6l4.ntr.mgjv@martien.heliotrope.home>

On Mon, 18 Sep 2000 12:45:28 GMT,
	Mike <m_j_o@my-deja.com> wrote:
> Hello,
> 
> I've got Perl 5.005_03 running on Solaris 7, and I'm getting an error
> from a glob call, but only from time to time. The error is like so:

glob in 5.005_03 still used to spawn a (c?)sh to do the actual globbing.
Any problems that the shell has would be problems of perl. In 5.6.0 it's
all done internally.

> glob failed (child exited with status 1) at cycle.pl line 45, <_GEN_3>
> chunk 534.

Sounds very much like the shell it spawned to do the actual globbing
barfed on something.

Have you checked perldiag?

$ perldoc perldiag
[snip]
       glob failed (%s)
           (W glob) Something went wrong with the external
           program(s) used for `glob' and `<*.c>'.  Usually, this
           means that you supplied a `glob' pattern that caused
           the external program to fail and exit with a nonzero
           status.  If the message indicates that the abnormal
           exit resulted in a coredump, this may also mean that
           your csh (C shell) is broken.  If so, you should
           change all of the csh-related variables in config.sh:
           If you have tcsh, make the variables refer to it as if
           it were csh (e.g.  `full_csh='/usr/bin/tcsh''); other­
           wise, make them all empty (except that `d_csh' should
           be `'undef'') so that Perl will think csh is missing.
           In either case, after editing config.sh, run `./Con­
           figure -S' and rebuild Perl.
[snip]

Ugly, ugly, ugly. But, as said, it's fixed in 5.6.0, hopefully without
introducing new problems.

> Does this sound familiar to anyone? I'm globbing a reasonably large
> directory (often has 2000+ messages), and the directory may be growing
> while the glob takes place. Are either of these characteristics a
> problem for a glob call?

On directories of this size, you shouldn't use globbing anyway.
Actually: let me rephrase that: Never use globbing, except for quick and
dirty work.

I would seriously rewrite this with opendir, readdir and closedir,
especially if you aren't going to upgrade to 5.6.0 soon.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd.   | password?
NSW, Australia                  | 


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

Date: Mon, 18 Sep 2000 15:18:13 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Just Cant Get The File Upload Thing
Message-Id: <39C61614.3731DAE7@schaffhausen.de>

> I would like to thank Joe and Brian for their assistance.
> I figured out why I was having some much trouble. In my main
> script I parse the form data. When I put the subroutine for
> the image upload features into the main script using the
> CGI.pm module's form features it was not picking up the
> form value. Maybe I am wrong in saying this, but I assume
> you cannot parse a form, then in a subroutine try to
> pick out a form value with the CGI features.
> Anyway, I dumped it into its own little script and passed
> values between the two.
> If my deductions are incorrect, please let me know. I am
> quickly learning more and more every day and am hoping
> to contribute back to the community when I am up to speed
> on these things.
> Again, thanks for everyone's help!!!

If you parse the form yourself and then let the CGI module try do it again
that will fail. However, there is no reason to parse to form yourself. You
can just let CGI.pm do it for you all the time, so you dont get in trouble
when you want to do a file upload.

later,

malte




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

Date: 17 Sep 2000 22:09:28 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Just curious..
Message-Id: <m3og1mbdlj.fsf@dhcp11-177.support.tivoli.com>

halofive <halo_five@my-deja.com> writes:

> I was, for the most part, just curious about how, or `if' for that
> matter, you could print "three" from the hash without using key() etc,
> but I'm probably just being anal.

For that matter, you might as well as the same thing about "one".  Do
you have an answer for that?

-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 18 Sep 2000 14:39:23 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <ssca8r5h3t7@corp.supernews.com>

Following is a summary of articles from new posters spanning a 7 day
period, beginning at 11 Sep 2000 15:39:06 GMT and ending at
18 Sep 2000 15:05:03 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" email address and name.
    - Original Content Rating (OCR) is the ratio of the original content
      volume to the total body volume.
    - Find the News-Scan distribution on the CPAN!
      <URL:http://www.perl.com/CPAN/modules/by-module/News/>
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Copyright (c) 2000 Greg Bacon.
      Verbatim copying and redistribution is permitted without royalty;
      alteration is not permitted.  Redistribution and/or use for any
      commercial purpose is prohibited.

Totals
======

Posters:  232 (43.8% of all posters)
Articles: 429 (24.6% of all articles)
Volume generated: 715.0 kb (23.2% of total volume)
    - headers:    349.2 kb (7,019 lines)
    - bodies:     351.0 kb (11,854 lines)
    - original:   233.0 kb (8,154 lines)
    - signatures: 14.4 kb (340 lines)

Original Content Rating: 0.664

Averages
========

Posts per poster: 1.8
    median: 1.0 post
    mode:   1 post - 140 posters
    s:      2.5 posts
Message size: 1706.7 bytes
    - header:     833.4 bytes (16.4 lines)
    - body:       837.8 bytes (27.6 lines)
    - original:   556.1 bytes (19.0 lines)
    - signature:  34.4 bytes (0.8 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

   28    55.6 ( 22.5/ 29.6/  5.7)  Anders Lund <anders@wall.alweb.dk>
   15    20.4 ( 11.0/  9.5/  8.6)  rathmore@tierceron.com
    9    31.0 ( 12.5/ 16.8/ 16.8)  David Steuber <nospam@david-steuber.com>
    8    12.8 (  7.3/  5.1/  1.4)  "James M. Luongo" <jluongonospam@draper.com>
    7     7.6 (  4.7/  3.0/  2.4)  Thom Harp <thomharp@flash.net>
    7    16.2 (  6.6/  9.6/  3.5)  Dave O'Brien <david.obrien@ssmb.com.au>
    6    11.2 (  4.1/  7.1/  2.8)  Kevin Metcalf <notkmetcalf@notlighthousemarketingnot.com>
    5     8.9 (  4.8/  4.2/  1.0)  ubl@schaffhausen.de
    5    12.1 (  4.8/  6.2/  4.0)  Ilmari Karonen <usenet11212@itz.pp.sci.fi>
    5     8.2 (  4.4/  3.8/  2.5)  "Tigz" <tigz@ntlworld.com>

These posters accounted for 5.4% of all articles.

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

  55.6 ( 22.5/ 29.6/  5.7)     28  Anders Lund <anders@wall.alweb.dk>
  31.0 ( 12.5/ 16.8/ 16.8)      9  David Steuber <nospam@david-steuber.com>
  20.4 ( 11.0/  9.5/  8.6)     15  rathmore@tierceron.com
  16.2 (  6.6/  9.6/  3.5)      7  Dave O'Brien <david.obrien@ssmb.com.au>
  12.8 (  7.3/  5.1/  1.4)      8  "James M. Luongo" <jluongonospam@draper.com>
  12.5 (  7.0/  5.5/  2.9)      4  David Hugh-Jones <davidhj@mail.com>
  12.1 (  4.8/  6.2/  4.0)      5  Ilmari Karonen <usenet11212@itz.pp.sci.fi>
  11.2 (  4.1/  7.1/  2.8)      6  Kevin Metcalf <notkmetcalf@notlighthousemarketingnot.com>
   8.9 (  4.8/  4.2/  1.0)      5  ubl@schaffhausen.de
   8.2 (  4.4/  3.8/  2.5)      5  "Tigz" <tigz@ntlworld.com>

These posters accounted for 6.1% of the total volume.

Top 10 Posters by OCR (minimum of three posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

1.000  (  1.3 /  1.3)      3  "Jim Verzino" <jimve@yahoo.com>
1.000  ( 16.8 / 16.8)      9  David Steuber <nospam@david-steuber.com>
0.976  (  3.4 /  3.5)      3  r.schwebel@zeutec.de
0.942  (  1.7 /  1.8)      3  andre_sanchez@my-deja.com
0.907  (  2.3 /  2.5)      3  Andy Flisher <news@flish.co.uk>
0.907  (  8.6 /  9.5)     15  rathmore@tierceron.com
0.809  (  2.4 /  3.0)      7  Thom Harp <thomharp@flash.net>
0.800  (  3.4 /  4.2)      3  "Someperson" <nothinghere!complainaboutthat!!!>
0.797  (  0.9 /  1.1)      3  wrathmolten@my-deja.com
0.731  (  1.1 /  1.5)      3  greg_sands@my-deja.com

Bottom 10 Posters by OCR (minimum of three posts)
=================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.485  (  0.7 /  1.4)      4  i0519@my-deja.com
0.467  (  0.6 /  1.3)      3  "Lucisferre" <lucisferre@email.com>
0.390  (  2.8 /  7.1)      6  Kevin Metcalf <notkmetcalf@notlighthousemarketingnot.com>
0.375  (  0.4 /  1.1)      3  Barna <barna@megapage.ch>
0.363  (  3.5 /  9.6)      7  Dave O'Brien <david.obrien@ssmb.com.au>
0.318  (  0.8 /  2.5)      4  TM <tm@kernelconsult.com>
0.273  (  1.4 /  5.1)      8  "James M. Luongo" <jluongonospam@draper.com>
0.252  (  0.9 /  3.6)      3  Patrick Connolly <patrickjos@hotmail.com>
0.235  (  1.0 /  4.2)      5  ubl@schaffhausen.de
0.192  (  5.7 / 29.6)     28  Anders Lund <anders@wall.alweb.dk>

34 posters (14%) had at least three posts.

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      36  comp.lang.perl
      28  alt.perl
      15  comp.lang.perl.modules
      11  comp.lang.javascript
       6  comp.lang.tcl
       5  comp.lang.awk
       5  comp.lang.python
       5  comp.lang.perl.tk
       5  comp.lang.java
       4  comp.programming

Top 10 Crossposters
===================

Articles  Address
--------  -------

       5  "Moshe Eshel" <moshe@u4all.com>
       5  Roy Terry <royterry@earthlink.net>
       5  sholden@BellAtlantic.net
       5  *frankie*@centurytel.net
       4  Radovan Garabik <garabik@center.fmph.uniba.sk.spam>
       4  "robert hou" <r_hou@yahoo.com>
       3  "Lucisferre" <lucisferre@email.com>
       3  Patrick Connolly <patrickjos@hotmail.com>
       2  "Hansgeorg Zauner" <hg_zauner@gmx.de>
       2  "Alvaro Bahamondes V." <alvaro@arbol-logika.com>


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

Date: Mon, 18 Sep 2000 13:51:43 GMT
From: sauloon_2000@my-deja.com
Subject: perlcc : *NOT* the DynaLoader problem
Message-Id: <8q56l6$ddd$1@nnrp1.deja.com>

Dear all,

  I am trying to compile the following code using
perlcc. The compilation went fine but upon
execution, I get an undefined symbol (Perl_sv_2uv)
problem. I have search in vain for help in the
newsgroups and would appreciate any kind of help.

  Thanks!

================== Perl code follows =============

#!/usr/local/bin/perl

use DynaLoader;
use LWP::UserAgent;

my($url) = shift || die "get <url>";
my($ua)  = new LWP::UserAgent;
my($req) = new HTTP::Request GET => $url;

print $req->as_string;
my($res) = $ua->simple_request($req);
print $res->as_string;

========= Compilation messages follows
==============

--------------------------------------------------------------------------------
Compiling get.pl:
--------------------------------------------------------------------------------
Making C(get.pl.c) for get.pl!
perl -I/usr/local/lib/perl5/5.6.0/i686-linux
-I/usr/local/lib/perl5/5.6.0
-I/usr/local/lib/perl5/site_perl/5.6.0/i686-linux
-I/usr/local/lib/perl5/site_perl/5.6.0
-I/usr/local/lib/perl5/site_perl -I. -MB::Stash
-c  get.pl
perl -I/usr/local/lib/perl5/5.6.0/i686-linux
-I/usr/local/lib/perl5/5.6.0
-I/usr/local/lib/perl5/site_perl/5.6.0/i686-linux
-I/usr/local/lib/perl5/site_perl/5.6.0
-I/usr/local/lib/perl5/site_perl -I.
-MO=C,-umain,-uAutoLoader,-uLWP,-uLWP::MemberMixin,-uLWP::Protocol,-uLWP::Debug,-uLWP::UserAgent,-uDB,-uData,-uData::Dumper,-uHTTP,-uHTTP::Status,-uHTTP::Response,-uHTTP::Headers,-uHTTP::Headers::Util,-uHTTP::Request,-uHTTP::Date,-uHTTP::Message,-uConfig,-uExporter,-uExporter::Heavy,-uwarnings,-uwarnings::register,-uHTML,-uHTML::Parser,-uHTML::HeadParser,-uHTML::Entities,-ustrict,-uVMS,-uVMS::Filespec,-uTime,-uTime::Zone,-uTime::Local,-uattributes,-uoverload,-uURI,-uURI::WithBase,-uURI::URL,-uURI::_generic,-uURI::Escape,-uURI::mailto,-uURI::file,-uURI::_foreign,-uvars,-uCarp,-uCarp::Heavy,-uMIME,-uMIME::Base64
get.pl
Starting compile
Walking tree
Exporter saved (it is in HTML::Entities's @ISA)
HTML::Parser saved (it is in HTML::HeadParser's
@ISA)
DynaLoader saved (it is in HTML::Parser's @ISA)
HTTP::Message saved (it is in HTTP::Request's
@ISA)
Prescan
Saving methods
Bootstrap attributes get.pl
Bootstrap HTML::Parser
/usr/local/lib/perl5/site_perl/5.6.0/i686-linux/HTML/Parser.pm
No definition for sub URI::WithBase::as_string
No definition for sub URI::WithBase::as_string
(unable to autoload)
Writing output
Loaded B
Loaded IO
Loaded Fcntl
Loaded HTML::Parser
bootstrapping HTML::Parser added to xs_init
get.pl syntax OK
Compiling C(get) for get.pl!
perl -I/usr/local/lib/perl5/5.6.0/i686-linux
-I/usr/local/lib/perl5/5.6.0
-I/usr/local/lib/perl5/site_perl/5.6.0/i686-linux
-I/usr/local/lib/perl5/site_perl/5.6.0
-I/usr/local/lib/perl5/site_perl -I.
/tmp/get.pl.tst
cc -fno-strict-aliasing -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64
-I/usr/local/lib/perl5/5.6.0/i686-linux/CORE -o
get get.pl.c   -L/usr/local/lib
-L/usr/local/lib/perl5/5.6.0/i686-linux/CORE
-lperl -lnsl -lndbm -lgdbm -ldb -ldl -lm -lc
-lposix -lcrypt
/usr/local/lib/perl5/5.6.0/i686-linux/auto/DynaLoader/DynaLoader.a
/usr/local/lib/perl5/5.6.0/i686-linux/auto/IO/IO.so
/usr/local/lib/perl5/site_perl/5.6.0/i686-linux/auto/HTML/Parser/Parser.so
/usr/local/lib/perl5/5.6.0/i686-linux/auto/Fcntl/Fcntl.so

============ Run time error messages follows
==========

192:~/scratch/perlcc> ./get http://www.cisco.com/
GET http://www.cisco.com/


 ./get: error in loading shared libraries:
/usr/local/lib/perl5/5.6.0/i686-linux/auto/Socket/Socket.so:
undefined symbol: Perl_sv_2uv

=================================================


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 19 Sep 2000 00:33:35 +1000
From: "Damien Dove" <Damien_Dove@bigpond.com>
Subject: Running a perl program as a daemon?
Message-Id: <SFpx5.53214$c5.148408@newsfeeds.bigpond.com>

Hi all. I was wondering how you program a perl script as a daemon using
inetd.

At the moment i have a program that runs selected commands to a schedule.
I'd like to convert that program to a daemon. What things do i have to
change etc.. Is there any information on the web that could shed some light
on the issue?

Thanks in advance
Damien





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

Date: Mon, 18 Sep 2000 13:31:15 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Serial port and threads
Message-Id: <slrn8sc6l8.ish.rgarciasuarez@rafael.kazibao.net>

Eric Bohlman wrote in comp.lang.perl.misc:
>Robert Schwebel (r.schwebel@zeutec.de) wrote:
>: I have to communicate with a device on the serial port which uses "\r"
>: as a line separator. 
>: 
>: The problem is that my application is multithreading with one thread
>: printing output to the terminal (which obviously has to use \n as line
>: separator) and another one communicating with a serial device (which
>: sends \r). 
>: 
>: How can this be done? Setting $/ from the "serial" thread changes the
>: line separator for the terminal output as well and vice versa. 
>: 
>: For the autoflush $| it is possible to select() the file handle for
>: which it should be changed, but this seems not to be possible with $/.
>
>$\ (I assume that $/ is a typo, as that's the *input* record separator)
>isn't associated with any particular filehandle, as you've discovered. 
>The best solution, IMHO, is to localize it and set it to the appropriate
>value whenever you have to output text.

Yes, but will it work with a multithreaded application? localizing $\
will give it a _global_ value (i.e. accessible from every point in the
program) in a _local_ block. If two different threads wait for input
from the serial port and from the terminal at the same time, this will
not work. It's a matter of application design -- and we don't even know
on which OS the application is developed. Using a separate buffering
process to read from the terminal may be an option. Another option is to
use the read() function to read from the terminal.

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


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

Date: 18 Sep 2000 15:06:43 +0100
From: Piers Cawley <pdcawley@bofh.org.uk>
Subject: Re: Shortest code for Fibonacci?
Message-Id: <m1bsxlhk0c.fsf@rt158.private.realtime.co.uk>

abigail@foad.org (Abigail) writes:
> CHECK {print "another "}  #  A tiger prowls beside
> INIT  {print "Perl "   }  #  a river. A flying
> BEGIN {print "Just "   }  #  mosquito. Eshun.
> END   {print "Hacker\n"}

That is a japh of luminous beauty. I am not worthy.

-- 
Piers


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

Date: 18 Sep 2000 13:17:44 GMT
From: eric@fruitcom.com (Eric Smith)
Subject: Re: single line regex and multi-line regex without resetting $/
Message-Id: <slrn8sc5fo.fc0.eric@plum.fruitcom.com>

>Eric:
>
>It really helps if you could post an example of what you are trying to
>do.
>
>Thanks,
>STEVE


Thank you Steve - I knew I should have provided an example - the typos I made 
did not help - of course - using a slow terminal in another hemisphere.

Ok here is an example of the text (heavily encrypted :)).

Ixxxxxxxxxxx
      Txxx xxxxxxxxxxxx xx xxxxxxxx xx xxxxxxxx xxx xxxxxxxxx xxx xxxxxxxx xx
      xxx Fxxxx Ixxxxxxxx xxx xxx xxxxxxxxxx xxx xxxxxxxxx xx xxxxxxxxxx xxx
      [xxxxxxxxxxxxxxxxx xx xxxx Ixxxxxxx xxx xxxxxxxxx xxxx xxxxxxx xxxxxxxxxx
      xxx xxxxxxxx xxxxxxxxxx xxxxxxxx. A xxxxx xx xxxx xx xxx xxxxxxxxxx xx
      xxxxxxxxxxxx x Cxxxxxxx xxxxxxxxx xxxxxx xxxxxxx xx xx xxx xxxx xxxx
      xxxxxx 5 xx 10 xxx] 
      xxxxx P2C (Pxxxxxxx xx Cxxxxxxx) xxxx xxxxxx xxx xxxx
      xpxxxxxxxx xxxxxxx xxxxxx xx xxxx Cxxxxxxx Ixxxxxxxxx.


Lxxxxxxxx
  Exxxxxxxx Sxxxxxx Rxxxxxxxxxxxx 
    Sxxxxxxx Pxxxxxxxxx, Pxxx Txxxxxxxx, Fxxxxxxxxx xxx Cxxxxxxx Axxxxx, Rxxx 
    Hxxxxxx xxx Axxxxxxx
      Mxxx xx xxxx xxx xxxxxx xxx xxxxxxxx xx xxxx-xxxxx Lxxxxxxxx
      xxxxxxxxxxxxxx. Txxx xxx xx xx xxxxxxxxxxxx xx xxxxxxxxx xxxxx
      xxxxxxx xxxxxxxxxxxxx xxxx xxx xxxxxxx xxx xxx xxxxx-xxxxxx xxxxxxxx
      xxxx xxxx xxxxxx xxxxxxxxx xx xxxxx xxxxxxxxx.
      Txx xxxxxxx xx xx xxxxxxxxxx xxxx xxxxxxxx xxxxxxxxxx xx xxx Lxxxxxxxx
      xxxxxxxxx xx xxx xxxxxxxx xx xxxxxxx xx xxxxxxxxx xxx xxxxxxx xx
      xx IT xxxxxxxxxxxxxx.
  Oxx xxxxxxxx xxxxxxxxxxx
      Ix xxxx xxxx xxx xxxxxxx xxxx xxxxx, xx xxxx xxxxxxxxx xxxxx xxxx Sxxxx 
      Fxxxx Txxxxxxxx (SAFT) xxxxxxxxx xxxxxxxxxxx xx xxxxxxxxx xx x xxxxxx
      [xx xx xxxxxxxx xx xxxxx xxxxxxxxx - xxx xxxxxxxxx xxx xxxxxxxxx xxxx
      xxxx xxxxxxxxx xxx xxxxxxxxx xxxxxxx.  Txx xxxxxxxxxxxx xx SAFx xxx 
      xxxxxxxx xxxx xxx xxx xxxxxxxxx xxxx xxxxxxx xxx xxxx EC xxxxx.]
  Fxxx xxxxxxx-xxxxxxxxxx Lxxxxxxxx Cxxxx
  Mxx xxxxxxxxxxxxx
  Vxx xxxx xxxxxxxx
  Oxxx

Now I nmeed to match each line by the number of spaces indented.  But the
parts of paragraphs enclosed by the [ ] characters needs to be stripped out - 
this is obviously the part that needs the multi-line matching.
Eric Smith posted
 > I have text that must be parsed line by line but also multi-line paragraphs
 > enclosed with the `[' `]' characters.  I can either to the single line
 > matchine or the multi-line matching, the latter by undef-ing $/;  Problem
 > is that I cannot get the single line groking to work even with locally
 > undef-ing the $/ and then redefining it again - once it is undefined, the
 > whole file is slurped of course.
 > 
 > I have tried the s///m and s///s operators but am obviously missing
 > something.
 > 
 > thanx for any help.
 > 
 > 
 > Eric Smith


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

Date: Mon, 18 Sep 2000 14:43:25 GMT
From: mexicanmeatballs@my-deja.com
Subject: Re: sprintf() rounding problem
Message-Id: <8q59m6$h4r$1@nnrp1.deja.com>

In article <8q517h$9d0$1@wanadoo.fr>,
  "Elisa Roselli" <e.roselli@volusoft.com> wrote:
>
> mexicanmeatballs@my-deja.com a écrit dans le message
> <8q4mm4$roj$1@nnrp1.deja.com>...
>
> >Round up if the fraction is greater than or equal to 0.5 (and the
> >value is positive):
> >
> >$rounded = ($value-int($value))>=0.5? int($value)+1 : int($value);
>
> Doesn't that still leave aproblem with the hundredths? I.e. we want a
> round-up at the second decimal place, not the first - 6.75 rounding up
to
> 6.76 as it were. So adding one to a whole value isn't going to help,
if I'm
> understanding you correctly.
>
> Elisa Francesca Roselli
>
>

I think you're understanding me (and the spec) better than I am.

To, hopefully, rescue me from looking like a 'right tool', I've got a
version based on text except for one 0.001 addition coupled with a
little test to highlight differences with sprintf, the (mostly)
textual rounding is done by textround():

Please excuse the rather grim formatting.

#!/usr/bin/perl -w
use strict;
my @v;
my $different=0;
while(!$different) {
    print chr(27),"[2J",chr(27),"[H"; # vt100 clear screen sequence

    for (0..20) {
	$v[$_] = int(rand(10000))/(10**int(rand(5)+1));
    }

    foreach my $v (@v) {
	my $v3=0+textround($v);
	my $v2=0+sprintf("%.2f",$v);
	print "$v\tText= ",$v3,"\tSprint= $v2\t",(($v2 ne
$v3)?'Different':''),"\n";
	$different = ($different || ($v2 ne $v3)) ? 1:0;
    }
}
exit;

sub textround {
    my $v = shift;

    if($v=~m/^\d*\.\d\d\d+$/) {
	my ($prefix, $keydigit)=$v=~m/^(\d*\.\d\d)(\d)\d*/;
	if($keydigit>=5) {
	    return($prefix+0.01);
	}else{
	    return($prefix);
	}
    }else{
	return $v;
    }
}

--
Jon
perl -e 'print map {chr(ord($_)-3)} split //, "MrqEdunhuClqdph1frp";'


Sent via Deja.com http://www.deja.com/
Before you buy.


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

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 V9 Issue 4357
**************************************


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