[6532] in Perl-Users-Digest
Perl-Users Digest, Issue: 157 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 21 21:07:18 1997
Date: Fri, 21 Mar 97 18:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 21 Mar 1997 Volume: 8 Number: 157
Today's topics:
Another dereferencing bug in 5.003 ? <jhg@austx.tandem.com>
Re: binhex support <eryq@enteract.com>
Re: download search engine for web site ? (Danny Aldham)
Re: Getting data in random order. (Andrew M. Langmead)
Re: Getting data in random order. <tchrist@mox.perl.com>
Re: Help needed with PERL script! (Stefan Piotr Dembowski)
how do i... (Jon Nathan)
Re: Looking backwards through a text file <tchrist@mox.perl.com>
Re: Looking backwards through a text file <mrchristopher@inorbit.com>
Re: Perl and MUDs (Jot Powers)
Re: Perl Compiler for DOS (Clay Irving)
Re: Perl Data Structures Cookbook. Wher did it go? <tchrist@mox.perl.com>
Re: Perl Data Structures Cookbook. Wher did it go? lvirden@cas.org
Re: perl-binaries for aix1.3 <minaret@sprynet.com>
Re: printing Opened File (Clay Irving)
q: c style include command in perl? (Scott Card)
Q: download htm from a perl script? <Wlodzimierz.Kaluza@mch.sni.de>
Questions about the System Command <bromberek@cems.umn.edu>
Re: Recognizing spaces (Abigail)
Re: Reg: tr command (Clay Irving)
Re: Reg: tr command <tchrist@mox.perl.com>
Re: Single character representing all regexp metacharac <tchrist@mox.perl.com>
Re: SybPerl Newbie Questions <mpeppler@mbay.net>
Uninitialized "next" with -w ? <dorman@lee.s3i.com.anti-spam>
Re: Unix and ease of use (WAS: Who makes more ...) <daniel@spidome.net>
Vanishing string terminators and premature end of scrip <mriggsby@sybex.com>
Re: What's a good Perl book? (Joe Brenner)
Re: Who makes more $$ - Windows vs. Unix programmers? (Joel Garry)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 21 Mar 1997 15:45:50 -0600
From: Jim Garrison <jhg@austx.tandem.com>
Subject: Another dereferencing bug in 5.003 ?
Message-Id: <3333018E.6102@austx.tandem.com>
Consider:
$x = [ [ 1,2,3 ] , [ 4,5,6 ] ];
and the following operations (run in the debugger):
DB<20> p $x
ARRAY(0x26ab20)
$x is a reference to an array
DB<21> p $x->[0]
ARRAY(0x26a850)
so is $x->[0]
DB<22> p $x->[0][0]
1
the implicit -> between the two subscripts yields the
'intiutive' result. However...
DB<23> p @$x->[0]
ARRAY(0x26a850)
DB<24> p @{$x->[0]}
123
I would have thought that these two expressions were
equivalent. If this isn't a bug, can someone please
explain exactly what the result of the first (DB<23>)
expression is? It looks syntactically like an array,
but the debugger seems to think it's a scalar reference
to an array. Note also the address returned in lines
<21> and <23>. This seems to indicate that the debugger
thinks $x->[0] and @$x->[0] are the same thing, which
is clearly not the case.
Can someone try this on 5.004 and let me know if you
get the same result? This could be another manifestation
of the "%$xxx" bug I recently found, which appears to
be corrected in 5.004.
--
James Garrison mailto:jhg@mpd.tandem.com
Tandem Computers, Inc
14231 Tandem Blvd, Rm 2346 Phone: (512) 432-8455
Austin, TX 78728-6699 Fax: (512) 432-2118
------------------------------
Date: Fri, 21 Mar 1997 17:13:17 -0600
From: Eryq <eryq@enteract.com>
To: Gottardo Zancani <zak@planet.mi.it>
Subject: Re: binhex support
Message-Id: <3333160D.24F97761@enteract.com>
Assuming I develop a BinHex module (for the MIME-tools package)
as per RFC1741, where should it go? Seems like
Convert::BinHex
would be appropriate, to go along with Convert::UU.
I think can have this ready in a trice, if no-one else is working
on it.
--
___ _ _ _ _ ___ _ Eryq (eryq@enteract.com)
/ _ \| '_| | | |/ _ ' / Hughes STX, NASA/Goddard Space Flight Cntr.
| __/| | | |_| | |_| | http://www.enteract.com/~eryq
\___||_| \__, |\__, |___/\ Visit STREETWISE, Chicago's newspaper by/
|___/ |______/ of the homeless: http://www.streetwise.org
------------------------------
Date: 21 Mar 1997 17:49:53 -0800
From: danny@hendrix.postino.com (Danny Aldham)
Subject: Re: download search engine for web site ?
Message-Id: <5gvds1$94d@hendrix.postino.com>
Nicola Gordon (nicola@uoguelph.ca) wrote:
: Hi, can anyone advise me on this subject...
: I would like to download a search engine to allow users to search my web
: site. Do you know any sites that allow this either for free or for a
: reasonable charge.
: I understand that they are often written in Perl/CGI and that these
: should not be too hard to implement. I hope there is something out there
: that you can suggest...
Take a look at Glimpse. It is in C , not perl, but free for non-commercial
users. Altavista should point you at it.
--
Danny Aldham SCO Ace, MCSE www.postino.com
------------------------------
Date: Fri, 21 Mar 1997 22:55:56 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Getting data in random order.
Message-Id: <E7F118.D86@world.std.com>
Timothy Shell <tshell@mcs.net> writes:
>I want to output a list of records in a random sequence each time the
>program runs. So if I have a data file with 100 records, I'd like to
>pick, say, 20 records at random and display them in no particular order.
One way would be to slurp the entire file into an array, one line per
file, and then pick a random element out of the array.
($chosen_line = $lines[rand $#lines];)
Some people might suggest seeking to a random place in the file,
reading a line and throwing it away, then reading the next
line. Others would argue that this method doesn't qualify as random
because it favors lines after long lines. Decide for yourself if you
mean random to mean "truly or close to statistically random", or
"relatively unknown sequence."
You could put your file in a TIE'd dbm file one line per record and
pull up a random record. (Maybe have the keys be the record number and
the value be the data, use rand to pick which record number, and
retrieve its coresponding value. If your input file changes
infrequently, this might be good, but if the file changes frequently,
then updating the dbm file might be a pain. Also dbm files are
big. (Even the ones that leave holes in the file to save disk space)
--
Andrew Langmead
------------------------------
Date: 22 Mar 1997 01:08:40 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Getting data in random order.
Message-Id: <5gvbeo$26t$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
tshell@mcs.net writes:
:I have been unable to come up with an elegant way to do this, and as
:always, there's this nagging suspicion that I'm overlooking something
:simple.
Like the FAQ?
:I want to output a list of records in a random sequence each time the
:program runs. So if I have a data file with 100 records, I'd like to
:pick, say, 20 records at random and display them in no particular order.
perlfaq4.pod:=head2 Why aren't my random numbers random?
perlfaq4.pod:=head2 How do I shuffle an array randomly?
perlfaq4.pod:=head2 How do I select a random element from an array?
perlfaq5.pod:=head2 How do I randomly update a binary file?
perlfaq5.pod:=head2 How do I select a random line from a file?
See http://www.perl.com/perl/faq/index.html
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Only God can make random selections.
------------------------------
Date: Fri, 21 Mar 1997 22:43:01 GMT
From: stefan@panix.com (Stefan Piotr Dembowski)
Subject: Re: Help needed with PERL script!
Message-Id: <33330e4d.111808962@nike>
On Fri, 21 Mar 1997 20:47:21 GMT, njohnson@enterprise.net (Neil
Johnson) wrote:
>The last problem is how to format the $TotalSizeMb string into
>999,999,999 instead of 999999999. I have found a piece of code that
>does this but I have no idea of where to put it!
>
>The peice of code is:
>
>1 while s/(\d)(\d\d\d)(?!\d)/$1,$2/g;
######################################################################
# This will format a number witha $, commas and a decimal point and no
# The first parm is the number, the second is the decimal place
# if the second is passed a '' it will simply strip the leading zeros
#and otherwise not format it...
sub formatnum {
local $tempstring = $_[0];
local $tempstring1 = '';
#pull out any damm decimal...
local $i;
for ($i=0;$i < length($tempstring);$i++) {
if (substr($tempstring, $i, 1) ne ".") {
$tempstring1 .= substr($tempstring, $i, 1);
}
}
#print "<!-- Tempstring1 = $tempstring1 -->";
$_[0] = $tempstring1;
local($temp);
# print $_[0],$_[1],$_[2], "\n";
local $temp1 = 0;
local $temp2 = 0;
# find the first np leading zero...
while (substr($_[0], $temp1, 1) =~ /0/) {
$temp1++;
}
# if all zero's...
if ($temp1 == length($_[0])) {
return "$_[1]0";
}
local $startofnum = $temp1;
local $endofnum = length($_[0]);
if ((length($_[0]) - $startofnum) <= 3 ){
return
join('', $_[1],substr($_[0], $startofnum ,(length($_[0]) -
$startofnum)));
}
$temp = $_[1];
local $decplace = $_[2];
local $firstcomma = (length($_[0]) - $startofnum) % 3;
for ($temp1 = 1, $temp2 = $startofnum ;
$temp2 <= $endofnum ; $temp1++, $temp2++) {
$temp0 = join('', $temp, substr($_[0], $temp2, 1));
$temp = $temp0;
if ((( (($temp1 - $firstcomma) - ($decplace - 1)) % 3) == 0)
&& ($temp1 < (length($_[0]) - $startofnum))) {
if ($_[2] != '') {
if ($temp1 == ((length($_[0]) - $startofnum) - $decplace)) {
$temp0 = join('', $temp, '.');
} else {
$temp0 = join('', $temp, ',');
}
}
$temp = $temp0;
}
}
return $temp;
}
########################################################################
------------------------------
Date: 21 Mar 1997 22:45:06 GMT
From: jn0729a@cage.cas.american.edu (Jon Nathan)
Subject: how do i...
Message-Id: <5gv31i$l3j$1@paladin.american.edu>
hello
this is what i would like to do:
have an html page with a list of links. when a user clicks one of the
links, it takes him to a template html page with a specific image on it.
this would be so that i don't have to write 50 simple html pages with an
image tag.
sounds like it should be easy, but i'm not sure where to start. how do i
pass a variable to the perl script depending on which link in the html
page is clicked? any help would be much appreciated - email preferable
thanks
Jon Nathan
jn0729a@american.edu
www.csis.american.edu/~jn0729a
------------------------------
Date: 21 Mar 1997 23:45:40 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Looking backwards through a text file
Message-Id: <5gv6j4$qmc$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
mrchristopher@inorbit.com writes:
:How do I go through a text file backwards rather than forwards without
:reading it into an array first ?
You don't. Everything else is too painful. What are you
going to do?
seek to the end
back up a byte
repeat {
read a byte
back up 2 byte
} until start of file
Or maybe you prefer reading say, 1000 bytes at a time, look for
line boundaries, use the part you have and save the part you
don't have the full line for yet, and iterate?
No thanks to both.
:Everything I've seen uses "while"
:going from start to finish.
That's because it's easiest.
foreach $line ( reverse <> ) {
# do something
}
Or
@lines = <>;
while ( $line = pop(@lines) ) {
}
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"The young think they are immortal, and are determined to prove otherwise."
--Larry Wall
------------------------------
Date: Sat, 22 Mar 1997 10:05:46 +0900
From: Christopher Wright <mrchristopher@inorbit.com>
Subject: Re: Looking backwards through a text file
Message-Id: <3333306A.B0D@inorbit.com>
Hmm Thanks people.. I thought I was missing something obvious. All I
really wanted to do was to avoid having to create a huge array that I
was only going to use the end of. I just wanted to go backwards line by
line through a text log file until I found the first instance of a word,
copy that out to another file, and continue line by line until the last
instance of the word. It seemed silly to read the whole log into an
array since the only data I would be interested in 90% of the time was
the last section.
A different question though to solve the problem - can I write the file
"backwards" in the first place ? (ie put the line of log text at the
front of the file rather than at the end ?)
Then I'll shut up and go away till I've learned some more...
Cheers, Christopher
Honza Pazdziora wrote:
>
> Christopher Wright <mrchristopher@inorbit.com> writes:
>
> > Hi Hi
> >
> > Sorry.... I've looked all over in beginner world and can't seem to
> > figure this one out and I'm sure it's pretty simple..
> >
> > How do I go through a text file backwards rather than forwards without
> > reading it into an array first ? Everything I've seen uses "while"
> > going from start to finish.
>
> I am not sure there is any easy way with today's computers. It's just
> so that files have beginnings and ends and you have to read them just
> that way.
>
> Of course, you can always do a "seek and read" from the back but that
> would not be too efficient. Operating systems are good in reading for
> you long buffers of chars, but always in the forward manner. Question
> is what you need it for. You might do a
>
> $wholefile = <>; $reversed = reverse $wholefile;
>
> and have it, if you do not like array. I can't think of other help to
> give you. But I am sure your problem can be well solved by some other
> more classical way.
>
> Hope this helps.
>
> --
> ------------------------------------------------------------------------
> Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
> I can take or leave it if I please
> ------------------------------------------------------------------------
------------------------------
Date: 22 Mar 1997 00:18:33 GMT
From: jot.mar97@tmp.medtronic.com (Jot Powers)
Subject: Re: Perl and MUDs
Message-Id: <5gv8gp$1lo$1@gazette.corp.medtronic.com>
In article <7vg1xpovz0.fsf@speedy.speakeasy.org>, Brett McCormick <brett@speedy.speakeasy.org> writes:
>I am certainly interested, and have been thinking about doing this for
>quite a long time.. I just need the free time to do it. However, if
>there was enough interest, I'm sure a cooperative development effort
>could get going. All interested, let me know and I'll create a
>mailing list (provided enough are interested).
>Wade Holst <wade@cs.ualberta.ca> writes:
>> I was wondering if there are any individuals currently looking into using
>> Perl as the programming language for a new type of Multiple-User-Dimension.
>> I'd be interested in contributing to such a venture.
Don't try to re-invent the wheel. :)
http://www.boutell.com/perlmud/
I haven't run it, but I'm guessing, given the author, that it works well.
--
Jot Powers jot.mar97@tmp.medtronic.com
Unix System Administrator, Medtronic Micro-Rel
"Subtlety is the art of saying what you think and getting out of the way
before it is understood."
------------------------------
Date: 21 Mar 1997 18:44:12 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Perl Compiler for DOS
Message-Id: <5gv6gc$ss1@panix.com>
In <3332CDA2.42F5@ix.netcom.com> Jason Williamson <jaywill@ix.netcom.com> writes:
>Guy Saner wrote:
>>
>> Does anybody have, or know the location of
>> a precompiled version of the Perl Compiler for DOS.
>> By Perl Compiler, I mean the compiler that converts
>> Perl code into C code. I think it's still in it's alpha release.
>>
>> Thanks in advance.
>>
>> Guy
>I know that the Walnut Creek CD release of Perl5 had a DOS perl compiler
>in the perlsrc directory.
So does CPAN in the 'ports' directory.
--
Clay Irving See the happy moron,
clay@panix.com He doesn't give a damn,
http://www.panix.com/~clay I wish I were a moron,
My God! Perhaps I am!
------------------------------
Date: 21 Mar 1997 23:41:38 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl Data Structures Cookbook. Wher did it go?
Message-Id: <5gv6bi$qmc$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Jerome O'Neil <joneil@is.ssd.k12.wa.us> writes:
:The requested URL /perl/nmanual/html/pod/perldsc.html was not found on
:this server.
Try again without the 'n'.
http://www.perl.com/perl/manual/html/pod/perldsc.html
Although both should work.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"Do we define evil as the absence of goodness? It seems only logical
that shit happens--we discover this by the process of elimination."
--Larry Wall
------------------------------
Date: 22 Mar 1997 00:49:47 GMT
From: lvirden@cas.org
Subject: Re: Perl Data Structures Cookbook. Wher did it go?
Message-Id: <5gvabb$i9e@srv13s4.cas.org>
According to Tom Christiansen <tchrist@mox.perl.com>:
:In comp.lang.perl.misc,
: Jerome O'Neil <joneil@is.ssd.k12.wa.us> writes:
::The requested URL /perl/nmanual/html/pod/perldsc.html was not found on
:Try again without the 'n'.
: http://www.perl.com/perl/manual/html/pod/perldsc.html
:Although both should work.
I still get failures regardless of the number of times that I've
tried this all day.
--
Larry W. Virden INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.
------------------------------
Date: 20 Mar 1997 11:39:35 GMT
From: "Geoff Mottram" <minaret@sprynet.com>
Subject: Re: perl-binaries for aix1.3
Message-Id: <01bc3523$227a5020$c4e8aec7@cactus>
On 19 Mar 1997, Jonny Birkelund wrote:
> I'm looking for binaries for aix1.3
The Bull Group has a site with AIX binaries at http://www.bull.de/pub/ that
may be of help.
--
Geoff Mottram
minaret@sprynet.com
------------------------------
Date: 21 Mar 1997 18:21:47 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: printing Opened File
Message-Id: <5gv56b$ost@panix.com>
In <33320fe6.8118784@202.37.101.7> vss@xtra.co.nz (Jeremy Coulter) writes:
>I am using the following code in an attempt to open an HTML file for
>viewing.
>When I run the script from the command line, it works. But what I call
>the script from a Button event, POST, it dosn't siplay anything.
If it runs from the command line, then Perl is working just fine. Therefore,
your problems *must* be something with CGI. Jump over to
comp.infosystems.www.authoring.cgi or check Lesson 1 of
CGI Programming 101
http://www59.metronet.com/dev/class/index.shtml
>Is something wrong with my code ????
No. The code is fine. The CGI part is broken.
Hint: Look for a message I posted to this newsgroup within the last two days.
--
Clay Irving See the happy moron,
clay@panix.com He doesn't give a damn,
http://www.panix.com/~clay I wish I were a moron,
My God! Perhaps I am!
------------------------------
Date: Fri, 21 Mar 1997 21:52:41 GMT
From: ils@pipcom.com (Scott Card)
Subject: q: c style include command in perl?
Message-Id: <333302d3.2334477@news.pipcom.com>
Is there a c++ style include command in perl for including
subroutines?
Thanks.
------------------------------
Date: Fri, 21 Mar 1997 23:47:59 +0000
From: Wlodzimierz Kaluza <Wlodzimierz.Kaluza@mch.sni.de>
Subject: Q: download htm from a perl script?
Message-Id: <33331E2F.5083@mch.sni.de>
Hi,
could somebody tell me how can I download a htm file from remote web
server with a perl script? I'd like to download (automaticaly) more html
pages at night.
Thanks in advance
Wlodek Kaluza
--
Wlodzimierz.Kaluza@mch.sni.de
------------------------------
Date: Fri, 21 Mar 1997 16:53:42 -0600
From: Bruce Bromberek <bromberek@cems.umn.edu>
Subject: Questions about the System Command
Message-Id: <33331176.41C6@cems.umn.edu>
Hello All-
I'm using Perl to write scripts for our image analysis system. I
currently use the system command control external devices like movable
stage and CCD camera. My understanding of how the command works based
on the Using and Learning PERL books. According to those sources
(unfortunatly NOT the second editions) the perl script should wait for
the system command to finish executing before continuing on to the next
line.
My experience has been just the opposite. For example: if the
following two commands are given in a shell
stage -i #initialize stage controller
stage -a 1000 1000 #move to 1000,1000
everything works just fine.
In my perl script
system("stage -i");
system("stage -a $x $y");
leads to an error because the device is still busy from the first
command when the second one is executed. My solution so far has been to
put a sleep command between the two. I would like to avoid this because
1) the time needed varies depending on how far the stage has to move
2) and a sleep value sufficient to work for all cases is too long for
normal use.
Can anyone out there offer advice (perferablely a solution) to this
problem. FYI I'm using perl on a SGI indy under IRIX 5.3.
Thanks in advance
Bruce Bromberek
PS - the the wonderful people who wrote the CGI-BIN perl libraries:
Thank you thank you thank you thank you thank you thank you!!!!
------------------------------
Date: Fri, 21 Mar 1997 21:55:02 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: Recognizing spaces
Message-Id: <E7Ey7q.Mp2@nonexistent.com>
On 21 Mar 1997 16:57:53 GMT, Jeffrey wrote in comp.lang.perl.misc:
++
++ [mail and post and cc to FAQ maintainer (possible inclusion Tom?)]
++
++ Matt Riggsby <mriggsby@sybex.com> wrote:
++ |> ...take the text (which I'm calling $message), strip out any existing
++ |> linefeeds, then parse through the text and put in a \n after every word
++ |> that takes a line over a given number of characters (as the code
++ |> fragment below indicates, I'm trying to end up with lines not much over
++ |> 60 characters long).
++
++ If you're looking for a ``hey, I didn't know I could do that'' method
++ to amaze and impress your friends, you might consider:
++
++ $DesiredWidth=60; # setup
++
++ :
++
++ $start = $DesiredWidth;
++ while ($start < length($message))
++ {
++ substr($message, $start) =~ s/(\S*)\s+/$1\n/;
++ $start += length($1) + $DesiredWidth + 1;
++ }
++
++ Yup, you can apply a substitution to a substr() of a variable and have it
++ ``work'' right.
++
++ However, if you want it simple, understandable, and a lot faster way....
++ The Perl Way... you might try simply:
++
++ $tmp = $DesiredWidth - 1;
++ $message =~ s/\G(.{1,$tmp}\S+)\s+/$1\n/go;
++
++ Basically, the /.{1,$tmp}/ grabs most of what you want, and the \S+ takes
++ you to the 60-column mark (or beyond). However, if the 60-column mark is
++ whitespace, the /.{1,$tmp}/ will backpedal to just before the start of the
++ whitespace. In either case, that's where the line is split -- whitespace is
++ then replaced by a single newline.
++
++ On the other hand, if you want to match up to *but not beyond* the Desired
++ Width, remove a key '+' and you're set:
++
++ $message =~ s/\G(.{1,$tmp}\S)\s+/$1\n/go;
++
++ It might be instructive to really understand, intrinsically, the difference
++ between the two.
Note that the above regex will fail in certain cases. For instance
'\G(.{1,$tmp}\S)\s+' won't match "a verylongword and another" for small $tmp.
Long words will be a problem.
2 days ago, I wrote a subroutine doing what Matt ask (and a few things more):
# Format a string, a bit ala LPC's breakstring, but we ignore newlines.
# Arguments:
# string: string to format.
# length: maximum length of the resulting text.
# width: same as length, just because I'm too lazy to remember.
# indent: length leading whitespace.
# nofirst: don't indent first line if set.
# notrailer: don't put a trailing newline if set.
sub format_string (%) {
my %args = @_;
my $string = $args {string} || "";
my $length = $args {"length"} || $args {width} || 75;
my $mlength = $length - 1;
my $indent = $args {indent} ? " " x $args {indent} : "";
$string =~ s/\n/ /g;
my @chunks = grep {defined;}
($string =~ m/\s+ # Leading white.
|(?:(.{1,$length})\s*$) # End of string.
|(?:(.{0,$mlength}\S)\s+) # Normal case.
|(\S+) # Too big.
/gx);
my $first = $args {nofirst} ? shift @chunks : "";
if (scalar @chunks == 0) {
$first .= "\n" unless $args {notrailer};
return $first;
}
my $line = join "\n", (map {"$indent$_";} @chunks);
$line = "$first\n$line" if $first ne "";
$line .= "\n" unless $args {notrailer};
$line;
}
Abigail
------------------------------
Date: 21 Mar 1997 18:46:16 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Reg: tr command
Message-Id: <5gv6k8$t6d@panix.com>
In <3332DD90.3E5B@eos.ncsu.edu> Zacharia George <zgeorge@eos.ncsu.edu> writes:
> Could someone please tell me how to convert from Uppercase to
>Lowercase in a string EXCEPT for the first letter of each word in the
>string. I assume that the "tr" command (I may be wrong!) can do this but
>I am not sure how.
>e.g.:
>to convert
>ZACHARIA GEORGE to Zacharia George
It's in the Perl FAQ: http://www.perl.com/perl/faq/index.html
--
Clay Irving See the happy moron,
clay@panix.com He doesn't give a damn,
http://www.panix.com/~clay I wish I were a moron,
My God! Perhaps I am!
------------------------------
Date: 22 Mar 1997 01:00:50 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Reg: tr command
Message-Id: <5gvb02$26t$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Zacharia George <zgeorge@eos.ncsu.edu> writes:
: Could someone please tell me how to convert from Uppercase to
:Lowercase in a string EXCEPT for the first letter of each word in the
:string. I assume that the "tr" command (I may be wrong!) can do this but
:I am not sure how.
You deserve to be FAQqed. It's in part4 of the faq
(http://www.perl.com/perl/faq/index.html), and it's been
discussed to death in the last week. Go look it up.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"You can only measure the size of your head from the inside." --Larry Wall
------------------------------
Date: 21 Mar 1997 23:57:19 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Single character representing all regexp metacharacters? wheeere?
Message-Id: <5gv78v$qmc$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
x@apocalypse.org writes:
:Is there a single escaped character which represents all the
:metacharacters recognized by the perl regexp engine?
NAME
perlfaq6 - Regexps ($Revision: 1.14 $)
........
How can I quote a variable to use in a regexp?
The Perl parser will expand $variable and @variable references
in regular expressions unless the delimiter is a single quote.
Remember, too, that the right-hand side of a `s///'
substitution is considered a double-quoted string (see the
perlop manpage for more details). Remember also that any
regexp special characters will be acted on unless you precede
the substitution with \Q. Here's an example:
$string = "to die?";
$lhs = "die?";
$rhs = "sleep no more";
$string =~ s/\Q$lhs/$rhs/;
# $string is now "to sleep no more"
Without the \Q, the regexp would also spuriously match "di".
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
If I had only known, I would have been a locksmith. --Albert Einstein
------------------------------
Date: Thu, 20 Mar 1997 16:59:32 -0800
From: Michael Peppler <mpeppler@mbay.net>
To: Scott Cairns <74602.3516@CompuServe.COM>
Subject: Re: SybPerl Newbie Questions
Message-Id: <3331DD74.E9@mbay.net>
Scott Cairns wrote:
>
> I have written a few prototype perl scripts using the sybperl
> package. One of the scripts reads the list of non-system
> databases from master..sysdatabases and issues a dump command.
>
> The first dump fires off fine but the next ones die with the
> infamous "attempt to start new operation with results pending".
> I've seen simalar behavior/problems with other calls to the
> sybperl implementation of dbresults(). It doesn't seem to block
> on operations like dump or load. It's almost like it forks off
> the operation and then comes back to the caller immediately.
Do you loop on dbresults() until it returns NO_MORE_RESULTS?
Michael
--
Michael Peppler, Data Migrations Inc.
mpeppler@mbay.net or mpeppler@bix.com
------------------------------
Date: 21 Mar 1997 19:27:46 -0500
From: Clark Dorman <dorman@lee.s3i.com.anti-spam>
Subject: Uninitialized "next" with -w ?
Message-Id: <dpvws4vp9.fsf@s3i.com>
I'm rather confused about what -w is complaining about in the following
code:
----------------------------------------------------------------------
#!/home/dorman/bin/perl -w
$clean_up = 0;
while ( $ARGV[0] =~ /^-/ ) {
$_ = shift ;
if ( /-c.*/ ) {
$clean_up++;
next;
}
}
&clean_up_sub if $clean_up;
----------------------------------------------------------------------
When I run this, it says:
blackbird:testdir (7:21pm) 91% h.pl -c
Use of uninitialized value at h.pl line 9.
blackbird:testdir (7:21pm) 92%
i.e., it doesn't like the "next". What value is uninitialized?
Is the above an acceptable way to do this, or what is the recommended
way to parse the command options to the perl program if not?
Clark
------------------------------
Date: Fri, 21 Mar 1997 15:46:04 -0600
From: Dan Odom <daniel@spidome.net>
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <3333019C.794BDF32@spidome.net>
Stephane Plattner wrote:
>
> mwolfe@shrike.depaul.edu wrote:
> >
> > In the end Linux will bury MS. Linux is open. This means open
> > competition. This means better products. LINUX RULES.
> >
>
> IMHO this answer contradicts to the basics of economics. Openess means
> to a great extent equality and equality prohibits competition.
> (communism). Competition rises only when differences exists and it's
> the market (or the environment), who dictates which product is better.
Uh, well, hmmm.... Microsloth will always rule the desktop market. This
is just a sad truth. Unix systems at large (not just Linux) do tend to
be more stable than MS operating systems and it is MUCH easier to
develop software for Unix. Corporate America, on the other hand,
doesn't even know what an operating system is, much less the difference
between Unix and NT. How many times have you said "What version of
Windows do you run?" to a PC user and heard the response, "I don't run
Windows, just Wordperfect and Excel?" I've heard technical support
people make statements similar to that ...
Unix is a better system for industrial strength applications -- I would
never willingly run a high-traffic web server, for example, under NT.
The quality of the system, however, is not what matters. What matters
is that corporate purchasers get Microsoft products for free (they come
with virtually all computers, which is the same thing), Windows users
are CHEAP (often minimum wage), and virtually every piece of software
that large organizations want to run is for Windows. Sure, writing a C
program is tougher in Windows than in Unix (what the hell does
"lpfnmapir" mean, for example), but Unix doesn't have anything like
Visual Basic or PowerBuilder, and those are what most people use. I
just left a job running an NT-based web site for a fortune 500
corporation, and out of 9,000 employees on four continents, they
employed two C programmers. Every bit of software we made was developed
with Visual Basic.
As far as competition goes, Steph is correct -- Linux represents the
opposite of the free market. Microsloth is the epitome of the free
market. Free operating systems (I run FreeBSD) don't advertise and
require expert users to make them work. Microsoft products are seen on
prime time TV and used in every public school, office, hospital,
library, government agency, etc., etc., in America. Which product
succeeds is NOT a matter of which one is better, it is a matter of which
one has better marketing, immediately followed by which one is less
expensive. Unix systems, even "free" ones, are far more expensive in
terms of labor than NT systems -- NT sysadmins can be had for $9.00 per
hour around here and are grateful for the good pay, while Unix people
tend to feel gipped at $25.00 per hour. This isn't a technology center
with NT gurus on every corner, either -- it's a town of 16,000 in rural
Kansas.
When stability is important (usually it isn't -- who cares if your
secretary's machine GPFs twice a day?) I will always choose Unix, but
when money is the only thing that is important, when hours are measured
in dollars rather than minutes, I'm afraid Microsloth wins hands-down.
Windows NT is Barton's gin ($5.00/bottle) and Unix is Isle of Jura
single malt scotch ($60.00/bottle). Sure, the scotch tastes better, but
which one is more popular?
--
Daniel Odom
System administrator (sometimes) and web guy (the rest of the time)
daniel@thelonious.spidome.net
http://www.spidome.net/daniel/
finger me for a PGP key
------------------------------
Date: Fri, 21 Mar 1997 15:07:02 -0800
From: Matt Riggsby <mriggsby@sybex.com>
Subject: Vanishing string terminators and premature end of script headers
Message-Id: <33331496.1CA@sybex.com>
Well, I'm fresh out of ideas on this one. I have a perl script that is
supposed to generate an HTML page. But, of course, it doesn't.
Checking my error logs, I see two error messages. First:
Can't find string terminator "NXRheader" anywhere before EOF at
(arglebargle including line number).
Needless to say, I've checked and I can find the header myself. The
problematic code goes something like this:
print <<'NXRheader';
<HTML>
<HEAD>
<TITLE>This space for rent</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff" BACKGROUND="/graphics/nxBar.gif">
(more html stuff)
NXRheader
That second instance of "NXRheader" is, so far as I can tell, alone on
the line without extraneous spaces, tabs, or other invisible characters,
so I can't understand why it isn't working.
The second error is:
access to (the script) failed for (me), reason: Premature end of script
headers
Checking the obvious, I have confirmed, so far as I can tell, that
#!/usr/bin/perl
is the correct first line (that's what my other scripts say at the
moment, and they all work), and I have correctly punctuated the next
line:
print "Content-type: text/html\n\n";
I've also confirmed that I gave my script proper permission to run
(chmod 755). Any clues? If it matters, I'm working with a Unix system
running an Apache server.
------------------------------
Date: 21 Mar 1997 16:34:08 -0800
From: doom@kzsu.Stanford.EDU (Joe Brenner)
Subject: Re: What's a good Perl book?
Message-Id: <5gv9e0$mu4@kzsu.Stanford.EDU>
Randal Schwartz <merlyn@stonehenge.com> writes:
>>>>>> "slacker" == slacker <slacker@dixonillinois.com> writes:
>slacker> Then the llamma book although the first chapter is a doosy until you
>slacker> figure out what it's referring to in the later chapters.
>Good. That means you read it right, and that chapter wasn't meant for
>*you* until later.
>Some people want concepts first, some people want structure first,
>some people want examples first. The second half of chapter one is
>for people that want examples first. If you're not that way, then
>it'll seem odd to you.
If you're interested, my reaction to the first chapter was
something like "Gee, this example he's working with is so
artificial. Wouldn't it be better if he could show how to
write something in Perl that's actually useful?"
------------------------------
Date: Fri, 21 Mar 1997 23:48:46 GMT
From: joelga@rossinc.com (Joel Garry)
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <1997Mar21.234846.25411@rossinc.com>
In article <5gk5o6$pus$1@news.nyu.edu> rw26@acf2.nyu.edu (Randy Wright) writes:
>Mark Lehrer (edge@mud.imperium.net) wrote:
>: futureprog@bridge.net.NOSPAM.PLEASE (Future Programmer) writes:
>: In general, I'd say that Windows work is easier to find because more
>: companies use it, but there are also more people with Windows skills
>: so you won't necessarily make as much. A good Unix programmer can
>: make a killing, but the work is harder to find...
>:
>
>In NYC it is not difficult to find either Unix work or Windows
>work.. or work on any other platform for that matter. You should
>be able to do what you want and make enough to pay Manhatten rent.
I've had more work than I could want this whole decade. The only problems
I've had have come when I don't want to be more than bike riding distance
from my house, and I live in the boonies. Of course, I do databases on
unix rather than being a "unix programmer."
>
>
>
> Randy Wright rw26@acf2.nyu.edu
> Distributed Computing and Information Services Group
> New York University
> Rm. 301 - 251 Mercer St.
> New York, New York 10012
>
--
Joel Garry joelga@rossinc.com Compuserve 70661,1534
These are my opinions, not necessarily those of Ross Systems, Inc. <> <>
%DCL-W-SOFTONEDGEDONTPUSH, Software On Edge - Don't Push. \ V /
panic: ifree: freeing free inodes... O
------------------------------
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 157
*************************************