[12177] in Perl-Users-Digest
Perl-Users Digest, Issue: 5778 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 25 16:07:23 1999
Date: Tue, 25 May 99 13:01:29 -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 Tue, 25 May 1999 Volume: 8 Number: 5778
Today's topics:
Perl, GUI and VAX VMS msutfin@my-dejanews.com
Perl5 Script OS Sol2.6: Using cgi-bin/html/sccs <clandon@fallschurch.esys.com>
Please, oo types, help with this! (Re: ooPerl is harde <kensai@nortel.com>
Re: Problems with a guestbook entry script <tim.shapcott@NOSPAMvirgin.net>
Re: removings " "s from strings <cassell@mail.cor.epa.gov>
Re: removings " "s from strings (Larry Rosler)
Re: removings " "s from strings <emschwar@rmi.net>
Re: removings " "s from strings (Larry Rosler)
Re: req: directional help <cassell@mail.cor.epa.gov>
Re: Return of array <jdporter@min.net>
Sorting Problem <ranson@rlaj.com>
Re: Sorting Problem (Greg Bacon)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 25 May 1999 18:28:45 GMT
From: msutfin@my-dejanews.com
To: pgravelle@affinitygroup.com
Subject: Perl, GUI and VAX VMS
Message-Id: <7ieq4o$89b$1@nnrp1.deja.com>
Can I use PERL for GUI development from Open VMS 3GL programs? I'd like
to execute PERL to display GUI's from VAX BASIC,C and send and receive
data to and from the GUI forms and the 3GL programs. Any input to this
will be much helpful.
Thanks in advance
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 25 May 1999 15:10:58 -0400
From: Cindy Landon <clandon@fallschurch.esys.com>
Subject: Perl5 Script OS Sol2.6: Using cgi-bin/html/sccs
Message-Id: <374AF5BE.8D86DB74@fallschurch.esys.com>
> Hi,
>
> I'm writing in hopes that you might have some insight with
> a Perl5 script using sccs and html which we've ported
from
> Irix 6.2 OS
> to Sol2.6.
>
>
>
> Seem to be having problems with sccs specifically the
> delget's.
> I'm not an expert by any means of incorporating html w/
> Perl5
> but have used Perl for about 5 years. So, my thoughts are
> that it could be something html wise that i'm missing or
> sccs from irix and sol2.6.
>
> Here is a sample of my code any thoughts would be
> appreciated!
> Aplogize if i sent TO much of the code. Just let me know.
>
> Thanks, Cindy
<HTML><HEAD>
<TITLE>System Integration Trouble Report
Acknowledgement</TITLE>
</HEAD><BODY>
<H3>System Integration Trouble Report Comment Reply</H3>
<HR>
Thank you <B>$in{'name'}</B> your comments have been added
to $file<P>
ProcessFormEnd1
$thisday = (Sun,Mon,Tue,Wed,Thu,Fri,Sat) [(localtime)[6]];
$Month =
(Jan,Feb,Mar,Apr,May,June,July,Aug,Sept,Oct,Nov,Dec)
[(localtime)[4]];
$Day = (localtime)[3];
$Year = (localtime)[5];
$Hour = (localtime)[2];
$Minute = (localtime)[1];
if ($in{'new_status'} eq $in{'old_status'}) {
$result=`cd $directory; /usr/bin/sccs edit $file`;
print "Retrieving original file: ",$result,"\n<BR>";
open(APPEND_FILE,">>$file");
print APPEND_FILE "Name: ",$in{'name'},"\t";
print APPEND_FILE $Month," ",$Day,", 19",$Year,"
",$Hour,":",$Minute,"\n";
print APPEND_FILE "\n";
print APPEND_FILE $in{'comment'},"\n";
print APPEND_FILE
"--------------------------------------------------\n";
close APPEND_FILE;
$result=`cd $directory; /usr/bin/sccs delget $file -yNO`;
print "Version: ",$result,"\n";
}
else {
$result=`cd $directory; /usr/bin/sccs edit $file`;
print "<BR>Retrieving old file: ",$result,"\n<P>";
open(ORIG_FILE,"<$file");
open(TMP_FILE,">/tmp/$strs_file");
$updated="";
while (<ORIG_FILE>) {
if (/Status: $in{'old_status'}/ && $updated eq "") {
$updated="yes";
$_ =~ s/Status: $in{'old_status'}/Status:
$in{'new_status'}/;
}
print TMP_FILE $_;
}
close (ORIG_FILE);
print TMP_FILE "Name: ",$in{'name'},"\t";
print TMP_FILE $Month," ",$Day,", 19",$Year,"
",$Hour,":",$Minute,"\n";
print TMP_FILE "\n";
print TMP_FILE $in{'comment'},"\n";
print TMP_FILE
"--------------------------------------------------\n";
close (TMP_FILE);
system("cd $directory; cp /tmp/$strs_file $file");
system("rm /tmp/$strs_file");
$result=`cd $directory; /usr/bin/sccs delget $file -yNO`;
print "Status has now been change to
<B>$in{'new_status'}</B><P>\n";
print "Version: ",$result, "\n";
}
print "</BODY></HTML>\n";
}
sub PrintChangeForm {
$query = $in{'file'};
if ($query ne "") {
$strs_file = $query;
$file=$directory.$strs_file;
}
print <<PrintFormEnd3;
<HTML><HEAD><TITLE>System Integration Trouble Report Change
Header Information</TITLE></HEAD>
<BODY>
<H2>System Integration Trouble Report Change Header
Information</H2>
file: $strs_file
<HR>
PrintFormEnd3
open (FOO,"$file");
$status = "";
#initialize values
$title = "";
$status = "";
$version = "";
$resp = "";
$priority = "";
$program = "";
$category = "";
$location = "";
$effort = "";
$description = "";
$amplify = "";
$state=0;
#search through file for keywords
while (<FOO>) {
if (/Title: (.*)/ && $title eq "" ) {
$title = $1;
}
if (/Status:(\s)*(\w+)/ && $status eq "") {
$status = $2;
}
if (/Number: (.*)/ && $version eq "") {
$version = $1;
}
if (/Responsible: (.*)/ && $resp eq "") {
$resp = $1;
}
if (/Priority:(\s)*(.*)/ && $priority eq "") {
$priority = $2;
}
if (/Location:(\s)*(\w+)/ && $location eq "") {
$location = $2;
}
if (/Effort:(\s)*(\w+)/ && $effort eq "") {
$effort = $2;
}
if (/Program:(\s)*(.*)/ && $program eq "") {
$program = $2;
}
if (/Category:(\s)*(.*)/ && $category eq "") {
$category = $2;
}
if (/Description:/ && $state==0 ) {$state=1;}
if (/Amplifying Information:/ && $state==1)
{$state=2;}
if (/---------------------------/ && $state==2)
{$state=3;}
if ($state==1) {
$description=$description.$_;
}
if ($state==2) {
$amplify=$amplify.$_;
}
}
close (FOO);
# print <<PrintFormEnd4;
print "<FORM method=\"POST\" ACTION=\"";
print $http_process;
print "\">";
print "<P>";
print "Title:\n";
print "<INPUT TYPE=TEXT NAME=\"title\" MAXLENGTH=65
SIZE=65 VALUE=\"";
print $title;
print "\">\n<p>\n";
print "Version Number:\n";
print "<INPUT TYPE=TEXT NAME=\"version\" MAXLENGTH=52
SIZE=52 VALUE=\"";
print $version;
print "\">\n<p>\n";
print "Responsible:\n";
print "<INPUT TYPE=TEXT NAME=\"responsible\" MAXLENGTH=59
SIZE=59 VALUE=\"";
print $resp;
print "\">\n<p>\n";
print "Priority:\n";
print "<SELECT NAME=\"priority\">\n";
print "<OPTION ";
if ($priority eq 1) {
print "SELECTED ";
}
print " VALUE=\"1\">1\n";
print "<OPTION ";
if ($priority eq 2) {
print "SELECTED ";
}
print " VALUE=\"2\">2\n";
print "<OPTION ";
if ($priority eq 3) {
print "SELECTED ";
}
print " VALUE=\"3\">3\n";
print "<OPTION ";
if ($priority eq 4) {
print "SELECTED ";
}
print " VALUE=\"4\">4\n";
print "<OPTION ";
if ($priority eq 5) {
print "SELECTED ";
}
print " VALUE=\"5\">5\n";
print "</SELECT>\n";
print "Category:\n";
print "<SELECT name=\"program\">\n";
print "<OPTION ";
if ($program eq "EDU1") {
print "SELECTED ";
}
print " VALUE=\"EDU1\">EDU1\n";
print "<OPTION ";
if ($program eq "EDU_All") {
print "SELECTED ";
}
print " VALUE=\"EDU_All\">EDU_All\n";
print "<OPTION ";
if ($program eq "Other") {
print "SELECTED ";
}
print " VALUE=\"Other\">Other\n";
print "</SELECT>\n";
print "Category:\n";
print "<SELECT name=\"category\">\n";
print "<OPTION ";
if ($category eq "HW") {
print "SELECTED ";
}
print " VALUE=\"HW\">Hardware\n";
print "<OPTION ";
if ($category eq "SW") {
print "SELECTED ";
}
print " VALUE=\"SW\">Software\n";
print "<OPTION ";
if ($category eq "Undet") {
print "SELECTED ";
}
print " VALUE=\"Undet\">Undet\n";
print "</SELECT>\n";
print "Location:\n";
print "<SELECT NAME=\"location\">\n";
print "<OPTION ";
if ($location eq "RSC_FC") {
print "SELECTED ";
}
print " VALUE=\"RSC_FC\">RSC_FC\n";
print "<OPTION ";
if ($location eq "Other") {
print "SELECTED ";
}
print " VALUE=\"Other\">Other\n";
print "Estimated Effort:\n";
print "<SELECT NAME=\"effort\">\n";
print "<OPTION ";
if ($effort eq "TBD") {
print "SELECTED ";
}
print " VALUE=\"TBD\">tbd\n";
print "<OPTION ";
if ($effort eq "LOW") {
print "SELECTED ";
}
print " VALUE=\"LOW\">Low\n";
print "<OPTION ";
if ($location eq "MED") {
print "SELECTED ";
}
print " VALUE=\"MED\">Medium\n";
print "<OPTION ";
if ($location eq "HIGH") {
print "SELECTED ";
}
print " VALUE=\"HIGH\">High\n";
print "<p><TEXTAREA NAME=\"description\" ROWS=\"10\"
COLS=\"80\">";
print $description;
print "</TEXTAREA>";
print "<p><TEXTAREA NAME=\"amplify\" ROWS=\"10\"
COLS=\"80\">";
print $amplify;
print "</TEXTAREA>";
# PrintFormEnd4
print <<PrintFormEnd5;
<P>
<BR>
<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Submit
Change\">
<INPUT TYPE=\"reset\" NAME=\"reset\" VALUE=\"Reset Form\">
<INPUT TYPE=\"hidden\" NAME=\"step\" VALUE=\"change\">
<INPUT TYPE=\"hidden\" NAME=\"done\" VALUE=\"done\">
<INPUT TYPE=\"hidden\" NAME=\"file_name\"
VALUE=\"$strs_file\">
</FORM>
</BODY></HTML>
PrintFormEnd5
}
sub ProcessChangeForm {
$directory = "/src/Library/TCS_STR/";
$strs_file = $in{'file_name'};
$file = $directory.$strs_file;
print <<ProcessFormEnd1;
<HTML><HEAD>
<TITLE>System Issue Report Acknowledgement</TITLE>
</HEAD><BODY>
<H3>System Issue Report Comment Reply</H3>
<HR>
Thank you <B>$in{'name'}</B> your changes have been added
$file<P>
ProcessFormEnd1
$thisday = (Sun,Mon,Tue,Wed,Thu,Fri,Sat) [(localtime)[6]];
$Month =
(Jan,Feb,Mar,Apr,May,June,July,Aug,Sept,Oct,Nov,Dec)
[(localtime)[4]];
$Day = (localtime)[3];
$Year = (localtime)[5];
$Hour = (localtime)[2];
$Minute = (localtime)[1];
$result=`cd $directory; /usr/bin/sccs edit $file`;
print "Retrieving old file: ",$result,"\n<BR>";
open(ORIG_FILE,"<$file");
open(TMP_FILE,">/tmp/$strs_file");
$updated="";
$state=0;
while (<ORIG_FILE>) {
if (/Title: (.*)/ && $in{'title'} ne "") {
$_ =~ s/Title: $1/Title: $in{'title'}/;
$in{'title'}="";
}
if (/Version Number: (.*)/ && $in{'version'} ne "") {
$_ =~ s/Version Number: $1/Version Number:
$in{'version'}/;
$in{'version'}="";
}
if (/Priority: (.*)/ && $in{'priority'} ne "") {
$_ =~ s/Priority: $1/Priority: $in{'priority'}/;
$in{'priority'}="";
}
if (/Affected Program: (.*)/ && $in{'program'} ne "") {
$_ =~ s/Affected Program: $1/Affected Program:
$in{'program'}/;
$in{'program'}="";
}
if (/Category: (.*)/ && $in{'category'} ne "") {
$_ =~ s/Category: $1/Category: $in{'category'}/;
$in{'category'}="";
}
if (/Location: (.*)/ && $in{'location'} ne "") {
$_ =~ s/Location: $1/Location: $in{'location'}/;
$in{'location'}="";
}
if (/Estimated Effort: (.*)/ && $in{'effort'} ne "") {
$_ =~ s/Estimated Effort: $1/Estimated Effort:
$in{'effort'}/;
$in{'effort'}="";
}
if (/Responsible: (.*)/ && $in{'responsible'} ne "") {
$_ =~ s/Responsible: $1/Responsible:
$in{'responsible'}/;
$in{'resp'}="";
}
if (/Description:/ && $state==0 ) {$state=1;}
if (/---------------------------/ && $state==3)
{$state=4;}
if ($state==1) {
print TMP_FILE $in{'description'};
$state = 2;
}
if ($state==2) {
print TMP_FILE $in{'amplify'};
$state = 3;
}
if ($state==0 || $state==4) { print TMP_FILE $_; }
}
close (ORIG_FILE);
close (TMP_FILE);
system("cd $directory; cp /tmp/$strs_file $file");
system("rm /tmp/$strs_file");
$result=`cd $directory; /usr/bin/sccs delget $file -yNO`;
print "Version: ",$result,"\n<P>";
print "Header Information has now been changed<P>\n";
print "</BODY></HTML>\n";
}
--
Cynthia A. Landon : Sr SW Systems Engineer
RAYTHEON Systems
clandon@fallschurch.esys.com : (703) 560-5000 x4526
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My opinions, only mine, so ya can't have 'em i tell ya!
------------------------------
Date: Tue, 25 May 1999 13:57:15 -0400
From: digital kensai <kensai@nortel.com>
To: kensai@bellsouth.net
Subject: Please, oo types, help with this! (Re: ooPerl is harder than it looks)
Message-Id: <374AE47B.9A82B0D8@nortel.com>
Well, I've got my class working now. I'd like to get some help planning
what I need my class to do.
Right now, I've a structure kind of like this; a board, floating in space,
with a set of pieces, floating in space, with a set of piece references,
again, off in la-la land.
What I want is a board, with a registry whose elements are the (blessed)
pieces (even though the main package 'makes' each piece seperately).
Oh, and I've heard from a couple of kind souls that I should use the
A* algorithm to solve the puzzle, and save myself the trouble of all these
objects... probably true. I *think* there is a simple solution that
brings the complexity of sliding puzzles from n**! down near the more
managable n**. The trade off is that it does not find the shortest path.
Here's v0.1 of Sboard.pm:
package Sboard;
#The class needs to work like this:
#
# $board = Sboard->new($rows, $columns);
# $piece = $board->new($prow, $pcolumn, $piecenum);
# #where the destination row for $piece is $piecenum/($rows*$columns)
# #& the destination column for $piece is $piecenuum%($rows*$columns),
#
# ($irow, $icolumn) = $piece->ideals;
#
# if($irow < $row){ # MOVE UP ... assume for this example, this is true
# $piece->move($piece->row-1, $piece->column); #STILL NOT IMPLIMENTED
# }
#
# #now later in the code I need to know what piecenum is in position
# #$row-1, $column...
# $piece_inquestion = $board->whosat($row-1, $column); # should return
$piece
sub new{
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = { "row" => shift, "column" => shift };
bless $self, $class;
(@_)? $self->_configurePiece(@_): $self->_configureBoard;
return $self;
}
sub _configureBoard{
my $self = shift;
Sboard->_rowsByColumns($self->row * $self->column);
Sboard->_rows($self->row);
Sboard->_columns($self->column);
}
sub _rowsByColumns{
shift;
$Sboard::_rowsByColumns = shift if (@_);
return $Sboard::rowsByColumns;
}
sub _rows{
shift;
$Sboard::_rows = shift if (@_);
return $Sboard::rows;
}
sub _columns{
shift;
$Sboard::_columns = shift if (@_);
return $Sboard::columns;
}
sub _configurePiece{
my $self = shift;
my ($row, $column, $piecenum) = ($self->row, $self->column, shift);
my $columns = $Sboard::_columns;
Sboard->_register($row, $column, $piecenum);
$self->irow(int($piecenum/$columns));
$self->icolumn($piecenum%$columns);
$self->num($piecenum);
}
# this function's job is to keep track of which piecenum resides on which
#row/column intersection
sub _register{
my $ref = shift;
my ($row, $column, $piecenum) = @_;
my $member;
$member = &Sboard::_board($row, $column);
$member->piece($piecenum) if(defined($piecenum));
return $member->piece;
}
sub _board{
my ($it, $row, $column) = @_;
if(!$column){
$column = $row;
$row = $it;
}
my $id = $row ."x". $column;
if($Sboard::{$id}){
return $Sboard::{$id};
}else{
$Sboard::{$id} = {};
return bless $Sboard::{$id};
}}
sub piece{
my $self = shift;
$self->{"piece"} = shift if (@_);
return $self->{"piece"};
}
sub pieceNameAt{
my $self = shift;
return %{Sboard->_board(shift, shift)}->{'piece'};
}
sub num{
my $self = shift;
$self->{"num"} = shift if (@_);
return $self->{"num"};
}
sub pos{
my $self = shift;
return $self->row, $self->column;
}
sub ideals{
my $self = shift;
return $self->irow, $self->icolumn;
}
sub row{
my $self = shift;
$self->{"row"} = shift if(@_);
return $self->{"row"};
}
sub column{
my $self = shift;
$self->{"column"} = shift if(@_);
return $self->{"column"};
}
sub irow{
my $self = shift;
$self->{"irow"} = shift if(@_);
return $self->{"irow"};
}
sub icolumn{
my $self = shift;
$self->{"icolumn"} = shift if(@_);
return $self->{"icolumn"};
}
1;
------------------------------
Date: Tue, 25 May 1999 19:53:26 +0100
From: "Tim Shapcott" <tim.shapcott@NOSPAMvirgin.net>
Subject: Re: Problems with a guestbook entry script
Message-Id: <7ierm0$j3r$1@nclient5-gui.server.virgin.net>
I am sorry for not acknowledging the reply. The reason for this was that
Outlook Express (I know it's crap) was pissing about and wouldn't download
new headers. I have sorted this out now. I did however recieve a reply via
email, which was what I was referrring to in the post.
I have now however got the script running, partly due to your post which I
finally managed to get hold of, so thanks.
Tim
Jonathan Stowe wrote in message <374acc59@newsread3.dircon.co.uk>...
>Tim Shapcott <tim.shapcott@virgin.net> wrote:
>> Hi
>>
>> I am treading very carefully here, because i tried to ask the same
question
>> a few days ago, but made the mistake of posting the script as an
attachment.
>> I hope i haven't offended anyone so much that they won't help me!
>>
>
>Yes and I also posted an answer which would allow you to fix it. Why
>are you unable to read the useful diagnostic messages yourself. Trying
>to debug a program solely in a CGI environment is a complete waste of time
>- download a copy of Perl before you go any further so you can at least
>run perl -c on the programs before you upload them.
>
>
>/J\
>--
>Jonathan Stowe <jns@gellyfish.com>
>
------------------------------
Date: Tue, 25 May 1999 11:28:28 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Daniel Vesma <daniel.vesma@thewebtree.com>
Subject: Re: removings " "s from strings
Message-Id: <374AEBCC.97D4F43B@mail.cor.epa.gov>
Daniel Vesma wrote:
>
> >Then you don't have Perl. Please install Perl and consult
> >its documentation.
>
> Yes I do. Running under win98.
Then you should have all the FAQ and much more at your
fingertips. ActiveState Perl comes with the program
perldoc, which will help you search the FAQ for your
questions. And it comes with a complete HTML tree, which
it puts on your Start menu for handy access. If you
still have trouble accessing these, you may want to
check out this URL:
http://www.perlmonth.com/articles//rtfm.html
which will tell you how to get more use out of the docs
on your machine. It's a lot faster than trying to get to
some distant URL every time you want to look at something.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 25 May 1999 10:00:00 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: removings " "s from strings
Message-Id: <MPG.11b476eb94e52591989aec@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <MPG.11b4c2d86f16d62a989702@news.surfnet.nl> on Tue, 25 May
1999 15:24:00 +0200, Real <real@earthling.net> says...
> Daniel Vesma wrote;
> # How can I remove spaces from the start and ends of strings, I have two
> # variables, $preOR and $postOR. Either may have spaces at the beginning or
> # the ends. I need to find some code that looks for the spaces and deletes
> # them if they are there.
>
> This will remove any leading of trailing spaces from $line :
> $line =~ s/^ *| *$//g;
>
> # Any ideas? Please? Help. I'm going nuts.
>
> If I'm not mistaken, this is in the FAQ. To prevent any more braindamage,
> I suggest you to keep it within reach :)
You are not mistaken. It is in the FAQ, and that is where you should
have looked yourself before posting the code you did. If you don't
understand why, perhaps this simple benchmark will help you. (The FAQ
uses "\s" instead of " ", which is more general but doesn't affect the
speed.)
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
my ($s0, $s1) = (' foobar ', 'foobar');
timethese(1 << (shift || 0), {
Cntrl => sub { $_ = $s0 },
FAQ0 => sub { $_ = $s0; s/^ +//; s/ +$// },
FAQ1 => sub { $_ = $s1; s/^ +//; s/ +$// },
Real0 => sub { $_ = $s0; s/^ *| *$//g },
Real1 => sub { $_ = $s1; s/^ *| *$//g },
Real2 => sub { $_ = $s0; s/^ +| +$//g },
Real3 => sub { $_ = $s1; s/^ +| +$//g },
});
Benchmark: timing 262144 iterations of Cntrl, FAQ0, FAQ1, Real0, Real1,
Real2, Real3...
Cntrl: 3 wallclock secs ( 3.20 usr + 0.00 sys = 3.20 CPU)
FAQ0: 7 wallclock secs ( 8.11 usr + 0.00 sys = 8.11 CPU)
FAQ1: 4 wallclock secs ( 4.30 usr + 0.00 sys = 4.30 CPU)
Real0: 11 wallclock secs (11.91 usr + 0.00 sys = 11.91 CPU)
Real1: 11 wallclock secs (11.17 usr + 0.00 sys = 11.17 CPU)
Real2: 10 wallclock secs (10.11 usr + 0.00 sys = 10.11 CPU)
Real3: 9 wallclock secs ( 7.58 usr + 0.00 sys = 7.58 CPU)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 25 May 1999 11:24:30 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: removings " "s from strings
Message-Id: <xkf7lpxgj01.fsf@valdemar.col.hp.com>
"Daniel Vesma" <daniel.vesma@thewebtree.com> writes:
> > somebody whose name he didn't bother to attribute said:
> > The Perl Frequently Asked Questions (FAQ) are *included* with
> > the perl distribution.
>
> Ahh, I don't seem to have them.
Then your distribution is broken. Find your administrator, and beat them
roundly about the head and shoulders until they agree to fix their broken
installation.
Not only is it faster than going to the web every time, but you also get
useful search features with perldoc.
-=Eric
------------------------------
Date: Tue, 25 May 1999 11:08:57 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: removings " "s from strings
Message-Id: <MPG.11b48714748d7403989aee@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <374acfab@cs.colorado.edu> on 25 May 1999 10:28:27 -0700, Tom
Christiansen <tchrist@mox.perl.com> says...
> In comp.lang.perl.misc, Alain Walrant <awalrant@softhome.net> writes:
> :$preOR =~ s/^[ ]*//g ;
> :$preOR =~ s/[ ]*$//g;
>
> Those brackets are wrong, and you mean + not *. Please check
> the answer in perlop or perlfaq4.
'Those brackets are wrong' is an esthetic judgment, as they don't affect
the semantics in this case. For that matter, neither do '+' vs '*' in
this case. To the same degree, the '/g' modifiers (which you didn't
mention) are 'wrong' in this case.
What's right:
1. The code, which *does* work as presented. TMTOWTDI, including ugly
and inefficient Ways.
2. The use of two regexes, rather than one bundled uglier regex.
3. Your suggestion that the answer should come from the FAQ!
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 25 May 1999 11:23:28 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: req: directional help
Message-Id: <374AEAA0.E156A89E@mail.cor.epa.gov>
Bastiaan S van den Berg wrote:
>
> hi!
>
> i'm a young internet enthousiast that is starting to look at perl for easy
> to maintain , template driven , database-like approaches to normal webpages
Good choice. But you'll probably need to learn enough Perl to be
able to recognize bad Perl programs when you find them on the
Web. Trust me, there are more bad ones out there than good ones.
Sturgeon's Law certainly applies to the Web.
> what i need is someone who can point me to some information about
> programming in perl , some good tutorials , maybe some articles on dbi
> (besides the one from tpj , i have that one here :)
Since you're using Lookout! Express to post this, you might
want to start with the Perl tutorial at:
http://www.netcat.co.uk/rob/perl/win32perltut.html
You might also want to read this article, which will tell you
how to look things up in the extensive Perl docs:
http://www.perlmonth.com/articles//rtfm.html
> plz help me , as my mind get's flooded like a sponge when i just use
> altavista with +perl +tutorial +dbi
Unfortunately, it doesn't help to use AltaVista with
+perl +tutorial +dbi +not_full_of_hideous_errors
But you can use Deja to look through posts in this newsgroup
about DBI and DBD issues, and glean dozens of good code
samples.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 25 May 1999 18:13:38 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Return of array
Message-Id: <7iep8e$7mm$1@nnrp1.deja.com>
In article <374ACFA2.F5B61266@nortel.com>,
digital kensai <kensai@nortel.com> wrote:
> $arrayref->[0] works, but @{$arrayref}->[0] has the added benefit
(IMHO) of
> clearly marking exactly what the array is ($arrayref is NOT the array,
as
> $arrayref->[0] visually, and incorrectly, implies).
Sorry Mr. Kensai, YHO is incorrect.
Any time there is an arrow, the thing on the LHS is a reference
(except when it's a package name). Understanding this,
$arrayref->[0] NEVER implies, to anyone familiar with Perl refs,
that $arrayref is the array.
Remember also that the arrow is optional when it's between levels of
a multi-level data structure dereference; and idiomatic Perl says
to leave it out in these cases. So @{$arrayref}->[0] is just (ugly)
long-hand for @{$arrayref}[0] -- which, as has already been mentioned,
is inappropriate unless you specifically want a slice.
--
John Porter
Put it on a plate, son. You'll enjoy it more.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 25 May 1999 13:22:51 -0500
From: Ranson <ranson@rlaj.com>
Subject: Sorting Problem
Message-Id: <374AEA7B.11CAF702@rlaj.com>
Greetings
I know this is a fundemental problem, and I should know this, but cant
find a solution.
I have a list of files I am reading in to an array:
page1.gif
page2.gif
~
~page 33.gif
I want to sort them so I get:
page1.gif
page2.gif
page3.gif
~
page33.gif
All I have been able to do is sort like this:
page1.gif
page10.gif
page11.gif
~
and so on.
I need to sort 1-2-3-4-5 and so on. Does anyone know how to do this? I
have all the books and if it is in there I cant find it. If someone has
a solution please post and email rlaj@rlaj.com -- thanks so much in
advance
Thanks
Ray
------------------------------
Date: 25 May 1999 18:53:42 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Sorting Problem
Message-Id: <7ierjm$s5r$2@info2.uah.edu>
In article <374AEA7B.11CAF702@rlaj.com>,
Ranson <ranson@rlaj.com> writes:
: I have a list of files I am reading in to an array:
: page1.gif
: page2.gif
: ~
: page 33.gif
:
: I want to sort them so I get:
: page1.gif
: page2.gif
: page3.gif
: ~
: page33.gif
This is a job for.. THE SCHWARTZIAN TRANSFORM! [fanfare]
my @sorted = map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
map { /^page(\d+)\.gif$/ ? [ $_, $1 ] : [ $_, 0 ] }
@files;
Broken down (and using temporaries), it works like this:
# turn "page33.gif" into [ "page33.gif", 33 ]
my @names_and_nums = map {
/^page(\d+)\.gif$/
? [ $_, $1 ]
: [ $_, 0 ]
} @files;
# sort them based on the numbers (index 1)
my @sorted_names_and_nums = sort { $a->[1] <=> $b->[1] }
@names_and_nums;
# now lose the extraneous numbers
my @sorted = map { $_->[0] } @sorted_names_and_nums;
Hope this helps,
Greg
--
Two most common elements in the universe: Hydrogen & Stupidity.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5778
**************************************