[15610] in Perl-Users-Digest
Perl-Users Digest, Issue: 3023 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 12 00:08:49 2000
Date: Thu, 11 May 2000 21:05:10 -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: <958104309-v9-i3023@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 11 May 2000 Volume: 9 Number: 3023
Today's topics:
[ANNOUNCE}: File::FlockDir compatibility update release (William Herrera)
A question from Dynamic Whistler bzooty@my-deja.com
Re: Accidental Creation of Static Variable <rick.delaney@home.com>
ANNOUNCE: User::Utmp 1.01 <mxp@dynalabs.de>
Anyone got ideas? How could Perl coorporate with a DLL <wstsoi@hongkong.com>
Re: call by reference subroutine!! (Tad McClellan)
Re: CGI problems (but it IS a perl thing) <rootbeer@redcat.com>
Re: CGI::Carp - Non fatal errors <bwalton@rochester.rr.com>
Re: Checking if Child Process is still Alive <rootbeer@redcat.com>
Help in reading cookie <aaronaw@my-deja.com>
Re: Help using split and arrays (Tad McClellan)
Re: Help using split and arrays <matt.stoker@motorola.com>
Re: Help using split and arrays (Tad McClellan)
How do you create a module and pass variables into and <david.shapiro@wcom.com>
Re: How to use Perl script in Windows Logon <rtietjen@connix.com>
Re: Is Perl fast enough? <nous@internet-ici.com>
Literate Programming and Perl <argoldman@mindspring.com>
Re: Literate Programming and Perl <bmb@ginger.libs.uga.edu>
Re: MUCH better DATA file formatting :) (THANK YOU) <bmb@ginger.libs.uga.edu>
Newbie CGI/Perl (DEDSRD)
Re: Perl 5.6 and XS <dan@tuatha.sidhe.org>
Re: Regex Question (hopefully, an educated guess) <bwalton@rochester.rr.com>
Re: Regular expression ? (Tad McClellan)
Re: Regular expression ? <jeff@vpservices.com>
Re: string and numeric data handling (Tad McClellan)
Re: Subroutine error stops module ?! (Tad McClellan)
Re: unpack c struct <bwalton@rochester.rr.com>
Re: Using Modules Breaks "-w"? <nospam@devnull.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 07 May 2000 21:08:38 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: [ANNOUNCE}: File::FlockDir compatibility update released
Message-Id: <8fflpv$s18$1@play.inetarena.com>
File::FlockDir cross-network flock() implementation version 0.99, an update for
newer perl version comptibility, has been released on CPAN.
---
The above from: address is spamblocked. Use wherrera (at) lynxview (dot) com for the reply address.
------------------------------
Date: Fri, 12 May 2000 01:18:13 GMT
From: bzooty@my-deja.com
Subject: A question from Dynamic Whistler
Message-Id: <8ffm49$edp$1@nnrp1.deja.com>
Hey. Dynamic Whistler is an information site about DHTML. We're a month
old and are starting to really get focused on content. We're thinking
about including PERL resources as well. Our question is:
What would be the most important resource that an PERL developer would
hope to find on our site?
Check us out at http://whistler.bccmedia.com and tell us what you think.
This is an educational project and NOT commercial. We are developers and
designers training ourselves in new (to us) technologies. The best way
to learn is to just do it. Having friends give us pointers doesn't hurt
either. Thank you very much.
Jerry Stogsdill
Dynamic Whistler
http://whistler.bccmedia.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 12 May 2000 02:26:50 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Accidental Creation of Static Variable
Message-Id: <391B6C5F.1BD4A3D5@home.com>
Abigail wrote:
>
> From the documentation:
> A `my' has both a compile-time and a run-time effect. At
> compile time, the compiler takes notice of it. The
> principle usefulness of this is to quiet `use strict
> 'vars'', but it is also essential for generation of closures
> as detailed in the perlref manpage. Actual initialization
> is delayed until run time, though, so it gets executed at
> the appropriate time, such as each time through a loop, for
> example.
>
> And that, for me, explains *exactly* what 'my $foo = 3 if $bar == 16'
^^^^^^^
Exactly? I don't see anything there about initializing (assigning?) the
previously held value, but only if that value was assigned in a
statement separate from the my.
$ perl -le 'for (1..10){my $i = $_ unless $_%3;$i=4 if/4/;print $i}'
3
4
4
6
9
Some clarification of "it gets executed" couldn't hurt.
> does. Once you understand the above paragraph, it's clear as crystal.
I'm sure.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 06 May 2000 19:59:45 +0200
From: Michael Piotrowski <mxp@dynalabs.de>
Subject: ANNOUNCE: User::Utmp 1.01
Message-Id: <8fflq4$s1f$1@play.inetarena.com>
I've just uploaded a new version of the User::Utmp module to CPAN.
Version 1.01 is a maintenance release: it now builds successfully on
Linux.
When it has migrated to its final destination, you should be able to
find it via
<http://search.cpan.org/search?dist=User-Utmp-1.01>
It's also immediately available from
<http://www.dynalabs.de/mxp/perl/User-Utmp-1.01.tar.gz>
<ftp://ftp.linguistik.uni-erlangen.de/pub/perl/User-Utmp-1.0.tar.gz>
Here's an excerpt from the README:
This module provides a simple Perl interface to utmp- and
utmpx-style databases on UNIX systems, the most important being
/etc/utmp, which provides information about users currently logged
in. There is also experimental support for writing utmp files.
For further details see the POD documentation embedded in the file
Utmp.pm, which will also be installed as User::Utmp(3) manpage, and
the example.pl script.
--
Michael Piotrowski, M.A. <mxp@dynalabs.de>
------------------------------
Date: Fri, 12 May 2000 09:58:21 +0800
From: "wstsoi" <wstsoi@hongkong.com>
Subject: Anyone got ideas? How could Perl coorporate with a DLL
Message-Id: <8ffo8n$5qn$1@justice.csc.cuhk.edu.hk>
As title, do anybody know How could Perl coorporate with a DLL?
mostly I need to call a DLL from a Perl script
or it is just impossible to do it?
thanks to evryone looking into my problem!!!
------------------------------
Date: Thu, 11 May 2000 19:38:54 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: call by reference subroutine!!
Message-Id: <slrn8hmh4e.laa.tadmc@magna.metronet.com>
On Thu, 11 May 2000 21:00:59 GMT, prakash_ojha@my-deja.com <prakash_ojha@my-deja.com> wrote:
>I want to write a subroutine that takes parameter by reference
How fortunate! That is how Perl does it too!
>just like
>in C,
and Perl.
>so that I can change the passed argument without returning a
>value of some thing of that sort. can anyone help?
Anyone who read the first 50-60 lines of perlsub.pod can help.
If you have a question about subroutines, you should read
the documentation for subroutines *before* you post it to
tens of thousands of computers around the world.
-----------------
#!/usr/bin/perl -w
use strict;
my $x = 100;
print "$x\n";
subtract_10($x);
print "$x\n";
sub subtract_10 { $_[0] -= 10 }
-----------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 11 May 2000 19:06:29 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: CGI problems (but it IS a perl thing)
Message-Id: <Pine.GSO.4.10.10005111900440.16364-100000@user2.teleport.com>
On Thu, 11 May 2000 simeon2000@my-deja.com wrote:
> I have checked out perldoc perlsec (and the camel book). I found the
> is_tainted function, and the way to supposedly "launder" the data, but
> it still is not working.
You didn't do it right. :-)
Cut your code down to the smallest example that demonstrates the problem,
then post that. You shouldn't need to make it a web-based program, since
you can get the data from @ARGV (among other places). And you don't need
to use a module like Mail::POP3Client if you use the is_tainted function
to identify whether the "laundering" worked.
BTW, the most common mistake is to think that a successful pattern match
makes the data lose its taintedness.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 12 May 2000 01:27:33 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: CGI::Carp - Non fatal errors
Message-Id: <391B5D13.E0E7C5FC@rochester.rr.com>
Jerome O'Neil wrote:
>
> Here is some odd behavior I have found new with the 5.6 release,
> and CGI::Carp.
>
> Given the following code:
>
> #!/usr/local/bin/perl -w
> use strict;
> use CGI qw{-no_debug};
> use CGI::Carp qw{fatalsToBrowser};
>
> BEGIN{
> for({qw{CGI Foo}){
^
won't compile!!!!!!!!
> if(!eval "require $_"){
> print qq{$_ is not installed\n};
> }else{
> print qq{$_ is installed\n};
> }
> }
> }
>
> If I run this under 5.005_03 perl DWIM and outputs:
>
> CGI is installed
> Foo is not installed
>
> However, if I run it under 5.6, perl carps about being unable to
> find out about Foo:
>
> Can't locate Foo.pm in @INC ...
>
> I'm not sure what the expected behavior is, but I like the
> first. I would think that a fatal error shouldn't be reported
> unless it realy is a fatal error.
>
> What, or who is broken?
>
> Thnks!
I verify that your program does not generate the error message output
when run with Perl 5.005_03, and that it does generate the error output
with 5.6. I note that execution is not stopped in either case, and that
"Foo is not installed" does come out in both versions. I would suppose
that the 5.6 behavior is not right. Anyone else?
--
Bob Walton
------------------------------
Date: Thu, 11 May 2000 19:13:50 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Checking if Child Process is still Alive
Message-Id: <Pine.GSO.4.10.10005111908190.16364-100000@user2.teleport.com>
On Thu, 11 May 2000, John J Green wrote:
> waitpid($pid, WNOHANG)
>
> Unfortunately, Win32 doesn't support the POSIX::WNOHANG value - you
> can import the sub, but when invoked, it says something like 'WNOHANG
> not supported on your implementation'
Here's an idea you can try; I haven't tested it because I don't have a
Windows machine.
my $wnohang = eval { WNOHANG } || 0;
# later, when you need it...
kill 'HUP', $pid unless $wnohang; # kill only on windows?
waitpid($pid, $wnohang);
The HUP signal is just to be safe, so that if $wnohang won't work for you
on windows (or on a non-POSIX machine) you can hope that the process will
be dead soon. That may or may not be what you want, of course. And there's
no reason you have to use 'HUP', if different signals actually do
different things on Windows.
Good luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 12 May 2000 03:18:13 GMT
From: Aaron <aaronaw@my-deja.com>
Subject: Help in reading cookie
Message-Id: <8fft5a$lsb$1@nnrp1.deja.com>
Hi. I'm using ActivePerl 5.6 on IIS4 (NT4). I'm trying to use the
CGI.pm to store and retrieve cookies. So far I've only been able to
store the cookie. however I'm unable to read the cookie back.
$packed_cookie = $q->cookie(-name=>"name1", -value=>"whatever you'd
like", -expires=>"+2y",);
print $q->header(-COOKIE=>$packed_cookie);
this snippet above is for storing the cookie part.
actual cookie file
------------------
name1
whatever%20you%27d%20like
daphne/scripts/cookie.pl
0
3589509888
29489497
3833554784
29342646
*
readcookie.pl
-------------
use CGI;
$q = new CGI;
%answers = $q->cookie(-name=>'name1');
print $q->header;
print $q->start_html(-title=>'Secrets of the Pyramids');
print "This is a test.";
print "Hello world!!!<BR>\n";
print "START";
if (%answers) {
foreach (sort keys %answers) {
print "<li>$answers{$_} $_\n";
}
} else {
print "Empty.";
}
so far the result is "Empty.". Could someone please advise? also is
there any sample code that I could refer to? thanks!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 11 May 2000 20:10:45 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help using split and arrays
Message-Id: <slrn8hmj05.laa.tadmc@magna.metronet.com>
On Thu, 11 May 2000 15:38:01 -0400, Gary Nielson <gnielson@charlotte.infi.net> wrote:
>I am having trouble using an array and split to parse an html document.
^^^^^^^^^^^^^^^^^^^^^^
You should be using a module for that (if you want it to be correct).
>I am trying to isolate just those lines that contain urls and links and
^^^^^^^^^^^^^^^^^^^^^^
There is a module specifically for extracting links
HTML::LinkExtor - Extract links from an HTML document
>until I am
>left with just the code I want, the URL and the link, separated by a "
>". The script works fine until I try to use split. My limited (but
>hopefully growing) understanding of perl is that you can't perform
>substitutions on arrays, just scalar variables.
Array elements *are* scalars, so whatever you can do to a
scalar you can to to an array element (but not, directly,
to the array as a whole).
You can use foreach or map to apply a s/// to each element
in an array.
>So as the script loops
>through the file and finds the desired lines, it pushes the scalar
>variable into an array.
>
>But then how do I split the array
I don't know what "split the array" means.
Sounds like take some elements and put them over here, and
put the other elements over there, but that doesn't sound
like the rest of your problem description...
>since perl won't let you split arrays,
>just scalars, but when I try to convert the array to a scalar, the
>syntax is telling perl $variable = @array to give me the number of
>elements. So I feel like I am caught in my own loop of sorts mixing
>scalars and arrays when trying to use split.
Sure would be a lot easier if you just used the already-invented wheel...
>So for now, I can get one array element that includes both the link and
>the URL, which is not what I want; I want each element to contain only a
>link or only the URL.
>
>Code below:
>
>$var = "";
my $var;
>@headlines = "";
There you are creating an array that contains a single element
(the empty string).
my @headlines;
>$delimiter = " ";
my $delimiter = " ";
>$filename = "docs/filename.htm";
my $filename = "docs/filename.htm";
>open(FILE, $filename);
You should always, yes *always*, check the return value from open():
open(FILE, $filename) || die "could not open '$filename' $!";
>while (<FILE>)
>{
> if (/<A HREF=/) # line contains <A HREF tag
That will miss some lines that contain <a> tags.
It will also miss other <a> tags, such as
$_ = '<A HREF = "http://www.perl.com/">
^ ^
It will also also miss legal HTML like:
$_ = '<A
HREF
=
"http://www.perl.com/"
>';
if ( /<A HREF\s*=\s*/i ) # line contains <A HREF tag
> {
> $var = $_;
You don't need to copy it to another variable.
You already have it in the $_ variable, just have your way with that.
># strip out crap
>
> $var =~ s/<DIGEST>|<\/DIGEST>|<\/FONT>|<\/TD>//g;
^ ^ ^
Use alternate pattern delimiters to avoid Leaning Toothpick Syndrome:
s#<DIGEST>|</DIGEST>|</FONT>|</TD>##gi;
or
s#<DIGEST>|</(DIGEST|FONT|TD)>##gi;
># $var =~ s/<[A-Za-z\_].+DIGEST[A-Za-z\_].+>|<\/FONT>|<\/TD>//g;
^ ^
^ you don't need those backslashes, underscore
is not a regex metacharacter
> $var =~ s/\n/$delimiter/g;
> $var =~ s/<\/A>//g;
> $var =~ s/\">/$delimiter/g;
^
^ another useless backslash, double quote is not
a regex metacharacter either
> push(@headlines, $var);
> }
>}
>close (FILE);
>#$tmp = @headlines ## won't work because returns the number of elements,
>doesn't convert back to scalar
>#split(m/$delimiter/, @headlines); ## wont work because I dont think
>split works on arrays, just scalars.
So loop over all of the scalars contained in the array instead:
foreach ( @headlines ) {
my($first, $second) = split /$delimiter/;
# do stuff with the split out parts
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 11 May 2000 18:13:52 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: Re: Help using split and arrays
Message-Id: <391B5AD0.4319A2AE@motorola.com>
You can do:
for ($i = 0; $i < @headlines; $i++)
{
splice (@headlines, $i, 1, split(/$delimiter/,$headlines[$i]));
}
This loops through each element of @headlines, splits it on $delimiter
and inserts the resulting list back into @headlines at the starting
position of the original element. I think this is what you are looking
for, although there are probably better ways to do what you desire using
the CPAN module HTML::Parser.
Gary Nielson wrote:
>
> I am having trouble using an array and split to parse an html document.
>
> I am trying to isolate just those lines that contain urls and links and
> create an array whose elements I can then insert into a form, with urls
> and links as separate elements.
>
> First, I find just though lines that contain an A HREF and grab that
> entire line. I then get rid of extraneous markup language until I am
> left with just the code I want, the URL and the link, separated by a "
> ". The script works fine until I try to use split. My limited (but
> hopefully growing) understanding of perl is that you can't perform
> substitutions on arrays, just scalar variables. So as the script loops
> through the file and finds the desired lines, it pushes the scalar
> variable into an array.
>
> But then how do I split the array since perl won't let you split arrays,
> just scalars, but when I try to convert the array to a scalar, the
> syntax is telling perl $variable = @array to give me the number of
> elements. So I feel like I am caught in my own loop of sorts mixing
> scalars and arrays when trying to use split.
>
> So for now, I can get one array element that includes both the link and
> the URL, which is not what I want; I want each element to contain only a
> link or only the URL.
>
> Code below:
>
> $var = "";
> @headlines = "";
> $delimiter = " ";
> $filename = "docs/filename.htm";
> open(FILE, $filename);
> while (<FILE>)
> {
> if (/<A HREF=/) # line contains <A HREF tag
> {
> $var = $_;
>
> # strip out crap
>
> $var =~ s/<DIGEST>|<\/DIGEST>|<\/FONT>|<\/TD>//g;
> # $var =~ s/<[A-Za-z\_].+DIGEST[A-Za-z\_].+>|<\/FONT>|<\/TD>//g;
> $var =~ s/\n/$delimiter/g;
> $var =~ s/<\/A>//g;
> $var =~ s/\">/$delimiter/g;
> push(@headlines, $var);
> }
> }
> close (FILE);
> #$tmp = @headlines ## won't work because returns the number of elements,
> doesn't convert back to scalar
> #split(m/$delimiter/, @headlines); ## wont work because I dont think
> split works on arrays, just scalars.
>
> print @headlines;
>
> Any help appreciated. Please email reply as well.
>
> Gary
--
/------------------------------------------------------------------\
| Matt Stoker | email: matt.stoker@motorola.com |
| Unit Process Modeling | Mail Drop: M360 |
| DigitalDNA(TM) Laboratories| Phone: (480)655-3301 |
| Motorola, SPS | Fax: (480)655-5013 |
| 2200 W Broadway Road | Pager: (888)699-8803 |
| Mesa, AZ 85202 | |
\------------------------------------------------------------------/
------------------------------
Date: Thu, 11 May 2000 20:34:46 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help using split and arrays
Message-Id: <slrn8hmkd6.lq2.tadmc@magna.metronet.com>
On Thu, 11 May 2000 17:44:52 -0400, Tina Mueller <tina@streetmail.com> wrote:
>you have to set the flag s for matching
>newlines
No you don't.
You need the m//s option if you want _dot_ to match newlines.
You can match newlines without 's' just fine:
---------------
#!/usr/bin/perl -w
use strict;
$_ = "first\nsecond\n";
if ( /first\n/ ) # matches newline without m//s
{ print "found 'first' at end of a like\n" }
---------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 10 May 2000 08:52:33 -0400
From: "David Shapiro" <david.shapiro@wcom.com>
Subject: How do you create a module and pass variables into and out of it?
Message-Id: <8fbmie$d4u$1@pumba.class.udg.mx>
I have seen a brief description of pakcage Some:Module that was posted to
daily_perl@yoak.com. But I do not understand it. I have a bunch of
functions that are common to many of my programs that I want to put in a
module that I can use in new programs. I think you put use package_name in
the new progrm, but perhaps it is just require package_name. I have not
understood the explainations of the differences between require and use.
After I do this, you can call the functions with
&package_name::function_name, but it is not clear to me how to allow the
package_name module to have access to variables that exist in the new
program and vice-versa. For example, if you had a function called mailinfo
that all programs use, I want to be able to do something like
&package_name::mailinfo($address,$attachment), where $address and
$attachment are defined in the new program. I see all kinds of things in
the packagee Some::Module example I do not understand: use Exporter ();,
@ISA, @EXPORT, %EXPORT_TAGS, etc. Any help on this and direction to good
reading resources for this would be greatly appreciated.
Thanks,
David
------------------------------
Date: 11 May 2000 22:33:57 -0400
From: Richard Tietjen <rtietjen@connix.com>
Subject: Re: How to use Perl script in Windows Logon
Message-Id: <87u2g4fqei.fsf@kale.connix.com>
I use ActiveState perl for to control login, by invoking the login
script from the wstation's startup folder. A batch file puts perl/bin
on the path then calls perl on a script. I just make sure that
perlcrt.dll is in the perl/bin directory, perl.exe knows to look there
for it. It's very handy this way, I don't have to install Perl on
each workstation. Large portions of my users' interaction with the
network are through perl scripts that run from the server.
HTH
Chuck Lawhorn <CharlieL3@yahoo.com> writes:
> Put PerlCRT.dll into the NetLogon share of all your domain controllers. I use
> scripts compiled with Perl2Exe in my scripts, and I put both of the required
> DLL's (PerlCRT and P2xdll.dll) into the NetLogon shares, and the compiled script
> runs on all PC's using logon scripts.
>
> Hope this helps,
> --Chuck
>
> JP wrote:
>
> > I am trying to put a logon script into the NT Netlogon share so that users
> > have to run the script during a login. The script is called by a batch file
> > and the domain controllers are all installed with Perl.
> >
> > The problem I have is that the script keeps complaining that the dynamic
> > library PerlCRT.dll cannot be located. There is no Perl installed on the
> > client. But I can run the script if I log on to the server.
> >
> > How can I have the logon script runs probably when the client log on from a
> > workstation?
> >
> > TIA.
>
--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--
Richard Tietjen rtietjen@connix.com
"Irony is what they make two-edged swords from."
--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--
------------------------------
Date: Fri, 12 May 2000 02:18:46 GMT
From: Rey of SynchroniCity <nous@internet-ici.com>
Subject: Re: Is Perl fast enough?
Message-Id: <8ffpls$i5q$1@nnrp1.deja.com>
In article <3918B862.3BB85505@vpservices.com>,
Jeff Zucker <jeff@vpservices.com> wrote:
> Eric Bohlman wrote:
> >
> > Jeff Zucker (jeff@vpservices.com) wrote:
> > : out of that setup. It's not the total number of lines that
matters,
> > : it's the total number you try to deal with simultaneously at any
one
> >
^^^^^^^^^^^^^^^^^^^^^^^^^
> > : point in time. Forgive me if I'm pointing out the obvious.
> > ^^^^^^^^^^^^^
> > Are you certain that that figure completely swamps out the impact of
> > things that you try to deal with simultaneously at different points
in
> > time? Perhaps the Department of Redundancy Department has done some
> > computations?
>
> Eric, Eric, Eric, you are out of date, my man. This whole issue of
> simultaneity at different points in time is covered in several
different
> module hierarchies. Get the Wells::Time::Machine,
Bradbury::Butterfly,
> or Jung::Synchronicity modules. If you thought race conditions were a
> problem before, you ain't seen nothin yet.
>
> --
> Jeff
>
--
From Rey of SynchroniCity
"Noos is a thinKING PLANiT"
"Glittering noosnaught wirkende craft zoom thru NooS and land
in SynchroniCity. The Sy Koyds are saved!"
You got that right... "Past", "Present" and "future" are
points of relativistic view. Time is subordinate to place and
if there is an envelope (for example, "noos") that embraces
the scroll of creation (BAM) in all its entirety, you aint see
nothing yet,... That is very correct....
Sincerley,
Rey
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 11 May 2000 23:25:44 -0400
From: "A. R. Goldman" <argoldman@mindspring.com>
Subject: Literate Programming and Perl
Message-Id: <391B79B7.1C1E4B2C@mindspring.com>
Greetings:
I am fairly new both to programming in general, and to Perl in
particular, but I feel that the earlier I create good habits the
better. To that end, I have become intrigued by the ideas of
Literate Programming (I am an editor by trade), and was hoping
that I might be pointed to any resources for Literate Programming
using Perl, or any resources for a beginner to get some initial
training in Literate Programming in general...]
Many thanks...
A. R. Goldman
------------------------------
Date: Thu, 11 May 2000 23:46:05 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Literate Programming and Perl
Message-Id: <Pine.A41.4.10.10005112342290.14222-100000@ginger.libs.uga.edu>
On Thu, 11 May 2000, A. R. Goldman wrote:
> Greetings:
> I am fairly new both to programming in general, and to Perl in
> particular, but I feel that the earlier I create good habits the
> better. To that end, I have become intrigued by the ideas of
> Literate Programming (I am an editor by trade), and was hoping
> that I might be pointed to any resources for Literate Programming
>
> using Perl, or any resources for a beginner to get some initial
> training in Literate Programming in general...]
> Many thanks...
> A. R. Goldman
At www.perl.com in the Perlland section is an article,
POD is Not Literate Programming
--Mark-Jason Dominus
It may not be what you're after, but it happens to be the only piece
I've ever read on the subject.
--
Brad
------------------------------
Date: Thu, 11 May 2000 23:34:06 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: MUCH better DATA file formatting :) (THANK YOU)
Message-Id: <Pine.A41.4.10.10005112322010.14222-100000@ginger.libs.uga.edu>
On 11 May 2000, The WebDragon wrote:
> (I managed to widen the linewrapping in my newsreader to 90 chars.. hope this is enough. )
Actually, it's bad news. It's better I think to leave the linewrapping
alone and teach yourself to manually wrap your lines of code in
meaningful places. Perl gives you plenty of opportunities.
> open(IN, "<$input_File");
> #I don't understand how to dereference this yet. um, 'help'? :)
> # @data = map {chomp; [split /\|/]} <IN>;
> #so I did it the 'long' way. is this the 'better' way?
> while (<IN>) {
> chomp;
> push @data, $_;
> }
> close IN;
1 #!/usr/local/bin/perl -w
2 use strict;
3
4 my $input_File = "xxx"; # input_File...oh, so close! :-)
5 my @data;
6
7 #open(IN, "<$input_File");
8 #This must have been a typo, because of course you meant this:
9 open(IN, "<$input_File") || die "Can't open $input_File: $!";
10
11 chomp( @data = <IN> ); # you need those parens
12
13 close IN;
14
15 print join "\n", @data, "\n";
Output:
Capture your desire
Mold its clay into a vase
Fill the vase with love
See also perldoc -f chomp (or whatever is the Mac equivalent).
--
Brad
------------------------------
Date: 12 May 2000 03:06:44 GMT
From: dedsrd@aol.com (DEDSRD)
Subject: Newbie CGI/Perl
Message-Id: <20000511230644.19175.00002234@ng-ci1.aol.com>
I've followed the install of Mac Perl.
I'm trying to build a comboform cgi script (i think)
Never used Perl or MPW
Q: Where do I start?
Q: Can I run a form on my own machine(Mac) before uploading to simulate how the
form will work in the browser?
Q: Is the .cgi and .pl extensions interchangeable does it matter which?
Darrell
------------------------------
Date: Fri, 12 May 2000 01:39:36 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Perl 5.6 and XS
Message-Id: <shJS4.83919$hT2.350198@news1.rdc1.ct.home.com>
Ben Kennedy <bkennedy@hmsonline.com> wrote:
> What exactly has changed in version 5.6 that prevents some older modules
> from compiling? A lot of modules install cleanly under 5.005 but not under
> 5.6 (for instance Crypt:::Blowfish uses the defunct sv_undef call). Is
> there a way to use these older modules with 5.6? I have a feeling that a
> lot of older but useful modules won't be rewritten. Thanks --
Sure. Add a POLLUTE=1 to the Makefile.PL invocation, like so:
perl Makefile.PL POLLUTE=1
All of perl's API now has either a Perl_ prefix (for functions) or a PL_
prefix (for data) to keep from messing up the C namespace. Polluting the
namespace was a problem that was just getting worse (especially with the
dirty and na variables), so Steps Were Taken.
This was all done for 5.005, but POLLUTE was the default there, in hopes
that module authors would clean up their modules. That tended not to be
the case, alas, but the change is in and it's staying.
Generally this *is* a good thing, though it can be annoying when building
modules that haven't taken it into account.
Dan
------------------------------
Date: Fri, 12 May 2000 01:38:25 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Regex Question (hopefully, an educated guess)
Message-Id: <391B5F9F.7DBE0289@rochester.rr.com>
mcnuttj@missouri.edu wrote:
...
> So here's the question: Is that regular expression a good one? More
> specifically:
>
> 1) How do the ^ and $ requirements affect the speed? Faster or slower?
>
> 2) How do the specific strings affect the speed? If the code around it
> is done properly, I could, for example, use / : (.*)$/ and it would work
> just fine, but is that slower than using the far-more-specific regex I
> have above?
>
> 3) If won't work in all cases, but someone mentioned before that 'split'
> might work better in a case like this. I could split on /\s+:\s+/, since
> the colon will never appear on the "left" side of the string (it might
> appear on the "right", but by then, the pattern is already matched). As
> long as I don't use s///g, it'll only match once, and I'll be all right,
> right?
With split, you will want to specify the "limit" argument so you won't
get more than two pieces.
>
> 4) How much do (\w+), (.+), (\s+), (\d+), etc. slow things down? I avoid
> the use of things like (.*) (the code shown above is an exception), but
> what about the + quantifier and the parentheses?
>
...
> --J
Check out:
use Benchmark;
Even if someone had the time and energy to run it for you, the results
might not apply to your data.
--
Bob Walton
------------------------------
Date: Thu, 11 May 2000 20:40:31 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Regular expression ?
Message-Id: <slrn8hmknv.lq2.tadmc@magna.metronet.com>
On Thu, 11 May 2000 14:16:46 -0700, Jeff Zucker <jeff@vpservices.com> wrote:
>tvn007@my-deja.com wrote:
>>
>> sorry, the input file is more complicate so I do not think I can use
>> split.
>>
>> The actual input file would be something like this:
>> abc : 0_0 2.02 A
>> 305 : 0_0 2.01 A
>> 306 : 0_0 1.80 AR
>> 305 : 0_0 2.50 AR
>>
>
>That would work exactly the same as the other with the split. The only
>thing that would break the split would be if there were a different
>number of non-whitespace elements before the one you want to catch.
That's what I though too when I saw it.
But I think the OP is trying to say that he wants to ignore
the first line because it does not start with digit characters,
so he wants a regex to require digits at the start.
Of course, you can _still_ do it with split:
--------------------
#!/usr/bin/perl -w
use strict;
while (<DATA>) {
my @parts = split;
next unless $parts[0] =~ /^\d+/;
# do something with $parts[3] only if line started with digits
print "number: $parts[3]\n";
}
__DATA__
abc : 0_0 2.02 A
305 : 0_0 2.01 A
306 : 0_0 1.80 AR
305 : 0_0 2.50 AR
--------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 11 May 2000 20:55:19 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Regular expression ?
Message-Id: <391B80A7.536BE061@vpservices.com>
Tad McClellan wrote:
>
> On Thu, 11 May 2000 14:16:46 -0700, Jeff Zucker <jeff@vpservices.com> wrote:
> >tvn007@my-deja.com wrote:
> >>
> >> sorry, the input file is more complicate so I do not think I can use
> >> split.
> >>
> >> The actual input file would be something like this:
> >> abc : 0_0 2.02 A
> >> 305 : 0_0 2.01 A
> >> 306 : 0_0 1.80 AR
> >> 305 : 0_0 2.50 AR
> >>
> >
> >That would work exactly the same as the other with the split. The only
> >thing that would break the split would be if there were a different
> >number of non-whitespace elements before the one you want to catch.
>
> That's what I though too when I saw it.
>
> But I think the OP is trying to say that he wants to ignore
> the first line because it does not start with digit characters,
> so he wants a regex to require digits at the start.
I guess my PSI::ESP is on the blink since you and Matt Stoker both
caught that. The lesson for the original poster and others who have
questions for the newsgroup is this: when *you* look at the data you
know what you want to accomplish, but *we* don't. You have to show us
both a small sample of the data (including as many of its possible
formats as possible) *and* you need to tell us what part of the data you
want to extract and what part you want to ignore. The data doesn't
speak for itself.
--
Jeff
------------------------------
Date: Thu, 11 May 2000 20:15:11 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: string and numeric data handling
Message-Id: <slrn8hmj8f.laa.tadmc@magna.metronet.com>
On Thu, 11 May 2000 19:26:25 GMT, nfin8axs@hotmail.com <nfin8axs@hotmail.com> wrote:
>I have a string of numbers that I wish to convert to a numeric
>value.
Why do you think that you need to do that?
In Perl, if you use a string as a number, perl will convert the
string into a number before performing the operation.
If you use a number as a string, perl will convert the number
into a string.
You seldom need to concern yourself with the difference between
numbers and strings, freeing you to work on your real problem
instead of jumping through hoops imposed by the programming
language.
You are wasting your time trying to do something that does
not need to be done.
>Will simple performing a numeric operation on the variable be
>enough? (eg : $data = $data + 0;) or is there a more intelligent method?
Yes that will work.
Yes there is a more intelligen method (just use it as a number,
e.g. $total += $data ).
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 11 May 2000 20:22:17 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Subroutine error stops module ?!
Message-Id: <slrn8hmjlp.laa.tadmc@magna.metronet.com>
On 11 May 2000 19:04:33 GMT, Hans <hans-jan@stack.nl> wrote:
>PS : I know this is not the best code ever made but this is the best I
^^^^^^
> can do at the moment.
^^^^^^
>
>#!/usr/bin/perl
No it isn't.
You can enable warnings.
#!/usr/bin/perl -w
>use strict;
That part is Very Good though!
>open (FLIST, "<list_2.txt") || die "Can't open list_2.txt";
^^^^^
>close (LIST);
^^^^
You would have been warned about that typo if you had enabled warnings.
Take all of the help that you can get.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 12 May 2000 01:42:25 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: unpack c struct
Message-Id: <391B6090.509B10E0@rochester.rr.com>
Eric Chen wrote:
>
> There's an API that returns some value which has the following C struct
> format.
>
> Typedef struct{
> UCHAR unMsgsize;
> UCHAR unErrorcode;
> UCHAR unMsgbody;
> USHORT unHour;
> USHORT unMinute;
> ULONG ulOpen;
> ULONG ulClose;
> }ReturnValue;
>
> How can I parse the return value in perl?
>
> Eric
...
Use "unpack". The exact template strings you will need to use might
depend upon your achitecture and compiler.
--
Bob Walton
------------------------------
Date: 12 May 2000 01:34:36 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: Using Modules Breaks "-w"?
Message-Id: <8ffn3c$lbv$0@216.155.33.118>
In article <morbus-516E0E.06590011052000@news.totalnetnh.net>, Morbus Iff
<morbus@disobey.com> wrote:
| Good day. I was doing some scripting for another fella - a simple little
| ditty that requires FTPing a file into a specific server. No big deal. I
| immediately turned to Net::FTP.
|
| And the script works wonderfully, with one problem. When I use "-w", I
| get various warnings from various sucked in modules that Net::FTP uses.
| Various warnings about {index} being {"index"} and uninitialized values,
| and error in concatenation in Config.pm.
|
| Stuff like that. I remove "-w" and everything works without a hitch. But
| it still bothers me. Why does this happen? Am I to expect this? My
| started lines were:
|
| #!/usr/bin/perl -w
|
| use Net::FTP;
| use strict;
I get similar errors with this simple Net::FTP script I put together
#!perl -w
use strict;
use Net::FTP;
my $ftp = Net::FTP->new("ftp.cdrom.com");
$ftp->login("anonymous", 'nospam@devnull.com') or die ("Could not log in! $!");
print $ftp->pwd() ."\n\n";
$ftp->cwd("/pub/planetquake/planetunreal/nalicity/utctf") or die ("Could not change
directory $!");
print $ftp->pwd()."\n";
# gah! damn server doesn't understand 'binary'
# $ftp->type("binary") or die ("could not change type! $!");
print $ftp->type("I")."\n"; # shows previous type if changed
print $ftp->type()."\n"; # confirm that type was changed
#optionally print a list of files in the directory.
# my @dirlist = $ftp->dir();
# for (@dirlist) {print "$_\n";};
$ftp->get('ctf-gateways.zip') or die ("Could not download File! $!");
print "File download Successful!";
$ftp->quit;
same warnings too about 'index'
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
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 3023
**************************************