[8206] in Perl-Users-Digest
Perl-Users Digest, Issue: 1824 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 6 18:07:21 1998
Date: Fri, 6 Feb 98 15:00:28 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 6 Feb 1998 Volume: 8 Number: 1824
Today's topics:
Re: \Q and variable interpolation in regexps <*@qz.to>
Re: Building a valid string <*@qz.to>
dbm performance <ecc@fc.hp.com>
Re: Determine if machine is connected to the Net? (Hasan Diwan)
Re: Determine if machine is connected to the Net? (I R A Aggie)
Re: Find ^M in file (SJL)
Re: How to get at stuff piped into Perl? <dgoddard@us.oracle.com>
How to use libnet <hargrave@concentric.net>
Re: How to use libnet (Mike Stok)
Re: How to use libnet (I R A Aggie)
New member guide?? <snorris@post.cis.smu.edu>
Re: New member guide?? (I R A Aggie)
Newbie with Perl 32 on NT workstation <ed@infodial.demon.co.uk>
Re: Newbie with Perl 32 on NT workstation <ludlow@us.ibm.com>
Re: Newbie about plunge into Perl asks... <camerond@mail.uca.edu>
Re: Newbie question re: Sorting (Chris Raettig)
Re: non-regex for potentially RFC-compliant email addre <*@qz.to>
Re: pattern with a star in it <*@qz.to>
Re: perl pointer puzzle (Andrew M. Langmead)
Re: perl pointer puzzle <jdporter@min.net>
Perl Win32 and Require's (David Stack)
Re: Perl Win32 and Require's (Craig Berry)
Porting Unix Perl scripts to Win NT (William van Zwanenberg)
proposal: open with flocking (Bart Lateur)
Re: Question: Searching files. (Kuma)
quick .signature hack <mecran01@homer.louisville.edu>
Quick Question on Efficiency <anton@elsquid.com>
Re: Quick Question on Efficiency <dagon@halcyon.com>
returning the date <dragonfyre91@hotmail.NOSPAM.com>
Re: returning the date (I R A Aggie)
Re: Saving variables? <*@qz.to>
Sending EOF to an opened pty (James F. Hranicky)
Re: Simplest regexp perl program? <*@qz.to>
Socket Connections <beverlyt@datequest.com>
Re: solution for multiline comments??? (Hasan Diwan)
Re: Syntax-coloring editor for NT <ecc@fc.hp.com>
Re: Syntax-coloring editor for NT <ecc@fc.hp.com>
Sys::Syslog help <farber@f-tech.net>
Using the Telnet module on Win32 <noel@integrityonline.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Feb 1998 21:46:20 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: \Q and variable interpolation in regexps
Message-Id: <qz$9802061609@qz.little-neck.ny.us>
Olivier Dehon <dehon_olivier@jpmorgan.com> wrote:
> I just came across this problem of using \Q in regexps:
...
> $pattern = '.*\\Qsomething\\E.*';
That is not a \Q in a regexp. That is a \\Q in a single quoted string.
You probably want
$pattern = ".*\Qsomething\E.*";
Also look into quotemeta().
> It looks as though perl does not interpret the \Q and \E after having
> interpolated the variable. Is this behaviour documented (I could not
That is correct. \Q...\E occurs at the time the value is first assigned
to the variable. This is a Good Thing(TM). In your case you made two
bads: the double \\ and the single quotes.
> find anything relevant in 'man perlre' or perlfaq)? Is it (or should
> it be considered) a bug?
Check the section on "Quote and Quote-like Chracters" in perlop.
> I also recently discovered what I think is a bug:
>
> $string =~ /\Q\E/;
:r! perl -we '$_="just fine\n"; /\Q\E/; print'
syntax error at -e line 1, near "\Q\E"
Execution of -e aborted due to compilation errors.
:r! perl -we '$_="just fine\n"; /\Q \E/x; print'
just fine
:r! perl -e '$_="just fine\n"; /\Q$a\E/; print'
just fine
:r! perl -we '$_="just fine\n";$a=q{}; /\Q$a\E/; print'
just fine
:r! perl -we '$_="just fine\n"; /\Q/; print'
just fine
Yeah, that may be a bug, but I'd say it is inconsequential.
Elijah
------
m'' is another context that does not do interpolation, BTW
------------------------------
Date: 6 Feb 1998 22:14:50 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Building a valid string
Message-Id: <qz$9802061701@qz.little-neck.ny.us>
David Hasbrouck <davidh@wwwpromote.com> wrote:
> What happens when this is ran is that the § piece is converted into
> the double SS character ('ion=Business not sure if it will display)
...
> I assume § must be some function call.
I betcha some program, eg a web browser, thinks '§ion' is the entity
for the sub-section character followed by 'ion'. It is not anything
wrong with your code, at least not the part you posted.
(If there was a § function call, it would be specific to your code
and we would be unable to help, probably.)
Elijah
------
by the way, what makes ' make a string "invalid"?
------------------------------
Date: Fri, 06 Feb 1998 13:51:46 -0700
From: Evan Clark <ecc@fc.hp.com>
Subject: dbm performance
Message-Id: <34DB77E2.6BB2@fc.hp.com>
I am currently looking for a lightweight database solution. Using
perl's built-in database packages would be an ideal solution since I am
already familiar with perl.
I have built some database test cases using perl. In general, reads seem
to do well, but creating the database from scratch seemed to take longer
than expected.
I fired up the database using:
tie (%HASH,'SDBM_File',myDBfile, O_RDWR|O_CREAT, 0666);
and then wrote to the database by populating %HASH. Creating a database
of 50k+ entries in this way seemed to take quite a while.
Has anyone noticed this behavior, and is there, perhaps a more 'modern'
package than SDBM which is optimized better for writes?
Also, has anyone had the opportunity to compare perl's dbm transactions
against commercial database applications?
-Evan Clark
--
"We're going to turn this team around 360 degrees."
-Jason Kidd
------------------------------
Date: 6 Feb 1998 15:29:37 -0500
From: hdiwan@shell.clark.net (Hasan Diwan)
Subject: Re: Determine if machine is connected to the Net?
Message-Id: <6bfrrh$p38@shell.clark.net>
efflandt@xnet.com (David Efflandt) writes:
>Is there a generic method that a perl script can tell if the machine
>it is running on is connected to the Internet (Linux)? I am going
>through a list of gethostbyname in an eval alarm loop to drop slow or
>invalid entries (so it does not take forever). But if the machine is
>not connected, all hostnames will drop. With autoconnect
>(request-route), a bunch at the beginning will drop until the
>connection is established.
>I could do a gethostbyname outside of the timeout loop, but then the
>question is what hostname to use for a portable script (they might
>have a local nameserver), or is there a quicker way to tell?
>This is for a Linux console Quake2 server browser/launcher and I am
>just trying to clean up the data before I feed qstat and save it for
>quicker future use (see: http://www.xnet.com/~efflandt/quickspy2/).
I am not entirely sure if this will work, but check the return value
from system("ping"); and based on it, continue with the program (check
the man page for the return values).
--
Hsiang Huang
University of California at Berkeley
Department of Electrical Engineering/Computer Science
hasandiwan@writeme.com
------------------------------
Date: Fri, 06 Feb 1998 17:11:35 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Determine if machine is connected to the Net?
Message-Id: <fl_aggie-0602981711350001@aggie.coaps.fsu.edu>
In article <6bfrrh$p38@shell.clark.net>, hdiwan@shell.clark.net (Hasan
Diwan) wrote:
+ I am not entirely sure if this will work, but check the return value
+ from system("ping"); and based on it, continue with the program (check
+ the man page for the return values).
Why call an external shell?
use Net::Ping;
$p = Net::Ping->new();
print "$host is alive.\n" if $p->ping($host);
$p->close();
This will require the libnet modules to be installed. This is an
interesting question, and the "ping" solution is dependent on whether
or not a particular machine is able to answer a ping request. My feeling
is that there is a Better Way.
But I'm not sure what that is.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Fri, 06 Feb 1998 21:03:19 GMT
From: perl@nospam.larson4.demon.co.uk (SJL)
Subject: Re: Find ^M in file
Message-Id: <34db7834.271225567@news>
On 28 Jan 1998 21:50:31 GMT, Tom Christiansen <tchrist@mox.perl.com>
wrote:
>I can't imagine a slower approach, even if it were right. Here's a tip:
>doing things a byte at a time in perl is much much much more often wrong
>than it is right.
Can you expand a bit on this? Specifically, if I'm using perl to read
from a binary data file (such as a PCM sampled .wav file) should
I do buffered reading rather than a byte-at-a-time? (or should I not
be using perl to manipulate such files?). Once upon a time I suppose
it was more efficient to do buffered i/o in C but I think nowadays
it's safe to assume the compiler is doing it for you. From your
statement, I take it that it is not safe to assume the same of perl?
TIA,
SJL
------------------------------
Date: Fri, 06 Feb 1998 13:25:40 -0800
From: Denis Goddard <dgoddard@us.oracle.com>
Subject: Re: How to get at stuff piped into Perl?
Message-Id: <34DB7FD4.677D59C2@us.oracle.com>
Michael Kairys wrote:
> > grep foo * | myscript.pl
>
> I can't figure out how to get at the output of the grep once I'm in
> myscript.pl. I've read all the references I can find about pipes but they
> all seem to be talking about using open and creating a process to read/write
> from/to.
1. The output from the grep will be available on STDIN with no work on your
part, ie,
@grep_result = <STDIN>;
should work just fine; this is the purpose of the pipeline. Output from process
A becomes input
to process B when you write "process_A | process_B".
2. Why are you doing the grep externally?
There are a jillion ways you could do this (and I'm sure you will see them if
you watch this space).
Due to my strong religious convictions, the following snippet is optimized for
clarity, not speed,
but you can do something like:
#!/usr/local/bin/perl5.004_04 -w
use strict;
my $regular_expression = "foo";
my @files_to_grep = glob("*");
my $file;
my @current_file_contents = ();
my @matching_lines_all_files = ();
my @matching_lines_current_file = ();
foreach $file (@files_to_grep) {
open(FILEHANDLE,"<$file") || die "opening $file";
@current_file_contents = <FILEHANDLE>;
close(FILEHANDLE);
@matching_lines_current_file =
grep( /$regular_expression/o, @current_file_contents );
push( @matching_lines_all_files, @matching_lines_current_file );
}
foreach (@matching_lines_all_files) {
print "$_";
}
__END__
------------------------------
Date: Fri, 06 Feb 1998 10:35:14 -0800
From: Vic Hargrave <hargrave@concentric.net>
Subject: How to use libnet
Message-Id: <34DB57E2.723362A6@concentric.net>
I'm getting started with using Perl for network programming. I have been
using the Socket library for doing the basics. Now I would like to use the
libnet for FTP and other high level protocols. I have two questions in this
regard:
1. How do you include libnet in your program to use its facilites?
In other words what do you put in the "use" statment, e.g.
"use Socket", to get libnet loaded?
2. Is libnet supported within the Perl for Win32 environment?
If anyone could help me with this I would greatly appreciate it.
Thanks in advance...
--
Vic Hargrave, 3rd Planet Citizen
http://www.concentric.net/~Hargrave
Cyberspace, the final frontier...
------------------------------
Date: 6 Feb 1998 16:04:35 -0500
From: mike@stok.co.uk (Mike Stok)
Subject: Re: How to use libnet
Message-Id: <6bftt3$73u$1@stok.co.uk>
In article <34DB57E2.723362A6@concentric.net>,
Vic Hargrave <hargrave@concentric.net> wrote:
>I'm getting started with using Perl for network programming. I have been
>using the Socket library for doing the basics. Now I would like to use the
>libnet for FTP and other high level protocols. I have two questions in this
>regard:
>
>1. How do you include libnet in your program to use its facilites?
> In other words what do you put in the "use" statment, e.g.
> "use Socket", to get libnet loaded?
libnet is a bundle of modules, so if you wanted to use FTP you might say
use Net::FTP;
in your script. The README for the libnet bundle includes:
The RFC implemented in this distribution are
Net::FTP RFC959 File Transfer Protocol
Net::SMTP RFC821 Simple Mail Transfer Protocol
Net::Time RFC867 Daytime Protocol
Net::Time RFC868 Time Protocol
Net::NNTP RFC977 Network News Transfer Protocol
Net::POP3 RFC1939 Post Office Protocol 3
Net::SNPP RFC1861 Simple Network Pager Protocol
The distribution also contains a module (Net::PH) which facilitates
comunicate with with servers using the CCSO Nameserver Server-Client
Protocol
Hope this helps (even though it answers just one of your 2 questions.)
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Fri, 06 Feb 1998 17:05:10 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: How to use libnet
Message-Id: <fl_aggie-0602981705110001@aggie.coaps.fsu.edu>
In article <34DB57E2.723362A6@concentric.net>, Vic Hargrave
<hargrave@concentric.net> wrote:
+ 1. How do you include libnet in your program to use its facilites?
+ In other words what do you put in the "use" statment, e.g.
+ "use Socket", to get libnet loaded?
perldoc Net::FTP
Net::FTP - FTP Client class
=head1 SYNOPSIS
use Net::FTP;
$ftp = Net::FTP->new("some.host.name");
$ftp->login("anonymous","me@here.there");
$ftp->cwd("/pub");
$ftp->get("that.file");
$ftp->quit;
[yadda, yadda, yadda]
+ 2. Is libnet supported within the Perl for Win32 environment?
Don't know.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Fri, 6 Feb 1998 14:32:28 -0600
From: "Scott Norris" <snorris@post.cis.smu.edu>
Subject: New member guide??
Message-Id: <6bfrt0$pto$1@hermes.seas.smu.edu>
I have heard various references to "THE Perl FAQ" and "the form you were
sent after your first posting". However, I recently reformatted, and lost
that message, which I assume contains links to help references. Would it be
possible to get another copy of this message?
Thanks,
scott norris
------------------------------
Date: Fri, 06 Feb 1998 17:12:28 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: New member guide??
Message-Id: <fl_aggie-0602981712280001@aggie.coaps.fsu.edu>
In article <6bfrt0$pto$1@hermes.seas.smu.edu>, "Scott Norris"
<snorris@post.cis.smu.edu> wrote:
+ I have heard various references to "THE Perl FAQ" and "the form you were
+ sent after your first posting". However, I recently reformatted, and lost
+ that message, which I assume contains links to help references. Would it be
+ possible to get another copy of this message?
Why not just do a little surfing at <url:http://www.perl.com> ?
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Fri, 6 Feb 1998 20:05:14 -0000
From: "Ed Os" <ed@infodial.demon.co.uk>
Subject: Newbie with Perl 32 on NT workstation
Message-Id: <886795093.3541.0.nnrp-11.9e98f6f2@news.demon.co.uk>
I just recently inherited an NT Workstation PC with Perl 32 installed on it.
Could anyone please give me pointers on how to get started. For example,
where is the Perl interpreter installed?
Do I need to modify the registry? Example scripts would also be helpful.
------------------------------
Date: Fri, 06 Feb 1998 15:41:16 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Newbie with Perl 32 on NT workstation
Message-Id: <34DB837C.1D56@us.ibm.com>
Ed Os wrote:
>
> I just recently inherited an NT Workstation PC with Perl 32 installed on it.
>
> Could anyone please give me pointers on how to get started. For example,
> where is the Perl interpreter installed?
> Do I need to modify the registry? Example scripts would also be helpful.
The Win32 FAQ is located at http://www.ActiveState.com/
Also check out http://www.perl.com/ for more general info.
You might want to download and reinstall your version just to make sure
that everything is up to date and in the right places.
--
James Ludlow (ludlow@us.ibm.com)
This isn't tech support, and all opinions are my own.
------------------------------
Date: Fri, 06 Feb 1998 16:03:50 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
To: jdporter@min.net
Subject: Re: Newbie about plunge into Perl asks...
Message-Id: <34DB88C6.27C691DD@mail.uca.edu>
(cc'd to JP)
John Porter wrote:
>
> Robbie Baldock (real email address at foot of message) wrote:
> > [slightly snipped to conserve space]
> > 1. Am I likely to run into troubles developing in Win95 and running in Unix?
> >
> > 2. ... should I buy a book on Win32 Perl (I
> > see O'Reilly has one of those too!) as well or will a general Perl
> > manual suffice?
>
> The answer to both questions is the same: you're developing to
> run on both platforms, so avoid any platform-dependent stuff.
> That means don't use (and don't bother learning, imho) the Win32
> modules.
OK, I see your logic there, but most general perl stuff _is not_ the
Win32::whatever modules. He should only run into them when he wants to
do win32-specific stuff.
> There are issues involved with cross-platform development, but
> none (that I know of) that are Perl-specific. You've got things
> like \ vs. /, environment variables, POSIX functions, access
> control, etc. etc.
Yes, that is also true, and so I would suggest getting _only_ the LPW32S
(gecko) to start with. Why? Because in addition to teaching how to use
perl on Windows, it also talks about differences with that and unix
systems (such as you point out above), and so IMHO is a better "really
general" book for those who need to be familiar with perl under both
OS's and only want to buy one tutorial.
Cameron Dorey
camerond@mail.uca.edu
------------------------------
Date: Fri, 06 Feb 1998 22:16:45 GMT
From: chrisr@cheese.org (Chris Raettig)
Subject: Re: Newbie question re: Sorting
Message-Id: <34dd8b6b.14933569@news.demon.co.uk>
Thanks for the help, people. The following line was suggested to me and solves
my problem....
@tome2 = sort {($aa) = $a =~ /(\d+) points\b/;($bb) = $b =~ /(\d+) points\b/;$bb
<=> $aa} @tome;
Sleepless Nights MUD thanks you all :-)
PS. Check out the game at
telnet: toes.cheese.org port: 6789
http://sleepless.cheese.org
Or check out the direct result of the script I asked for help on...
http://www.cheese.org/cgi-bin/sn/tome/topof.pl
Regards,
Chris.
------------------------------
Date: 6 Feb 1998 20:57:40 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: non-regex for potentially RFC-compliant email address (was Re: Quickie: regexp for valid e-mail addresses)
Message-Id: <qz$9802061544@qz.little-neck.ny.us>
? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au> wrote:
> Russell Schulz <Russell_Schulz@locutus.ofB.ORG> writes:
> >this is not true, for the domain-part. and there should be at LEAST
> >two characters after the `@', and almost always at least one `.'.
> Nope
Two characters, is pretty much true. One character TLDs with MX records
don't really occur all that often. Dots the "almost" bit of "almost
always" is more likely to come into play.
> dformosa@st(look)nepean(no)uws(dots)edu(here)au
That is a sendmail-ism and is not likely to work with other programs.
Elijah
------
or even all configurations of sendmail
------------------------------
Date: 6 Feb 1998 22:07:36 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: pattern with a star in it
Message-Id: <qz$9802061650@qz.little-neck.ny.us>
Sylvain Juneau <sjuneau@microtec.net> wrote:
> emask A700*P
> imask *P dbim 2 Y food/cis dbadd
> imask *C dbim 2 Y food/cis dbadd
>
>
> I have another file. I open that file and I want to search in it:
>
> A700*P then *P then *C.
>
> My question is how do I search through this file using a wildcard?
If I understand you, then this may illustrate things:
$ANOTHER_FILE = '/path/to/file';
open ANOTHER_FILE or die "Aww, schucks $!";
while(<ANOTHER_FILE>{
last if /(\Q A700*P \E)/x
}
if (defined($1)) {
while(<ANOTHER_FILE>) {
if (/( \Q *P \E | \Q *C \E)/x) {
print "Found a $1 line!\n"
}
}
} else {
print "A700*P was not found in $ANOTHER_FILE\n"
}
Key to this, you may notice, is that \Q...\E is used to escape
meta characters in the RE.
Elijah
------
note my use of /x to put whitespace in as well
------------------------------
Date: Fri, 6 Feb 1998 20:24:49 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: perl pointer puzzle
Message-Id: <Enz4pD.H3H@world.std.com>
Dan Boorstein <dboorstein@shopcfn.com> writes:
>Andrew M. Langmead wrote:
>> > $temp{'var'} = "variable";
>[cut]
>> The first question, is there a reason to use the symbolic reference
>> "$temp{var} = 'variable'"? Look it over again. Symbolic references are
>[cut]
>hmm, perhaps i am a bit confused. i thought:
> $temp{var} = 'variable'
>was an assignment of the string 'variable' to the hash 'temp' at
>subscript 'var'. clarifications?
Yes, but then it is used to access the scalar 'output_1' which is
contained in the variable "$variable". This type of access, having a
variable contain the name of the package variable which contains the
actual data, is a symbolic reference.
The example could be rewritten without symbolic references as follows.
$temp{var} = \$variable; # use hard reference
$variable = "output_1";
$reference = \${$temp{var}};
# which is a convoluted way of saying "$reference = $temp{var}"
print "$$reference\n";
--
Andrew Langmead
------------------------------
Date: Fri, 06 Feb 1998 15:34:28 -0500
From: John Porter <jdporter@min.net>
Subject: Re: perl pointer puzzle
Message-Id: <34DB73D4.7DDE@min.net>
Your main misconception is that the symbolic reference should
contain the $ (or @ or %). Perhaps you're getting symbolic
and hard references confused.
In the first case, you're simply dereferencing a string as a
symbolic reference:
$temp{'var'} = "variable";
$reference = $temp{'var'}; # $reference now contains "variable"
$variable = "output_1";
print "$reference\n"; # prints "variable"
print "$$reference\n"; # prints "output_1"
In the second case, you're creating a hard reference from a
symbolic one:
$variable_2 = "output_2";
$temp = "variable_2";
$reference_2 = \$$temp; # deref the symbolic, create a hard one.
print "$reference_2\n"; # prints SCALAR(0x1dead)
print $$reference_2 . "\n"; # deref the hard ref.
That's neat. I didn't know you could do that.
hth,
John Porter
------------------------------
Date: Fri, 06 Feb 1998 20:46:44 GMT
From: dstack@netcom.com (David Stack)
Subject: Perl Win32 and Require's
Message-Id: <34dc74ac.684671@news.supernews.com>
I am having a problem using the "require" statement with perl on my
windows 95 machine. The program is very simple and basically
illustrates how to use the "require" statement.
The program works fine when I run it from the DOS command line.
But when I go to execute the same script through the webserver, I get
the following error.
>ERROR:
>Message: CGI output from d:/musicstack/test/test.cgi
>contained no blank line separating header and data
If I comment out the "require" statement the program will work fine.
Anyone have any ideas?
Dave
------------------------------
Date: 6 Feb 1998 22:01:56 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl Win32 and Require's
Message-Id: <6bg18k$t14$1@marina.cinenet.net>
David Stack (dstack@netcom.com) wrote:
: I am having a problem using the "require" statement with perl on my
: windows 95 machine. The program is very simple and basically
: illustrates how to use the "require" statement.
:
: The program works fine when I run it from the DOS command line.
: But when I go to execute the same script through the webserver, I get
: the following error.
:
: >ERROR:
: >Message: CGI output from d:/musicstack/test/test.cgi
: >contained no blank line separating header and data
:
: If I comment out the "require" statement the program will work fine.
: Anyone have any ideas?
My guess is that the require is generating an error message (perhaps the
required file cannot be found under the server environment?). One
syndrome I've often seen (and sworn at) on NT servers is that . (the
current working dir) is *not* the dir from which your script is being run
by the server. This would cause the require to fail, if it's being loaded
by relative path. Try requiring it by absolute path and see if that
resolves the problem. If it does, just leave in the absolute path, or
change your server config (if possible) to make . = app dir.
If none of this works, try the CGI-related newsgroups for more help.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Fri, 06 Feb 1998 20:04:11 +0000
From: will@willz.demon.co.uk (William van Zwanenberg)
Subject: Porting Unix Perl scripts to Win NT
Message-Id: <will-0602982004110001@willz.demon.co.uk>
This has probably been covered by this newsgroup a thousand times already
but can anyone advise as to good web sites that I might look at that will
teach me how to go about porting some Perl CGI scripts that have been
written for a unix based Web server (Sun Solaris machine running Apache
Web Server) to an Windows NT server running Internet Information server?
Thanking you in advance,
Will
---------------------------------------------------------------
Will van Zwanenberg Email: will@willz.demon.co.uk
WWW: http://www.willz.demon.co.uk/
"Education is the means by which we acquire a higher grade of predjudices..."
------------------------------
Date: Fri, 06 Feb 1998 21:13:08 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: proposal: open with flocking
Message-Id: <34de71ed.2974353@news.tornado.be>
People are all having problems with file locking. Well... they are
having problems on Unix. These kinds of problems don't exist on toy
operating systems, like DOS and the Mac. ;-)
So I wonder if Unix isn't doing it wrong: people really shouldn't be
having problems with file locking. That is a far too low-level kind of
nitty-gritty.
So I think that Perl should patch it. If you open a file for append, you
want to add text at the end. Of course you want this to clash with
another script trying the same thing at the same time. So of course you
want file locking in this case. But why do you have to provide this
yourself manually? I think this is a far too basic problem for people
having to break their heads over, trying to get it right. Too low-level.
So, I think Perl should provide a file-open command, or at least, a
filelocking open command mode. Patch the OS, so to say. Something like a
special character before the file name, like (e.g.)
open(OUT,"!>$file");
although I do think that in some file opening modes, like append and
output, this should always happen by itself.
The only cases where you don't need to lock open files, is when you only
want to read from a file (provided it isn't opened for wrting by another
program), or in special cases like database files, where you only want
to lock part of a file. These still should be handled differently.
There. I've had my say.
Bart.
------------------------------
Date: Fri, 06 Feb 1998 20:06:05 GMT
From: tgy@chocobo.org (Kuma)
Subject: Re: Question: Searching files.
Message-Id: <34df6cb5.228773438@news.oz.net>
On Thu, 05 Feb 1998 23:10:37 GMT, phil@freed.com (Philip Freed) wrote:
>I just learned a few tricks tracing this one. A slight correction,
>though:
>
>>++ I can handle the forms and opening and closing the data file, but the
>>++ search loops are proving a problem. Can anyone help?
>>
>>map {$_ -> [1]}
>> grep {$_ -> [0] =~ /\Q$query/}
>> map {[map {reverse} reverse split /\t/, reverse, 2]} <FILE>;
>
>The last line should be
> map {[map {scalar reverse} reverse split /\t/, reverse, 2]} <FILE>;
>
>Otherwise, the reverse (in array context) simply takes the one-element
>array and returns it.
Almost. It actually returns an empty list, since $_ is only default
in scalar context:
@old = qw/moogle chocobo sylph/;
@new = map {reverse} @old; # empty!
@new = map {reverse $_} @old; # moogle, chocobo, sylph
@new = map {scalar reverse} @old; # elgoom, obocohc, hplys
--
Kuma
------------------------------
Date: Fri, 6 Feb 1998 17:49:29 -0500
From: Mark Crane <mecran01@homer.louisville.edu>
Subject: quick .signature hack
Message-Id: <Pine.HPP.3.95.980206171845.2062O-100000@homer.louisville.edu>
This is a pathetic attempt to get some perl wizard to write a
simple script for me. Please stop reading now if you find this
annoying, etc.
<plead>
I am trying to figure out how to do the following:
In order to use multiple random sigs on Pine, I am trying to
cobble a
script together that will
1. look at a file of quotes or sigs delimited by multiple
returns or some pre-chosen character string, like "$$$$"
2. select a quote at random.
3. write it to the file ".sig"
That's it. I would have it run every time I went into pine. Is
this doable in 4 lines or less? (not that it matters--I'm trying
to goad someone into writing it for me because I am
lazy/busy/newbie)
</plead>
thanks,
Mark Crane
------------------------------
Date: Fri, 06 Feb 1998 12:00:02 -0800
From: Anton Reut <anton@elsquid.com>
Subject: Quick Question on Efficiency
Message-Id: <34DB6BC2.D6C0E3F@elsquid.com>
Given a constant server processing speed. Im trying to find the fastest
way to compare a variable containing a employee ID to a list of
employees.
The file is a flat text file..who it be faster to
a.
open(MYFILE, "$file") || die ;
@filedata = <MYFILE> ;
close(MYFILE) ;
and then compare the string to each line in the array.
or would it be faster to compare it to each line as its read..
ie
open(MYFILE, "$file") || die ;
P: while($line = <MYFILE>){
if($line=~/$someid$/){
yadda yadda yadda;
last P;}
}
E-L-S-Q-U-I-D Man..
anton
------------------------------
Date: 6 Feb 1998 12:43:32 -0800
From: Mark Rafn <dagon@halcyon.com>
Subject: Re: Quick Question on Efficiency
Message-Id: <6bfslk$t48$1@halcyon.com>
[CC'd and posted to group]
anton@elsquid.com arranged electrons in a pattern like this:
>Given a constant server processing speed. Im trying to find the fastest
>way to compare a variable containing a employee ID to a list of
>employees. The file is a flat text file..would it be faster to
>[slurp file into @filedata and then do comparisons]
>[compare each line, use last to skip rest when found]
Answer A - direct answer to question asked.
Depends on how big the file is, and how often you're doing the lookup.
Slurping it all into memory allows you to do lots of lookups without
touching the file again. Big win, but see 1) below. Comparing while
reading allows you to skip a lot of reading if you get an early match.
Also big win.
Use times() to check performance a few hundred times each way and see
what's best for your situation.
Answer B - other considerations.
First, if the file is under a hundred K and it's accessed less than a
dozen times per hour, don't bother worrying about it. If it's large
and/or often-used, then the following may help:
1) For the case where it's accessed often and the file isn't huge:
This screams "HASH" to me. I'd set it up so it reads the file once,
builds a hash of IDs, and does all the lookups on the hash. This
doesn't work if you need to read the file only once per instance of your
program (but in that case, there are probably other areas you should
work on first).
2) For the case where it's a large or huge file, but not accessed constantly:
Strongly consider DBM functions (I'm partial to GDBM, but they're
mostly interchangeable for this. perldoc AnyDBM_File is a good starting
place. Basically, you read the file once, build a hash of IDs, but the
hash is tied to a DBM file, so future programs do the following:
Check dates on DBM file and userlist file. If DBM is old, lock the
DBM, rebuild hash. If new, do lookup in DBM file.
If it's a big file _AND_ accessed often:
Option 2 gets to be a hassle when you get to the point that lookups
are happenning more often than one every 10 - 30 seconds or so.
3) In this situation (large list, constant access), a good option is to
write a server process that keeps a hash of the names (DBM or memory,
depending on size), and each lookup just asks the server rather than
doing it's own file manipulation.
--
Mark Rafn dagon@halcyon.com <http://www.halcyon.com/dagon/> !G
------------------------------
Date: 6 Feb 1998 13:57:50 +600
From: "Kevin" <dragonfyre91@hotmail.NOSPAM.com>
Subject: returning the date
Message-Id: <01bd3339$dcacb360$cd96c4ce@hsegal.dnvr.uswest.net>
Hi...
I have a database (straight text, one item per line) which is frequently
updated by a perl script. Can anyone tell me how I would list next to each
item, the date (and maybe time) that it was added to the database?
So I'm looking for this:
itemone 02/05/98
itemtwo 02/06/98
(Date format not important.)
If it makes any difference, I'm running Perl5 on an NT server.
Thanks for the help!
Kevin
------------------------------
Date: Fri, 06 Feb 1998 17:19:25 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: returning the date
Message-Id: <fl_aggie-0602981719260001@aggie.coaps.fsu.edu>
In article <01bd3339$dcacb360$cd96c4ce@hsegal.dnvr.uswest.net>, "Kevin"
<dragonfyre91@hotmail.NOSPAM.com> wrote:
+ So I'm looking for this:
+ itemone 02/05/98
+ itemtwo 02/06/98
+ (Date format not important.)
Good.
$date_string=localtime();
print "$date_string\n";
Fri Feb 6 17:19:05 1998
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: 6 Feb 1998 21:56:41 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Saving variables?
Message-Id: <qz$9802061644@qz.little-neck.ny.us>
Burt Lewis <burt@ici.net> wrote:
> I have a form on a page that I would like to be able to have users review
> their entrys and if they want to use what they entered they hit submit to
> accept or press back to change.
>
> What's the most common way to handle something like this?
>
> Any ideas or examples would be appreciated.
Find a group that discusses CGI programs. This is not such a group.
In that group, find a FAQ. In that FAQ look for "shopping cart".
Elijah
------
thought this was going to be a perl question
------------------------------
Date: 6 Feb 1998 22:40:12 GMT
From: jfh@tick.cise.ufl.edu (James F. Hranicky)
Subject: Sending EOF to an opened pty
Message-Id: <6bg3gc$428$1@thunder.cise.ufl.edu>
Hi there,
Anyone know how to send an EOF to program B (stdin, stdout, stderr are all
dup(2)'ed to an open pty) from program A? I tried
system("stty eof '^d' < /dev/pts/<whatever>" )
but that didn't seem to work. I need to be able to send a bunch of output
to the pty'ed program (e.g. sort), send an eof, and read back the results,
similar to using shutdown(3n) on a socket. However, I don't know how to
do this with a pty.
I'm currently trying to do this on Solaris 2.[56] using perl5.004
(IO::Pty for the pty) if any of that matters.
----------------------------------------------------------------------
| Jim Hranicky, Senior SysAdmin UF/CISE Department |
| E314E CSE Building Phone (904) 392-1499 |
| jfh@cise.ufl.edu http://www.cis.ufl.edu/~jfh |
----------------------------------------------------------------------
------------------------------
Date: 6 Feb 1998 20:17:24 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Simplest regexp perl program?
Message-Id: <qz$9802061410@qz.little-neck.ny.us>
Posted and mailed.
Sean McAfee <mcafee@seawolf.rs.itd.umich.edu> wrote:
> David Lee Lambert <lamber45@EGR.msu.edu> wrote:
> >I'm trying to learn perl, so that I can use it within a procmail
> >anti-spam filter. Specifically, I want a program that scans its input
Perhaps you should go and ask what people have already written
that can help you. I'd recommend:
ftp://cs.uta.fi/pub/ssjaaa/pm-tips.html
> >for valid E-mail addresses that look like return addresses and prints them
I'm sending this from a valid email address. Your guess about what is
or is not valid is likely to be futile.
> >as a comma-seperated list on the output. Even a program that takes a
> >list, one per line, and puts them as commas would help.
>
> >I've tried stuff like:
>
> >while (<>) {print m/.*/, ", "}
>
> >but this seems to be providing a scalar context for the m//, since I get
> >sessions like
Maybe you want:
$, = ", ";
while (<>) { print m/.*/g }
print "\n";
> This will print a comma-separated list of all words in the input:
>
> while (<>) { push(@list, /\w+/g) }
> print join(", ", @list);
Mine does not use a temporary list variable.
> >[A-Za-z0-9._+-]{3,40}@([A-Za-z0-9_-]\.)+([a-z]{2,3}|uucp|arpa)
> Incidentally, this could be shortened a bit:
> [\w.+-]{3,40}@([\w-]\.)+([a-z]{2,3}|uucp|arpa)
Yes it could, but both are wrong (for matching email addresses.
Elijah
------
does not *think* "-.heh" is a legal hostname; knows "_.fun" is not
------------------------------
Date: Fri, 06 Feb 1998 14:36:06 -0800
From: Beverly Treadwell <beverlyt@datequest.com>
Subject: Socket Connections
Message-Id: <34DB9056.2F2D2AAA@datequest.com>
Hi,
I am trying to run the following code and am getting the error message
'Unsupported socket function "getprotobyname" called at prereg.pl line
29'. What's wrong? The socket.pm file is being found. Any help would
be truly appreciated. My code looks like this.
#!/usr/bin/perl
use Socket;
$| = 1;
$port = "4080";
$ipaddress = "207.165.90.100";
@pieces = split(/\./, $ipaddress);
$packname = pack("C4", @pieces);
$session = sockaddr_in($port, $packname);
$proto = getprotobyname('tcp');
$method = "GET";
$newstring = "post_new_user";
socket(S, AF_INET, SOCK_STREAM, $proto) || die "socket: $!";
connect(S, $session) || die "connect: $!";
select(S); $| = 1; select(STDOUT);
print S "$method $newstring HTTP/1.0\n\n";
sleep 1;
close(S);
I'm running on WinNT.
Thanks.
------------------------------
Date: 6 Feb 1998 15:17:40 -0500
From: hdiwan@shell.clark.net (Hasan Diwan)
Subject: Re: solution for multiline comments???
Message-Id: <6bfr54$n9u@shell.clark.net>
bart.mediamind@tornado.be (Bart Lateur) writes:
>mgjv@comdyn.com.au (Martien Verbruggen) wrote:
>>BTW. Would you ask on comp.lang.c if it maybe was possible to have
>>shell style comments in c source?
>Weeellllll.... "//" style comments are a pretty common feature.
Bart-
// is a C++-specific comment style. I would like to see C/C++ move
more towards perl than the other way around (I'm an engineering
student and find the '**' operator very convenient).
--
Hsiang Huang
University of California at Berkeley
Department of Electrical Engineering/Computer Science
hasandiwan@writeme.com
------------------------------
Date: Fri, 06 Feb 1998 13:33:01 -0700
From: Evan Clark <ecc@fc.hp.com>
Subject: Re: Syntax-coloring editor for NT
Message-Id: <34DB737D.7D7F@fc.hp.com>
Shawn McMahon wrote:
>
> Anybody know of a 32-bit NT editor that will do syntax-coloring for Perl?
>
> I know I can program Winedit or AY Pad to do it, but I'd kind of like to
> find something already done. Maybe a config for either of those programs,
> or an entirely different program.
>
> I don't care whether it lets me fire up perl.exe or not, just so long as it
> colors the keywords.
>
> (Be aware of the anti-spam addition in my email address if you want to
> respond via email.)
>
> --
>
> Shawn McMahon
> Network Systems Administrator
> Pre-Paid Legal Services, Inc.
If you are familiar with vi, you'll love the GUI version of vim for
UNIX, win32, etc etc. It does syntax coloring for everything I've ever
heard of.
-Evan Clark
--
"A verbal contract isn't worth the paper it's written on."
-Samual Goldwyn
------------------------------
Date: Fri, 06 Feb 1998 13:48:46 -0700
From: Evan Clark <ecc@fc.hp.com>
Subject: Re: Syntax-coloring editor for NT
Message-Id: <34DB772E.5762@fc.hp.com>
It is at www.vim.org
------------------------------
Date: Fri, 6 Feb 1998 16:46:08 -0500
From: "Paul Farber" <farber@f-tech.net>
Subject: Sys::Syslog help
Message-Id: <6bfvm9$d1s$1@news3.microserve.net>
Im trying to write a perl script that will log the failure of a routing to
the system logs. The script runs fine (even using perl -w) and the use
Sys::Syslog; is there, the code in question:
openlog('poplock','pid','user');
syslog('info',"lock file exists for $finfo[8]");
closelog();
$finfo[8] is a filename (it works, the name is printed out in a print
statement before the openlog call.
Please help.
Paul
------------------------------
Date: Fri, 06 Feb 1998 14:19:14 +0000
From: Mike Noel <noel@integrityonline.com>
Subject: Using the Telnet module on Win32
Message-Id: <34DB1BE1.5E7C0602@integrityonline.com>
I am trying to use the Net::Telnet package on a windows NT system with
the following script ($hostname, $username, and $password all have valid
value when the script is run).
# This script tests the telnet package.
BEGIN { push(@INC,"c:\\perl\\lib\\Net"); }
use Net::Telnet;
$t = net Net::Telnet ("$hostname");
$t->open("$hostname");
$t->waitfor('login:');
$t->print("$username");
$t->waitfor('Password:');
$t->print("$password");
$t->waitfor('ch%');
$t->print("ls");
$out = $t->waitfor('ch%');
print $out,"\n\n";
exit;
When I run the script I get the following error:
Can't locate auto/Net/Telnet/net.al in @INC (@INC contains:
C:\Perl\lib\site C:\Perl\lib c:\perl\lib c:\perl\lib\site
c:\perl\lib\site . c:\perl\lib\Net) at C:\noel\bin\ttest.pl line 7
I'm using perl version 5.004_02 (not the activestate one).
Thanks.
_M_
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 1824
**************************************