[17222] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4644 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 17 18:06:23 2000

Date: Tue, 17 Oct 2000 15:05:19 -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: <971820318-v9-i4644@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 17 Oct 2000     Volume: 9 Number: 4644

Today's topics:
    Re: Abiguity of $ in regular expression (was: Problem w <lr@hpl.hp.com>
    Re: about newsgroup <jraff@home.com>
        Accessing methods created on the fly michaeljgardner@my-deja.com
        ANN: ScriptViewer (formerly PHPViewer) 1.2.6 <ddwyer@ncic.com>
    Re: branch coverage testing <mjcarman@home.com>
        By the way - I'm using perl 5.003 on NT sp 5 <pauls_spam_no@pauls.seanet.com>
    Re: Bytemanipulating <mjcarman@home.com>
    Re: Bytemanipulating <lr@hpl.hp.com>
        Can someone help with this scrip? Sytax error! <donotreply@interbulletin.bogus>
    Re: Can someone help with this scrip? Sytax error! <uri@sysarch.com>
    Re: converting a binary file to ascii michaeljgardner@my-deja.com
    Re: converting a binary file to ascii <lr@hpl.hp.com>
    Re: converting a binary file to ascii <pauls_spam_no@pauls.seanet.com>
        Date Arithmetic - how???? <don@lclcan.com>
    Re: Date Arithmetic - how???? michaeljgardner@my-deja.com
    Re: Erroneous Forward Slash in HTML Code by CGI.pm (David H. Adler)
    Re: Erroneous Forward Slash in HTML Code by CGI.pm <jeff@vpservices.com>
    Re: Erroneous Forward Slash in HTML Code by CGI.pm (David H. Adler)
    Re: Erroneous Forward Slash in HTML Code by CGI.pm <ctucker@no.omenmedia.spam.com>
        Fork: What exactly does 'copy on write' mean? pickup22@my-deja.com
    Re: Fork: What exactly does 'copy on write' mean? (Craig Berry)
    Re: Fork: What exactly does 'copy on write' mean? (Colin Watson)
        Help with Array webbgroup@my-deja.com
    Re: Help with Array <ssearle at maplesoft>
        HTML to PERL to uniVerse and Back <mattc@country-life.com>
    Re: Is perl object oriented? <java@dashmail.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 17 Oct 2000 11:27:11 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Abiguity of $ in regular expression (was: Problem with a regular expression (Please Help))
Message-Id: <MPG.145639dcb6b153bd98ae3c@nntp.hpl.hp.com>

In article <u9lmvnxuq1.fsf@wcl-l.bham.ac.uk> on 17 Oct 2000 18:07:02 
+0100, nobull@mail.com <nobull@mail.com> says...
> kenlaird@yahoo.com (Ken Laird) writes:

 ...

> > if (/^thing=$var$/) {
> 
> > I wanna get beginning of thing (^) with end of something ($) ,
> > it seems to work ,but it looks a bit odd to me.
> > I'm worried if there could be any exceptions that won't work.
> 
> I trust you want the contents of $var to be interpreted as a regular
> expression.  If you want the contents of $var to be interpreted as a
> plain string then you need \Q before $var in that pattern.

And, in order for the following $ to be interpreted as 'end of string, 
possibly followed by newline', you need \E after $var in that pattern:

    if (/^thing=\Q$var\E$/) {

The same effect can be achieved using the quotemeta function:

    my $qvar = quotemeta $var;

    if (/^thing=$qvar$/) {

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 17 Oct 2000 19:29:42 GMT
From: "john" <jraff@home.com>
Subject: Re: about newsgroup
Message-Id: <GM1H5.68353$ib7.9183779@news1.rdc1.nj.home.com>

The list of NEWS groups may be found here;
ftp://ftp.isc.org/pub/usenet/CONFIG/newsgroups

This also might be helpful;
ftp://ftp.isc.org/pub/usenet/control/alt/alt.binaries.emanuals.Z
----------------------------------------------------------------------
"Lucas" <wstsoi@hongkong.com> wrote in message
news:8scmv3$1675@imsp212.netvigator.com...
> Hi How could I fetching all the newsgroup names from
> my news server for further sorting and searching?
>
> And I can't install NET::NNTP by ppm in my Window,
> Why? How could I do?
>
> Thanks for any helps very much.
>
>




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

Date: Tue, 17 Oct 2000 19:48:42 GMT
From: michaeljgardner@my-deja.com
Subject: Accessing methods created on the fly
Message-Id: <8siaen$6t2$1@nnrp1.deja.com>

I have a module that creates an object out of a database.  Part of the
code in the module creates methods (closures) to access the contents of
a particular field by it's position in the string that makes up that
record of the database.  This code creates the subroutines.

# HEADERINFO CONTAINS INFO ABOUT THE FIELDS IN THE DATABASE WHICH ARE
# KEYED BY THE FIELD NAME
foreach my $name (sort keys %headerinfo){

# SUBROUTINE CREATED ON-THE-FLY, NAMED AFTER FIELD NAME
# $LINE IS PASSED TO THE SUBROUTINE WITH A RAW RECORD OF DATABASE
    *$name = *{uc $name}=sub {my($line)=shift;
# ELEMENTS 3 AND 1 OF THE ARRAY ARE THE POSITION AND LENGTH OF THE
# FIELD NAME.
  $fieldvalue=substr($line,$headerinfo{$name}[3],$headerinfo{$name}[1]);
        $fieldvalue=~s/[^0-9A-Za-z-.]//g;
        $fieldvalue;
                              }
};

This works, all I have to do is read a record of the database into a
scalar, and then use the subroutine on the scalar to return the
appropriate data.

$line='field1field2field3...fieldn'
$value=MODULENAME::FIELD1($line)

in this case, $value would be 'field1'.  My problem is that I'd like to
use the subroutine without having to type the module name every time I
want to access the contents of a given field.

I've tried monkeying around with the @EXPORT and @EXPORT_OK arrays, and
even PUSHing the names of the subroutines created on the fly into the
arrays, but each time I get an error saying

undefined subroutine &Main::Subname

Is there a way to export these subroutines created on the fly so that I
don't have to invoke the package/module name every time I want to use
them??

Thanks,
Michael


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


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

Date: Tue, 17 Oct 2000 13:56:13 -0500
From: "Daaron Dwyer" <ddwyer@ncic.com>
Subject: ANN: ScriptViewer (formerly PHPViewer) 1.2.6
Message-Id: <39eca0aa$0$23251@wodc7nh0.news.uu.net>

Hello All,

If you are unfamiliar with ScriptViewer, it is a free Windows application
allowing someone to surf script pages without the need of a webserver.  The
intended use is for stand-alone materials like CD-ROMs and for testing pages
when you don't want to load PWS.  It works by firing off the scripting
engine,
then showing the result in an embedded MSIE browser.

FIXES:
I have implemented suggestions a few of you have been providing.
In the new version, the INI file has been changed to non-UNC naming that was
throwing a few people off.  INI files now support system-defined values,
like the executable directory and windows directory, making it easier to
install and run without having to know about the user's system.

ADDITIONS:
Commands are the newest addition, allowing an HTML page author to specify
commands that PHPViewer will respond to, including registry manipulation,
file details, and system details.  A very basic first library is included,
with updates to come on request.

The update is available on my site: www.angorasoftware.com/phpviewer.html


Enjoy!










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

Date: Tue, 17 Oct 2000 14:48:40 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: branch coverage testing
Message-Id: <39ECAD18.E3F9ECC1@home.com>

Matt Leinhos wrote:
> 
> Could anyone tell me if there is a branch coverage test program/script
> for perl? I am interesting in testing all the branches of a perl 
> script I've been working on.

Not that I'm aware of. I'd like one too, but I have a bad feeling that
Perl's syntax is a bit too flexible to make such a thing feasible.

-mjc


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

Date: Tue, 17 Oct 2000 14:48:44 -0700
From: Paul Spitalny <pauls_spam_no@pauls.seanet.com>
Subject: By the way - I'm using perl 5.003 on NT sp 5
Message-Id: <39ECC93C.AD29E8BF@pauls.seanet.com>

I'm using active ware perl 5.003 on NT4 sp 5. Does "binmode" work in NT??


Paul Spitalny wrote:

> Hi,
> I have a binary file, how can I convert it to ascii? I think I need to
> read in the file byte by byte but can't figure out how to do it. Any
> help appreceated!
>
> thanks
>
> Paul
>
> --
> To respond to this posting, remove -nospam- from my email address.
> Sorry for the inconvenience

--
To respond to this posting, remove -nospam- from my email address.
Sorry for the inconvenience




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

Date: Tue, 17 Oct 2000 13:25:57 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Bytemanipulating
Message-Id: <39EC99B5.BF246537@home.com>

Joe wrote:
> 
> Hi there!
> Can i do this...
> -----------------
> struct abc
> {
>         int first : 3;
>         int second : 5;
> }
> -----------------
> somehow in perl?
> 
> With this statements, "first" consists of 3 bits and "second" consists
> of 5 bits. I can set them independent from each other but also handle
> them together as one Byte (with the struct abc).
> 
> Is something like that also possible in perl?

No. Perl has the builtin data types scalar, array, and hash. You cannot
define your own types or control the bit size of the builtins.

That said, Perl does allow for classes and structures. If you really
wanted to, you could implement a class 'abc' and define methods for
getting at the specific bits via the various bit operations. That's kind
of a kludge, though, and I doubt it's worth the trouble.

If you're planning to do serious amounts of bit manipulation in your
program, you may be better off writing it in C, or at least writing the
bitwise stuff in C and the rest in Perl.

-mjc


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

Date: Tue, 17 Oct 2000 13:03:15 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Bytemanipulating
Message-Id: <MPG.1456506163c4ef2698ae40@nntp.hpl.hp.com>

In article <39EC99B5.BF246537@home.com> on Tue, 17 Oct 2000 13:25:57 -
0500, Michael Carman <mjcarman@home.com> says...
> Joe wrote:
> > 
> > Hi there!
> > Can i do this...
> > -----------------
> > struct abc
> > {
> >         int first : 3;
> >         int second : 5;
> > }
> > -----------------
> > somehow in perl?
> > 
> > With this statements, "first" consists of 3 bits and "second" consists
> > of 5 bits. I can set them independent from each other but also handle
> > them together as one Byte (with the struct abc).
> > 
> > Is something like that also possible in perl?
> 
> No. Perl has the builtin data types scalar, array, and hash. You cannot
> define your own types or control the bit size of the builtins.

The Perl equivalent for the above bitfield access is easy to write and 
to generalize:

    $first  = ($abc >> 5) & 07;
    $second = $abc & 037;

    $abc = $abc & (~07 << 5) | ($first << 5);
    $abc = $abc & ~037 | $second;

> That said, Perl does allow for classes and structures. If you really
> wanted to, you could implement a class 'abc' and define methods for
> getting at the specific bits via the various bit operations. That's kind
> of a kludge, though, and I doubt it's worth the trouble.

And it makes something already slow even slower.

> If you're planning to do serious amounts of bit manipulation in your
> program, you may be better off writing it in C, or at least writing the
> bitwise stuff in C and the rest in Perl.

Rather a severe recommendation, I think.  As you imply, the performance 
will be much slower than the equivalent C access.  However, there also 
the built-in vec() function, and bit-manipulation modules implemented in 
C, available on CPAN.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 17 Oct 2000 19:48:12 +0000
From: Richard Morris <donotreply@interbulletin.bogus>
Subject: Can someone help with this scrip? Sytax error!
Message-Id: <39ECACFC.267249C4@interbulletin.com>


Sorry, Newbie here.

I have a script and when run, gives the message:

[root@qube rdm3]# perl massadd.pl list
syntax error at massadd.pl line 31, near "= ) "
syntax error at massadd.pl line 37, near "}"
Might be a runaway multi-line "" string starting on line 35)
Execution of massadd.pl aborted due to compilation errors.


Attached below is the script. Can anyone help?  Thanks in advance,

Richard Morris
richard.morris@vivao.net

#!/usr/bin/perl 

# Cobalt Networks, INC 8-16-98 
# This script is NOT SUPPORTED! 
# The password-list file should contain, Last Name, First Name, User ID 
# The user id will also become the password 

use Cobalt::User; 

$error_file = "Usage: massadd.pl 
"; 
$error_help = "Usage: massadd.pl --help 
"; 
# This set the default of 5MB quota for each user(done in blocks) 
$quota = 5000; 


@ARGV = ('-') unless @ARGV; 
while ($ARGV = shift) { 
if ($ARGV eq "--help"){ 
print $error_file; 
print "The file should contain: Last Name, First Name, User ID. 
"; 
print "The user ID will become the password. 
"; 
} 
else { 
open(PASSIT, $ARGV) or die $error_file, $error_help; 
} 
} 
while ($line = ) { 
($l_name, $f_name, $uid) = split(/[ ,]/, $line); 
chomp($uid); 
$fullname = join(' ', $f_name, $l_name); 
print user_add($uid,$fullname,$uid,$quota), " 
"; 
} 
close(PASSIT);

_____EOF
_______________________________________________
M$ Upgrade: Windows98 + 2 Windows = Windows2000
Submitted via WebNewsReader of http://www.interbulletin.com
Complaint against spamming pls. to: abuse @ InterBulletin.com



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

Date: Tue, 17 Oct 2000 20:48:35 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Can someone help with this scrip? Sytax error!
Message-Id: <x7vgurry70.fsf@home.sysarch.com>

>>>>> "RM" == Richard Morris <donotreply@interbulletin.bogus> writes:

  RM> Sorry, Newbie here.

  RM> [root@qube rdm3]# perl massadd.pl list
  RM> syntax error at massadd.pl line 31, near "= ) "
  RM> syntax error at massadd.pl line 37, near "}"
  RM> Might be a runaway multi-line "" string starting on line 35)
  RM> Execution of massadd.pl aborted due to compilation errors.


  RM> Attached below is the script. Can anyone help?  Thanks in advance,

did you look at the lines in question?


  RM> $error_file = "Usage: massadd.pl 
  RM> "; 

why are you inserting a real newline in there? use \n and clean up your
code.

  RM> $error_help = "Usage: massadd.pl --help 
  RM> "; 

same here.


  RM> @ARGV = ('-') unless @ARGV; 
  RM> while ($ARGV = shift) { 
  RM> if ($ARGV eq "--help"){ 
  RM> print $error_file; 
  RM> print "The file should contain: Last Name, First Name, User ID. 
  RM> "; 
  RM> print "The user ID will become the password. 
  RM> "; 
  RM> } 

use some indenting. however simple this code is, your style is hard to
read and therefore harder to find syntac errors in

  RM> while ($line = ) { 
                  ^^^

what are you assiging to line? an invisible value?

  RM> ($l_name, $f_name, $uid) = split(/[ ,]/, $line); 
  RM> chomp($uid); 
  RM> $fullname = join(' ', $f_name, $l_name); 
  RM> print user_add($uid,$fullname,$uid,$quota), " 
  RM> "; 

where did you get that bad habit of real newlines in strings?

i don't see the runaway string but with your odd formatting and newline
use, my eyes may not catch it. or the first syntax error is all you have
and it triggered the others.

uri


-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Tue, 17 Oct 2000 18:08:03 GMT
From: michaeljgardner@my-deja.com
Subject: Re: converting a binary file to ascii
Message-Id: <8si4hr$1bu$1@nnrp1.deja.com>

In article <39EC7B03.1C456A08@pauls.seanet.com>,
  pauls@pauls.-nospam-seanet.com wrote:
> Hi,
> I have a binary file, how can I convert it to ascii? I think I need to
> read in the file byte by byte but can't figure out how to do it. Any
> help appreceated!
>
> thanks
>
> Paul
>
> --
> To respond to this posting, remove -nospam- from my email address.
> Sorry for the inconvenience
>
>
Paul,

Can you give an example of what you're trying to do?  I'm not exactly
sure what your binary file and your resultant ascii file look like, or
should look like.

Perl can read in binary files using the binmode(filehandle) after the
file is opened.

HTH
Michael


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


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

Date: Tue, 17 Oct 2000 11:29:11 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: converting a binary file to ascii
Message-Id: <MPG.14563a55a552ed7298ae3d@nntp.hpl.hp.com>

In article <Pine.LNX.4.21.0010171239030.26081-
100000@hawk.ce.mediaone.net> on Tue, 17 Oct 2000 12:43:51 -0500, Andrew 
N. McGuire  <anmcguire@ce.mediaone.net> says...
> On Tue, 17 Oct 2000, Paul Spitalny quoth:
> 
> PS> I have a binary file, how can I convert it to ascii? I think I need to
> PS> read in the file byte by byte but can't figure out how to do it. Any
> PS> help appreceated!
> 
> use PSI::ESP;
> 
> perldoc -f read
> perldoc -f pack
> perldoc -f seek
> perldoc -f unpack
> 
> and probably others,

Indeed.  Possibly the most important:

  perldoc -f binmode

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 17 Oct 2000 14:35:07 -0700
From: Paul Spitalny <pauls_spam_no@pauls.seanet.com>
Subject: Re: converting a binary file to ascii
Message-Id: <39ECC60B.1C45767F@pauls.seanet.com>

Hi Gang,
Here, I try to be more specific. I have a simulation program that saves
it's data in binary format (to save on file size). The file is some
floating point numbers stored in binary form. The binary file is more than
one lines worth of stuff.

I have tried something like this:

open(NEW,'<bin_only.dat');
open(OUT,'>thebin.dat');
binmode NEW;
while ($_=<NEW>)
        {
        $line = $_;
        print OUT "line is $line\n";
        }
close(NEW);
close(OUT);

The result of the print statement is binary hierogliphics! What is it that
I am failing to do? I have this idea that I need to go through the file
byte by byte and assemble the floating point numbers. Most of the work
with files that I've done addresses a file line by line. This time, it's
byte by byte (At least I think it should be). Any tips or suggestions much
appreciated!




Paul Spitalny wrote:

> Hi,
> I have a binary file, how can I convert it to ascii? I think I need to
> read in the file byte by byte but can't figure out how to do it. Any
> help appreceated!
>
> thanks
>
> Paul
>
> --
> To respond to this posting, remove -nospam- from my email address.
> Sorry for the inconvenience

--
To respond to this posting, remove -nospam- from my email address.
Sorry for the inconvenience




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

Date: Tue, 17 Oct 2000 15:09:02 -0400
From: Don <don@lclcan.com>
Subject: Date Arithmetic - how????
Message-Id: <39ECA3CE.F3DE77AE@lclcan.com>

Hello,

I am using the DBD module to read data from a dBase III+ file.  One of
the fields I do is a date field. Now, I wish to increment this field by
adding an integer to it which reflects a number of days.  My code looks
like this:

$my_date = $dbf_date[8] + $num_days[2];

where $dbf_date is the date field from my dbf
and $num_days[2] is a numeric field from my dbf

although the above works without an error, it does not do date
arithmetic properly.

Example: 11/30/2000 + 4 = 11/34/2000 which is an invalid date.

Is there a function in either Perl or the DBD module (the docs are
lacking) that does date arithmetic properly.

Thanks,
Don



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

Date: Tue, 17 Oct 2000 19:55:43 GMT
From: michaeljgardner@my-deja.com
Subject: Re: Date Arithmetic - how????
Message-Id: <8siarr$7bp$1@nnrp1.deja.com>

In article <39ECA3CE.F3DE77AE@lclcan.com>,
  Don <don@lclcan.com> wrote:
> Hello,
>
> I am using the DBD module to read data from a dBase III+ file.  One of
> the fields I do is a date field. Now, I wish to increment this field
by
> adding an integer to it which reflects a number of days.  My code
looks
> like this:
>
> $my_date = $dbf_date[8] + $num_days[2];
>
> where $dbf_date is the date field from my dbf
> and $num_days[2] is a numeric field from my dbf
>
> although the above works without an error, it does not do date
> arithmetic properly.
>
> Example: 11/30/2000 + 4 = 11/34/2000 which is an invalid date.
>
> Is there a function in either Perl or the DBD module (the docs are
> lacking) that does date arithmetic properly.
>
> Thanks,
> Don
>
>

Don,

Check out Date::Calc available from CPAN.

HTH,
Michael


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


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

Date: 17 Oct 2000 18:50:19 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Erroneous Forward Slash in HTML Code by CGI.pm
Message-Id: <slrn8up7r7.r2s.dha@panix2.panix.com>

On Thu, 12 Oct 2000 12:37:04 -0700, Jeff Zucker <jeff@vpservices.com>
wrote:

>From the CGI.pm docs:
>
>     By default, CGI.pm versions 2.69 and higher emit XHTML 
>     (http://www.w3.org/TR/xhtml1/). The -no_xhtml pragma 
>     disables this feature.
>
>XHTML uses a slash on tags that don't have end tags. It shouldn't matter
>in this case since AFAIK all browsers will display the tags with the
>trailing slash as long as there is a space before it.

Not, apparently, with Navigator 4.06 (which is what I happen to have
lying around on this machine...).  <p/> gets ignored.  Ick.

I'm still unclear how I feel about that default behavior... :-/

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Tegan's always being posessed!  She just wants attention.
	- Adric


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

Date: Tue, 17 Oct 2000 12:28:40 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Erroneous Forward Slash in HTML Code by CGI.pm
Message-Id: <39ECA868.B678759D@vpservices.com>


"David H. Adler" wrote:
> 
> On Thu, 12 Oct 2000 12:37:04 -0700, Jeff Zucker <jeff@vpservices.com>
> wrote:
> 
> >From the CGI.pm docs:
> >
> >     By default, CGI.pm versions 2.69 and higher emit XHTML
> >     (http://www.w3.org/TR/xhtml1/). The -no_xhtml pragma
> >     disables this feature.
> >
> >XHTML uses a slash on tags that don't have end tags. It shouldn't matter
> >in this case since AFAIK all browsers will display the tags with the
> >trailing slash as long as there is a space before it.
> 
> Not, apparently, with Navigator 4.06 (which is what I happen to have
> lying around on this machine...).  <p/> gets ignored.  Ick.

Did you catch those last nine words in the part my posting you cited?

Try <p />, not <p/>.   Maybe it doesn't work either, but at least give
it a shot and let me know.

-- 
Jeff


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

Date: 17 Oct 2000 20:23:57 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Erroneous Forward Slash in HTML Code by CGI.pm
Message-Id: <slrn8updat.f6n.dha@panix2.panix.com>

On Tue, 17 Oct 2000 12:28:40 -0700, Jeff Zucker <jeff@vpservices.com>
wrote:

>"David H. Adler" wrote:
>> 
>> On Thu, 12 Oct 2000 12:37:04 -0700, Jeff Zucker <jeff@vpservices.com>
>> wrote:
>> 
>> >From the CGI.pm docs:
>> >
>> >     By default, CGI.pm versions 2.69 and higher emit XHTML
>> >     (http://www.w3.org/TR/xhtml1/). The -no_xhtml pragma
>> >     disables this feature.
>> >
>> >XHTML uses a slash on tags that don't have end tags. It shouldn't matter
>> >in this case since AFAIK all browsers will display the tags with the
>> >trailing slash as long as there is a space before it.
>> 
>> Not, apparently, with Navigator 4.06 (which is what I happen to have
>> lying around on this machine...).  <p/> gets ignored.  Ick.
>
>Did you catch those last nine words in the part my posting you cited?
>
>Try <p />, not <p/>.   Maybe it doesn't work either, but at least give
>it a shot and let me know.

Yes, I caught the words and horribly misparsed them... :-/  Sorry.

Yeah, it works.  interesingly, <p/> only behaves differently for
netscape - lynx and IE seem to deal with it fine.  odd.

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
All hail El Cabeza Del Oro!  <http://www.panix.com/~dha/elcabeza.html>


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

Date: Wed, 18 Oct 2000 07:58:53 +1100
From: "Colin Tucker" <ctucker@no.omenmedia.spam.com>
Subject: Re: Erroneous Forward Slash in HTML Code by CGI.pm
Message-Id: <39ecbde0$0$9195$7f31c96c@news01.syd.optusnet.com.au>

Unfortunately, it seems almost everything behaves differently in Netscape
for me.  :o(

</Colin>

"David H. Adler" <dha@panix.com> wrote in message
news:slrn8updat.f6n.dha@panix2.panix.com...
> Yeah, it works.  interesingly, <p/> only behaves differently for
> netscape - lynx and IE seem to deal with it fine.  odd.





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

Date: Tue, 17 Oct 2000 18:53:00 GMT
From: pickup22@my-deja.com
Subject: Fork: What exactly does 'copy on write' mean?
Message-Id: <8si768$3qs$1@nnrp1.deja.com>

I've been boning up on Fork since it makes sense for a two projects I'm
working on but there is one thing in particular that has me stumped.  I
keep seeing that memory/variables are available as 'copy on write' with
no explanation.  What does this mean?  Thanks.


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


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

Date: Tue, 17 Oct 2000 20:58:03 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Fork: What exactly does 'copy on write' mean?
Message-Id: <supfardhateie0@corp.supernews.com>

pickup22@my-deja.com wrote:
: I've been boning up on Fork since it makes sense for a two projects I'm
: working on but there is one thing in particular that has me stumped.  I
: keep seeing that memory/variables are available as 'copy on write' with
: no explanation.  What does this mean?  Thanks.

"Copy on write" means that when a resource is cloned for use by two
clients, they actually share the same underlying resource object until
either tries to write to it (as opposed to just reading).  When a write
occurs, the object is 'really' cloned with the writer now operating on its
own private copy.

This scheme can save a huge amount of processing and memory overhead if
most resources tend to be read-only. 

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Quidquid latine dictum sit, altum viditur."
   |


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

Date: 17 Oct 2000 21:28:34 GMT
From: cjw44@flatline.org.uk (Colin Watson)
Subject: Re: Fork: What exactly does 'copy on write' mean?
Message-Id: <8siga2$65i$1@riva.ucam.org>

pickup22@my-deja.com wrote:
>I've been boning up on Fork since it makes sense for a two projects I'm
>working on but there is one thing in particular that has me stumped.  I
>keep seeing that memory/variables are available as 'copy on write' with
>no explanation.  What does this mean?  Thanks.

A Google search on "fork copy on write" returns various useful links,
but ...

When a process forks, most resources (e.g. file descriptors, the
contents of memory, etc.) become available to the two processes. Like
'perldoc -f fork' says, fds and sometimes their locks are shared, but
everything else is (or at least appears to be) copied. Of course, it
makes very little sense for an expensive memory copy to take place when
it's not needed; the most frequent use of a fork() on Unix systems is
one immediately followed by an execve(), which gets rid of all that
memory anyway.

Thus, on most systems on which Perl runs, memory is not copied while
both processes are doing nothing but reading from it. When one of the
forked processes tries to write to a page of memory, a copy of that page
will be made by the operating system for the exclusive use of that
project. Relatively big processes that fork a lot - like web servers
running CGI scripts - definitely care about this optimization.

To bring this slightly back on-topic for clpm, here's a micro-benchmark
(probably spurious, but hey, this is Usenet :) - the test machine was a
P3-450 with 192Mb of RAM):

-- fork-benchmark.pl
#! /usr/bin/perl -w
use strict;
use Benchmark;
use POSIX qw(times);

my $bigscalar = '0' x 25_000_000;
# Would use Benchmark, but it doesn't work across forks due to the way
# times() is defined.
my $timestart = (POSIX::times)[0];

defined(my $pid = fork) or die "couldn't fork: $!";
if ($pid)   # parent
{
    waitpid $pid, 0;
}
else        # child
{
    printf "Fork:  %s clock tick(s)\n", (POSIX::times)[0] - $timestart;
    timethese(1, {
        '1: Copy-on-write' => sub { $big = '1' x 25_000_000 },
        '2: Write again' => sub { $big = '2' x 25_000_000 },
        '3: Write again' => sub { $big = '3' x 25_000_000 },
    });
}
-- end fork-benchmark.pl

[cjw44@riva ~/src/perl]$ ./fork-benchmark.pl 
Fork:  1 clock tick(s)
Benchmark: timing 1 iterations of 1: Copy-on-write, 2: Write again, 3:
Write again...
1: Copy-on-write:  1 wallclock secs ( 0.40 usr +  0.42 sys =  0.82 CPU)
            (warning: too few iterations for a reliable count)
2: Write again:  0 wallclock secs ( 0.46 usr +  0.25 sys =  0.71 CPU)
            (warning: too few iterations for a reliable count)
3: Write again:  1 wallclock secs ( 0.47 usr +  0.25 sys =  0.72 CPU)
            (warning: too few iterations for a reliable count)

Note the sixth of a second or so spent copying memory the first time the
child process uses it. Not a big deal here on this computer, but it
matters if you're forking a lot.

-- 
Colin Watson                                     [cjw44@flatline.org.uk]
"Logic is about flogging a dead horse." - Computer Science lecturer


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

Date: Tue, 17 Oct 2000 18:18:56 GMT
From: webbgroup@my-deja.com
Subject: Help with Array
Message-Id: <8si565$20k$1@nnrp1.deja.com>

Hey guys, I really appreciate you help.

I am writing a script that is bringing in raw data( an IP address and a
hostname) in a file. The file has the IP and hostnames separated by one
space
127.0.0.1 localhost

I am trying to writing the script that will call that file and go down
the list line by line and execute like a ping command to see if it is
up.

This is what I have so far. I am having trouble calling the names from
the file and executing the command


# Get the host file and change it
open(FILE, "newhosts.txt") || die("Host file not found!\n");
@mine=<FILE>;
close(FILE,"newhosts.txt");

# process the file
foreach $line(@mine)
        {
        print $line;
        # Change the newhosts.txt file and put them into
variables         $arg1=$mine[0];
        $arg2=$mine[1];
        # I figure that if I can get the printout working,
        # I will be able to get it to execute the ping command.
        print "The IP address is: $arg1 Hostname: $arg2 \n";         }


Any suggestions??



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


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

Date: Tue, 17 Oct 2000 14:46:06 -0400
From: "Scott Searle" <ssearle at maplesoft>
Subject: Re: Help with Array
Message-Id: <39ec9f0d@vega>

open(FILE, "hosts.txt") || die "dead";
while(<FILE>) {
    my ($host, $ip) = split;
    print("IP of $host is $ip\n");
}
close(FILE);

    -S

<webbgroup@my-deja.com> wrote in message news:8si565$20k$1@nnrp1.deja.com...
> Hey guys, I really appreciate you help.
>
> I am writing a script that is bringing in raw data( an IP address and a
> hostname) in a file. The file has the IP and hostnames separated by one
> space
> 127.0.0.1 localhost
>
> I am trying to writing the script that will call that file and go down
> the list line by line and execute like a ping command to see if it is
> up.
>
> This is what I have so far. I am having trouble calling the names from
> the file and executing the command
>
>
> # Get the host file and change it
> open(FILE, "newhosts.txt") || die("Host file not found!\n");
> @mine=<FILE>;
> close(FILE,"newhosts.txt");
>
> # process the file
> foreach $line(@mine)
>         {
>         print $line;
>         # Change the newhosts.txt file and put them into
> variables         $arg1=$mine[0];
>         $arg2=$mine[1];
>         # I figure that if I can get the printout working,
>         # I will be able to get it to execute the ping command.
>         print "The IP address is: $arg1 Hostname: $arg2 \n";         }
>
>
> Any suggestions??
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

Date: Tue, 17 Oct 2000 16:19:12 -0400
From: Matt Carey <mattc@country-life.com>
Subject: HTML to PERL to uniVerse and Back
Message-Id: <39ECB440.46FDA19D@country-life.com>

I recently began developing intranet web applications for my employer.
I am developing an intranet web application  that will potentially be
used by multiple users at the same time.  The application consists of
an HTML form, a PERL script,  and a UNIVERSE BASIC program and follows
these four basic steps:

1. the HTML form is filled out and submitted by a user.
2. The perl script takes all the values from the form, creates a
file(say FILE1) and writes the data  out to the file in a pipe delimited
format (ie. Name|street|city|state|zip). The script then waits several
seconds before directing the user to another web page which is created
in the following step.
3. A BASIC program continuously checks for the existence of  FILE1. If
FILE1 exists, then the BASIC program moves FILE1 to another location,
reads the data into an array, deletes FILE1, and then passes the data to
a subroutine. The subroutine uses the data to update files and/or to
retrieve data from files.  It also generates  the web page that the user
is about to be directed to as described in the previous step. Once
created,  the web page is written to the location that the perl script
is about to direct the user to.
4. The perl script directs the user to the web page that was created by
the BASIC subroutine.

I am concerned that if a number of people are running the application at
the same time that  some sort of interference may occur.  The perl
script writes data to the same location for each user and the BASIC
program sends the web page it creates to the same location for each
user. I could change this.  What other options might be available for
me  to  ‘isolate’  each user from the others so that there is no chance
for any type of interference?

P.S.
The OS is HP-UNIX
Web Server is Apache






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

Date: Tue, 17 Oct 2000 14:50:52 -0700
From: John Golubenko <java@dashmail.net>
Subject: Re: Is perl object oriented?
Message-Id: <39ECC9BC.2D329375@dashmail.net>

First before you try to fool someone....
do you know Java? Did you wrote any application in Java?
You opinion is simply based in other's opinion, and you have no
idea what OOP means. And it's absolutely dosnt mean you have to hate
other languages, because you are using Perl.
So, keep your opinions for yourself.



"Randal L. Schwartz" wrote:

> >>>>> "nobull" == nobull  <nobull@mail.com> writes:
>
> nobull> "Mark" <mark@mediamasters.net> writes:
> >> Is perl a object oriented language?
>
> nobull> No, not like Java or Smalltalk, but like many languages it has some
> nobull> facilities to allow an object oriented programming approach.
>
> Perl *is* pseudo-OO like Java, but not pure OO like Smalltalk.
>
> Please keep the categories straight.  Didn't you get the handout? :)
>
> nobull> perldoc perltoot
>
> and perldoc perlboot, for a gentler introduction.
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!





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

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


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