[21911] in Perl-Users-Digest
Perl-Users Digest, Issue: 4115 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 13 18:06:41 2002
Date: Wed, 13 Nov 2002 15:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 13 Nov 2002 Volume: 10 Number: 4115
Today's topics:
Re: #!/usr/local/bin/perl <pkent77tea@yahoo.com.tea>
Re: [Q] Getting started with perl programming? <pkent77tea@yahoo.com.tea>
ATTENTION comp.lang.perl.misc ADMIN - my posts won't ca <newsComments17@sellers.com>
Re: ATTENTION comp.lang.perl.misc ADMIN - my posts won' (Walter Roberson)
Re: ATTENTION comp.lang.perl.misc ADMIN - my posts won' (Tad McClellan)
Re: Binary Deployment for Perl? <pkent77tea@yahoo.com.tea>
computing network transfer speed... <N.Hirani@hgmp.mrc.ac.uk>
Getting "locate" error but library does exist <reb@timevest.com>
Re: Help with a regular expression <dperham@wgate.com>
Re: Help with a regular expression <barryk2@delete_me.mts.net>
Re: Help with a regular expression (Peter J. Acklam)
Re: Help with a regular expression <john@imrie37.fsnet.co.uk>
Re: Help with a regular expression <john@imrie37.fsnet.co.uk>
Re: Help with https and lwp <pa@panix.com>
Re: Help! Bad Interperter: no such file or directory (Corey Andrews)
Re: how do I turn off unicode on file I/O? <goldbb2@earthlink.net>
Re: how do I turn off unicode on file I/O? dmeyers+perl@panix.com
Re: how do I turn off unicode on file I/O? <goldbb2@earthlink.net>
Re: How to send variable to CGI from browser <nospam@nospam.org>
pattern matching <kyi@kyi.sytes.net>
Re: pattern matching <tassilo.parseval@post.rwth-aachen.de>
Perl newbie w/ code <mjwilusz@acsu.buffalo.edu>
Re: Perl newbie w/ code <usenet@dwall.fastmail.fm>
Re: Perl newbie w/ code <stevenm@blackwater-pacific.com>
Re: Perl newbie w/ code <tassilo.parseval@post.rwth-aachen.de>
Re: Perl newbie w/ code <flavell@mail.cern.ch>
Re: Simple question - What is unicode? <pkent77tea@yahoo.com.tea>
Re: UTF8 counting first octet hi bits (Alan Barclay)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 13 Nov 2002 22:13:12 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: #!/usr/local/bin/perl
Message-Id: <pkent77tea-540926.22131213112002@news-text.blueyonder.co.uk>
In article <mhs4tugebma4vggr8rurur3dk0m5qarhh3@4ax.com>,
zzapper <zzapper@ntlworld.com> wrote:
<shebang lines>
> Hi has anyone got a win32 solution for this?
>
> Activestate Perl & Apache 1.3.24 WinXP-Prof
Personally I always turn on the Apache setting that gets the location of
Perl from the registry, ah yes... see the 'ScriptInterpreterSource'
setting in the core of Apache. Shebang lines are thus ignored.
That way you can put perl wherever you want and Apache goes "ah I'm
supposed to execute his file - now, what program is used to run .pl
files? Oh, C:/foo/perl/bin/perl.exe !"
I think this setting is probably what you'll (or the original poster)
find easiest and most maintainable.
[I missed some articles in this thread but I assume you/they must be
talking about CGI programs because the Windows shell/kernel/whatever
doesn't look for the magic '#!' bytes at the start of an executable file
TTBOMK and hence shebang lines are not used. Please correct me if needed]
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Wed, 13 Nov 2002 22:21:18 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: [Q] Getting started with perl programming?
Message-Id: <pkent77tea-50B0AB.22211813112002@news-text.blueyonder.co.uk>
In article <3dd23d5b.10120987@news.pacific.net.sg>,
NOSPAMmdknight@pacific.net.sg (Sir Loin of Beef) wrote:
> What would I need to get started with perl programming? Apart from a
> Perl interpreter, do I need any modules?
You can get binary (i.e. precompiled) copies of perl for most popular
platforms, and that comes with the standard library of many modules.
You'll need a text editor of some kind to write the perl code in -
anything from Notepad/Simpletext/vi up to Ultraedit/Emacs/nedit/BBEdit
and the like - but you'll have one of those already.
And perl comes with all its documentation right there.
Looking at your headers I'll guess you're on windows - in that case I'd
recommend ActivePerl, a Windows perl distribution with all the standard
modules, the standard perl utilities like GET and perldoc, and all the
documentation in HTML format. Download from
http://www.activeperl.com/ leading to
http://www.activeperl.com/Products/Download/Download.plex?id=ActivePerl
Indigo perl is another distibution I hear mentioned round here, but I've
no personal experience.
With either of those distributions you only need a text editor to start
writing perl and experimenting, etc.
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Wed, 13 Nov 2002 20:31:36 GMT
From: John Sellers <newsComments17@sellers.com>
Subject: ATTENTION comp.lang.perl.misc ADMIN - my posts won't cancel
Message-Id: <3DD2B6D5.4060702@sellers.com>
(If anyone knows how I can reach this ADMIN directly, please drop me a
note, just in case he/she doesn't see this note right away.)
Due to black box reasons I have been unable to debug, a post I tried to
revise 4 times, duplicated itself on the comp.lang.perl.misc server.
Cancel fails to work for me, so I need some help.
This is an important post and the older copies may cause some
misunderstanding so I ask you to cancel or delete the following
postings. (as well as this posting if you wish)
Re: wish fast method of counting of characters Xref: 451143
11/12/2002 4:01 PM by John Sellers <newsComments17@sellers.com>
Re: wish fast method of counting of characters Xref: 451149
11/12/2002 4:56 PM by John Sellers <newsComments17@sellers.com>
Re: wish fast method of counting of characters Xref. 451165
11/12/2002 6:42 PM by John Sellers <newsComments17@sellers.com>
If you need confirmation of my ID, do a whois on sellers.com and call
collect.
Thanks fo yo do it
------------------------------
Date: 13 Nov 2002 21:13:09 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: ATTENTION comp.lang.perl.misc ADMIN - my posts won't cancel
Message-Id: <aquf95$hsb$1@canopus.cc.umanitoba.ca>
In article <3DD2B6D5.4060702@sellers.com>,
John Sellers <newsComments17@sellers.com> wrote:
:(If anyone knows how I can reach this ADMIN directly, please drop me a
:note, just in case he/she doesn't see this note right away.)
You yourself are as much an "ADMIN" of comp.lang.perl.misc as
anyone else is. Unmoderated Usenet newsgroups are collective anarchies,
not centrally controlled.
:Due to black box reasons I have been unable to debug, a post I tried to
:revise 4 times, duplicated itself on the comp.lang.perl.misc server.
:Cancel fails to work for me, so I need some help.
:This is an important post and the older copies may cause some
:misunderstanding so I ask you to cancel or delete the following
:postings. (as well as this posting if you wish)
:Re: wish fast method of counting of characters Xref: 451143
:11/12/2002 4:01 PM by John Sellers <newsComments17@sellers.com>
You need to know the article-ids in order to create cancels.
The Xref numbers are purely local to your news server.
With the article-ids, someone could "forge" cancels on your behalf.
But it's probably easiest for you to just follow up each one saying
"Please ignore this version, I sent it too soon."
--
WW{Backus,Church,Dijkstra,Knuth,Hollerith,Turing,vonNeumann}D ?
------------------------------
Date: Wed, 13 Nov 2002 15:52:46 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: ATTENTION comp.lang.perl.misc ADMIN - my posts won't cancel
Message-Id: <slrnat5ide.4g1.tadmc@magna.augustmail.com>
John Sellers <newsComments17@sellers.com> wrote:
> (If anyone knows how I can reach this ADMIN directly
There *is no* admin for this unmoderated newsgroup.
> Due to black box reasons I have been unable to debug, a post I tried to
> revise 4 times, duplicated itself on the comp.lang.perl.misc server.
^^^
^^^
There are *tens of thousands* of newservers that carry clp.misc.
> Cancel fails to work for me, so I need some help.
Contact your ISP, they are the ones providing your news service.
> This is an important post
If you are referring to the posts where you feed Our Troll,
then they are *not* important.
If they say something important about Perl, then ignore this part.
> and the older copies may cause some
> misunderstanding
Are those the ones with the "attachments".
If so, then you are right, they caused a scorefile entry for your address.
> so I ask you to cancel or delete the following
> postings. (as well as this posting if you wish)
Nobody believes what Our Troll says, so don't worry about it.
Please do not feed the troll!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 13 Nov 2002 22:44:36 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Binary Deployment for Perl?
Message-Id: <pkent77tea-9915CB.22443513112002@news-text.blueyonder.co.uk>
In article <9acc2ac1.0211130136.3fa250ce@posting.google.com>,
peterwu@hotmail.com (Peter Wu) wrote:
> As I am learning Perl, I find that I can run a Perl program (*.pl or
> *.cgi) that may leverages any existing Perl Modules (*.pm).
Cool isn't it? You say you're new to perl, but are you experienced in
commercial programming in other languages? If so, are those compiled
languages or interpreted languages? ...
> My question is whether we have to deploy our Perl programs to be *open
> source*? I mean whether we can deploy a Perl prgram, at least PM, in a
> binary format so that customers or end users will not be able to see
> the source code I make.
...I ask because your company's policy w.r.t. source code and licences
etc. can probably be applied to perl programs aswell.
Here's an example - you build a compiled binary from C source code. You
add in some config files and deployment scripts. You tar.gz it and the
customer has to unpack the archive and run 'installme.bat' or something.
Right, just because the customer can read the saource of 'installme.bat'
does that mean they are allowed to pass it off as their own work? Are
you going to allow them to sell it? [ignore the fact that the install
script is going to be quite simple] No, I bet your install scripts will
have a big "This is proprietary software of the Peter Wu Corporation. Do
not modify, sell, etc etc"
> Do I have to open my source if I choose Perl to program? Thank you!
The choice of licence, if any, is up to your legal department in your
company, or you as the author, or ... well, somebody. But not Larry Wall
:-)
In other words, just because Perl is an open source project and a lot of
perl modules are open source, do lot be led[1] into thinking that
anything you write to be executed by Perl must also be open source. You
should probably consult your legal department to ensure they can cover
human-readable source files, or can modify the appropriate contracts and
licences.
There may be a FAQ about this too.
P
[1] certain large corporations like to spread these kind of lies, fear,
uncertainty, and doubt.
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Wed, 13 Nov 2002 21:58:53 +0000
From: Naran Hirani <N.Hirani@hgmp.mrc.ac.uk>
Subject: computing network transfer speed...
Message-Id: <3DD2CB1D.ABF82023@hgmp.mrc.ac.uk>
Hi,
I've written a little perl/cgi web application which zip data files on
the fly.
I know the total size of files to be zipped and so if I could some how
estimate
the current transfer speed between the end user browser and the web
server I could
tell the user roughly how long it might take.
So, any ideas people can suggest of how I might to do this using perl?
If poss. please could you CC any replies to: N.Hirani@hgmp.mrc.ac.uk
TIA.
Naran
------------------------------
Date: 13 Nov 2002 20:37:23 +0000
From: Time Vest Insurance <reb@timevest.com>
Subject: Getting "locate" error but library does exist
Message-Id: <l8zadkd5hq4.fsf@timevest.com>
I'm getting this error message when I do a perl -c
Can't locate loadable object for module Sybase::DBlib in @INC (@INC contains: /usr/local/lib/perl5/5.\
8.0/sun4-solaris /usr/local/lib/perl5/5.8.0 /usr/local/lib/perl5/site_perl/5.8.0/sun4-solaris /usr/lo\
cal/lib/perl5/site_perl/5.8.0 /usr/local/lib/perl5/site_perl .) at /usr/local/lib/perl5/site_perl/Uti\
ls.pm line 22
Compilation failed in require at /usr/local/lib/perl5/site_perl/Utils.pm line 22.
BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/Utils.pm line 22.
Compilation failed in require at index.cgi line 9.
BEGIN failed--compilation aborted at index.cgi line 9.
There does exist /usr/local/lib/perl5/site_perl/Sybase/DBlib.pm
It is readable
The SysAdmin did just upgrade perl to 5.8.0.
Any ideas why it doesn't find the object since it seems to exist?
Bob
------------------------------
Date: 13 Nov 2002 14:16:14 -0500
From: Doug Perham <dperham@wgate.com>
Subject: Re: Help with a regular expression
Message-Id: <81n0odgu0x.fsf@wgate.com>
spiff_swipnet@hotmail.com (Emil) writes:
> I've used the following line to replace all words between double
> colons (::word::) with a <img>-tag.
>
> $line =~ s!::(\S*)::!<img src=\"$1.gif\">!gi;
>
\S* will greedily eat up *all* successive characters until white space
or the end of the string is reached. Perhaps, you want everything
except whitespace and ":" (I also think that at least one of these
should be required), as follows
$line =~ s!::([^:\s]+)::!<img src=\"$1.gif\">!gi;
> If $line was set to "hello bla bla ::smile::";
>
> ::smile:: will be changed to <img src="smile.gif">
>
> Now to my problem, if $line consist of multiple ::smile:: written
> together after each other (::smile::::smile::::smile::) it doesn't
> work as I want it to do.
>
> They all will be replaced with <img
> src="smile::::smile::::smile.gif">, when I want it to be 3 img-tags
> after each other, like this <img src="smile.gif"><img
> src="smile.gif"><img src="smile.gif">
>
> How do I fix this?
--
Doug Perham o{..}o
dperham@wgate.com moo! (oo)___
WorldGate Communications, Inc. (______)\
/ \ / \
------------------------------
Date: Wed, 13 Nov 2002 13:21:09 -0600
From: godzilla <barryk2@delete_me.mts.net>
Subject: Re: Help with a regular expression
Message-Id: <MPG.183c62223cd299f3989753@east.usenetserver.com>
In article <7c7e06b6.0211131058.45ca0ab8@posting.google.com>,
spiff_swipnet@hotmail.com says...
> I've used the following line to replace all words between double
> colons (::word::) with a <img>-tag.
>
> $line =~ s!::(\S*)::!<img src=\"$1.gif\">!gi;
>
> If $line was set to "hello bla bla ::smile::";
>
> ::smile:: will be changed to <img src="smile.gif">
>
> Now to my problem, if $line consist of multiple ::smile:: written
> together after each other (::smile::::smile::::smile::) it doesn't
> work as I want it to do.
>
> They all will be replaced with <img
> src="smile::::smile::::smile.gif">, when I want it to be 3 img-tags
> after each other, like this <img src="smile.gif"><img
> src="smile.gif"><img src="smile.gif">
>
> How do I fix this?
>
You need to use minimal pattern matching (sometimes refered to as non-
greedy).
$line =~ s!::(\S*?)::!<img src=\"$1.gif\">!gi;
Given
$buffer = "ABXFGHX";
The pattern /A.*X/
will match the entire string
The pattern /A.*?X/
will match "ABX"
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: Wed, 13 Nov 2002 20:55:35 +0100
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: Help with a regular expression
Message-Id: <d6p9w8g8.fsf@online.no>
godzilla <barryk2@delete_me.mts.net> wrote:
> You need to use minimal pattern matching (sometimes refered to
> as non- greedy).
>
> $line =~ s!::(\S*?)::!<img src=\"$1.gif\">!gi;
No need to escape the double quotation marks, and no need for the
/i modifier.
$line =~ s!::(\S*?)::!<img src="$1.gif">!g;
Peter
--
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;
------------------------------
Date: Wed, 13 Nov 2002 19:55:36 +0000
From: John Imrie <john@imrie37.fsnet.co.uk>
Subject: Re: Help with a regular expression
Message-Id: <3DD2AE38.5080404@imrie37.fsnet.co.uk>
Peter J. Acklam wrote:
> godzilla <barryk2@delete_me.mts.net> wrote:
>
>
>>You need to use minimal pattern matching (sometimes refered to
>>as non- greedy).
>>
>> $line =~ s!::(\S*?)::!<img src=\"$1.gif\">!gi;
>>
>
>
I like that. I tend to forget about the minimal stuff. However I like to
be a bit more strict with my regxes so I'd do it as
$line =~ s!::([^:]+)::!<img src="$1.gif">!g;
John Imrie
------------------------------
Date: Wed, 13 Nov 2002 20:16:52 +0000
From: John Imrie <john@imrie37.fsnet.co.uk>
Subject: Re: Help with a regular expression
Message-Id: <3DD2B334.9050909@imrie37.fsnet.co.uk>
John Imrie wrote:
>
>
> Peter J. Acklam wrote:
>
>> godzilla <barryk2@delete_me.mts.net> wrote:
>>
>>
>>> You need to use minimal pattern matching (sometimes refered to
>>> as non- greedy).
>>>
>>> $line =~ s!::(\S*?)::!<img src=\"$1.gif\">!gi;
>>>
>>
>>
>
> I like that. I tend to forget about the minimal stuff. However I like to
> be a bit more strict with my regxes so I'd do it as
>
> $line =~ s!::([^:]+)::!<img src="$1.gif">!g;
>
> John Imrie
>
I've been thinking about this and it won't work if your data looks like
this is text ::fred:flintstone::
In that case I'd go with the patern above
------------------------------
Date: Wed, 13 Nov 2002 21:19:26 +0000 (UTC)
From: Pierre Asselin <pa@panix.com>
Subject: Re: Help with https and lwp
Message-Id: <aqufkr$25j$1@reader1.panix.com>
In <Pine.GSO.4.44.0211130852040.12616-100000@pine> ETAN WEINTRAUB <eweintra@jhmi.edu> writes:
>> > 500 (Internal Server Error) Can't connect to localhost:443 ()
>> > Client-Date: Tue, 12 Nov 2002 20:32:21 GMT
>[ ... ]
>Nope, https:// does work at the site. Checked that before I even thought
>of posting here....
I think the "Can't connect" is generated by Solaris. Is there a
process listening on that interface and port? What does netstat say?
If the "Can't connect" is in fact generated by LWP, you can grep the
entire tree to find it and figure out exactly who's complaining about
what.
------------------------------
Date: 13 Nov 2002 13:07:33 -0800
From: matirxrabbit@Hotmail.com (Corey Andrews)
Subject: Re: Help! Bad Interperter: no such file or directory
Message-Id: <8e213620.0211131307.1c36bffb@posting.google.com>
matirxrabbit@Hotmail.com (Corey Andrews) wrote in message news:<8e213620.0211111926.1b507c09@posting.google.com>...
> Hey,
> I'm running slack 8.1, and for some odd reason, my perl scripts won't
> run. When I type in the cmd "perl script.pl" it tests and runs fine,
> but typing in the "./script.pl" by itself comes out with the error "
> bad interperter: no such file or directory ". Is this normal?
> Checking twice (using cmd "which perl")..i'm pretty sure I got
> everything down. It's chmod 755 and I even downloaded the most recent
> perl interperter to be sure. But it's still no go. I need to be able
> to run this correctly so my cgi scripts will work on my httpd server.
> Any ideas?
>
> Corey
Ah. I got it guys. I ftp downloaded the script from my Windows
machine under binary and that was the problem. Thanks.
Corey
------------------------------
Date: Wed, 13 Nov 2002 14:46:03 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: how do I turn off unicode on file I/O?
Message-Id: <3DD2ABFB.C81ECE47@earthlink.net>
Jamie Zawinski wrote:
>
> Can someone please explain to me how to break the legs off
> of Perl 5.8.0's Unicode support?
>
> I have files that have Latin1 characters in them. I want
> Perl to *not convert them at all*. My program wants to treat
> these files as simple bytes, with no interpretation.
>
> If I set $LANG to C, then everything works as expected, but
> I would like my program to work in the default locale that
> Red Hat 8 ships, which is "en_US.UTF-8". I'd rather not
> have to tell users "set $LANG before running this program."
If $LANG is set to a utf-8 locale, then that is an indication, from the
operating system, that all text files and terminal streams are in utf-8.
If the operating system is lying, that's not perl's fault.
If you have a text file which is encoded differently from the operating
system's preferred encoding, then either you should convert it, or else
you should use binmode() on that filehandle to specify precisely what
encoding it is in.
To tell perl to treat a filehandle as bytes, you can use:
binmode(FH, ":bytes");
or:
binmode(FH, ":raw");
or:
binmode(FH);
To tell perl that a filehandle is specifically latin-1, you can use:
use Encode;
binmode(FH, ":encoding(latin1)");
Or:
use Encode;
binmode(FH, ":encoding(iso-8859-1)");
In addition to using binmode, you can incorporate the file mode into the
open statement, such as:
open( FH, "<:raw", $filename ) or die "Couldn't open filename: $!";
If *all* of your filehandles will be in latin1, you might want to use
the open pragma.
use open IO => ':bytes';
Note that this only effects filehandles that have yet to be opened, not
ones which are opened before the open pragma was run.
You can also use the open pragma to change the encoding of your
program's stdin and stdout, by doing:
use open ':std', IO => ':bytes';
You can even do this on the commandline, using:
perl -Mopen=:std,IO,:bytes program.pl
For input and output to be seperate encodings, you can specify IN =>
:layer, OUT => :layer, instead of doing IO => :layer.
> I've tried all kinds of variants of "use bytes" and other
> things mentioned in the various man pages with no luck.
> I've also tried calling "setlocale" and setting $ENV{LANG}
> within the program, with no effect.
See perldoc perllocale to see what kind of effect setlocale has.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 13 Nov 2002 15:07:49 -0500
From: dmeyers+perl@panix.com
Subject: Re: how do I turn off unicode on file I/O?
Message-Id: <yobvg31p71m.fsf@panix2.panix.com>
Benjamin Goldberg <goldbb2@earthlink.net> writes:
> Jamie Zawinski wrote:
> >
> > Can someone please explain to me how to break the legs off
> > of Perl 5.8.0's Unicode support?
> > Red Hat 8 ships, which is "en_US.UTF-8". I'd rather not
> > have to tell users "set $LANG before running this program."
I have the same issue. Except that it gets a little worse...
> To tell perl to treat a filehandle as bytes, you can use:
> binmode(FH, ":bytes");
> or:
> binmode(FH, ":raw");
> or:
> binmode(FH);
etc. etc. - _very_ helpful - thanks!
However - the place I've run into this is not a file
I'm reading on stdin or a filehandle that I'm opening
explicitly - it's on the Date::Manip module.
Malformed UTF-8 character (unexpected continuation byte 0x81, with no
preceding start byte) at
/path/to/Date/Manip.pm line 5312.
He's got 8-bit characters embedded directly in the file in
names of weekdays and months and such in a variety of languages.
Unless I set the $LANG before I run Perl at all,
I get those error messages - it doesn't seem to
respond to changing the ENV in a BEGIN{} before
the use Date::Manip; line.
After reading your note, though, I tossed a
use open ':std', IO => ':bytes';
in front of the use Date::Manip; and it seems to
have shut the thing up.
Since I'd never used any unicode-anything before,
I'm hoping that this is unlikely to cause any troubles.
Am I correct in assuming that the above line effectively
is telling perl to behave, at least with respect to
stdio, as it did in 5.6.x?
Thanks, again
--d
--
------------------------------
Date: Wed, 13 Nov 2002 16:27:04 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: how do I turn off unicode on file I/O?
Message-Id: <3DD2C3A7.786245CC@earthlink.net>
dmeyers+perl@panix.com wrote:
[snip]
> However - the place I've run into this is not a file
> I'm reading on stdin or a filehandle that I'm opening
> explicitly - it's on the Date::Manip module.
>
> Malformed UTF-8 character (unexpected continuation byte 0x81, with
> no preceding start byte) at
> /path/to/Date/Manip.pm line 5312.
>
> He's got 8-bit characters embedded directly in the file in
> names of weekdays and months and such in a variety of languages.
The proper fix for this would be to alter Date/Manip.pm, and add a line
saying 'use encoding qw(latin1);" to it.
> Unless I set the $LANG before I run Perl at all,
> I get those error messages - it doesn't seem to
> respond to changing the ENV in a BEGIN{} before
> the use Date::Manip; line.
>
> After reading your note, though, I tossed a
>
> use open ':std', IO => ':bytes';
You don't need the ':std', unless you want to make STD{IN,OUT,ERR} into
bytes, too.
> in front of the use Date::Manip; and it seems to
> have shut the thing up.
>
> Since I'd never used any unicode-anything before,
> I'm hoping that this is unlikely to cause any troubles.
> Am I correct in assuming that the above line effectively
> is telling perl to behave, at least with respect to
> stdio, as it did in 5.6.x?
Actually, it's sorta telling perl to *misbehave* in a way that
counteracts another misbehavior :)
Perl source code should *NOT* have bytes with the high-bit set, unless
there's an explicit indication of what encoding it is. If there is no
explicit indication, then high-bits will get interpreted either as bytes
or as utf8 in a locale dependent way. The open pragma overrides this,
though.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Wed, 13 Nov 2002 14:39:33 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: Re: How to send variable to CGI from browser
Message-Id: <aqu9pl$mpf4@nrn2.NRCan.gc.ca>
"Asad" <g0khaasa@cdf.toronto.edu> wrote in message
news:Pine.LNX.4.30.0211131338170.1689-100000@b210-02.cdf...
> How can I send a variable to a perl script. I know how to do that if I am
> using a form, but what if I have a hyperlink as follows:
>
> <a href="cgi-bin/fetchMovies.pl" target="content">Movies</a><br/>
>
> and I want to send in a variable that holds lets say the string "movies".
> How can I do that?
<a href="cgi-bin/fetchMovies.pl?variable=this&other_variable=that"
target="content">Movies</a><br/>
By using:
use CGI qw(param);
$variable = param("variable"); # $variable now contains "this"
$other_variable = param("other_variable"); # $other_variable now contains
"that"
Christian
------------------------------
Date: Wed, 13 Nov 2002 14:15:23 -0800
From: kyi <kyi@kyi.sytes.net>
Subject: pattern matching
Message-Id: <ut5jnrru9a7ga0@corp.supernews.com>
I have been trying to create a script to match email address patterns in a
text file. All I seem to be able to get is the entire line the email
address is on and not just the address it self. I am still very new to perl
and if someone could point me to the correct documents to get this workng I
would very much apperciate it. Below is a sample of what the text doc looks
like.
Dave Sixpack <dsixpack@ci.someplace.ca.us>
Gus Sixpack <gsixpack@ci.someplace.ca.us>
"Steve Sixpack, <SSixpack@ci.someplace.ca.us>"
"Terry M. Sixpack, <KSixpackd@ci.someplace.ca.us>"
City Stop <citystop@ci.someplace.ca.us>
There are more then 2000 lines like this, so editing it by hand is not an
option.
Thanks in advance for any help.
- Jayson Garrell
------------------------------
Date: Wed, 13 Nov 2002 23:45:35 +0100
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: pattern matching
Message-Id: <aqukmf$5hp$00$1@news.t-online.com>
Also sprach kyi:
> I have been trying to create a script to match email address patterns in a
> text file. All I seem to be able to get is the entire line the email
> address is on and not just the address it self. I am still very new to perl
> and if someone could point me to the correct documents to get this workng I
> would very much apperciate it. Below is a sample of what the text doc looks
> like.
You don't show us what you tried.
> Dave Sixpack <dsixpack@ci.someplace.ca.us>
> Gus Sixpack <gsixpack@ci.someplace.ca.us>
> "Steve Sixpack, <SSixpack@ci.someplace.ca.us>"
> "Terry M. Sixpack, <KSixpackd@ci.someplace.ca.us>"
> City Stop <citystop@ci.someplace.ca.us>
Try:
my ($email) = $line =~ /<(.*?)>/;
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Wed, 13 Nov 2002 15:34:36 -0500
From: Michael J Wilusz <mjwilusz@acsu.buffalo.edu>
Subject: Perl newbie w/ code
Message-Id: <aqucvn$9es$1@prometheus.acsu.buffalo.edu>
Hey Again,
Well, I took about a half hour, looked through an online Perl book and
just wrote some preliminary code. I took the steps Mr. Chang had given and
broke those down (as you can see below) and tried to match code up to them.
I must say step 4 is giving me some trouble. I looked through the book, and
wasn't sure exactly what to do. I tried looking through a chapter on file
manipulation, but it doesn't seem to have anything pertaining to seprating
the information. Ah well... give it a look over... tell me what you all
think. I know Doug (my supervisor) floats around in this group, so if you
see this Doug, maybe you can point me to the right chapter or such. Have a
good day all!
-Mike
1. print the heading;
print " Phone Book\n"; #prints "Phone Book" followed by a new line
print "Name Phone Number";
2. open the file (look up open in
the the text and also read the perlopentut documentation);
chdir ("/ubfs/shared/cit/HelpDesk/Ushsoft/databases"); #Switches to
directory of the names.dat
$file="names.dat"; #opens the names.dat
3. read the lines
from the file (probably the same chapter in the text);
open (DATFILE, "names.dat"); #opens the names.dat and sets as type DATFILE
4. split each line into a list of the separate fields
5. print out the designated fields
6. making the necessary adjustment to the phone number
8. close the file
------------------------------
Date: Wed, 13 Nov 2002 21:47:53 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Perl newbie w/ code
Message-Id: <Xns92C5AAE0E3939dkwwashere@216.168.3.30>
Michael J Wilusz <mjwilusz@acsu.buffalo.edu> wrote on 13 Nov 2002:
> Hey Again,
> Well, I took about a half hour, looked through an online Perl book
> and
> just wrote some preliminary code. I took the steps Mr. Chang had given
> and broke those down (as you can see below) and tried to match code up
> to them. I must say step 4 is giving me some trouble. I looked through
> the book, and wasn't sure exactly what to do. I tried looking through a
> chapter on file manipulation, but it doesn't seem to have anything
> pertaining to seprating the information. Ah well... give it a look
> over... tell me what you all think. I know Doug (my supervisor) floats
> around in this group, so if you see this Doug, maybe you can point me to
> the right chapter or such. Have a good day all!
use strict;
use warnings;
These lines should start every Perl program you write. They will make you
be more careful and will also give you informative error messages when you
do something wrong or questionable.
> 1. print the heading;
>
> print " Phone Book\n"; #prints "Phone Book" followed by a new line
> print "Name Phone Number";
You probably want a newline at the end here, too.
>
> 2. open the file (look up open in
> the the text and also read the perlopentut documentation);
>
> chdir ("/ubfs/shared/cit/HelpDesk/Ushsoft/databases"); #Switches to
> directory of the names.dat
There's nothing particularly wrong with this, but it's (usually) not
necessary unless you really need to be operating in that directory.
> $file="names.dat"; #opens the names.dat
This line only sets the value of $file to 'names.dat'.
To open the file, you could do something like
open DATFILE, "/ubfs/shared/cit/HelpDesk/Ushsoft/databases/names.dat"
or die "Cannot open names.dat: $!";
Or even
my $file = "/ubfs/shared/cit/HelpDesk/Ushsoft/databases/names.dat";
open DATFILE, $file or die "Cannot open $file: $!";
(Notice that I declared $file using the my() function)
>
> 3. read the lines
> from the file (probably the same chapter in the text);
>
> open (DATFILE, "names.dat"); #opens the names.dat and sets as type
> DATFILE
It's opening the file for reading and associating the filehandle DATFILE
with it. There's no such thing as 'type DATFILE', at least not in Perl.
You should *always* check to see if the open() succeeded, as shown above.
That's the "or die" part: if the open doesn't succeed, the die() stops the
program and prints an error message.
Now that the file is opened, we can start reading it:
while (<DATFILE>) {
# do stuff with an input line
}
>
> 4. split each line into a list of the separate fields
perldoc -f split
> 5. print out the designated fields
>
> 6. making the necessary adjustment to the phone number
I didn't see the earlier post -- but shouldn't these steps be reversed?
Adjust the phone number and THEN print it?
> 8. close the file
perldoc -f close
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Wed, 13 Nov 2002 14:09:30 -0800
From: Steven May <stevenm@blackwater-pacific.com>
Subject: Re: Perl newbie w/ code
Message-Id: <aquiak$pru$1@quark.scn.rain.com>
David K. Wall wrote:
> Michael J Wilusz <mjwilusz@acsu.buffalo.edu> wrote on 13 Nov 2002:
>
>
>>Hey Again,
>> Well, I took about a half hour, looked through an online Perl book
>> and
>>just wrote some preliminary code. I took the steps Mr. Chang had given
>>and broke those down (as you can see below) and tried to match code up
>>to them. I must say step 4 is giving me some trouble. I looked through
>>the book, and wasn't sure exactly what to do. I tried looking through a
>>chapter on file manipulation, but it doesn't seem to have anything
>>pertaining to seprating the information. Ah well... give it a look
>>over... tell me what you all think. I know Doug (my supervisor) floats
>>around in this group, so if you see this Doug, maybe you can point me to
>>the right chapter or such. Have a good day all!
>
>
> use strict;
> use warnings;
>
> These lines should start every Perl program you write. They will make you
> be more careful and will also give you informative error messages when you
> do something wrong or questionable.
>
>
>>1. print the heading;
>>
>>print " Phone Book\n"; #prints "Phone Book" followed by a new line
>>print "Name Phone Number";
>
>
> You probably want a newline at the end here, too.
>
>
>>2. open the file (look up open in
>>the the text and also read the perlopentut documentation);
>>
>>chdir ("/ubfs/shared/cit/HelpDesk/Ushsoft/databases"); #Switches to
>>directory of the names.dat
>
>
> There's nothing particularly wrong with this, but it's (usually) not
> necessary unless you really need to be operating in that directory.
>
>
>>$file="names.dat"; #opens the names.dat
>
>
> This line only sets the value of $file to 'names.dat'.
>
> To open the file, you could do something like
>
> open DATFILE, "/ubfs/shared/cit/HelpDesk/Ushsoft/databases/names.dat"
> or die "Cannot open names.dat: $!";
>
> Or even
>
> my $file = "/ubfs/shared/cit/HelpDesk/Ushsoft/databases/names.dat";
> open DATFILE, $file or die "Cannot open $file: $!";
>
> (Notice that I declared $file using the my() function)
>
>
>>3. read the lines
>>from the file (probably the same chapter in the text);
>>
>>open (DATFILE, "names.dat"); #opens the names.dat and sets as type
>>DATFILE
>
>
> It's opening the file for reading and associating the filehandle DATFILE
> with it. There's no such thing as 'type DATFILE', at least not in Perl.
>
> You should *always* check to see if the open() succeeded, as shown above.
> That's the "or die" part: if the open doesn't succeed, the die() stops the
> program and prints an error message.
>
> Now that the file is opened, we can start reading it:
>
> while (<DATFILE>) {
>
> # do stuff with an input line
>
> }
>
>
>>4. split each line into a list of the separate fields
>
>
> perldoc -f split
>
>
>>5. print out the designated fields
>>
The OP should also take a look at either substr or format if he wants
the colums to line up properly.
s.
------------------------------
Date: Wed, 13 Nov 2002 23:22:46 +0100
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Perl newbie w/ code
Message-Id: <aqujbl$g5g$06$1@news.t-online.com>
Also sprach Michael J Wilusz:
> Well, I took about a half hour, looked through an online Perl book and
> just wrote some preliminary code. I took the steps Mr. Chang had given and
> broke those down (as you can see below) and tried to match code up to them.
> I must say step 4 is giving me some trouble. I looked through the book, and
> wasn't sure exactly what to do. I tried looking through a chapter on file
> manipulation, but it doesn't seem to have anything pertaining to seprating
> the information. Ah well... give it a look over... tell me what you all
> think. I know Doug (my supervisor) floats around in this group, so if you
> see this Doug, maybe you can point me to the right chapter or such. Have a
> good day all!
>
>
> -Mike
>
>
> 1. print the heading;
>
> print " Phone Book\n"; #prints "Phone Book" followed by a new line
> print "Name Phone Number";
>
> 2. open the file (look up open in
> the the text and also read the perlopentut documentation);
>
> chdir ("/ubfs/shared/cit/HelpDesk/Ushsoft/databases"); #Switches to
> directory of the names.dat
> $file="names.dat"; #opens the names.dat
^^^^^^^^^^^^^^^^^^^
This comment is misleading. So far, you are only assigning a string to
the scalar variable $file.
Also, you probably don't need the chdir(). open() can easily deal with
absolute paths.
> 3. read the lines
> from the file (probably the same chapter in the text);
>
> open (DATFILE, "names.dat"); #opens the names.dat and sets as type DATFILE
Now this does actually the open while it does not yet read anything.
Furthermore, it is always a good thing to check for the success of your
operations. open() can fail for a number of reasons in which case it is
probably not reasonable to proceed with the script. $! will tell you
what went wrong:
open DATFILE, "/ubfs/shared/cit/HelpDesk/Ushsoft/databases/names.dat"
or die "Error opening file: $!";
Some blanks from now on? ;-)
> 4. split each line into a list of the separate fields
Each line commonly means:
while(<DATFILE>) {
# each line now in $_
chomp; # removes line endings
...
}
Since I forgot the exact format of your file I can't give you a proper
split statement. It would look like:
my @fields = split /pattern/; # splits $_
Or you use named scalars for the fields:
my ($name, $phone, ...) = split /pattern/;
> 5. print out the designated fields
This should be easy.
> 6. making the necessary adjustment to the phone number
Possibly a regex:
$phone =~ s/$pattern/$replace/;
Useful documentation on that to be found in perlretut.pod and
perlre.pod where the latter is the reference material.
> 8. close the file
close DATFILE;
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Wed, 13 Nov 2002 23:37:36 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Perl newbie w/ code
Message-Id: <Pine.LNX.4.40.0211132150020.18654-100000@lxplus071.cern.ch>
On Nov 13, Michael J Wilusz inscribed on the eternal scroll:
> print " Phone Book\n"; #prints "Phone Book" followed by a new line
The comment, if there is one, should rather say something like "print
the heading". Comments which only repeat the obvious action of the
program statement are pointless: if a comment is worth anything at
all, then it should explain the context of the action, its purpose, or
some special feature of why it's being done this way - rather than
some other, perhaps more-obvious, way.
> chdir ("/ubfs/shared/cit/HelpDesk/Ushsoft/databases"); #Switches to
> directory of the names.dat
As a comment, that was rather better: it explains why, rather than
merely restating the obvious.
However, I think you'll find that it's more usual to program an 'open'
of the complete file path, rather than first changing directory and
then opening the file name alone.
> $file="names.dat"; #opens the names.dat
No, it doesn't!!
> open (DATFILE, "names.dat"); #opens the names.dat and sets as type DATFILE
Never do anything like that without testing for success and taking
appropriate action on failure.
One suspects that "names.dat" was meant to be $file
And saying 'as type DATAFILE' seemed a bit odd. It's a filehandle,
not a 'type'.
In any case - if it's not meant to be interpolated, then 'names.dat'
would be better than "names.dat". (double-quotish context calls for
interpolation, but there isn't any, and then the reader starts to
wonder what's gone wrong).
good luck with yr assignment
------------------------------
Date: Wed, 13 Nov 2002 22:55:45 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Simple question - What is unicode?
Message-Id: <pkent77tea-7DE73B.22554413112002@news-text.blueyonder.co.uk>
In article <0r24tusf4iu0sgep6o3gpg1gpb32vurnl3@4ax.com>,
Bart Lateur <bart.lateur@pandora.be> wrote:
> pkent wrote:
> >So rather than a literal ;left single
> >smart quote' you have to put '–' or whatever in your XML.
...
> There you can see that the "left single smart quote" is hex 0x91, or
> decimal 145, in Windows (150 is the "ndash"); but hex 0x2018, decimal
hence the "or whatever" - I just made up the number 150 there. I think I
did know the number was the Unicode code point, actually, but it was
late :-/
ObXML:
In any case, I spent a couple hours today systematically kicking
XML::Parser with
my $p = new XML::Parser(blah blah => 'Tree');
my $x = some data read from an XML file
my $res = $p->parse( $x );
which dies with "Can't use string "<?xml stuff from the file..." as
symbol ref while 'strict refs' in force" or similar.
Could I reproduce the error? Go on, guess.
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: 13 Nov 2002 22:29:57 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: UTF8 counting first octet hi bits
Message-Id: <1037226597.872218@elaine.furryape.com>
In article <B9F6EDE3.49EF%ekulis@apple.com>,
Ed Kulis <ekulis@apple.com> wrote:
>I'd like some clever way to determing the number of bits before the 0.
#!/usr/bin/perl -w
use strict;
my @a = ( "\x7f","\x8f","\xcf","\xef","\xf7","\xf9","\xfd","\xfe","\xff");
foreach(@a){
(my $bin=unpack("B8",$_)) =~ s/^(1*)/length($1)/e;
print $bin,"\n";
}
------------------------------
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 4115
***************************************