[19552] in Perl-Users-Digest
Perl-Users Digest, Issue: 1747 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 14 14:10:26 2001
Date: Fri, 14 Sep 2001 11:10:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1000491011-v10-i1747@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 14 Sep 2001 Volume: 10 Number: 1747
Today's topics:
Re: Problems with format (perlform) and carriage return (James Minor)
Re: recognize MS Windows with perl <matt@starnix.com>
Re: Recommendations for a PERL editor (zawy)
Re: Running perl scripts (Tad McClellan)
Re: Source Code Bracket Matching Utility Needed (Ralph Freshour)
Re: Source Code Bracket Matching Utility Needed (Malcolm Dew-Jones)
use autouse 'Data::Dumper' => qw(Dump); (EED)
Re: Using the c preprocessor for non c purposes <paul.johnston@dsvr.co.uk>
Re: Using the c preprocessor for non c purposes (Malcolm Dew-Jones)
Re: Warning on adding hash element (so)
Re: What about Pod::Html? (Eric Bohlman)
Re: Why the client still waits for input? <gortona@cs.man.ac.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Sep 2001 08:14:26 -0700
From: jminor@crystal.cirrus.com (James Minor)
Subject: Re: Problems with format (perlform) and carriage returns...
Message-Id: <d68b5964.0109140714.2be68a02@posting.google.com>
Thank you everyone for the comments and suggestions! This is my first
post to this group, and I'm glad to see so many helpful people.
Please see below for my comments...
> > open (REL_NOTES, ">relnotes") or die ("cannot open: $!");
> > select (REL_NOTES);
> > &relnotes;
>
> This is a bit oldfashioned, and could be something else than you mean.
> Subroutines without arguments are normally called as relnotes().
I'm actually maintaining someone else's code here, and they weren't
the best in style :(
> Maybe you can use this instead:
>
> $details = "1\n2\n3\n4\n5\n";
> write;
>
> format STDOUT =
> Details
> ====================================
> @*
> $details
> .
I'd love to use this, but I really need the line to be specific
length, thus the series of '<'s. I know another work around is to
replace all of the '\n's with a token character, than write the
format, then go back and replace the token with '\n's. If the method
I'm trying to use worked, though, it'd be exactly what I need :)
> Now, what this is all about, I can't tell you, but it certainly isn't
> the correct behaviour.
Is there someone I should notify that this appears to be a bug? As a
programmer myself, I usually like to make sure that even though
something appears to just 'not work', I like to at least insure that
something somewhere else isn't affected by the bug (if this is one).
------------------------------
Date: 14 Sep 2001 09:29:28 -0400
From: Matthew Rice <matt@starnix.com>
Subject: Re: recognize MS Windows with perl
Message-Id: <lv7kv1uchz.fsf@sol.starnix.com>
"Zachary Kent" <zkent@adelphia.net> writes:
> <ducking>I use if (-e '\autoexec.bat') to distinguish my Win95 development
> machine from my Unix server.</ducking>
This may have been answered already and I am coming in at the end of the
thread but can you not use the value of:
$OSNAME
$^O The name of the operating system under which this
copy of Perl was built, as determined during the
configuration process. The value is identical to
"$Config{'osname'}". See also the Config manpage
and the -V command-line switch documented in the
perlrun manpage
See the perlvar man page.
--
matthew rice <matt@starnix.com> starnix inc.
tollfree: 1-87-pro-linux thornhill, ontario, canada
http://www.starnix.com professional linux services & products
------------------------------
Date: 14 Sep 2001 07:32:51 -0700
From: zawy@yahoo.com (zawy)
Subject: Re: Recommendations for a PERL editor
Message-Id: <bb2f439c.0109140632.43c32f22@posting.google.com>
> Can someone recommend to me a reliable Windows-based editor that WON'T
> create these problems for me ???
EditPlus has been my favorite for Windows
http://www.editplus.com/
It's similar to textpad
------------------------------
Date: Fri, 14 Sep 2001 15:18:01 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Running perl scripts
Message-Id: <slrn9q41oi.je6.tadmc@tadmc26.august.net>
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>On Thu, 13 Sep 2001 16:31:30 -0500,
> Michael Carman <mjcarman@home.com> wrote:
[snip cwd in path]
[snip bad 'xs' program waiting for 'cd' to be mistyped]
>There are other 'standard' typos of commands.
Do you know where there is a list of them? I'd like to scan the fs
for such names from time to time.
I have:
alias gerp='/bin/grep'
alias sl='/bin/ls'
in some of my startup config files.
P.S. For some strange reason I like pronouncing "gerp". It's not
in the same class as "salsa", but it's nice anyway :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 14 Sep 2001 14:10:08 GMT
From: ralph@primemail.com (Ralph Freshour)
Subject: Re: Source Code Bracket Matching Utility Needed
Message-Id: <3ba20fec.816165@news-server>
It was running OK for a long time and had always passed the perl -c
check - I made several changes the other day and ran the -c check
again when I was finished - thats when I noticed the failure. I went
back to the area's I modified but could not see any brace mis-matches.
I finally got tidyperl to run on my linux system and it flagged the
suspect area - I saw the mis-matched brace and fixed it - -c then ran
without errors so it is now OK.
Thanks to all who helped me.
Ralph
On 14 Sep 2001 07:53:49 GMT, sholden@pgrad.cs.usyd.edu.au (Sam Holden)
wrote:
>On Fri, 14 Sep 2001 05:44:05 GMT, Ralph Freshour <ralph@primemail.com> wrote:
>>Perl reports at the end of my script that there is an unmatched
>>bracket or brace *somewhere* - not much help, my script is 6000+ lines
>>long.
>
>Maybe you should have tried to run it before it got to be 6000+ lines
>long. That way you would have found the missing brace in the last bit of
>code you changed/added...
>
>--
>Sam Holden
------------------------------
Date: 14 Sep 2001 09:41:31 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Source Code Bracket Matching Utility Needed
Message-Id: <3ba2333b@news.victoria.tc.ca>
Chris Fedde (cfedde@fedde.littleton.co.us) wrote:
: In article <3ba1788c.6708330@news-server>,
: Ralph Freshour <ralph@primemail.com> wrote:
: >Bracket matching utility wanted:
: >
: >Is there a perl utility that will let me check bracket matching in my
: >script? I have a large script and I cannot manually find the
: >mis-matched bracket.
: >
: Normally your editor can help with this.
Yes, use it to align your brackets vertically and then you won't have
these problems.
while ( something )
{
do something else
}
while ( a long and complex test
that will take numerous lines
to put in your code
)
{
more lines
}
Brackets either align horizontally or vertically. Horizontal alignment
should not be used for complex logic or code.
Some people hate it, but you can check the above syntax even on a printout
while riding the bus home from work, no special editor or other technology
required.
Even absurdly long blocks can be matched by putting the cursor on the
bracket and then pressing the up or down arrows to scan the entire file to
see how they align (actually works better than many bracket matching
editors for large blocks) and again, that works in virually any editor.
------------------------------
Date: Fri, 14 Sep 2001 16:31:44 +0200
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: use autouse 'Data::Dumper' => qw(Dump);
Message-Id: <3BA214D0.7275CF94@eed.ericsson.se>
Hi guys,
I'd like to only load the Data::Dumper module in my CGI-script
if the DEBUG information is requested (by a string in PATH_INFO):
$DEBUG = $query -> path_info =~ /DEBUG/;
So I've tried doing it this way:
use autouse 'Data::Dumper' => qw(Dump);
...
print '<PRE>',
Dump ([$hohref, $cnaref], [qw(hohref cnaref)]),
'</PRE>' if $DEBUG;
but nothing gets printed between the <PRE>-tags.
I wonder if my "use ..." statement is correct. I've also tried:
use autouse 'Data::Dumper' => ('Data::Dumper::Dump');
use autouse 'Data::Dumper' => ('Data::Dumper->Dump');
but it doesn't help - I get:
:!perl -cwT paclist.pl
autouse into different package attempted at paclist.pl line 33
BEGIN failed--compilation aborted at paclist.pl line 33.
shell returned 255
Thank you for any hints
Alex
------------------------------
Date: Fri, 14 Sep 2001 15:46:36 +0100
From: Paul Johnston <paul.johnston@dsvr.co.uk>
Subject: Re: Using the c preprocessor for non c purposes
Message-Id: <3BA2184C.B5F769B2@dsvr.co.uk>
Hi,
> While just toying around, I was wondering if I can use the c preprocessor
> for just about anything.
Yes you can, it works fine. A Unix tool called m4 is the traditional
generic preprocessor, but its use seems rare. For a while I used the C
preprocessor to build my website. I ended up writing a C pre-processor
clone in Perl, which ommitted some of the features relevant to C and
added features I wanted for my website (automatic navigation bars,
graphical titles, etc.)
A word of warning though, other people may find your source code hard to
understand if you make heavy use of preprocessing, especially if using a
language where this is not normally done (e.g. batch files).
Paul
------------------------------
Date: 14 Sep 2001 09:48:27 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Using the c preprocessor for non c purposes
Message-Id: <3ba234db@news.victoria.tc.ca>
Paul Johnston (paul.johnston@dsvr.co.uk) wrote:
: Hi,
: > While just toying around, I was wondering if I can use the c preprocessor
: > for just about anything.
Though on windows the tools required are usually missing. The Perl angle
is that a perl script that uses the proprocess option won't run on a
typical windows machine even when it has an otherwise complete and working
perl installed.
------------------------------
Date: 14 Sep 2001 09:04:08 -0700
From: soosterh@my-deja.com (so)
Subject: Re: Warning on adding hash element
Message-Id: <db6cb1f3.0109140804.7125ffd4@posting.google.com>
Philip Newton <pne-news-20010913@newton.digitalspace.net> wrote in message news:<kv02qt8pnpl2p3fm20su584qk4unpssg78@4ax.com>...
> This looks as if $sInfo is a hashref.
>
> > > > print start_html( $sInfo ), "\n";
> > > >
> > Actually all I did was modify an example from the CGI page:
> >
> > print $q->start_html(-title=>'The Riddle of the Sphinx',
> > -script=>{-language=>'JavaScript',
> > -src=>'/javascript/sphinx.js'}
> > );
>
> And here the example passes an unrolled hash, not a hashref. The
> equivalent in your case would be
>
> print start_html( %$sInfo );
>
> and not
>
> print start_html( $sInfo );
>
> So you can't really compare the example code with your code, since they
> do different things.
That may or may not be, but with and without @ARGV set, the following
piece of code produces the same output with the same warnings...
use strict;
use CGI qw( :standard escapeHTML );
if( @ARGV )
{
&cgi_header( { -title=>"Page\n" , -BGCOLOR=>'DFDFDF', } );
}else{
print start_html(
{ -title=>"Page\n" , -BGCOLOR=>'DFDFDF',
'-script' => { -language=>'javascript', -src=>'/macros_so.js' }});
}
sub cgi_header
{
my( $sInfo ) = shift;
if( $sInfo and ref $sInfo )
{
$sInfo->{ '-script' } = { -language=>'javascript', -src=>'/macros_so.js' };
print start_html( $sInfo ), "\n";
}
}
...produces (in both cases)...
Use of uninitialized value at (eval 9) line 17.
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD><TITLE>Page
</TITLE>
<SCRIPT SRC="/macros_so.js" LANGUAGE="javascript"></SCRIPT>
</HEAD><BODY BGCOLOR="DFDFDF">
BTW Line 17 is the line : my( $sInfo ) = shift;
Obviously the warning is originating in start_html(), as it happens
in both cases. When @ARGV is not set the subroutine is not even
touched... Also if I add a bunch of white space at the beginning of
the program, it still claims that line 17 is the offending line.
If the '-script' element is omitted then no warnings occur.
Note that the HTML that is produced is correct -- I just dislike having
code with warnings.
One more thing. The macro file is found as the macros that are called
work.
------------------------------
Date: 14 Sep 2001 15:50:11 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: What about Pod::Html?
Message-Id: <9nt8vj$h7b$1@bob.news.rcn.net>
Horst Fickenscher <horst.fickenscher@sealsystems.de> wrote:
> The latest Pod::Html I've got with Perl 5.6 is version 1.03.
> It seem's outdated for me; e.g it does not use Pod::Parser.
> CPAN-search didn't help.
> Does anyone have any hints or suggestions?
It should be in podlators.
------------------------------
Date: Fri, 14 Sep 2001 18:19:01 +0100
From: Andrew Paul Gorton <gortona@cs.man.ac.uk>
Subject: Re: Why the client still waits for input?
Message-Id: <3BA23C05.CC7FB259@cs.man.ac.uk>
You should use '^C' instead of '^D' this will return you to the command
line.
Dai Yuwen wrote:
>
> Hi, all
>
> The following code is from the 'perlipc' manpage. It's a interactive
> client. But when I press '^D' to end the seesion, the client still waits
> for input. Any idea? Thank in advance.
>
> best regards,
> Dai Yuwen
>
> #! /usr/bin/perl -w
>
> # interactive client
>
> use strict;
> use IO::Socket;
>
> my ($host, $port, $kidpid, $handle, $line);
>
> unless (@ARGV >= 2) { die "usage: $0 host port\n";}
> $host = shift @ARGV;
> $port = shift @ARGV;
>
> # create a tcp connection to the specified host and port
> $handle = IO::Socket::INET->new (Proto => "tcp",
> PeerAddr => $host,
> PeerPort => $port)
> or die "can not connect to port $port on $host: $!";
>
> $handle->autoflush (1);
> print STDERR "[Connected to $host:$port]\n";
>
> # split the program into two processes, identical twins
> die "cann't fork: $!" unless defined ($kidpid = fork ());
>
> # the if{} block runs only in the parent process
> if ($kidpid) {
> # copy the socket to standard output
> while (defined ($line = <$handle>)) {
> print STDOUT $line;
> }
> kill ("TERM", $kidpid);
> }
> # the else{} block runs only in the child process
> else {
> # copy standard input to the socket
> while ( ($line = <STDIN>)) {
> print $handle $line;
> }
>
> }
------------------------------
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 1747
***************************************