[8785] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2402 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 23 13:07:34 1998

Date: Thu, 23 Apr 98 10:00:26 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 23 Apr 1998     Volume: 8 Number: 2402

Today's topics:
    Re: Array / List question <merlyn@stonehenge.com>
    Re: beginnings.... <jbc@west.net>
        BUG or FEATURE? -- splice() doesn't extend arrays <mikec@cnet.com>
    Re: Calling in Config files <jdf@pobox.com>
        cgi-lib.pl (Jeff)
    Re: cgi-lib.pl <jdporter@min.net>
        cgi.pm book <dturley@ravine.binary.net>
    Re: CGI.PM Question & ASCII/HEX problem <rootbeer@teleport.com>
    Re: Command line instructions don't execute in Win95 (Bbirthisel)
    Re: Defending Perl (Wayne C. McCullough)
    Re: Defending Perl (Mark-Jason Dominus)
    Re: Defending Perl (Chris Nandor)
        HTML::Table <stuart@euronova.com>
        Memory allocation and CGI Performance (Charles Ball)
        PB : sendmail subroutine <affix@usa.net>
    Re: PC-based editors for Perl? (Jason Gloudon)
    Re: Perl for NT <chasecreek.systemhouse@usa.net>
    Re: Perl for NT <upsetter@shore.net>
    Re: perl library to read excel file <perlguy@inlink.com>
    Re: print $fh redefinition eryq@zeegee.com
        problem: num/str related <xah@love.com>
        Read-only value? <wwilliam@cisco.com>
    Re: Read-only value? (Jason Gloudon)
    Re: Regular Expression to match a valid IP address <jdporter@min.net>
    Re: RMS should be invited to O'Reilly's "Free Software  <dak@mailhost.neuroinformatik.ruhr-uni-bochum.de>
    Re: Symbolic ref and angle opeator (Mark-Jason Dominus)
    Re: There *IS* a visual IDE for Perl! <jdporter@min.net>
    Re: There *IS* a visual IDE for Perl! <jdporter@min.net>
    Re: There *IS* a visual IDE for Perl! <jdporter@min.net>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 23 Apr 1998 14:20:49 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
To: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Array / List question
Message-Id: <8c1zuotyau.fsf@gadget.cscaper.com>

>>>>> "Jonathan" == Jonathan Feinberg <jdf@pobox.com> writes:

Jonathan> Here's an excerpt from one Randal post
Jonathan> (<8cenaq6vs8.fsf@gadget.cscaper.com>):

Jonathan>    Ouch. Please don't do this.  It's considered bad form to use map or
Jonathan>    grep in a void context.  Use the equivalent foreach instead:

Jonathan> 	   $sum = 0;
Jonathan> 	   for (@nums) { $sum += $_ }

Jonathan> Here's another (<8csp1xydui.fsf@gadget.cscaper.com>):

Jonathan>    I'm no longer "randal the clever hack author".  I'm trying to stay a
Jonathan>    little more mainstream these days.  map and grep in a void
Jonathan>    context... Ick. :-)

I fully expected there to be something next like:

    And here's what Randal said on this same subject just outside his
    hotel room door last Thursday to a passerby: ...

I feel like I'm being stalked. :-)

(Yeah, yeah, Dejanews... I know.)

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 131 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Thu, 23 Apr 1998 10:06:10 -0700
From: John Callender <jbc@west.net>
Subject: Re: beginnings....
Message-Id: <353F7502.8FC24F99@west.net>

Allan M. Due wrote:
> 
> Cons,
> 1) One iteration behind

A related con is that that iteration is the one that added *lots* of
great documentation (part of the size difference you noted, I assume).
If someone is installing it as a learning tool, I'd think the docs that
come with the standard distribution would be an important factor.

--
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Thu, 23 Apr 1998 08:58:07 -0700
From: Mike Clemens <mikec@cnet.com>
Subject: BUG or FEATURE? -- splice() doesn't extend arrays
Message-Id: <353F650F.6550B314@cnet.com>

I'm trying to use splice() to munge arrays starting at a particular
array index, but was surprised to find that it (splice) doesn't
automatically extend arrays if you're accessing beyond the end.  An
example:

#!/perl

@foo = qw(A B C);
splice(@foo,10,1,'Z');
print join(":",@foo);

# EOF

The output is:

A:B:C:Z

What I *expected* was:

A:B:C::::::::Z

That is, 'Z' would be splice'd into the 11th position in the array
(offset 10), with undef's automagically appearing in the other
elements.  I'm really trying to do this with a list of elements, not a
scalar, since I'd just plunk it in directly

#!/perl

@foo = qw(A B C);
$foo[10] = 'Z';
print join(":",@foo);

# EOF

Outputs:

A:B:C::::::::Z

Since the array Does The Right Thing, my feeling is that this is a
splice() bug.

Thanks,
- Mike

-- 
Michael P. Clemens    mailto:mikec@cnet.com    Senior Software Engineer
http://www.cnet.com   (415) 395-7805 x5137   CNET: The Computer Network
>>> Take a gander at my son: http://www.mindspring.com/~clemota/ian <<<


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

Date: 23 Apr 1998 12:32:23 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Calling in Config files
Message-Id: <af9cv3yw.fsf@mailhost.panix.com>

skruzich@stc.net writes:

> #!/opt/perl5/bin/perl
> #include cfgfile;

You want "require", which is documented in perlfunc.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY


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

Date: Thu, 23 Apr 1998 14:50:44 GMT
From: jeffmcc@mindspring.com (Jeff)
Subject: cgi-lib.pl
Message-Id: <353f5481.11876227@news>

Has anyone worked with cgi-lib.pl?  I'm using cgi_lib to read the form
and file for processing.  It reads and writes the first couple of
lines then it spits out "unknown request method:".  Please help.

Jeff


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

Date: Thu, 23 Apr 1998 15:17:33 GMT
From: John Porter <jdporter@min.net>
Subject: Re: cgi-lib.pl
Message-Id: <353F5D12.22B6@min.net>

Jeff wrote:
> 
> Has anyone worked with cgi-lib.pl? 

Yes. [spit spit]

> I'm using cgi_lib to read the form...

The relief you seek comes by using CGI.pm instead.

John Porter


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

Date: 23 Apr 1998 16:58:07 GMT
From: David Turley <dturley@ravine.binary.net>
Subject: cgi.pm book
Message-Id: <6hnruv$hor$1@oksennus.binary.net>

TPJ has an ad for a book called Lincoln Stein's Guide to CGI.pm. My
bookstore has a book called Official Guide to Programming with cgi.pm, by 
Stein.

Same book?
-- 
_____________________________________________________________________
David Turley
dturley@pobox.com
http://www.pobox.com/~dturley

"You don't want to be the only person sitting on a crocodile's back."
                                        -- heard on a PBS nature show
______________________________________________________________________


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

Date: Thu, 23 Apr 1998 15:24:09 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: squid@fish.net
Subject: Re: CGI.PM Question & ASCII/HEX problem
Message-Id: <Pine.GSO.3.96.980423082251.6132I-100000@user2.teleport.com>

On Thu, 23 Apr 1998 squid@fish.net wrote:

> >> while ($bytesread = read($filename,$buffer,1024)) {
> >
> >Is $filename, as the name implies, a file name? That's odd...
> >
> $filename is the filename...the var was used for example

Then the quoted line of code is almost certainly wrong. Check the docs for
read() to be sure. Good luck with it!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 23 Apr 1998 14:10:17 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Command line instructions don't execute in Win95
Message-Id: <1998042314101700.KAA21934@ladder03.news.aol.com>

Hi Creede:

>>Not so; it's the DOS *shell* that doesn't understand single quotes.
>>Perl on Win32 has exactly the same syntax as other perls.
>>
>>--
>>Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
>
>Technically you're right, but I think it's a distinction without a
>difference. If it doesn't work at the command line, it isn't going to
>work in WinPerl, whether it's implemented or not.

Lots of people use "other-than-default" shells on Win95. I use the Cygnus
"bash" - and it handles perl command lines in the "proper" fashion.

"Viva la difference." (probably misquoted)

-bill




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

Date: 23 Apr 1998 14:12:24 GMT
From: wayne@Glue.umd.edu (Wayne C. McCullough)
Subject: Re: Defending Perl
Message-Id: <6hni88$7tb$1@hecate.umd.edu>

Marjorie Roswell (roswell@umbc.edu) wrote:
: I'd like to answer the fellow who wrote this in response to my brief
: perl advocacy on a mailing list.

: "Perl does indeed offer alot of power, especially when working with
: data. (And its being free certainly doesn't hurt!!)  However, it
: offers problems as well.  Very few people use Perl, and since it is
: interpreted it has some performance and installation problems.  It is
: almost easier to work in the power of C or C++. 

: So: How many people use perl?
: Is it hard to install? (I don't think so.)
: Does it have performance problems?

Well, first of all, Perl isn't really interpreted.  It is compiled at
run time.  Compare a Perl and a shell script that do similar things.

I forget where, but somewhere in the man pages they make the claim that
Perl will run as fast as C for most things.  Yes, you have the compile
time on top to deal with, but in general it is fast.

I have had the most problems performance wise with Perl using up too
much memory than anything else.  Now, mind you, this is with big (say
100,000+) arrays.  I think Perl isn't very good at keeping data
structures as tight as they could be.  

Hard to install?  I don't know.  I have only installed it on a win-95
machine.  There it was more difficult to install than most aplications,
but it didn't take me more than 20 minutes to do.  

On a UNIX box, I suspect it all depends on how savy you are.  I have had
some problems installing Tk on unix boxes, but that is probably my own
stupidity.  I suspect someone with a little bit of experience and a lot
of willingness to read all the help files could install Perl on most
UNIX machines fairly easily.

Perl vs C, C++?  I believe Perl is more portable than C.  Perl uses native
formats for floating point numbers, so in some cases you will similar
programs work differently on different computers.  Also, if you use "fork",
you may have some problems.  

However, as far as porting a GUI written in Perl Tk, my (limited) experience
has been that it is no problem what so ever.  Get that claim on any GUI
written in C or C++, esp between a wintel box and a UNIX box.

And Perl is easier to code.  I can't put it into a more scientific
arguement, I just find Perl to be easier in many things.  (to 
paraphrase an episode of "The Tick" ... the one with "Mr Sarcastro"...
"No, no. I  ... I ... I ... I just like Perl.")

W


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

Date: 23 Apr 1998 10:42:20 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Defending Perl
Message-Id: <6hnk0c$gub$1@monet.op.net>

In article <pudge-2304980809410001@ppp-8.ts-1.kin.idt.net>,
Chris Nandor <pudge@pobox.com> wrote:
>Anyway, it seemed to me that the person was talking about installatin
>problems of perl itself, not a script to run under perl.

That's how I took it, but actually I don't think he knew *what* he was
talking about.

Hence my non-constructive answer.  You can't refute an idiot.


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

Date: Thu, 23 Apr 1998 08:09:39 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Defending Perl
Message-Id: <pudge-2304980809410001@ppp-8.ts-1.kin.idt.net>

In article <6hlu2j$l8o@mozo.cc.purdue.edu>, gebis@albrecht.ecn.purdue.edu
(Michael J Gebis) wrote:

# Can I ship a script to you and guarantee it will work?

Yes.

# No.

Yes.  :)

# You'll only need to change the #!/usr/bin/perl5 line, but to some
# people, this could be a big deal.  (For example, I can't put perl
# scripts on a CD.)

  perl your_script

You have as good a chance with perl -- probably better -- than with C
source, and probably a C binary, too.

Anyway, it seemed to me that the person was talking about installatin
problems of perl itself, not a script to run under perl.

Did you know that Netscape Enterprise Server run on Perl scripts (on
Solaris, server 3.x, anyway)?  In [server_root]/install it has a perl
binary that it ships with (it is 5.001m, shhhh, say nothing, act casual),
a couple of modules, and a script or two.  They don't include any standard
distriution, except for the binary and the artistic license.  Works just
fine.

--
Chris Nandor               pudge@pobox.com           http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==                    MacPerl: Power and Ease                     ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#


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

Date: 23 Apr 1998 14:55:23 GMT
From: "st" <stuart@euronova.com>
Subject: HTML::Table
Message-Id: <01bd6ec7$72cb3830$ef6995c1@server>

I often use a module I wrote a while back for creating HTML tables. I've
put it at http://www.euronova.com/pub/htmltable.zip 
Feel free to use it. Any feedback, improvements are welcome.
Below is the readme.
Cheers,
Stuart

_______________________________________________________________
Stuart Thorn                                 thorn@spinnaker.fr
Spinnaker Internet Services             http://www.spinnaker.fr 



An HTML::Table is a grid of cells. By default the table has one cell at
[0,0].
Wherever cells are added the table expands to accommodate that point.
  
The table style can be set at HTML::Table->new  
 my $table = new HTML::Table( { 'border' => 0, 'cellpadding' => 1 } );
 my $table = new HTML::Table( { 'border' => 0, 'cellpadding' => 1 }, 
                              { 'columns' => 5, 'rows' => 10, 'ucTags' => 1
} );

or by calling 
 $table->setTableTags( { 'border' => 1, 'cellspacing' => 0} )
 $table->setColumns( 5 );
 $table->setRows( 10 );    
but this should be done before adding cols otherwise you could 
lose rows/columns that are outside your set value

Each cell is a hash containing
 ->{text}            : the text of the cell
 ->{tags}            : the <td> tags :'align' => "center" etc.
 ->{formats}         : HTML tags that can be put either side of ->{text}
                      for example ["<b>", "</b>"] ( array reference )

These are set when adding cells
 $table->addCell( [5,4], "test cell" );       
 $table->addCell( [5,4], "text of cell", {'align' => "center", 'colspan' =>
3 }, 
                         ["<font color=blue><b>", "</b></font>"] );
 $table->addCell( [-4, -8], "to extend table back and up" );
 $table->appendCell( "test cell", { 'align' => "center", 'colspan' => 3,
'rowspan' => 2 } );
watch out when using colspans and rowspans: they will create extra
rows/columns if necessary

Or by adding columns/rows
 my $col = $table->appendColumn( [$table->firstRow() .. $table->lastRow()],

                                 { 'align' => "center" } );
 $table->setColumnTextFormat( $col, ["<b>", "</b>"] );
 $table->setColumnTags( $col, { 'align' => "center" } );
 $table->prependColumn( ["puts", "column", "to left of table"], 
                        { 'valign' => "top" }, ["<b>", "</b>"] );
 $table->appendRow( ["new", "row", "appended"] );
 $table->prependRow( ["new", "row", "prepended"] );
 $table->addColumn( 5, ["add", "column", "to", "specific", "place"] );
 $table->addRow( 5, ["add", "row", "to", "specific", "place"] );  

If your set on having your tags in upper case
 table->setUcTags( 1 );
or at new
 new HTML::Table( {'border' => 1}, {'ucTags' => 1 } )

Unused outer columns/rows can be got rid of by
 $table->crop();

Eventually get table as HTML code by
 my $html = $table->toHTMLString();

or as its equivalent in text
 my $txt  = $table->toTextString();
This loses text formatting but keeps structure formatting such as colspan,
rowspan




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

Date: 23 Apr 1998 14:24:01 GMT
From: cball@bu.edu (Charles Ball)
Subject: Memory allocation and CGI Performance
Message-Id: <6hniu1$ddq$1@news1.bu.edu>

I'm working on a CGI script which uses or requires a handful of
supporting libraries.  This program has adequate performance for a single
execution, but when I test it with multiple simultaneous executions,
performance degrades much more quickly than can be explained by the
number of processes.  We have observed the same behaviour with other CGI 
scripts.  Analysis of a system with 10-20 simultaneous executions running 
shows that far more context switches occur than seems reasonable.  Our
conclusion is that the CGI perl processes are systematically giving up
their time slices early.

After investigating several dead ends, my current hypothesis is that
perl's use of memory allocation during compilation/interpretation is a
problem.  Tracing the startup phase of several scripts (using truss on
solaris 2.5.1) shows that brk() typically accounts for ~80% of the
system call activity.  I've included a short example below with stats
at the end. 


Does anyone know of a way to pre-extend memory allocated to the process
so that compilation and interpeted modules can expand into much larger
chunks of memory and avoid hundreds [actually, this is thousands for
any significant program] of brk()'s to get another 2k bytes.  I've tried
allocating and undef'ing a large array,

	BEGIN {$x = "\0" x 1024*1024; undef $x;}

but while I can verify that the allocation occurs early on, this space
doesn't get reused by the compiler/interpreter. 

Any help would be greatly appreciated.

Charles Ball
Information Technology
Boston University


Here's an example script with a sorted list of the system calls invoked.

-----------------------------------
#!/usr/local/bin/perl
 
  
use CGI;
print "hello world\n";
-----------------------------------

A sorted count of the system calls for this "script":

Total system calls: 627

brk = 485(77.4%)
read = 30(4.8%)
mmap = 25(4.0%)
open = 20(3.2%)
close = 14(2.2%)
fstat = 14(2.2%)
munmap = 8(1.3%)
getcontext = 7(1.1%)
lseek = 6
ioctl = 6
getuid = 2
getgid = 2
setcontext = 1
time = 1
write = 1
_exit = 1
execve = 1
stat = 1
getpid = 1
getgroups = 1



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

Date: 23 Apr 1998 10:52:31 GMT
From: <affix@usa.net>
Subject: PB : sendmail subroutine
Message-Id: <01bd6ea5$61c4f980$b26d9ec2@clubinternet.club-internet.fr>

Hi,
I dont understand why my message isn't sent.
I have the right paht for the mailprogram (mail) and i have made the
changes in the sub routine.
The last message i had in the error_log was :
"Name "main::CONFIG" used only once: possible typo at bourdaismail.cgi line
334.
Use of uninitialized value at bourdaismail.cgi line 334.
No mail for bourdais"

Thank you
laurent
----------------------------------------
sub send_mail {
    # Localize variables used in this subroutine.                          
 #
    local($print_config,$key,$sort_order,$sorted_field,$env_report);

    # Open The Mail Program
    open(MAIL,"|$mailprog $CONFIG{'recipient'}");

    print MAIL "From: $Config{'email'} ($Config{'realname'})\n";

    # Check for Message Subject
    if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\n\n"
}
    else                    { print MAIL "Subject: WWW Form Submission\n\n"
}

    print MAIL "Below is the result of your feedback form.  It was
submitted by\n";
    print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";
    print MAIL "-" x 75 . "\n\n";

    if (@Print_Config) {
        foreach $print_config (@Print_Config) {
            if ($Config{$print_config}) {
                print MAIL "$print_config: $Config{$print_config}\n\n";
            }
        }
    }



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

Date: Thu, 23 Apr 1998 16:31:56 GMT
From: jgloudon@hyssop.bbn.com.bbn.com (Jason Gloudon)
Subject: Re: PC-based editors for Perl?
Message-Id: <slrn6jur7f.ail.jgloudon@hyssop.bbn.com>

Lee Roth <leeroth-nospamo@worldnet.att.net> wrote:
>
>Any suggestions for an editor on a PC that would be 'better suited' to
>writing Perl code than native editors such as Notepad, Wordpad or
>(uck) a word processing package ?
>
>My personal editor is SEDT, available as freeware at
>http://www.ultranet.com/~anker/sedt/sedt.htm - works on a number of
>platforms (VMS,DOS/Windows,Unix) and offers many nice features among
>which I find valuable for Perl programming:
>
> 1) 'Find the matching curly brace' functionality
> 2) Auto-indent of left margin (indents same as previous line)
> 3) Ability to record keystroke macros and program keys on the fly

Go to http://www.dejanews.com/home_ps.shtml, and search for
perl and editor and windows or win32. We've had several recommendations
for the week.

--
Jason Gloudon


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

Date: Thu, 23 Apr 1998 10:15:42 GMT
From: Bill 'Sneex' Jones <chasecreek.systemhouse@usa.net>
Subject: Re: Perl for NT
Message-Id: <353F132F.57E4544A@usa.net>

Nathan Stanford wrote:
> 
> Does Tom Phoenix have to put down everyone when they ask a question.

I don't get it?!  Tom's prolly the NICEST person here!

__________________________
Bill Jones...............|
Sneaker's Nest...........|
Chasecreek Systemhouse...|


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

Date: 23 Apr 1998 15:22:56 GMT
From: Art Cohen <upsetter@shore.net>
Subject: Re: Perl for NT
Message-Id: <6hnmcg$mr8@fridge.shore.net>

Nathan Stanford <nathan@cyberservices.com> wrote:
: Does Tom Phoenix have to put down everyone when they ask a question.  This
: is a Perl Misc and Perl is a leading CGI Scripting Lang.  Since the person
: is wanting to know about Perl for NT vs Perl for Unix, he seems be in the
: right place.   This is Perl (hmmm)  and misc (Misc hmm)

: One of the many differences beside the programs that do not work on the NT
: like sendmail unless you install a seperate app. is the way Directories are
: pointed to the path...

You're criticizing Tom P. and you can't even write a coherent sentence?

Tom Phoenix is one of the most helpful people in this group. He virtually
always points the person in the right direction to find the answer to
their question, and with a minimum of snideness (unlike certain other
folks around here). In this case, he told the person which module to use
to avoid platform-related filesystem issues and pointed them to a Perl for
Windows FAQ. Perhaps you'd have been happier if he just wrote the
application for this guy?

--Art

National Ska/Reggae Calendar: www.ziplink.net/~upsetter/ska/calendar.html
        Boston Ska Home Page: www.ziplink.net/~upsetter/ska/index.html



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

Date: Thu, 23 Apr 1998 11:07:59 GMT
From: Brent Michalski <perlguy@inlink.com>
To: "Karel.DeBruyne" <dbruyne@uia.ua.ac.be>
Subject: Re: perl library to read excel file
Message-Id: <353F210F.A1BD29DA@inlink.com>

Karel,

If you are running Perl on a Windows box, there should be 2 examples of
using OLE & Excel in your x:/perl/eg directory.  They are called
excel1.pl and excel2.pl
     ^- That is the number one.

I don't know how useful they'll be, but they should give you a starting
point.

Brent


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

Date: Thu, 23 Apr 1998 08:50:44 -0600
From: eryq@zeegee.com
Subject: Re: print $fh redefinition
Message-Id: <6hngvk$19v$1@nnrp1.dejanews.com>

In article <6himo7$mda12@fizban.pprd.abbott.com>,
  Albert Chin-A-Young <china.no-spam@pprd.abbott.com> wrote:
>
> I'd like to have:
> 	print $fh "foo";
> call my own print routine. What I have in mind is something like:
>
(snip)

Read the "perltie" manpage, to find out about tied filehandles.

You might *also* be interested in downloading the IO-stringy
toolkit from http://www.perl.com/CPAN in the authors/Eryq
directory: it already gives you filehandles that can be tied
to scalars, arrays of scalars, and arrays of lines.

Off the top of my head...

	require 5.004;

	# Alpha syntax, but it probably will stay around...
	my $fh = IO::Lines->new_tie(\@lines);
	print $fh "This is\nsome";
	print $fh "text...\n";
	$fh->print("...and\nso is this!\n");
	close $fh;

@lines will now contain:

	("This is\n",
	 "some text...\n",
	 "...and\n",
	 "so is this!\n")

Give it a shot.  Yell if it breaks.  :-)
--
   ___  _ _ _   _  ___ _  Eryq (eryq@zeegee.com)
  / _ \| '_| | | |/ _ ' / President, Zero G Inc: http://www.zeegee.com
 |  __/| | | |_| | |_| |      "Talk is cheap. Let's build." - Red Green.
  \___||_|  \__, |\__, |___/\ Visit STREETWISE, Chicago's newspaper by/
            |___/    |______/ of the homeless: http://www.streetwise.org

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Thu, 23 Apr 1998 05:18:30 -0700
From: "Xah" <xah@love.com>
Subject: problem: num/str related
Message-Id: <6hnb84$cj8$1@nntp2.ba.best.com>

I've been debugging a script for 3 hours, and am in severe pain now. I've
narrowed the script to the following. The problem lies in the two _elsif_
lines. I assume the problem is related to conversion between numbers and
strings. If anyone can help out, greatly appreciated.

The script is pretty much self-explainatory. Try typing "scriptName 199801
199803" without the quotes in a unix prompt, where scriptName is the same of
the  script. The problem is that it will not pass the verifyArgument
subroutine, stucking at the two elsif lines.

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

use strict;

sub verifyArgument {
    my($d1,$d2)= @_;

    print "$d1, $d2, \n";

    if (undef($d1) or undef($d2)) {return "start date or end date are not
given.\
";}  elsif ($d2 < $d1) {
return "end date must be later than start date.";}
    elsif (("$d1" !~ m@^\d{6}$@) or ("$d2" !~ m@^\d{6}$@)) {return "date
must be\
 of the form yyyymm. e.g. 199803 for 1998 March.";}
#    elsif (($d1 < 199701) or ($d2 < 199701)) {return "date must not be
earlier \
than 199701";}
    elsif ('true') {return 'true';};
};

MAIN:{

# verify and assign arguments.
    my($arg1,$arg2)=@ARGV;

    my($temp1)=verifyArgument($arg1,$arg2);
    if ($temp1 ne 'true') {
        print "$temp1\n\n";
        print "problem !!!\n\n";
        print "$arg1, $arg2\n\n"
    };
};

__END__


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

Thanks for hints.

 Xah
 xah@best.com
 http://www.best.com/~xah/SpecialPlaneCurves_dir/specialPlaneCurves.html
 Mountain View, CA, USA


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

Date: Thu, 23 Apr 1998 10:23:46 -0500
From: Wade Williams <wwilliam@cisco.com>
Subject: Read-only value?
Message-Id: <353F5D02.2D14D662@cisco.com>

foreach $val (@{$v->{ord}},@{$v->{ordpoints}})
 {
 	if (! $val)
 	{
 		$val="&nbsp";
 	}
 }


Naturally, $v->{ord} is a reference to an array.

When I run this code, I get "Attempt to modify read-only value"

My understanding it that $val should contain a reference to each element
of the array as the loop iterates, and thus, I should be able to modify
$val, and thus the array.

I've got identical code that works, but doesn't involve a reference, so
I suspect it's just how I'm dereferencing the reference.  (However, if I
go into the debugger, and do a "x @{$v->{ord}}" I do get the dump of the
array, exactly as I would expect)

Anyone have any ideas on what my mistake could be?

Thanks,
Wade
wwilliam@cisco.com


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

Date: Thu, 23 Apr 1998 16:46:33 GMT
From: jgloudon@hyssop.bbn.com.bbn.com (Jason Gloudon)
Subject: Re: Read-only value?
Message-Id: <slrn6jus2s.ail.jgloudon@hyssop.bbn.com>

Wade Williams <wwilliam@cisco.com> wrote:
 .
>foreach $val (@{$v->{ord}},@{$v->{ordpoints}})
 .

When you write this, Perl 'flattens' your two arrays into a single anonymous 
array out of your two arrays, so $_ is no longer a reference to the elements
of your arrays.

You could putting the loop code in a sub routine, which takes an array of
array references :).

--
Jason Gloudon


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

Date: Thu, 23 Apr 1998 14:10:43 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Regular Expression to match a valid IP address
Message-Id: <353F4D68.77A7@min.net>

This little subroutine validates decimal numeric IP addresses
of the form 8.8.8.8, 8.8.16, 8.24, and 32.

sub is_ip {
  local $_ = shift;
  return 0 if /[^0-9.]/;
  my @a = split /\./, $_;
  my $tail = pop @a;
  for ( @a ) {
    return 0 unless $_ < 256;
  }
  $tail < (256 ** ( 4 - @a ));
}

John Porter


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

Date: 23 Apr 1998 16:48:21 +0200
From: David Kastrup <dak@mailhost.neuroinformatik.ruhr-uni-bochum.de>
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <m2ogxsvbka.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>

eugene@cs.umb.edu (Eugene O'Neil) writes:

> >Your other licenses allow free code to be hoarded. The GPL takes a
> >firm *positive* stance against hoarding by requiring that GPL code
> >must never be distributed non-freely.

> Or you could say it takes a *negative* stance against people making
> money. The only difference is how you phrase it.

It takes a negative stance against people making money in a certain
way, namely by posing restrictions on the software (up to making them
very hard to fix in case of error for lack of source) that are not
desirable to the user.

People not in favor of contract killers are not automatically hostile
against all forms of contracts.

In fact, outlets like RedHat Software and Cygnus are making quite a
bit of money and are expanding, at the same time they have little
problems adapting to the framework of the GPL.

> >None of the other licenses guarantee this, therefore all the other
> >licenses are inferior.
 
> None of the other licenses guarentee that your work won't be touched
> by most commercial developers with a ten-foot pole, therefore, all
> other licenses are... um... could you run that by me again?

It's all the same to me.  If my alternatives are to either not have
commercial developers not be involved with my work, or have them
involved in a way where I am not legally allowed to make any use of
their derived stuff from my work, it's pretty much the same to me.
Except that in the former case I do not have to enter in a competitive
fight for people interested in my software and helping to debug it.

> Yes they have. The version that was RELEASED as free code will
> ALWAYS be free!  Any improvements people CHOOSE to contribute as
> free software will also be free! Only non-free dirivative works will
> not be free: they wouldn't be free under the GPL either, they simply
> wouldn't exist. Does less software make the world a better place?

For Windows, there are loads and loads of small independent shareware
programs like editors that are good for a few things, but sadly
lacking in most respects.  The lack of sharing resources leads to
massively mediocre products.  The central and consistent licensing as
well as the complete availability of prior art in source in the GNU
realm has lead to a concentration of development forces on few
software pieces that get exceptionally good and useful.  This
concentration of forces does not make the world a worse place, in my
opinion.  Note that when technical or other reasons are at bail, a
splitoff because of technical or other reasons is always possible (a
few have happened, the last important one perhaps egcs).  A splitoff
from GPLed software can always occur without throwing away all
previous development, as long as you choose to stay with the GPL.

The unifying processes tend to work the worse, the less mature
existing products are, and the smaller the cost of starting new,
consequently.  For example, at least before the announcement of
Mozilla, there were new GPLed browser developments started every few
weeks from scratch (I cannot remember the names of all of them).

In the world of Windows, Microsoft products dictate the course of
great unification.  While this concentration of development and
resources (like money) is in itself not bad, the way in which
Microsoft stifles competition by legal, marketing and sabotaging
(undocumented interface wars) excellence is not beneficial for future
development.  Also, their massive assets in the form of existing
proprietary code increasingly destroy the chances for contenders to
develop technical excellence into a competitive product because the
stage at which they will be able to gather appropriate popularity
resulting in funding for future development is lots harder to reach.

When competing on a GPLed basis, your popularity gains are
proportional on the differential work you do on the globally available
GPL code base, not on the amounts you have been able to accumulate so
far.  This is a much more stable development ensuring lots less wasted
work.

Of course, once every programmer on the world will be paid by
Microsoft, the goal of having everything available to every programmer
will be met, too.

I prefer the unification of resources caused by the GPL, though,
because it has a more open and voluntary character.


-- 
David Kastrup                                     Phone: +49-234-700-5570
Email: dak@neuroinformatik.ruhr-uni-bochum.de       Fax: +49-234-709-4209
Institut f|r Neuroinformatik, Universitdtsstr. 150, 44780 Bochum, Germany


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

Date: 23 Apr 1998 10:49:41 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Symbolic ref and angle opeator
Message-Id: <6hnke5$h0i$1@monet.op.net>
Keywords: Cobb crap Senegal tow


In article <6hld7b$aja$1@monet.op.net>, Mark-Jason Dominus <mjd@op.net> wrote:
>Blah blah blah.  The only language I can think of offhand that
>*doesn't* have a syntax like that is (surprise!) APL.

Come to think of it, APL does have an ...[...] array subscript
notation, so I have to take it back.


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

Date: Thu, 23 Apr 1998 14:14:03 GMT
From: John Porter <jdporter@min.net>
Subject: Re: There *IS* a visual IDE for Perl!
Message-Id: <353F4E2E.1FCF@min.net>

Randal Schwartz wrote:
> 
> Nothing can parse Perl like /usr/bin/perl.  It just can't be done.

Which is exactly why it ought to be extended to optionally output
parse trees and/or other post-parse info.  Especially via the API,
although via command-line would be nice too.

John Porter


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

Date: Thu, 23 Apr 1998 14:59:46 GMT
From: John Porter <jdporter@min.net>
Subject: Re: There *IS* a visual IDE for Perl!
Message-Id: <353F58E6.1502@min.net>

Calle Dybedahl wrote:
> 
> John Porter <jdporter@min.net> writes:
> 
> > Which is exactly why it ought to be extended to optionally output
> > parse trees and/or other post-parse info.
> 
> You mean like "perl -Dx" does, or something else?

Yes, that might be sufficient...
Is it possible (in C code) to query an embedded perl interpreter for
the syntax tree resulting from an eval?

John Porter


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

Date: Thu, 23 Apr 1998 15:30:40 GMT
From: John Porter <jdporter@min.net>
Subject: Re: There *IS* a visual IDE for Perl!
Message-Id: <353F6024.7EA3@min.net>

John Porter wrote:
> 
> Calle Dybedahl wrote:
> >
> > You mean like "perl -Dx" does, or something else?
> 
> Yes, that might be sufficient...

Actually it probably isn't.
What we need is a way to get the parser output, and no
execution.  Something similar to -u (dump): compile, do
the report, and stop.

John Porter


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


------------------------------
End of Perl-Users Digest V8 Issue 2402
**************************************

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