[29677] in Perl-Users-Digest
Perl-Users Digest, Issue: 921 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 10 00:09:44 2007
Date: Tue, 9 Oct 2007 21:09:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 9 Oct 2007 Volume: 11 Number: 921
Today's topics:
Re: an exe (generated by pp) then using ShellExecute to <mluvw47@gmail.com>
Re: an exe (generated by pp) then using ShellExecute to <ben@morrow.me.uk>
Re: ISALPHA <glennj@ncf.ca>
Re: ISALPHA <dummy@example.com>
Re: ISALPHA <ben@morrow.me.uk>
Re: join("") somehow changes characters after 'z' <ben@morrow.me.uk>
Re: Load file into a hash <uri@stemsystems.com>
Re: Perl-ish mail formatting question regarding "\t" <uctraing@ultranet.com>
Re: Problem with SOAP::Lite xhoster@gmail.com
Re: Profiling Perl with better granularity than Devel:: <clint.olsen@gmail.com>
Regular Expression $1? <ysongfinance@gmail.com>
Re: Regular Expression $1? <allergic-to-spam@no-spam-allowed.org>
Re: Script not able to work on Server 2003 <uctraing@ultranet.com>
Re: Script not able to work on Server 2003 <rkb@i.frys.com>
Re: The Modernization of Emacs: terminology buffer and nebulous99@gmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 09 Oct 2007 21:36:45 -0000
From: Mav <mluvw47@gmail.com>
Subject: Re: an exe (generated by pp) then using ShellExecute to catch the error
Message-Id: <1191965805.955945.85790@o3g2000hsb.googlegroups.com>
On Oct 8, 7:45 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Mav <mluv...@gmail.com>:
>
> > Hi, all
> > how do I return error from a pl script(convert into .exe) when it
> > is called by ShellExecute.
>
> > I have a small helloworld.pl program that I used pp(Par-Packer) to
> > convert that become an helloworld.exe
> > helloworld.pl is very simple, just like below:
>
> > use Win32::Registry;
>
> Where is
>
> use strict;
> use warnings;
>
> > my $name;
> > my $error = 0;
> > $! = 0; #first clear $! from previous error code
> > $::HKEY_LOCAL_MACHINE->Open("SOFTWARE\\XYZ\\Configurationn",
> > $config);
>
> > #check see if the XYZ software is install.
> > if ($!) {
> > $error = 100
> > return fail; } #Is that how to return error to another program on
> > perl???
>
> Err... no. Where did you get that idea from? Did you even try it?
>
> > else
> > { #continue doing something
> > }
>
> > Now on VC++ my progam call app.exe
> > When I tried to call my helloworld.exe
>
> > #this is app.exe
> > ShellExecute(NULL,"open","helloworld.exe", "","", SW_SHOW );
>
> > how to check if any error code get return by helloworld.exe (if it
> > got error how can I get the error code 100)?
>
> You can set helloworld's exit status with the exit Perl builtin. How you
> would then go about retrieving this from ShellExecute is rather beyond
> me... Is there a good reason you can't use system() or CreateProcess()
> from C++?
>
> Ben
Hi, Ben
Thanks for you answer again. Yea...I think at the end I decide to
use the exit code on the perl and the CreateProcess on C++. That is
working. However, when my perl script is abnormal terminal like:
...
my $ssh = new Net::SSH::W32Perl($host,
protocol => '2,1',
#debug=>1,
);
...
where if $host name is invalid, I could not get the exit code from C++
side, the pl script just got terminated. Any better idea? Or do you
know when I can read some more about this?
thanks,
Mav
------------------------------
Date: Wed, 10 Oct 2007 01:29:30 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: an exe (generated by pp) then using ShellExecute to catch the error
Message-Id: <a0jtt4-9k9.ln1@osiris.mauzo.dyndns.org>
Quoth Mav <mluvw47@gmail.com>:
> On Oct 8, 7:45 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> > Quoth Mav <mluv...@gmail.com>:
> >
> > > Now on VC++ my progam call app.exe
[helloworld.exe is a pp-packed Perl program]
> > > When I tried to call my helloworld.exe
> >
> > > #this is app.exe
> > > ShellExecute(NULL,"open","helloworld.exe", "","", SW_SHOW );
> >
> > > how to check if any error code get return by helloworld.exe (if it
> > > got error how can I get the error code 100)?
> >
> > You can set helloworld's exit status with the exit Perl builtin. How you
> > would then go about retrieving this from ShellExecute is rather beyond
> > me... Is there a good reason you can't use system() or CreateProcess()
> > from C++?
>
> Thanks for you answer again. Yea...I think at the end I decide to
> use the exit code on the perl and the CreateProcess on C++. That is
> working. However, when my perl script is abnormal terminal like:
> ...
> my $ssh = new Net::SSH::W32Perl($host,
This syntax (new Foo ()) is considered a bad idea nowadays. I can see
the attraction if you're coming from C++ (that's why it was added to
Perl in the first place), but under the wrong circumstances it can do
unexpected things. I would write that
my $ssh = Net::SSH::W32Perl->new($host, ...);
> protocol => '2,1',
>
> #debug=>1,
> );
> ...
> where if $host name is invalid, I could not get the exit code from C++
> side, the pl script just got terminated. Any better idea? Or do you
> know when I can read some more about this?
Net::SSH::Perl->new (which is what Net::SSH::W32Perl->new calls) ends up
calling 'die' if it can't connect. This is not actually documented: I
had to poke through the source to make sure, so I don't blame you for
not realising :).
When a Perl program calls 'die', normally perl prints a message to
STDERR and exits with status 255; if you don't ever normally exit with
this value you can use this to determine something went wrong. To find
out more, you can wrap the call to new (or, indeed, the whole body of
your program) in an eval block: eval and die are Perl's exception
mechanism, like try and catch in C++. The message (or object, but in
this case it's a simple message) passed to 'die' shows up in $@ (which
is always the null string if there was no error), so you can do
something like
eval {
my $ssh = Net::SSH::W32Perl->new(...);
}
if ($@) { # there was an exception
if ($@ =~ /
^Can't\ connect\ to\ (.*),\ port\ (.*)
:\ (.*)\ at\ $0\ line\ \d+.$
/x) {
# the exception was from Net::SSH::Perl
my ($host, $port, $error) = ($1, $2, $3);
warn "SSH connect to $host:$port failed: $!";
# your calling program knows that exit code 3 means 'I
# couldn't connect'.
exit 3;
}
die $@; # otherwise propagate the error
}
It's not the neatest way ever to handle exceptions, but it's usually
workable... If you want to do something more sensible with the failure
than simply reporting it to the user, you will need to communicate the
details of what went wrong back to C++ somehow. This will having some
connection open with your Perl program when you run it; one simple way
would be to redirect perl's STDERR to a file, and see what's in there
after it exits. If you do that there's no point bothering with the eval
stuff, of course.
Ben
------------------------------
Date: 9 Oct 2007 20:19:10 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: ISALPHA
Message-Id: <slrnfgnohv.fao.glennj@smeagol.ncf.ca>
At 2007-10-09 02:50PM, "fred78980@yahoo.com" wrote:
> To take into account words with accent I wrote this while ($txt =~ /
> \p{IsAlpha}/); The script does not give error message but it doesn't
> work.
> Your help is appreciated
I don't see "IsAlpha" in the perlunicode man page. Perhaps you want
"Letter" or "Alphabetic" instead.
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
------------------------------
Date: Tue, 09 Oct 2007 20:32:09 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: ISALPHA
Message-Id: <dzROi.20$G25.8@edtnps89>
Glenn Jackman wrote:
> At 2007-10-09 02:50PM, "fred78980@yahoo.com" wrote:
>> To take into account words with accent I wrote this while ($txt =~ /
>> \p{IsAlpha}/); The script does not give error message but it doesn't
>> work.
>> Your help is appreciated
>
> I don't see "IsAlpha" in the perlunicode man page. Perhaps you want
> "Letter" or "Alphabetic" instead.
perldoc perlre
[ SNIP ]
The following equivalences to Unicode \p{} constructs and equivalent
backslash character classes (if available), will hold:
[:...:] \p{...} backslash
alpha IsAlpha
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Tue, 9 Oct 2007 21:35:11 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: ISALPHA
Message-Id: <v85tt4-9u8.ln1@osiris.mauzo.dyndns.org>
Quoth krahnj@telus.net:
> fred78980@yahoo.com wrote:
> > To take into account words with accent I wrote this while ($txt =~ /
> > \p{IsAlpha}/); The script does not give error message but it doesn't
> > work.
> > Your help is appreciated
>
> perldoc perllocale
No. \p is a Unicodeism; locales and Unicode do not play well together
under current versions of perl. The locale-friendly version would be
use bytes; # just for good measure
use locale;
$txt =~ /[[:alpha:]]/;
Ben
------------------------------
Date: Tue, 9 Oct 2007 22:13:29 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: join("") somehow changes characters after 'z'
Message-Id: <pg7tt4-p49.ln1@osiris.mauzo.dyndns.org>
[I have re-wrapped Paul's text to fit in 79 real columns (bytes as
opposed to characters): as a general rule, it's a lot easier when
dealing with charset problems to run your output through od so we can
see what's actually happening]
Quoth Paul Lalli <mritty@gmail.com>:
> I understand diddlysquat about "wide" characters, characters vs bytes,
> etc. And for the first time, it's biting me. Can someone please
> point me to some resource that will help me to understand why these
> two one liners produce such drastically different output?
>
> This is the only time I can ever remember seeing a list of characters
> being printed differently than a string comprised of those same
> characters, joined by the empty string.
>
> $ perl -le'print map { chr($_) } grep { (chr($_) =~ /\p{IsAlpha}/) }
> (1..256);'
> Wide character in print at -e line 1.
This is your first problem; solving this also incidentally removes the
problem you were asking about... :)
Perl doesn't know what character encoding you are expecting on STDOUT.
As a result, it is printing the raw bytes of its own internal
representation, which changes if you do something requiring Unicode.
It's all rather a mess, mostly as a result of trying to support both
Unicode-aware and non-Unicode-aware programs without breaking backwards
compatibility.
To tell Perl what encoding you are expecting on STDOUT, you push an
:encoding layer with binmode:
binmode STDOUT, ':encoding(utf8)';
for instance, which says to use Perl's slightly lax form of UTF-8. (The
principal difference is that Perl allows you to use codepoints with no
assigned Unicode characters: if you ask instead for :encoding(UTF-8)
then you get the strict version.)
BTW, don't be tempted to use the :utf8 layer directly. While it works
well enough for output, on input it causes a real mess if it gets fed
invalid data.
> ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÀÁÂÃÄÅ
> ÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêë
> ìíîïðñòóôõöøùúûüýþÿÄ
Here every character except the last can be represented by a single
ISO8859-1 byte, so internally it is. Since Perl is dumping its raw
representation on STDOUT, every character except the last is output as
one byte.
(Something somewhere must have converted Perl's output to UTF8, as
that's what arrived here: probably your newsreader and/or your
terminal...)
> $ perl -le'print join "", map { chr($_) } grep { (chr($_) =~ /
> \p{IsAlpha}/) } (1..256);'
> Wide character in print at -e line 1.
> ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzªµºÃÃÃÃÃ
>
> ÃÃÃÑÒÓÔÕÖØÙÚÛÃÃÃÃà áâ
> ãäåæçèéêëìÃîïðÃ
> ±Ã²Ã³Ã´ÃµÃ¶Ã¸Ã¹ÃºÃ»Ã¼Ã½Ã¾Ã¿Ä
Here you join the characters into a single string before printing; this
forces Perl to 'upgrade' the whole lot to UTF8 so it can represent the
last character. Thus, the output here is actually valid UTF8, it's just
that your terminal (or whatever) is interpreting it as ISO8859-1 and
so seeing a whole lot of extra characters.
If you set an :encoding you get the same behaviour in either case:
output in the charset you asked for, with a (configurable) error if you
try to print something that can't be represented (only possible with
non-UTF charsets).
> Before anyone asks, yes I did see this notation in `perldoc -f chr`:
> Note that characters from 128
> to 255 (inclusive) are by default not encoded in
> UTF-8 Unicode for backward compatibility reasons
> but I don't really grok what it means, or why it would make the two
> prints different.
The Unicode documentation in 5.8 is rather patchy: it's written from the
point of view of someone who understands the implementation (which is
slightly weird) and wants to list the various gotchas. If and when you
have a good grasp of all this from a user's point of view, a doc patch
or two would certainly be appreciated... :)
What this is saying is that the string returned by chr(129) is
internally represented as one byte, but will need to be changed into two
bytes if it is joined to a UTF8-encoded string: exactly as happened to
you. This is all something that you as a user should not need to be
concerned with, but occasionally imperfections in the implementation
allow it to show through.
Ben
------------------------------
Date: Tue, 09 Oct 2007 21:16:57 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Load file into a hash
Message-Id: <x7hcl0xa2e.fsf@mail.sysarch.com>
>>>>> "BM" == Brian McCauley <nobull67@gmail.com> writes:
BM> On Oct 6, 3:06 pm, Brian McCauley <nobul...@gmail.com> wrote:
>>
>> my %hash = map { /(.*?)\t(.*)/ } <$fh>;
BM> Oh, and since we're slurping the file anyhow we can save a few lines
BM> by using File::Slurp
BM> use File::Slurp;
BM> my %hash = map { /(.*?)\t(.*)/ } read_file('test.txt');
i was going to chime in with slurp as well. :)
i have a better and faster idiom for slurping files into hashes
(untested for typos):
my %hash = read_file('test.txt') =~ /^([^\t]+)\t(.*)$/gm ;
and for most config type files slurping is fast since they are likely
smaller than even the OS's I/O block size which can be 64k or even
256k. there is no savings using perl's i/o system and reading many files
line by line. it is a great teaching technique but it is slower than
slurping in a whole file and parsing it in one regex call (as is
possible in many cases).
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Tue, 09 Oct 2007 21:02:19 GMT
From: - Bob - <uctraing@ultranet.com>
Subject: Re: Perl-ish mail formatting question regarding "\t"
Message-Id: <o1rng315686521q45oc3e559130g614ljs@4ax.com>
On Sun, 07 Oct 2007 09:10:36 -0700, Bill H <bill@ts1000.us> wrote:
>Its an Outlook thing. If you want to control the layout best thing is
>to go with mime headers and then you can use the <TT> tag to get fixed
>font size and use spaces instead of tabs.
>
>Bill H
Thanks. I was hoping to avoid MIME headers and keep the mail more
universal.
------------------------------
Date: 09 Oct 2007 20:36:06 GMT
From: xhoster@gmail.com
Subject: Re: Problem with SOAP::Lite
Message-Id: <20071009163608.870$1E@newsreader.com>
info@xperience-webdevelopment.nl wrote:
> When I call a webservice on a .net machine with the script below, I
> only receive a 1 or a true as a result.
> $result = $client->GetProductsForTourOperator($res);
I think that what you are getting here is a result object, and that object
has overloaded stringification (or boolean which is being bootstrapped into
stringification, or something) so that instead of printing as an object
usually does (something like "CGI=HASH(0x609210)"), it instead prints as
"1", presumably to indicate that the result object is not in an error
state.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Tue, 09 Oct 2007 16:48:36 -0500
From: Clint Olsen <clint.olsen@gmail.com>
Subject: Re: Profiling Perl with better granularity than Devel::DProf
Message-Id: <slrnfgntpk.2p2n.clint.olsen@belle.0lsen.net>
On 2007-10-09, Ben Morrow <ben@morrow.me.uk> wrote:
> Uh... that's weird... I presume that Perl_regexec_flags somehow got
> truncated, then, as there's no Perl_regexec in 5.8.7 either.
You are correct. The function was Perl_regexec_flags. It was truncated
with ellipses and I just didn't see them.
> Sorry, I was unclear... when I said '$N', I meant $1, $2, etc., not $^N.
> In any case, how you get hold of the captures later is unimportant: as
> soon as a match contains ordinary capturing parens, perl has to copy the
> capture every time it matches, just in case you look in $1 (or $^N)
> later. If you're doing a lot of matches which fail, you may save time by
> retrying the match with captures only if the pattern actually matches.
> If you're actually doing a lot of capturing, then, well, you're going to
> spend most of your time copying strings :).
I will definitely review and audit capture buffers to ensure that only the
necessary ones are kept.
Thanks,
-Clint
------------------------------
Date: Tue, 09 Oct 2007 18:12:36 -0700
From: Yang <ysongfinance@gmail.com>
Subject: Regular Expression $1?
Message-Id: <1191978756.137661.264600@g4g2000hsf.googlegroups.com>
I want to get everything between () in the file, say (5), (6), so I
wrote the following:
while(my $line = <FIN>){
chomp $line;
if($line =~ /\(\d*\)/{
print $1;
}
}
But it always returns error saying that $1 is uninitialized.
------------------------------
Date: Wed, 10 Oct 2007 03:40:42 +0200 (CEST)
From: Jim Cochrane <allergic-to-spam@no-spam-allowed.org>
Subject: Re: Regular Expression $1?
Message-Id: <slrnfgobci.mtm.allergic-to-spam@no-spam-allowed.org>
On 2007-10-10, Yang <ysongfinance@gmail.com> wrote:
> I want to get everything between () in the file, say (5), (6), so I
> wrote the following:
>
> while(my $line = <FIN>){
> chomp $line;
> if($line =~ /\(\d*\)/{
> print $1;
> }
> }
>
> But it always returns error saying that $1 is uninitialized.
>
I think you want:
if ($line =~ /(\(\d+\))/ {
...
}
[CE: not tested.]
--
------------------------------
Date: Tue, 09 Oct 2007 21:13:50 GMT
From: - Bob - <uctraing@ultranet.com>
Subject: Re: Script not able to work on Server 2003
Message-Id: <p8rng39gqovg3msplelkct4a243r5mvfcl@4ax.com>
On Mon, 08 Oct 2007 16:10:46 -0700, Joe <jruffino@gailborden.info>
wrote:
>Here is my code, I picked one of my shorter scripts:
>
><code>#!/usr/bin/perl -w
>
># Joe Ruffino Daily WebOpac.pl
># This program will read in a text file, and print it out
># in table format
># Written: January 30, 2004
># Revised: December 09, 2004, Jan 03, 2005
Joe:
I think you problems are simpler than examining your code. At the very
least, you need to check the basics.
Have you tried writing a VERY SIMPLE script and trying to get it to
run? If you get the same error from all of your scripts, then you have
a very basic configuration problem or testing problem. Write something
that just produces the HTML MIME header and some simple hardcoded
output. Test it in the EXACT same way that you are testing your more
complex code. Odds are that it will fail. Find the basic problem with
that an move from there.
One other test that's good to do is to run the program on the server
in a command window. Setting up post parameters can be an issue but
it's a good way to test the server. Simple programs (see above) should
run properly at a command prompt and the output should be exactly what
you get sent to the browser. If it's not, you have a server issue to
look for.
If you don't know how to see raw output back to the browser, ask,
there's a free MS program that will return all the raw output (or you
can use telnet).
------------------------------
Date: Tue, 09 Oct 2007 20:23:38 -0700
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: Script not able to work on Server 2003
Message-Id: <1191986618.473416.251390@r29g2000hsg.googlegroups.com>
John and Mumia have pointed out most of the problems, but here are
some more.
On Oct 8, 4:10 pm, Joe <jruff...@gailborden.info> wrote:
> Here is my code, I picked one of my shorter scripts:
>
> <code>#!/usr/bin/perl -w
>
> # Joe Ruffino Daily WebOpac.pl
> # This program will read in a text file, and print it out
> # in table format
> # Written: January 30, 2004
> # Revised: December 09, 2004, Jan 03, 2005
>
> use CGI qw(:standard :html3);
> use CGI::Carp qw(fatalsToBrowser);
> use strict;
>
> ##########################################################################
> # Set Variables
> #
>
> my $ip_hold = 0;
> my $sec;
> my $min;
> my $hour;
> my $day;
> my $month;
> my $year;
> my $ip_list;
> my $monthfind;
> my $monthm;
> my $countip;
>
> my $stationip;
> my $stationname;
>
> my @stationip;
> my @stationname;
>
> my $dayopac;
> my $daym;
> my $dayopacm;
> my $dayfind;
> my $headerpage;
> my $dayflag;
> my $namev;
> my $one;
> my $two;
> my $three;
> my $monthcurr;
> my $monthnow;
> my $countin;
> my $countout;
> my $ip;
> my $date;
> my $time;
> my $firstp;
> my $secondp;
> my $thirdp;
> my $fourthp;
> my $firstip;
> my @firstip;
> my $sn;
> my $count;
> my $date_month;
> my $date_day;
> my $date_year;
> my $i;
> my $ips;
> my @Names;
> my %Names;
> my $ext_ip;
> my %seen;
> my $countint;
> my $totalcnt;
> my $totalline;
> my $station_name;
> my @opacline;
> my %count;
> my @staionip;
> my $line;
> my $opac_month;
> my $hold_date;
> my $date_cnt;
> my $ip_day_cnt;
> my $day_array;
> my $ip_day_cnt;
> my $four;
> my @ext_line;
> my %day_array;
> my %letters;
> my $tot_ip_cnt;
> my $ip_cnt;
> my $four;
>
> ##########################################################################
> # Subroutine for finding the text month when numerical month is given
> #
> sub dayfind {
>
> #Setup date field
> if ($dayopacm eq "01") {
> $dayfind = "January"; }
>
> if ($dayopacm eq "02") {
> $dayfind = "February"; }
>
> if ($dayopacm eq "03") {
> $dayfind = "March"; }
>
> if ($dayopacm eq "04") {
> $dayfind = "April"; }
>
> if ($dayopacm eq "05") {
> $dayfind = "May"; }
>
> if ($dayopacm eq "06") {
> $dayfind = "June"; }
>
> if ($dayopacm eq "07") {
> $dayfind = "July"; }
>
> if ($dayopacm eq "08") {
> $dayfind = "August"; }
>
> if ($dayopacm eq "09") {
> $dayfind = "September"; }
>
> if ($dayopacm eq "10") {
> $dayfind = "October"; }
>
> if ($dayopacm eq "11") {
> $dayfind = "November"; }
>
> if ($dayopacm eq "12") {
> $dayfind = "December"; }
> return $dayfind;
>
> }
>
> ##########################################################################
> # Subroutine for finding the numerical month when text month is given
> #
> sub monthfind {
>
> #Setup date field
> if ($monthm eq "Jan") {
> $monthfind = "01"; }
>
> if ($monthm eq "Feb") {
> $monthfind = "02"; }
>
> if ($monthm eq "Mar") {
> $monthfind = "03"; }
>
> if ($monthm eq "Apr") {
> $monthfind = "04"; }
>
> if ($monthm eq "May") {
> $monthfind = "05"; }
>
> if ($monthm eq "Jun") {
> $monthfind = "06"; }
>
> if ($monthm eq "Jul") {
> $monthfind = "07"; }
>
> if ($monthm eq "Aug") {
> $monthfind = "08"; }
>
> if ($monthm eq "Sep") {
> $monthfind = "09"; }
>
> if ($monthm eq "Oct") {
> $monthfind = "10"; }
>
> if ($monthm eq "Nov") {
> $monthfind = "11"; }
>
> if ($monthm eq "Dec") {
> $monthfind = "12"; }
> return $monthfind;
>
> }
>
> ##########################################################################
> # Find current Time and Date info
> #
> ($sec,$min,$hour,$day,$month,$year) = localtime(time);
> $year = $year +1900;
>
> # ignore used for testing
> $ip_list = "OpacIP";
> # ignore used for testing
>
> ##########################################################################
> # Open IP file and test data file
> # Then split IP file into IP address and Station Name array's
> #
> open (LISTIN,"ipnew.txt") || die "Cannot Open File ipadd.txt for
> reading: $!";
>
> while (<LISTIN>) {
> ($staionip[$countip], $stationname[$countip]) = split(/\s+/);
> $countip++;
>
> }
>
> $stationip = @stationip;
> $stationname = $stationname;
>
> close (LISTIN);
>
> ##########################################################################
> # If a file name has been given, process the file
> #
>
> $line = 0;
> if (param()) {
>
> # Set filename entered to a variable
> my $dayopac = param("dayopac");
>
> # Split file name into month and day by assuming a dash is there
> ($dayopacm, $daym) = split(/-/, $dayopac);
> if ($daym) { # if there is a 2-digit day
> $dayflag = "yes";
>
> # find the text month by sending the 2-digit month
> $monthfind = dayfind($dayopacm);
> if ($monthfind eq "December") {
> #$year = $year -1;
> }
> $headerpage = "Daily Stats for " . $monthfind . " " . $daym . ",
> " . $year;
> } else {
>
> # if not a day to be procressed, check to see if it is a month
> to
> # be processed
> $dayflag = "no";
> $daym = "01";
>
> # Split file name into process name and month by assuming an
> # underscore is there
> ($namev, $monthm) = split(/_/, $dayopac);
>
> # find the 2-digit month by sending the text month
> $monthcurr = monthfind($monthm);
>
> # if current month is equal to the month entered
> if ($month eq $monthcurr) { # if it is 1 - 9
> if ($month > 9) {
> $dayopacm = $month; # set current month to month holder
> } else {
> # set current month to month holder and append a '0
> $dayopacm = "0" . $month;
> }
> } else {
> # if not equal set month entered to month holder
> $dayopacm = $monthcurr;
> }
> # Go to subroutine to find the FULL text month
> $monthnow = dayfind($dayopacm);
> if ($monthnow eq "December") {
> $year--;
> }
> ($one, $two, $three, $four) = split(/\\/, $dayopac);
>
> # Set title for HTML Output page using text month that was found
> $headerpage = "Monthly Stats for $monthnow $year";
> }
>
> $ip_list .= "_" . $monthm .".txt";
> open (OPAC_IP, ">$ip_list") || die "$ip_list open failed: $!";
>
> $opac_month = $dayopac . "_" . $year . ".html";
> open (OPAC_WEB, ">$opac_month") || die "$ip_list open failed: $!";
>
> # Append .txt to filename given, and open file for reading
> $dayopac .= ".txt";
> open (OPAC,$dayopac) || die ($dayopac . " open failed: $!");
>
> # Print title on new HTML page and first line
> print OPAC_WEB <<END;
1) You're not specifing the DOCTYPE
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
> <HTML><HEAD>
> <META name="description" content="GBPL Titles with Holds">
> <META name="robots" content="nofollow">
> <TITLE>WebOpac $headerpage</TITLE>
> </HEAD>
2) You're missing the opening body tag.
3) HTML tags should be in lowercase, not uppercase.
> <CENTER>
4) The <CENTER> tag is deprecated.
> <H1>$headerpage</H1>
> END
5) Dynamicaly creating a static html file that you later redirect to
doesn't make sense. Skip the file creation and just output your page.
>
> ($ip,$date,$time,$sn) = split(/ +/);
> $hold_date = $dayopacm . "-" . $daym . "-" . substr(($year - 1900),
> 1,2);
>
> $countin = 0; # zero out counter for ip numbers used in an
> array
> $date_cnt = 0;
> $ip_day_cnt = 0;
>
> while (<OPAC>) {
> chomp;
> $countout++; # count number of records processed
>
> ($ip,$date,$time,$sn) = split(/ +/);
>
> # If IP is internal, process
> if ($ip =~ /192.168.33/) {
>
> # Split IP in to 4 parts using a period
> ($firstp,$secondp,$thirdp,$fourthp) = split(/\./, $ip);
>
> # If IP is between 1 and 9, append 00 to it
> if ($fourthp > 0 && $fourthp < 10) {
> $fourthp = "00" . $fourthp;
> } else {
>
> # If IP is between 10 and 99, append 0 to it
> if ($fourthp > 9 && $fourthp < 100) {
> $fourthp = "0" . $fourthp;
> }
> }
> # Assign IP to an array element
> $firstip[$countin] = $fourthp;
>
> # Add 1 to array counter
> $countin++;
> } else {
> if ($date ne $hold_date) {
> foreach $ip (sort keys %day_array) {
> $ip_day_cnt++;
> }
> $tot_ip_cnt += $ip_day_cnt;
> $ext_line[$line] = "<b><i>" . $hold_date . "</b></i> has <b><i>" .
> $ip_day_cnt . "</b></i> unique External IPs.<p>";
> $date_cnt = 0;
> $ip_day_cnt = 0;
> %day_array = " ";
> $line++;
> }
> $ext_ip++;
> $letters{$ip} = 1;
> $day_array{$ip} = 1;
> $date_cnt++;
> }
> $hold_date = $date;
> }
>
> foreach $ip (sort keys %day_array) {
> $ip_day_cnt++;}
>
> $tot_ip_cnt += $ip_day_cnt;
> $ext_line[$line] = "<b><i>" . $hold_date . "</b></i> has <b><i>" .
> $ip_day_cnt . "</b></i> unique External IPs.<p>";
>
> # print OPAC_IP @Names;
> close (OPAC_IP);
>
> foreach $ip (sort keys %letters) {
> $ip_cnt++;
>
> }
>
> #print "<p>$ip_cnt";
> # Set length of array to variable
> $countint = @firstip;
>
> # Tally distinctive ips
> foreach $ips(@firstip) {
> $count{$ips}++;
> }
>
> foreach $ips(sort(keys %count)) {
> for ($i = 0; $i <= $countip; $i++) {
> if ($ips == $staionip[$i]) {
> $opacline[$totalcnt] = "The Station <b><i>".$stationname[$i]."</i></
> b> with IP <b><i>".$ips. "</i></b> has visited Opac <b><i>".
> $count{$ips}."</i></b> times.\n";
> $totalcnt++;
> if ( $count{$ips} > $ip_hold) {
> $ip_hold = $count{$ips};
> $station_name = $i;
> }
> }
>
> }
> }
> close(OPAC);
>
> if ($countint == 0) { $totalcnt = 0;}
>
> if ($dayflag eq "yes") {
> $totalline = "There are <b><i> " . $totalcnt . "</i></b> total
> patron stations used for <b><i>" . $monthfind . " " . $daym . "</i></
> b>.";
> } else {
> $totalline = "There are <b><i> " . $totalcnt . "</i></b> total
> patron stations used for the Month of <b><i>" . $monthnow . "</i></
> b>.";
> }
> print OPAC_WEB hr();
> print OPAC_WEB p("There are <b><i>" . $countint . "</i></b>
> internal IP address hits.");
> print OPAC_WEB p("There are <b><i>" . $ext_ip . "</i></b> external
> IP address hits.");
> # print p("There are <b><i>" . ($countout-$countin) . "</i></b>
> external IP address hits.");
> print OPAC_WEB p("There are <b><i>" . $countout . "</i></b> total
> IP address hits.");
> print OPAC_WEB p($totalline);
> print OPAC_WEB p("The Station <b><i>".
> $stationname[$station_name]."</i></b> has the greatest number of hits
> of <b><i>".$ip_hold."</i></b> times.");
> print OPAC_WEB p("There are <b><i>" . $tot_ip_cnt . "</i></b> Total
> unique External IP hits for All Days in <b><i>$monthnow</i></b>.");
> print OPAC_WEB p("There are <b><i>" . $ip_cnt . "</i></b> unique
> External IP hits for the Month of <b><i>$monthnow</i></b>.");
> print OPAC_WEB "<FONT SIZE=\"4\" COLOR=\"#FFFFFF\">";
> print OPAC_WEB "<A NAME=\"int\">Internal<\/A><\/font>";
> print OPAC_WEB "<A HREF=\"\#ext\">External Hits<\/a> ";
> print OPAC_WEB hr();
>
> for ($i = 0; $i <= $totalcnt; $i++) {
> print OPAC_WEB p($opacline[$i]);
> }
> print OPAC_WEB hr();
> print OPAC_WEB "<FONT SIZE=\"4\" COLOR=\"#FFFFFF\">";
> print OPAC_WEB "<A NAME=\"ext\">External<\/A><\/font>";
> print OPAC_WEB "<A HREF=\"\#int\">Internal Hits<\/a>";
> print OPAC_WEB p(@ext_line);
> print OPAC_WEB hr();
> print OPAC_WEB "</center>";
6) You need to learn the different quoting methods so you can avoid
the "leaning tower syndrom".
If you don't need variable interpolation, then use single quotes
instead of double quotes.
e.g., print OPAC_WEB '<A NAME="ext">External</A></font>';
>
> use CGI; print redirect("$opac_month");
7) Why are you tring to load the CGI module for a second time?
8) The redirect is probably why you're getting a blank page. From
what I can tell, you're only passing the filename. When doing a
redirect, you need to specify the full url, which includes the
protocal.
http://search.cpan.org/~lds/CGI.pm-3.29/CGI.pm#GENERATING_A_REDIRECTION_HEADER
>
> } else {
>
> ##########################################################################
> # If a file name has not been given, process the file, create webpage
> to
> # ask for it
> #
> print header, start_html("Monthly WebOpac"), h1("Monthly WebOpac
> Report");
>
> print hr();
> print start_form();
> print p("Day File: ",textfield("dayopac"), "<b> * form should be
> WebOpac_(<i>3-letter Month</i></b>)");
> # print p("Check Test: ",checkbox("opaccheck"));
>
> print p(submit("Submit Entry"));
> print end_form(), hr();
>
> }
>
> print end_html;</code>
------------------------------
Date: Wed, 10 Oct 2007 01:05:11 -0000
From: nebulous99@gmail.com
Subject: Re: The Modernization of Emacs: terminology buffer and keybinding
Message-Id: <1191978311.987341.271000@r29g2000hsg.googlegroups.com>
On Oct 8, 7:32 am, Joost Kremers <joostkrem...@yahoo.com> wrote:
> bbo...@gmail.com wrote:
> > Don't both "man" and those words for measurement come ultimately from
> > words for "hand" (similarly to words like "manual", as in labor)?
>
> no.
Do not bluntly contradict me in public.
> "manual" is derived from latin "manus" meaning "hand". the word "man"
> is related to (though not directly derived from) "mind", and the latin word
> "mens", which means "mind".
So you assert, but "man" bears a much closer resemblance to "manus"
than it does to "mens".
Or are you proposing that the plural word "men" came first? That would
be ... odd.
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 921
**************************************