[22276] in Perl-Users-Digest
Perl-Users Digest, Issue: 4497 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 31 18:15:06 2003
Date: Fri, 31 Jan 2003 15:05:09 -0800 (PST)
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, 31 Jan 2003 Volume: 10 Number: 4497
Today's topics:
Array Slice of one element <kenrose@rogers.com>
Re: Array Slice of one element <dha@panix2.panix.com>
compare text <user@someserver123abc.com>
Re: Crossposting (was: Fetchrow Question) <mgarrish@rogers.com>
Re: How to find @INC in a mod_perl compiled httpd binar (Kyndig)
Re: How to find @INC in a mod_perl compiled httpd binar (Ben Morrow)
Re: Launching parallel scripts (waitpid type thing?) <goldbb2@earthlink.net>
my sorting is slow <user@someserver123abc.com>
Re: my sorting is slow <uri@stemsystems.com>
Re: my sorting is slow <jurgenex@hotmail.com>
Re: newbie EASY problem :-) <glex_nospam@qwest.net>
Re: Perl Operations (docs) <penny1482@attbi.com>
Re: Perl Operations (docs) (Ben Morrow)
Re: Perl Operations (docs) <usenet@dwall.fastmail.fm>
Perldoc in emacs? <no_spam@fromyou.thanks-anyways.com>
Re: Perldoc in emacs? <joachim.pense@t-online.de>
Re: pipes: A script works on SCO, but not on Linux <goldbb2@earthlink.net>
printf %*v02x - something happened to 5.8 (Jay Tilton)
Re: RFC Date <thisis@bogus.com>
Scope in a format? <jackstraw@witchita>
Re: Scope in a format? <skuo@mtwhitney.nsc.com>
Re: Scope in a format? (h\)
sending system output to a perl variable <ed.doyle@motorola.com>
Re: sending system output to a perl variable <jurgenex@hotmail.com>
Re: sending system output to a perl variable <pkrupa@redwood.rsc.raytheon.com>
Using split with "df -k" <racsw@frontiernet.net>
VMS Readdir() with file versions (Jeremy Robbins)
Re: Web server permissions problem for Quota::query?? Andrew Lee
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 31 Jan 2003 14:34:15 -0500
From: Kenneth Rose <kenrose@rogers.com>
Subject: Array Slice of one element
Message-Id: <b1ej3o$mvr$1@tabloid.uwaterloo.ca>
Consider the following code:
@a = ( 0, 1, 'Hello World', 'booyah' );
$firstElement = @a[0]; # not good since doing an array slice
$secondElement = $a[1]; # much better
I've read that the assignment of $firstElement is less efficient than
the assignment of $secondElement (since an array slice is used). Is it
in fact less efficient and if so, why?
Thanks.
/<en
------------------------------
Date: Fri, 31 Jan 2003 20:36:36 +0000 (UTC)
From: "David H. Adler" <dha@panix2.panix.com>
Subject: Re: Array Slice of one element
Message-Id: <slrnb3lnik.jtm.dha@panix2.panix.com>
In article <b1ej3o$mvr$1@tabloid.uwaterloo.ca>, Kenneth Rose wrote:
>
> $firstElement = @a[0]; # not good since doing an array slice
> $secondElement = $a[1]; # much better
>
> I've read that the assignment of $firstElement is less efficient than
> the assignment of $secondElement (since an array slice is used). Is it
> in fact less efficient and if so, why?
I don't remember ever reading that it's less efficient (although it may
well be). The real problem is that they're actually different things,
which can cause rather annoying problems.
That aspect is covered in the faq under "What is the difference between
$array[1] and @array[1]?".
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
I believe myself to be the daughter of a one-eyed space robot named
Malcolm. -Fallon Young, http://www.bobbins.org/d/20000915.html
------------------------------
Date: Fri, 31 Jan 2003 15:31:32 -0500
From: someuser <user@someserver123abc.com>
Subject: compare text
Message-Id: <3E3ADD24.22521F96@someserver123abc.com>
I'm writting the following program to compare two texts.
when you first open the CGI, you get two TEXTAREAs
you put your two text to be compared in each box.
after submit if the two are different the first line that is different
is the dividing line.
everything above that is placed in the top TEXTAREA what's below that is
placed in a newly created TEXTAREA.
here's the problem.
a resubmit removes the first LF or CRLF in the bottom box.
try it and see.
#!/usr/bin/perl
use CGI qw/param/;
print "content-type: text/html \n\n";
# variables
$thisFileName="compareText.pl";
#parsed variables
@text=(param('textA'),param('textB'),param('textC'),param('textD'));
$numOfBoxes=@text; $numOfBoxes--;
for ($box=0;$box<=$numOfBoxes;$box++){
if (index($text[$box],"\015\012") >= 0){
#take out the ^M (012 is \n)
$text[$box] =~ s/\015\012/\n/g, $text[$box]; # 15 & 12=crlf
$unixOrDos= "DOS";
$origLFChar="\015\012";
}
elsif (index($text[$box],"\012") >= 0){
$unixOrDos= "UNIX";
$origLFChar="\012";
}
}
$text1=$text[0].$text[2];
$text2=$text[1].$text[3];
@text1=split /\n/, $text1;
@text2=split /\n/, $text2;
$text1Size=@text1; $text1Size--;
$text2Size=@text2; $text2Size--;
if ($text1Size > $text2Size){$size=int($text1Size); }
else {$size = int($text2Size);}
#split, top half are same, the first line that's different to the rest
of text are in bottom half.
$diff="false"; undef $textA; undef $textB; undef $textC; undef $textD;
for ($s=0;$s<=$size;$s++){
# print "$s vs $text1Size and $text2Size<br>\n";
if ($text1[$s] eq $text2[$s] && $diff eq "false"){
$textA.="$text1[$s]\n";
$textB.="$text2[$s]\n";
}
else {
if ($s <= $text1Size){$textC.="$text1[$s]\n";}
if ($s <= $text2Size){$textD.="$text2[$s]\n";}
$diff = "true";
}
}
#put back the ^M
$textA =~ s/\n/$origLFChar/g, $textA; # 15 and 12 = crlf (\n, ^M)
$textB =~ s/\n/$origLFChar/g, $textB; # 15 and 12 = crlf (\n, ^M)
$textC =~ s/\n/$origLFChar/g, $textC; # 15 and 12 = crlf (\n, ^M)
$textD =~ s/\n/$origLFChar/g, $textD; # 15 and 12 = crlf (\n, ^M)
print "<html><head><title>text compare tool</title></head><body>\n";
print "<form method=\"POST\" action=\"$thisFileName\">\n";
print "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n";
print "<td colspan=\"2\" align=\"center\">Text Compare -- text type:
$unixOrDos</td></tr>\n";
print "<tr>\n";
print "<td>\n";
if (length($textC) >= 1 || length($textD) >= 1){ $rows="16"; }
else {$rows="32";}
print "<textarea name=\"textA\" cols=\"50\"
rows=\"$rows\">$textA</textarea>\n";
print "</td>\n";
print "<td>\n";
print "<textarea name=\"textB\" cols=\"50\"
rows=\"$rows\">$textB</textarea>\n";
print "</td>\n";
print "</tr>\n";
if (length($textC) >= 1 || length($textD) >= 1){
print "<tr><td><textarea name=\"textC\" cols=\"50\"
rows=\"16\">$textC</textarea></td>\n";
print "<td><textarea name=\"textD\" cols=\"50\"
rows=\"16\">$textD</textarea></td>\n";
print "</tr>";
}
print "</table>";
print "<input type=\"submit\" value=\"submit\">\n";
print "</form>\n";
print "explanation...";
print "</body></html>\n";
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
------------------------------
Date: Fri, 31 Jan 2003 21:16:37 GMT
From: "mgarrish" <mgarrish@rogers.com>
Subject: Re: Crossposting (was: Fetchrow Question)
Message-Id: <VIB_9.235932$pDv.24272@news04.bloor.is.net.cable.rogers.com>
"Brian McCauley" <nobull@mail.com> wrote in message
news:u9hebp1amw.fsf_-_@wcl-l.bham.ac.uk...
>
> The whole point crossposted article is that is a single article that
> appears in multiple groups because is has multiple items in the
> Newsgroup line.
>
Is that actually a sentence?
Matt
------------------------------
Date: 31 Jan 2003 12:19:07 -0800
From: kyndig@knife-fighting.com (Kyndig)
Subject: Re: How to find @INC in a mod_perl compiled httpd binary?
Message-Id: <ed882ecb.0301311219.2c8ead8f@posting.google.com>
Thank you to all who replied!
I've narrowed down my question better:
This is the @INC of my old httpd:
/web/perl /usr/lib/perl5/5.6.0/i386-linux /usr/lib/perl5/5.6.0
/usr/lib/perl5/site_perl/5.6.0/i386-linux
/usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .
/usr/local/apache/ /usr/local/apache/lib/perl /web/perl /web/perl
This is the @INC of my new httpd:
/web/perl /web/perl /usr/local/lib/perl5/5.6.1/i686-linux
/usr/local/lib/perl5/5.6.1
/usr/local/lib/perl5/site_perl/5.6.1/i686-linux
/usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl .
/usr/local/apache/ /usr/local/apache/lib/perl /web/perl
My question is where is the difference coming from? I did not change
the httpd.conf, or the perlstart.pl(the PerlRequire file) which has a
'use lib' statement. In fact; the perlstart.pl file only defines one
directory for the path:
push(@INC, "/web/perl");
;there are no perl statements in the httpd.conf and here are the only
two env statements:
SetEnv PERL5LIB /web/perl
PerlSetEnv PERL5LIB /web/perl
, so shouldn't @INC only contain "/web/perl" ? Where does the rest of
the path originate?
Is it a general perl system wide setting? If that's the case, I
haven't changed it, so shouldn't it still apply to the new binary as
well?
Thanks again for the responses!
------------------------------
Date: Fri, 31 Jan 2003 21:36:14 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: How to find @INC in a mod_perl compiled httpd binary?
Message-Id: <b1eq8e$12p$1@wisteria.csv.warwick.ac.uk>
kyndig@knife-fighting.com (Kyndig) wrote:
>Thank you to all who replied!
>
>I've narrowed down my question better:
>
>This is the @INC of my old httpd:
>
>/web/perl /usr/lib/perl5/5.6.0/i386-linux /usr/lib/perl5/5.6.0
>/usr/lib/perl5/site_perl/5.6.0/i386-linux
>/usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .
>/usr/local/apache/ /usr/local/apache/lib/perl /web/perl /web/perl
>
>This is the @INC of my new httpd:
>
>/web/perl /web/perl /usr/local/lib/perl5/5.6.1/i686-linux
>/usr/local/lib/perl5/5.6.1
>/usr/local/lib/perl5/site_perl/5.6.1/i686-linux
>/usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl .
>/usr/local/apache/ /usr/local/apache/lib/perl /web/perl
>
>My question is where is the difference coming from? I did not change
>the httpd.conf, or the perlstart.pl(the PerlRequire file) which has a
>'use lib' statement. In fact; the perlstart.pl file only defines one
>directory for the path:
>
>push(@INC, "/web/perl");
>
>;there are no perl statements in the httpd.conf and here are the only
>two env statements:
>SetEnv PERL5LIB /web/perl
>PerlSetEnv PERL5LIB /web/perl
>, so shouldn't @INC only contain "/web/perl" ? Where does the rest of
>the path originate?
>
>Is it a general perl system wide setting? If that's the case, I
>haven't changed it, so shouldn't it still apply to the new binary as
>well?
These other paths are built-in to perl at compile time. Your new mod_perl has
been build with --prefix=/usr/local (or equivalent: I don't know how mod_perl
is built). You want to reinstall any modules which are currently under
/usr/lib/perl5/site_perl under /usr/local/lib/perl5/site_perl, for which you
can use CPAN.pm with a perl built into /usr/local or any other method of you
choice (including copying the directory over/symlinking them if the new and
old builds are binary-compatible).
Ben
------------------------------
Date: Fri, 31 Jan 2003 16:33:22 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Launching parallel scripts (waitpid type thing?)
Message-Id: <3E3AEBA2.7B5492A@earthlink.net>
Mike Hunter wrote:
>
> Hi everybody,
>
> I have a driver script which sets up some files, calls 6 other scripts
> that deals with the files, and then deletes the fiels once the 6
> scripts are finished.
>
> The machine I'm using is a dual-processor, so I'd like to get 2 of the
> 6 child scripts running at once. But if I background them, I won't
> know how long to wait to delete the files.
Why not just wait until they're done? Perl can do job control, after
all.
Also, considering that for *all* of your scripts, there's likely to be
at least *some* of the work that's IO bound, not CPU bound, you should
try and get them *all* going at once.
The OS will automatically handle scheduling them so that each processor
has something running on it all the time... well, until all your scripts
but one are done, at which point only one processor will be working on
your stuff.
> I could accomplish this with file locks, but that seems silly. Can
> anybody think of an elegant way to do this in perl? I saw that
> waitpid is available in posix (?),
Even without posix, it's available.
perldoc -f waitpid
Note that waitpid *only* works on those processes which your process
itself has started. If you were to use system("foo &"), that has the
effect of starting a shell, which in turn starts "foo" ... you can't use
waitpid on the "foo" process, since it's the shell's child, not your
own.
> but I'm currently using system()...do I need to switch to something
> fancier?
Yes. Something like this:
my @progs = (
[qw(program one and arguments)],
[qw(program two and arguments)],
.... # all 6 programs.
);
fork ? next : exec @$_ for @progs;
wait for @progs;
I've ommited error checking for simplicity.
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Fri, 31 Jan 2003 15:48:20 -0500
From: someuser <user@someserver123abc.com>
Subject: my sorting is slow
Message-Id: <3E3AE114.45FA2DC1@someserver123abc.com>
why is this sorting so damn slow?
I'm tring to sort out a table by column.
yeah, I know, lots of for loops.
what's better?
#proprietory sorting.
for ($iOut=1;$iOut<=$size;$iOut++)
{
for ($iIn=1;$iIn<=$size;$iIn++)
{
$iIn2=$iIn + 1;
@fields1=split /\|/, $db[$iIn];
@fields2=split /\|/, $db[$iIn2];
$a=$fields1[$FORM{column}];
$b=$fields2[$FORM{column}];
#strip then sort:
#using $a, strip non alpha/numeric/space
$stripSize=length($a); $stripSize--;
$stripText=undef;
for ($l=0;$l<=$stripSize;$l++) #loop thru each char of
string
{
$charCk=substr($a,$l,1);
if ($charCk =~ /^[A-Za-z0-9\s]$/ && $FORM{sortMethod} eq
"alphabetic") {
$stripText .= $charCk;}
elsif ($charCk =~ /^[0-9]$/ && $FORM{sortMethod} eq "numeric"){
$stripText .= $charCk;}
}
$a=$stripText;
#using $b, strip non alpha/numeric/space
$stripSize=length($b); $stripSize--;
$stripText=undef;
for ($l=0;$l<=$stripSize;$l++) #loop thru each char of
string
{
$charCk=substr($b,$l,1);
if ($charCk =~ /^[A-Za-z0-9\s]$/ && $FORM{sortMethod} eq
"alphabetic") {
$stripText .= $charCk;}
elsif ($charCk =~ /^[0-9]$/ && $FORM{sortMethod} eq "numeric"){
$stripText .= $charCk;}
}
$b=$stripText;
# actual sort process
if (uc($a) ge uc($b) && $FORM{sortMethod} eq "alphabetic") {
#switch current record with next one
$holder=$db[$iIn];
$db[$iIn]=$db[$iIn2];
$db[$iIn2] = $holder;
}
if ($a >= $b && $FORM{sortMethod} eq "numeric") {
#switch current record with next one
$holder=$db[$iIn];
$db[$iIn]=$db[$iIn2];
$db[$iIn2] = $holder;
}
}
}
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
------------------------------
Date: Fri, 31 Jan 2003 21:07:53 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: my sorting is slow
Message-Id: <x77kclyqmv.fsf@mail.sysarch.com>
>>>>> "s" == someuser <user@someserver123abc.com> writes:
s> why is this sorting so damn slow?
s> I'm tring to sort out a table by column.
s> yeah, I know, lots of for loops.
s> what's better?
anything.
you must be doing this on purpose but you seem to have chosen the
slowest method do any operation. it would be hard to make this any
slower.
i will make a few comments but you should read this paper:
http://www.sysarch.com/perl/sort_paper.html
s> #proprietory sorting.
s> for ($iOut=1;$iOut<=$size;$iOut++)
s> {
s> for ($iIn=1;$iIn<=$size;$iIn++)
perl for loops are much faster and easier. you must be coming from c or
a similar language where you index. in perl, indexing isn't needed that
much.
s> @fields1=split /\|/, $db[$iIn];
s> @fields2=split /\|/, $db[$iIn2];
s> $a=$fields1[$FORM{column}];
s> $b=$fields2[$FORM{column}];
your code looks like a bubble sort which is the slowest sort
algorithm. did you know perl has a fast sort function as a builtin?
s> #strip then sort:
s> #using $a, strip non alpha/numeric/space
s> $stripSize=length($a); $stripSize--;
s> $stripText=undef;
s> for ($l=0;$l<=$stripSize;$l++) #loop thru each char of
s> string
s> {
s> $charCk=substr($a,$l,1);
processing strings char by char is also not the perl way. break your
the meme of 'string as char array'.
s> # actual sort process
s> if (uc($a) ge uc($b) && $FORM{sortMethod} eq "alphabetic") {
s> #switch current record with next one
you are doing all the work over and over in the compare code. factor it
out before the sorting.
s> $holder=$db[$iIn];
s> $db[$iIn]=$db[$iIn2];
s> $db[$iIn2] = $holder;
( $db[$iIn], $db[$iIn2] ) = ( $db[$iIn2], $db[$iIn] )
but needing to swap elements is bad design. let perl do the work for
you.
so was this real code? or were you trying to troll with some very
strange sorting code?
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Fri, 31 Jan 2003 21:24:09 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: my sorting is slow
Message-Id: <ZPB_9.5986$x63.4338@nwrddc01.gnilink.net>
someuser wrote:
> why is this sorting so damn slow?
> I'm tring to sort out a table by column.
> yeah, I know, lots of for loops.
> what's better?
[code snipped]
Although your code is somewhat hard to read this appears to be bubble sort.
Why on earth did you choose _that_ if you are looking for speed (my
appologies if it's not bubble sort)?
In any case, for most standard situations you will be hard pressed to find
anything faster than Perl's build in sort. Not to mention that it will be
almost impossible to find anything more convenient.
Just supply your own comparison function. For further details please see
perldoc -f sort
perldoc -q sort
Your sort criteria seems to be a bit complex. So maybe you want to check out
the Schwartzian Transformation, too, to avoid recomputing the criteria over
and over again.
jue
------------------------------
Date: Fri, 31 Jan 2003 13:19:12 -0600
From: Jeff D Gleixner <glex_nospam@qwest.net>
Subject: Re: newbie EASY problem :-)
Message-Id: <9Zz_9.48$63.37469@news.uswest.net>
Noerd wrote:
> Jeff D Gleixner wrote:
>
>
>>[...]
>>
>>>"Owners manual (W/383 Pages)"
>>>
>>>Where would I put the word, "Pages," in my perl code
>>>
>>>I tried these, but they don't work:
>>>$itemdescription[2] =~ s+\(W\\/(.*?)Pages\)+
>>>$itemdescription[2] =~ s+\(W\\/(.*Pages)\)+
>>>
>>>Thank you!!!
>>>
>>>Oh, by the way, I need to leave all the backslashes "\" in there because
>>>the previous portion of my script has to escape all kinds of characters
>>>(I want to leave my code format, etc., intact....I just what to find out
>>>where in the dickens to put the word, "Pages." :-)
>>
>>Why are you using the substitute (=~ s)?
>>
>
>
> Here is what I had in mind:
>
> ##"Processor (W/16MB Ram)"
> $itemdescription[2] =~ s+\(W\\/(.*?)\)+\<FONT
> COLOR\=\"\#FFGG00\"\>\<B\>Reminder\:\<\/B\>\<\/FONT\> Comes with $1. +;
> ##will upload this into my sql database, via many lines of perl code:
> ## "Processor REMINDER: Comes with 16MB Ram."
>
> ##"Owners Manual (W/287 Pages)"
> $itemdescription[2] =~ s+\......WHAT GOES HERE.......+\<FONT
> COLOR\=\"\#FFGG00\"\>\<B\>NOTICE\:\<\/B\>\<\/FONT\> This has $1. +;
> ##Heres what I want:
> ## "Owners Manual NOTICE: This has 287 Pages."
>
> Thank you!!! :-)
Ok, again, without actully seeing the value of $itemdescription[2] before
you're doing the regex, it's tough to get it correct. but...since you're trying
to capture
a series of digits within a string, you'd probably want something like:
$itemdescription[2] =~ s{\(W/\s(\d+)\sPages\)} {This has $1.};
Probably a bit better as...
if ( $itemdescription[2] =~ m{\(W/\s(\d+)\sPages\)})
{
$description="<font>blahhh..This has $1 Pages.</font>";
}
That way you can keep the value of $itemdescription[2] and just find the
number you're looking for in the string.
If the number of spaces varies around the '287', add in the "*" wildcard for \s,
to match 0 or more whitespaces.
BTW, if you're escaping all of these characters for SQL, that's not needed. You
should
only need to escape very few, if any, characters. If you really have to, wait
to escape it
until it's needed for the SQL. No need to clutter up a perfectly good string.
:-) Check
"perldoc DBI" for escaping things and use either DBI's quote method or Perl's q()
operator when inserting the data. My guess is you'll find that you won't need
to escape
much if anything in your strings, making your regex's much easier.
See ya
------------------------------
Date: Fri, 31 Jan 2003 21:02:29 GMT
From: "Dick Penny" <penny1482@attbi.com>
Subject: Re: Perl Operations (docs)
Message-Id: <FvB_9.114587$AV4.3680@sccrnsc01>
> Further, the exhortation to look up perldoc X, is
> shorthand to look up X in the standard Perl
> documentation that comes standard with every
> Perl installation. It can be browsed and searched
> with all kinds of tools, although the perldoc program
> is bundled for that purpose. On Activestate Perl
> installations a copy of it is found in HTML format
> under C:/Perl/html/ and it can be read online
Au countraire my dear Helgi, searching Perldocs is most DIFFICULT on
my Win2K box, and the CPAN search mechanism is close to useless (not
totally).
The prior docs (from AS of course)((don't know how much prior)), were GREAT.
One could do a global search in the MS 'help' tool/file
format/distribution, a *.chm file I think.
I have no idea why AS decided on the 'pure' html and browser approach - it
stinks.
Dick Penny
------------------------------
Date: Fri, 31 Jan 2003 21:40:02 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Perl Operations (docs)
Message-Id: <b1eqfi$16s$1@wisteria.csv.warwick.ac.uk>
"Dick Penny" <penny1482@attbi.com> wrote:
>
>> Further, the exhortation to look up perldoc X, is
>> shorthand to look up X in the standard Perl
>> documentation that comes standard with every
>> Perl installation. It can be browsed and searched
>> with all kinds of tools, although the perldoc program
>> is bundled for that purpose. On Activestate Perl
>> installations a copy of it is found in HTML format
>> under C:/Perl/html/ and it can be read online
>
>Au countraire my dear Helgi, searching Perldocs is most DIFFICULT on
>my Win2K box, and the CPAN search mechanism is close to useless (not
>totally).
>
>The prior docs (from AS of course)((don't know how much prior)), were GREAT.
>One could do a global search in the MS 'help' tool/file
>format/distribution, a *.chm file I think.
>
>I have no idea why AS decided on the 'pure' html and browser approach - it
>stinks.
AS perl includes the program perldoc. Get a decent shell & terminal emulator
and use it.
Ben
------------------------------
Date: Fri, 31 Jan 2003 22:09:58 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Perl Operations (docs)
Message-Id: <Xns9314AE9F856F4dkwwashere@216.168.3.30>
Dick Penny <penny1482@attbi.com> wrote on 31 Jan 2003:
[Helgi Briem wrote:]
>> Further, the exhortation to look up perldoc X, is
>> shorthand to look up X in the standard Perl
>> documentation that comes standard with every
>> Perl installation. It can be browsed and searched
>> with all kinds of tools, although the perldoc program
>> is bundled for that purpose. On Activestate Perl
>> installations a copy of it is found in HTML format
>> under C:/Perl/html/ and it can be read online
>
> Au countraire my dear Helgi, searching Perldocs is most DIFFICULT on
> my Win2K box, and the CPAN search mechanism is close to useless (not
> totally).
>
> The prior docs (from AS of course)((don't know how much prior)), were
> GREAT. One could do a global search in the MS 'help' tool/file
> format/distribution, a *.chm file I think.
>
> I have no idea why AS decided on the 'pure' html and browser approach -
> it stinks.
Maybe because people like me sent them email asking where the documentation
was. Being forced to use IE sucked. The fonts were tiny and hard to read,
making the docs useful only for quick reference. I ended up about a foot
from the screen, squinting and trying to read those @#%@#%! little letters.
IE provides minimal support for setting your own font choices; some other
browsers make it easy to specify preferred fonts and custom style sheets.
Also, as I recall, when you added a module its docs were NOT added to the
"compiled HTML" help file. The current system is nicer: add a module with
ppm and its docs are integrated with all the other HTML docs.
I don't often need to search through all the documentation, but when I do,
I have a copy of GNU grep compiled for win32. Or I can use the built-in
search that comes with windows. Or I could write my own search program.
(So far I've not needed to write my own, but I would if I felt the need
for it.)
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Fri, 31 Jan 2003 19:42:23 GMT
From: "Bullet" <no_spam@fromyou.thanks-anyways.com>
Subject: Perldoc in emacs?
Message-Id: <zkA_9.13100$Dy.3521673253@newssvr10.news.prodigy.com>
When I try and run perldoc from within EMACS I get..
[me@localhost ~]$ perldoc perlfaq
WARNING: terminal is not fully functional
/tmp/x2sGTEYJUS (press RETURN)
And I end up with a vi sesion inside of emacs and formatted text starts
looking really ugly fast..
So I went in search of perldoc for emacs on google and I keep running
into the following utility for emacs which sounds like it should do just
what
I want -- however the URL below keeps coming up as server cannot be
found.. http://www.gnusoftware.com/Emacs/Lisp/perldoc.el
Since I cant seem to find a working link.. I was just wondering whether
this utility is something I should be trying to find or if perhaps there was
another alternative?
Providing this is what I want .. does anyone know where I can grab a
copy from?
------------------------------
Date: Fri, 31 Jan 2003 21:27:25 +0100
From: Joachim Pense <joachim.pense@t-online.de>
Subject: Re: Perldoc in emacs?
Message-Id: <b1em58$fvu$02$3@news.t-online.com>
Bullet wrote <zkA_9.13100$Dy.3521673253@newssvr10.news.prodigy.com>:
> When I try and run perldoc from within EMACS I get..
>
> [me@localhost ~]$ perldoc perlfaq
> WARNING: terminal is not fully functional
> /tmp/x2sGTEYJUS (press RETURN)
>
> And I end up with a vi sesion inside of emacs and formatted text starts
> looking really ugly fast..
>
I do not know that perldoc.el. My usual two workarounds are
M-X manual-entry perlfaq
or (for perldoc stuff that is not accessible with the "man" command):
start a server within emacs
make emacsclient your EDITOR
start perldoc outside of EMACS with the -t option
and press v
Joachim
(well, I did not answer your question, but,...)
------------------------------
Date: Fri, 31 Jan 2003 16:41:12 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: pipes: A script works on SCO, but not on Linux
Message-Id: <3E3AED78.310778F7@earthlink.net>
morden wrote:
>
> This script works just fine on SCO (perl 5.002) but sptbcgen fails to
> write to pipe BCGENW on Linux (perl 5.6.1) :
>
> unless (pipe(BCGENR,BCGENW)) {
> die("can't open a pipe\n");
> }
> $opipe=fileno(BCGENW);
> $pname = "|sptbcgen ".$opipe." ".fileno(BCGENR);
Any handle whose fileno is greater than $^F will have the CLOSEXEC flag
set.
Only those handles whose CLOSEXEC flag is *not* set get inherited by
child programs started by open(... "|foo").
Anyway... the *proper* way to make this all work is:
use IPC::Open2;
my $pid = open2( my($bcgenr, $bcgen), "sptbcgen" );
And have your C program read from it's stdin, and write to it's stdout.
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Fri, 31 Jan 2003 22:48:00 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: printf %*v02x - something happened to 5.8
Message-Id: <3e3afb24.30030635@news.erols.com>
With ActivePerl 5.6, I could do this:
C>perl -we "printf '%*v02x', ' ', 'foo'"
66 6f 6f
Now, with 5.8, I can't.
C>perl -we "printf '%*v02x', ' ', 'foo'"
Invalid conversion in printf: "%0" at -e line 1.
%*v02x
The documentation for sprintf() changed considerably between versions,
but I noticed nothing to indicate this should be broken now, or that I
was previously exploiting a misfeature that is now fixed.
As ever, TIMTOWTDI, but I'm more concerned with finding a reason why
this should no longer work. Is there one?
------------------------------
Date: Fri, 31 Jan 2003 14:16:13 -0500
From: "Duke" <thisis@bogus.com>
Subject: Re: RFC Date
Message-Id: <v3lirukpe39fee@news.supernews.com>
"Michael Budash" <mbudash@sonic.net> wrote in message
news:mbudash-2B25C2.10032531012003@typhoon.sonic.net...
> if i understand the thread (it's not completely posted):
>
> you could skip the [possible] need to install Date::Format and use the
> built-in Posix module.
>
> perldoc Posix
>
> search for 'strftime'
Great, thanks! Current version:
use POSIX;
my $rfcdate = POSIX::strftime('%a, %e %b %Y %X %z', localtime);
print $rfcdate;
------------------------------
Date: Fri, 31 Jan 2003 16:47:54 -0500
From: Jack Straw <jackstraw@witchita>
Subject: Scope in a format?
Message-Id: <3tql3v02v430me1g11ap9e7dugod7lr55o@4ax.com>
I've been banging my head for a while now, and I just think I'm
missing the trees for the forest. I've spent the day w/ my nose
buried in perltoot, perlobj, the cookbook, and PP. I think I'm too
tired, but I just want to get over the hump.
I'm working on my first object-oriented module, just for education's
sake. I can set instance data from outside, I can read instance data
from outside. But, for the life of me, I'm having a hard time *using*
the instance data from within an object.
I've focused on three solutions, all of which are (obviously) wrong
1) Call the subroutine w/ "&reportid".
Error = "use of an uninitialized value in formline"
2) Call the scalar w/ "$self->{reportid}"
Error = "global symbol $self requires explicit package name"
3) OK, fine, let's qualify it w/ "$Report::self->{reportid}"
Now, I'm back to "use of an un-initialized value"
Now, I know the value is getting set, 'cause in my calling program,
I'm doing a print to STDOUT, and it's there. Does using a format do
something funky to my scope? I can get the value I want to print from
within my print() sub, but it's only in the format that I'm hosed.
Thanks for taking the time to look at this.
========= module ===========
package Report;
use diagnostics;
use strict;
sub new {
my $self = {};
bless ($self);
return $self; }
sub reportid {
my $self = shift;
if (@_) {$self->{reportid} = shift;}
return $self->{reportid}; }
sub print {
my $self = shift;
write; }
format =
@<<<<<<<<<
&reportid
.
======== end module =============
======== program ============
#!/usr/bin/perl -w
use strict;
use diagnostics;
use Report;
my $i=0; # loopcounter for platter number array
my @datatypes;
my @platternum;
my $card;
my $platter;
my $datatype;
my $platternum;
# load arrays of potential values
@datatypes = qw(TXT TIF);
for ( $i=0; $i<2; $i++){
push @platternum,$i;
}
foreach $platter (@platternum){
foreach $datatype (@datatypes){
$card = Report->new();
$card->reportid("MIC$platter$datatype");
#set the reportid
print "Get value from program: ".$card->reportid."\n";
$card->print();
}
}
======== end program =============
--
JackStraw
0x3D561045
------------------------------
Date: Fri, 31 Jan 2003 14:37:16 -0800
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Scope in a format?
Message-Id: <Pine.GSO.4.21.0301311427260.20377-100000@mtwhitney.nsc.com>
On Fri, 31 Jan 2003, Jack Straw wrote:
> ...
> I'm working on my first object-oriented module, just for education's
> sake. I can set instance data from outside, I can read instance data
> from outside. But, for the life of me, I'm having a hard time *using*
> the instance data from within an object.
>
> I've focused on three solutions, all of which are (obviously) wrong
>
> 1) Call the subroutine w/ "&reportid".
> Error = "use of an uninitialized value in formline"
reportid is a method, and should not (and in this case, cannot) be
called without its associated object. Also &reportid returns a
value, not a variable.
> 2) Call the scalar w/ "$self->{reportid}"
> Error = "global symbol $self requires explicit package name"
You don't have a package scoped variable called $self.
> 3) OK, fine, let's qualify it w/ "$Report::self->{reportid}"
> Now, I'm back to "use of an un-initialized value"
Ditto (more below).
> Now, I know the value is getting set, 'cause in my calling program,
> I'm doing a print to STDOUT, and it's there. Does using a format do
> something funky to my scope? I can get the value I want to print from
> within my print() sub, but it's only in the format that I'm hosed.
>
> Thanks for taking the time to look at this.
>
>
>
> ========= module ===========
> package Report;
> use diagnostics;
> use strict;
>
> sub new {
> my $self = {};
> bless ($self);
> return $self; }
>
> sub reportid {
> my $self = shift;
> if (@_) {$self->{reportid} = shift;}
> return $self->{reportid}; }
>
> sub print {
> my $self = shift;
> write; }
>
> format =
> @<<<<<<<<<
> &reportid
> .
> ======== end module =============
You should use the 2 argument form of 'bless'. I think in this
particular case, you might try using a lexically scoped variable to
hold the value of "reportid" as class data:
#! /usr/local/bin/perl
package Foo;
use strict;
use warnings;
my $report_id; # lexically scoped class data
sub new {
my $class = shift;
my $self = {};
bless $self, $class;
return $self;
}
sub reportid {
my $self = shift;
if (@_) {
$self->{reportid} = $report_id = shift;
}
return $self->{reportid};
}
sub print {
write;
}
format =
@|||||||||
$report_id
.
1;
--
Hope this helps,
Steven
------------------------------
Date: Fri, 31 Jan 2003 23:57:20 +0100
From: "Michael Peuser \(h\)" <post@mpeuser.de>
Subject: Re: Scope in a format?
Message-Id: <b1euui$21u$03$1@news.t-online.com>
"Jack Straw" <jackstraw@witchita> schrieb im Newsbeitrag
news:3tql3v02v430me1g11ap9e7dugod7lr55o@4ax.com...
> I'm working on my first object-oriented module, just for education's
> sake. I can set instance data from outside, I can read instance data
> from outside. But, for the life of me, I'm having a hard time *using*
> the instance data from within an object.
>
> I've focused on three solutions, all of which are (obviously) wrong
>
> 1) Call the subroutine w/ "&reportid".
> Error = "use of an uninitialized value in formline"
reportid() needs a first parameter, right?
> 2) Call the scalar w/ "$self->{reportid}"
> Error = "global symbol $self requires explicit package name"
That's just a SUGGESTION from the compiler - it cannot know what you are
really after ;-)
> 3) OK, fine, let's qualify it w/ "$Report::self->{reportid}"
> Now, I'm back to "use of an un-initialized value"
Granted ypu are a newbie that should mean nonsense to even you.....
> Now, I know the value is getting set, 'cause in my calling program,
> I'm doing a print to STDOUT, and it's there. Does using a format do
> something funky to my scope?
Scope! Thats it!
You have to use a variable or whatever that format can "see". It cannot see
your internal hash references! Because format is a quite old concept you
have to adapt to it. A class variable should do the trick:
package Report;
use diagnostics;
use strict;
my $globalReportID;
sub new {
my $self = {};
bless ($self);
return $self; }
sub reportid {
my $self = shift;
if (@_) {$self->{reportid} = shift;}
return $self->{reportid}; }
sub print {
my $self = shift;
$globalReportID=$self->{reportid};
write; }
format =
@<<<<<<<<<
$globalReportID
.
------------------------------
Date: Fri, 31 Jan 2003 14:23:17 -0500
From: "Ed Doyle" <ed.doyle@motorola.com>
Subject: sending system output to a perl variable
Message-Id: <b1eigr$8be$1@newshost.mot.com>
Hi,
From inside a perl script, I would like to issue a shell command and have
the results go to a perl variable. For example, I would like to do
something similar to this:
my @array;
system("cleartool ls mydirecory");
In the above, the 2nd line sends its output to stdout. What I would like to
do is have the 2nd lines output go into the array.
Any suggestions would be appreciated.
Ed
ed.doyle@motorola.com
or
doyleed@sprynet.com
------------------------------
Date: Fri, 31 Jan 2003 19:47:21 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: sending system output to a perl variable
Message-Id: <dpA_9.1733$2A4.99@nwrddc04.gnilink.net>
Ed Doyle wrote:
> my @array;
> system("cleartool ls mydirecory");
>
> In the above, the 2nd line sends its output to stdout. What I would
> like to do is have the 2nd lines output go into the array.
>
> Any suggestions would be appreciated.
I suggest
- reading previous posts in this NG
- consulting google for previous posts with that very question
- and the fastest and best way: consult TFM for the functions you are using:
"perldoc -f system":
[...] This is
*not* what you want to use to capture the output from a command,
for that you should use [...]
jue
------------------------------
Date: Fri, 31 Jan 2003 21:22:42 +0000
From: "Peter A. Krupa" <pkrupa@redwood.rsc.raytheon.com>
Subject: Re: sending system output to a perl variable
Message-Id: <3E3AE922.4D4ACD72@redwood.rsc.raytheon.com>
Actually, that'd be a "perldoc -q system":
Why can't I get the output of a command with system()?
You're confusing the purpose of system() and backticks (``).
system() runs a command and returns exit status information (as
a 16 bit value: the low 7 bits are the signal the process died
from, if any, and the high 8 bits are the actual exit value).
Backticks (``) run a command and return what it sent to STDOUT.
$exit_status = system("mail-users");
$output_string = `ls`;
------------------------------
Date: Fri, 31 Jan 2003 17:09:39 -0500
From: Robert Krueger <racsw@frontiernet.net>
Subject: Using split with "df -k"
Message-Id: <v3lt14kgral2c3@corp.supernews.com>
I'm just learning Perl with a couple of new books, but I ran into something
that i thought should work, but doesn't, and i don't know why.
I'm trying to find out how much space is left on my internal Zip drive, so I
did this:
#!/usr/bin/perl -w
my $Mnt_Point='/mnt/zip';
@Left=split(/ /, `df -k $Mnt_Point`);
print $Left[4];
The way I understand it, my second line should break up the return from "df
-k" into separate words separated by spaces, and place them into the array
@Left.
So instead of having this:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hdd4/hdd4 244464 240664 3800 99% /mnt/zip
...I should have this in the array @Left:
Filesystem 1K-blocks Used Available Use% Mounted on /dev/hdd4/hdd4
244464 240664 3800 99% /mnt/zip
...which is a series of words in different indices, "Filesystem" being [0],
"1K-blocks' being [1], etc, etc.
I don't get an error, I just get nothing.
Could someone help me out a little?
Thanks,
Robert
------------------------------
Date: 31 Jan 2003 11:07:57 -0800
From: robbinj@pweh.com (Jeremy Robbins)
Subject: VMS Readdir() with file versions
Message-Id: <43806035.0301311107.54e3ab47@posting.google.com>
I would like to use readdir on a VMS system and have access to all of
the files including multiple versions in that directory. I am haiving
trouble decipehering the information that I have found on the web.
Help is greatly appreciated.
Thanks
jerm
------------------------------
Date: Fri, 31 Jan 2003 14:16:02 -0500
From: Andrew Lee
Subject: Re: Web server permissions problem for Quota::query??
Message-Id: <l4il3vgl2vj29ee5jc94b30uagmmci3ddp@4ax.com>
On 31 Jan 2003 10:34:28 -0800, it.andrew.mccall@oldham.gov.uk (Andrew
McCall) wrote:
>Hi All,
>
>Following my previous post, I have started to work with Quota:Query.
>I have written a script, and it works from the command line, and does
>indeed return the correct % of quota used.
>
>However when I run it from a browser via my web server, it always
>tells me there is a problem with the user here is the script :
Ooops -- what user runs cgi? (on many systems it is 'nobody')
>
>Could it be something to do with permissions? I.e. The user my web
>browser is set to isn't allowed to get the quota for the user I want
>to see?
That is probably it and that is as it should be.
>
>How do I get round this?
This may not be the most elegant solution but : run a cron job that gets
quotas and prints them to a file every day, hour, five minutes
(depending on your needs). Have your cgi read that file, parse it and
print the results.
Be mindful that the file is going to be accessed by more than one
program -- you will have to consider some locking mechanism to properly
implement this scheme. See perldoc -f sysopen or perldoc -q lock for
more details on file locking.
hth
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 4497
***************************************