[25410] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 7655 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 15 18:05:30 2005

Date: Sat, 15 Jan 2005 15:05:09 -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           Sat, 15 Jan 2005     Volume: 10 Number: 7655

Today's topics:
    Re: Adding a delimiter inbetween number characters and  <bik.mido@tiscalinet.it>
    Re: Adding a delimiter inbetween number characters and  <news@chaos-net.de>
    Re: convention regarding lexical filehandles <abigail@abigail.nl>
    Re: convention regarding lexical filehandles <abigail@abigail.nl>
    Re: How to convert MS doc to plain text using Perl on u <s.patterson@freeuk.com>
    Re: How to convert MS doc to plain text using Perl on u <1usa@llenroc.ude.invalid>
        Perl error <travisq@gmail.com>
    Re: Perl error <1usa@llenroc.ude.invalid>
    Re: Perl error <spamtrap@dot-app.org>
    Re: system command on Win98 <kalinaubears@iinet.net.au>
    Re: system command on Win98 <mikeflan@earthlink.net>
    Re: system command on Win98 <mikeflan@earthlink.net>
    Re: system command on Win98 <1usa@llenroc.ude.invalid>
    Re: system command on Win98 <1usa@llenroc.ude.invalid>
    Re: utf-8, was Re: Three questions: UTF-8, DBM, hash of <groleau+news@freeshell.org>
    Re: utf-8, was Re: Three questions: UTF-8, DBM, hash of <flavell@ph.gla.ac.uk>
    Re: VB to Perl <matternc@comcast.net>
    Re: VB to Perl <groleau+news@freeshell.org>
    Re: VB to Perl <1usa@llenroc.ude.invalid>
    Re: VB to Perl <tadmc@augustmail.com>
    Re: VB to Perl <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 15 Jan 2005 20:56:27 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <kisiu01jfjsp00b9dkenig0a46f6gijalc@4ax.com>

On 15 Jan 2005 13:12:21 GMT, Martin Kissner <news@chaos-net.de> wrote:

>In my second attempt - I repeat it here for your convenience - I tried
>a diffrent approach.
>
>    [...]
>    local $/;
>    my $content = <DATA>; 
>    $content =~ s/\n\D//g;
>    $content =~ s/(^\d+|\n\d)/$1-/g;
>    print $content;
>    [...]
>
>Now I wonder whether there might be a performance penalty when
>processing very large files.
>I would guess yes; Is that right?
>If there is another point of criticism, please let me know.

Well, let's say that generally it is advised not to slurp a whole file
in, if possible. It will indeed be memory consuming if the file is
"large". How large "large" really is depends on many factors. I'd say
that if processing line by line is doable then IMHO it should be done,
just to be sure.

Apart from this I only can add that instead of $content I'd use $_, so
that I could save some keystrokes a la:

     s/\n\D//g;
     s/(^\d+|\n\d)/$1-/g;
     print;

Also, the first regex removes the non-digit charachter: you may want
to do

     s/\n(?=\D)//g;

instead. And the second one has an error in it (a typo?), but even
fixing that, I'd do

     s/^(\d+)/$1-/gm;

instead.


HTH,
Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


------------------------------

Date: 15 Jan 2005 21:59:29 GMT
From: Martin Kissner <news@chaos-net.de>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <slrncuj4i1.6s3.news@maki.homeunix.net>

Michele Dondi wrote :
> On 15 Jan 2005 13:12:21 GMT, Martin Kissner <news@chaos-net.de> wrote:
>
>
> Apart from this I only can add that instead of $content I'd use $_, so
> that I could save some keystrokes a la:
>
>      s/\n\D//g;
>      s/(^\d+|\n\d)/$1-/g;
>      print;

Thanks for that hint.
I use $_ far to rarely.

> Also, the first regex removes the non-digit charachter:

Shame on me.
I should have used less confusing exampledata

>
>      s/\n(?=\D)//g;
>

I din't know (?=...) .
After consulting the docs its clear what this does.
I had used s/\n(\D)/$1/g

> [...] And the second one has an error in it (a typo?), but even
> fixing that, I'd do
>
>      s/^(\d+)/$1-/gm;

I first had trouble with this substitution, because I startet with
searching for the pattern \n\d, but this misses the first line.
your pattern, of course, is much more elegant.

Thanks for your advice.
This helped a lot.

Martin

-- 
Epur Si Muove (Gallileo Gallilei)


------------------------------

Date: 15 Jan 2005 22:10:38 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: convention regarding lexical filehandles
Message-Id: <slrncuj56u.5au.abigail@alexandra.abigail.nl>

Michele Dondi (bik.mido@tiscalinet.it) wrote on MMMMCLV September
MCMXCIII in <URL:news:q64iu0tuoqtn682ae81cte2ilvuq90hm39@4ax.com>:
\\  
\\  Using the two args form of open() leaves a big security hole.

No, it doesn't have to. People where able to write Perl 5.005 programs
without having security holes.



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s};;;
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};                # Perl 5.6.0 broke this...
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


------------------------------

Date: 15 Jan 2005 22:11:19 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: convention regarding lexical filehandles
Message-Id: <slrncuj587.5au.abigail@alexandra.abigail.nl>

Michele Dondi (bik.mido@tiscalinet.it) wrote on MMMMCLV September
MCMXCIII in <URL:news:lfnhu0d5irl5b2q6tp3ulb9fgst4dske8s@4ax.com>:
][  On 14 Jan 2005 22:43:10 GMT, Abigail <abigail@abigail.nl> wrote:
][  
][ >And a - is a valid character in most file systems as well. Yet 'rm -r'
][ >doesn't remove the file. Is rm broken?
][  
][  rm -- -r


perl-program "./>file.txt"



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


------------------------------

Date: Sat, 15 Jan 2005 19:12:34 +0000
From: Stephen Patterson <s.patterson@freeuk.com>
Subject: Re: How to convert MS doc to plain text using Perl on unix
Message-Id: <34t8d9F4ebb01U1@individual.net>

Diandian Zhang wrote:
> Does anyone have an idea, how to do this? Thanks!

If you're on windows and have word, Win32::OLE


------------------------------

Date: 15 Jan 2005 22:22:01 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How to convert MS doc to plain text using Perl on unix
Message-Id: <Xns95DFB0AD233DCasu1cornelledu@132.236.56.8>

Stephen Patterson <s.patterson@freeuk.com> wrote in news:34t8d9F4ebb01U1
@individual.net:

> Diandian Zhang wrote:
>> Does anyone have an idea, how to do this? Thanks!
> 
> If you're on windows and have word, Win32::OLE

Once again, the perils of putting your entire question in the subject 
line are demonstrated.

The OP needs this on Unix.

One alternative is to take a look at word2x (google for it).

On the other hand, if all one wants to is, say, to index contents of a 
Word file, the following would work to a certain extent:

#! /usr/bin/perl

use strict;
use warnings;

use File::Slurp;

my $word_file = shift;
my $doc = read_file($word_file, binmode => ':raw');

$doc =~ s/[^\015\012\011\040-\176]//g;
write_file(\*STDOUT, $doc);

__END__

Sinan


------------------------------

Date: 15 Jan 2005 13:08:17 -0800
From: "quartet" <travisq@gmail.com>
Subject: Perl error
Message-Id: <1105823297.270006.258140@z14g2000cwz.googlegroups.com>

Can someone tell me why this script is failing with, "Use of
uninitialized value in string at ./xmldoc line 16."


use XML::Simple;
#use Data::Dumper;
#use Carp;

my ($xml,$data);

$xml = new XML::Simple;

$data = $xml->XMLin("/tmp/config.xml");
#print Dumper($data)

print "$data->{PostBindUID}";



------------------------------

Date: 15 Jan 2005 21:29:45 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl error
Message-Id: <Xns95DFA7D034E19asu1cornelledu@132.236.56.8>

"quartet" <travisq@gmail.com> wrote in news:1105823297.270006.258140
@z14g2000cwz.googlegroups.com:

> Can someone tell me why this script is failing with, "Use of
> uninitialized value in string at ./xmldoc line 16."

The subject line of your post is incorrect. It should have been 
"programmer error".

> use XML::Simple;
> #use Data::Dumper;
> #use Carp;

use strict;
use warnings;

missing.

> my ($xml,$data);
> 
> $xml = new XML::Simple;
> 
> $data = $xml->XMLin("/tmp/config.xml");

Did this call succeed? You are the only one who can know but you choose 
not to tell us. What are we to do?

> #print Dumper($data)
> 
> print "$data->{PostBindUID}";

Please read the posting guidelines for this group and follow the steps 
suggested in that document when posting here.

Sinan. 



------------------------------

Date: Sat, 15 Jan 2005 17:30:12 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Perl error
Message-Id: <fvOdnRHcBLjoBHTcRVn-qg@adelphia.com>

quartet wrote:

> Can someone tell me why this script is failing with, "Use of
> uninitialized value in string at ./xmldoc line 16."

The script you posted is twelve lines long, therefore there is no line 16 to
have an error. Please post your real script.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


------------------------------

Date: Sat, 15 Jan 2005 20:43:13 +0000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: system command on Win98
Message-Id: <41e98fe3$0$999$5a62ac22@per-qv1-newsreader-01.iinet.net.au>

Mike Flannigan wrote:
> On Win2000, my scripts that execute another program
> with system (or exec) work fine.  But when I try the
> same scripts on Win98, it gives an error "bad command
> or file name" when it hits the system (or exec) command.
> 

That means that the shell doesn't understand the system command. You 
have to set things up so that the shell does understand the command - 
which, for a start, would involve making sure that the file in question 
exists in the system path on the 98 box. You'll also need to add the 
'.fch' extension to the pathext system variable. (I would have to do 
precisely the same on my 2k box if I wanted to run that system command.)

Cheers,
Rob

-- 
To reply by email u have to take out the u in kalinaubears.



------------------------------

Date: Sat, 15 Jan 2005 22:35:33 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: system command on Win98
Message-Id: <41E99AEE.F0C94A2B@earthlink.net>


"A. Sinan Unur" wrote:

>
> What are you talking about? That discussion is entitled "How do I fork a
> process under Win 32?"
>
> You mentioned system or exec. The two do different things. Which one is it?
>

My problem is with system, which I read somewhere creates
a fork to execute the file, but maybe I am wrong about that.


> Post a short but complete script others can run.

My script is:
use strict;
use warnings;

system 'lltost.fch';

__END__

But I don't expect others can run that as-is.

I guess a better generic test would be:
system 'C:/Windows/explorer.exe';
which also does not work for me (does not fire up explorer),
but at least it does not give a warning or error.  It just
runs, terminates, and does not appear to do anything
useful.


> Describe what happens and
> what you thought would happen. Read the posting guidelines for this group
> for more information on how to post here.

I did describe what happened.  I expected the program
to run as it does on my Win2000 machine.


> > I also see that the shell on Win98 sucks.
>
> It works.

Yeah, but it doesn't seem to keep a historical record of
typed lines that can be recalled with the up arrow.
That's why I say it sucks.  I need to see if I can
find another one that I like better.


> > The command I am using is:
> > system 'lltost.fch';
>
> What on God's Orange Titan is lltost.fch??? Does that file exist? Is that
> really an executable? If not, does the associated application exist? If it
> does, have you tried

Yes, the file is in the same directory as the perl script
that I am running.  It is associated with an application
and runs fine if you double click on it.

It is a programing language that I create with the
Perl script and then execute immediately.


> system 'start lltost.fch';
>
> If you have done these things, why are you hiding the information? If
> haven't why not?

I'm not sure I understand you here, but I did not
previously try the 'start lltost.fch'.  I just tried it
now for the first time and it worked!  So thanks.

Yes, I should have figured that out from the
links I posted, but I tried about a hundred other
things and did not try that one until now.



Mike Flannigan




------------------------------

Date: Sat, 15 Jan 2005 22:39:23 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: system command on Win98
Message-Id: <41E99BD6.1A5C1FAA@earthlink.net>


Sisyphus wrote:

> That means that the shell doesn't understand the system command. You
> have to set things up so that the shell does understand the command -
> which, for a start, would involve making sure that the file in question
> exists in the system path on the 98 box. You'll also need to add the
> '.fch' extension to the pathext system variable. (I would have to do
> precisely the same on my 2k box if I wanted to run that system command.)
>
> Cheers,
> Rob

Thanks for the reply.

I put the directory in the path and that did not solve
the problem.  No change.  I'm kinda glad it didn't
solve the problem, because that would have confused
me, and proved that I don't understand Path.

system 'start lltost.fch' does work, thanks to Sinan pointing
that out.  Not sure why 98 needs that 'start' in there, but
apparently it does.

Thanks again,


Mike




------------------------------

Date: 15 Jan 2005 22:44:09 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: system command on Win98
Message-Id: <Xns95DFB46D28D58asu1cornelledu@132.236.56.8>

Mike Flannigan <mikeflan@earthlink.net> wrote in
news:41E99AEE.F0C94A2B@earthlink.net: 

> 
> "A. Sinan Unur" wrote:

>> > I also see that the shell on Win98 sucks.
>>
>> It works.
> 
> Yeah, but it doesn't seem to keep a historical record of
> typed lines that can be recalled with the up arrow.

Oh, well, you should familiarize yourself with the system you are 
working on. Try typing doskey on the command line. And, please do not 
ask follow up questions regarding this.

>> > The command I am using is:
>> > system 'lltost.fch';
>>
>> What on God's Orange Titan is lltost.fch??? Does that file exist? Is
>> that really an executable? If not, does the associated application
>> exist? If it does, have you tried
> 
> Yes, the file is in the same directory as the perl script
> that I am running.  It is associated with an application
> and runs fine if you double click on it.

The standard way to open such files from the command line on Windows 
systems (all of them) is to use start.

I suspect .fch appears in your PATHEXT environment variable on the Win2K 
system.

>> system 'start lltost.fch';
>>
>> If you have done these things, why are you hiding the information? If
>> haven't why not?
> 
> I'm not sure I understand you here, but I did not
> previously try the 'start lltost.fch'.  I just tried it
> now for the first time and it worked!  So thanks.

You asked an operating system question disguised as a Perl question. You 
created further confusion and work for the reader by including 
references to two utterly irrelevant articles on forking and ruby. 
Please do not consider this an accomplishment and try and avoid it in 
the future.

I repeat, you should familiarize yourself with the platform you are 
working on.

Sinan.


------------------------------

Date: 15 Jan 2005 22:48:30 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: system command on Win98
Message-Id: <Xns95DFB52A41A3asu1cornelledu@132.236.56.8>

Mike Flannigan <mikeflan@earthlink.net> wrote in
news:41E99BD6.1A5C1FAA@earthlink.net: 

> 
> Sisyphus wrote:
> 
>> That means that the shell doesn't understand the system command. You
>> have to set things up so that the shell does understand the command -
>> which, for a start, would involve making sure that the file in
>> question exists in the system path on the 98 box. You'll also need to
>> add the '.fch' extension to the pathext system variable. (I would
>> have to do precisely the same on my 2k box if I wanted to run that
>> system command.) 

> Thanks for the reply.

Odd, it does not look like you read it.

> 
> I put the directory in the path and that did not solve
> the problem.  No change.  I'm kinda glad it didn't
> solve the problem, because that would have confused
> me, and proved that I don't understand Path.

The variable being referred to is PATHEXT not PATH. I am not sure if it 
would work on Win 98, though (I still haven't turned on the Win 98 
machine).

Sinan.


------------------------------

Date: Sat, 15 Jan 2005 15:31:24 -0500
From: Wes Groleau <groleau+news@freeshell.org>
Subject: Re: utf-8, was Re: Three questions: UTF-8, DBM, hash of lists, ...
Message-Id: <uYGdnUK8eNa5H3TcRVn-tA@gbronline.com>

Alan J. Flavell wrote:
> There are no special awards for folding several questions into one 

No rewards expected or requested.

> hanging-off the original posting.  Confusion all round.

Welcome to Usenet.

>>1. At the moment, my source is pure ASCII, but I want to
>>   treat it as UTF-8 because the text I work with is UTF-8
>>   and my editor is configured accordingly. 
> 
> Please distinguish carefully between your program source and your 
> data.

I did.  When I said "source," I meant "source" and when
I said "text" I meant what you apparently call "data."

> As a matter of fact, us-ascii -is- a subset of utf-8 - utf-8 was 
> deliberately designed that way - but you *don't* have to use utf-8 
> encoding in your program source in order to process unicode data.

I know that.  However, I prefer that everything on my system
be interpreted as UTF-8, as I work with French, Spanish, Polish,
and Japanese.  The script is all ASCII _now_ but I could add
literals for searching or whatever at any time.

> In any case, Perl's unicode implementation is supposed to be 
> transparent, i.e you shouldn't normally need to know that its internal 
> representation happens to be utf-8.  What you /do/ need to know is 

I don't want to know what it does internally, as long as everything
comes out UTF-8 and is decoded as such going in.

> what encoding is used in your /external data/, and to tell Perl about 
> it at the appropriate time (e.g by an encoding layer on an I/O 
> statement).

Since I want _everything_ UTF-8, the appropriate time
is (if possible) at the beginning of the script.

> In many situations, you might be better advised to write unicode 
> characters into the source by means of their \x{..} representation.

My terminal renders the glyphs correctly when I 'cat' UTF-8.
Why should I have to look up the codes every time instead?
And although I can compose characters in hex, why should
I do that instead of cut-and-paste from the editor?

> Which is not to deny that there can also be situations where you'd 
> want to write unicode characters directly - but then you have to be a 
> lot more careful with how you edit and transfer your source code.
> See 
> http://www.perldoc.com/perl5.8.4/pod/perlunicode.html#Effects-of-Character-Semantics
> for more details.

Yes, I read that.  I'm trying to minimize the need for "being careful"
about all those ten zillion details by specifying "everything is UTF-8."

> -C is a request to use wide system calls.  It doesn't influence Perl's 
> interpretation of your program source or data "as such".

You're right:

man perlrun
 ....

As of 5.8.1, the "-C" can be followed either by a number or a list
of option letters.  The letters, their numeric values, and effects
are as follows; listing the letters is equal to summing the numbers.

    I     1    STDIN is assumed to be in UTF-8
    O     2    STDOUT will be in UTF-8
    E     4    STDERR will be in UTF-8
    S     7    I + O + E
    i     8    UTF-8 is the default PerlIO layer for input streams
    o    16    UTF-8 is the default PerlIO layer for output streams
    D    24    i + o

Seems to say -CSDA should handle all my IO (I left off the A because
I still have a little bit of resistance to overcome from the shell)
except for the script itself.  A detail I missed.  Not an issue yet,
but I'd like to fix it before it becomes one.

>> But
>>   another man page seemed to say that "use utf8;" covered
>>   something that -CSD did not, so I put that in, too. 
> 
> The perlunicode pod, for the version of Perl that you're using, should 
> be your "bible".  Don't go tossing-in arbitrary bits and pieces that 

I have 5.8.1 but no pod, so my 'elsewhere' is the man pages
derived from the pod.

> See what 
> http://www.perldoc.com/perl5.8.4/pod/perlunicode.html#Important-Caveats
> says about "use utf8;".

It says the same as my man page: that the pragma is needed
to "enable UTF-8" in scripts.  It doesn't say whether
"enable" means the script itself or the IO or both.
However, 'man perlrun' says the -CSD handles the IO,
and perlunicode says for script encoding, see encoding
which says that UTF-8 already works in scripts.

So, things are a little unclear.  I put in both, and
was able to read UTF-8 text, put it in a DBM hash, and
get it back out.  That's good enough for now.

-- 
Wes Groleau
   "Beware the barrenness of a busy life."
                                -- George Verwer



------------------------------

Date: Sat, 15 Jan 2005 22:00:10 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: utf-8, was Re: Three questions: UTF-8, DBM, hash of lists, ...
Message-Id: <Pine.LNX.4.61.0501152136500.22303@ppepc56.ph.gla.ac.uk>

On Sat, 15 Jan 2005, Wes Groleau wrote:

> Welcome to Usenet.

Indeed.  It seems from your response, and the rarity of responses from 
other contributors, that you're in the position to offer us all a 
valuable tutorial on the topic.

> I don't want to know what it does internally, as long as everything
> comes out UTF-8 and is decoded as such going in.

Fine, then we're pretty much up to speed already, and I'm sorry that I 
misinterpreted your original posting.

> > Which is not to deny that there can also be situations where you'd 
> > want to write unicode characters directly - but then you have to 
> > be a lot more careful with how you edit and transfer your source 
> > code. See 
> > http://www.perldoc.com/perl5.8.4/pod/perlunicode.html#Effects-of-Character-Semantics 
> > for more details.
> 
> Yes, I read that.  I'm trying to minimize the need for "being 
> careful" about all those ten zillion details by specifying 
> "everything is UTF-8."

Point made.  If you're really in control of all that data then you're 
in a much happier position than I've ever been ;-)

>    I     1    STDIN is assumed to be in UTF-8
>    O     2    STDOUT will be in UTF-8
>    E     4    STDERR will be in UTF-8
>    S     7    I + O + E
>    i     8    UTF-8 is the default PerlIO layer for input streams
>    o    16    UTF-8 is the default PerlIO layer for output streams
>    D    24    i + o
> 
> Seems to say -CSDA should handle all my IO 

It does, doesn't it?  Did I miss the specific problem you were having, 
and your test case that demonstrated it?

> > > But
> > >   another man page seemed to say that "use utf8;" covered
> > >   something that -CSD did not, so I put that in, too. 
> > 
> > The perlunicode pod, for the version of Perl that you're using, 
> > should be your "bible".  Don't go tossing-in arbitrary bits and 
> > pieces that
> 
> I have 5.8.1 but no pod, so my 'elsewhere' is the man pages
> derived from the pod.

No disagreement there.  More than one way to...read the documentation.

> > See what
> > http://www.perldoc.com/perl5.8.4/pod/perlunicode.html#Important-Caveats
> > says about "use utf8;".
> 
> It says the same as my man page: that the pragma is needed
> to "enable UTF-8" in scripts.

Hmmm?  At 5.8.4 (and I don't remember it being different in recent 
versions before that) it says [this'll need monospace display, and go 
sadly wrong with these newfangled usenet-ish interfaces, sorry]:

 As a compatibility measure, the use utf8 pragma must be explicitly 
 included to enable recognition of UTF-8 in the Perl scripts 
                                         ^^^^^^^^^^^^^^^^^^^
 themselves (in string or regular expression literals, or in 
 ^^^^^^^^^^
 identifier names) on ASCII-based machines or to recognize UTF-EBCDIC 
 on EBCDIC-based machines. These are the only times when an explicit
                                         ^^^^^^^^^^ 
 use utf8 is needed.

> However, 'man perlrun' says the -CSD handles the IO,

Indeed, and (fwiw) I don't see anything there about encoding of the 
script's source code itself.

> and perlunicode says for script encoding, see encoding
> which says that UTF-8 already works in scripts.

It "works", yes, but (as I understand it, anyway) I think you have to 
ask for it.  It could just be that if you call for locale-awareness 
with -CL, and you have utf-8 in your locale, it will come out in the 
wash; but I don't see any harm in asking for it directly, if you're so 
certain that you'll never not want it (sorry for the double-negative).

> So, things are a little unclear.  I put in both, 

Looks as if you're (a) right and (b) unlikely to cause any harm.

> was able to read UTF-8 text, put it in a DBM hash, and
> get it back out.  That's good enough for now.

Good luck


------------------------------

Date: Sat, 15 Jan 2005 14:12:42 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: VB to Perl
Message-Id: <w8adnbTLerK39nTcRVn-sA@comcast.com>

Robert Sedlacek wrote:

> Larry wrote:
> 
>> and I need to that in Perl!!
> 
> What? You haven't said what it does. Shall we learn VB to help you?
> 
> 
I'm not gonna learn VB.  I can't afford the IQ loss.

-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


------------------------------

Date: Sat, 15 Jan 2005 15:37:47 -0500
From: Wes Groleau <groleau+news@freeshell.org>
Subject: Re: VB to Perl
Message-Id: <ZIGdnfWztcg-HnTcRVn-rg@gbronline.com>

Larry wrote:
> Hi all,
> 
> Sorry for gettin back on this question but I wasn't able to go about it!
> 
> Below is a chunk of VB code:
> 
> [vb]
> Private Type WaveInCaps
>    ManufacturerID As Integer
>    ProductID As Integer
>    DriverVersion As Long
>    ProductName(1 To 32) As Byte
>    Formats As Long
>    Channels As Integer
>    Reserved As Integer
> End Type

defines what Ada/Pascal calls a record, C or C++ a struct

> Dim Caps As WaveInCaps

Creates one of those and names it Caps

> Call waveInGetDevCaps(0, VarPtr(Caps), Len(Caps))

Calls a function and passes it some information
about Caps.

-- 
Wes Groleau
   "Two things are infinite, the universe and human stupidity.
    But I'm not so sure about the universe."
                                -- Albert Einstein


------------------------------

Date: 15 Jan 2005 21:23:44 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: VB to Perl
Message-Id: <Xns95DFA6CB41C29asu1cornelledu@132.236.56.8>

Larry <dontmewithme@got.it> wrote in news:dontmewithme-
EB45C4.18523315012005@twister2.tin.it:

> Sorry for gettin back on this question but I wasn't able to go 
> about it!
> 
> Below is a chunk of VB code:

This is a Windows 32 API call. Surprisingly enough, there is a Perl module 
called Win32::API on CPAN.

 ...

> and I need to that in Perl!!

Then you should consider trying to do it yourself first and posting 
questions about the _specific_ problems you encounter.

On the other hand, I am getting tired of pointing out this obvious maxim 
to people who are obviously never going to learn. Here's some untested 
code. Enjoy!

> sorry again!

Don't apologize. Just do what the posting guidelines suggest and there 
won't be any need for apologies. Useless apologies create just as much 
noise as asinine queries.

#! /usr/bin/perl

use strict;
use warnings;

use Win32::API;
use Win32::API::Struct;

use Data::Dumper;

Win32::API::Struct->typedef(WAVEINCAPS => qw(
        INT ManufacturerID;
        INT ProductID;
        LONG DriverVersion;
        TCHAR ProductName[32];
        LONG Formats;
        INT Channels;
        INT Reserved;
    )
);

Win32::API->Import(winmm => q{
    LRESULT waveInGetDevCaps(
        UINT_PTR     DeviceID,
        LPWAVEINCAPS pwic,
        UINT         cbwic
    )}
);

my $caps = Win32::API::Struct->new('WAVEINCAPS');

# You probably need a way of finding out a valid device id
# 0 seems suspect

my $result = waveInGetDevCaps(
    0, 
    $caps, 
    Win32::API::Struct->sizeof('WAVEINCAPS')
);

print Dumper $caps;

__END__


------------------------------

Date: Sat, 15 Jan 2005 13:21:06 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: VB to Perl
Message-Id: <slrncuir92.1gj.tadmc@magna.augustmail.com>

Larry <dontmewithme@got.it> wrote:


> Below is a chunk of VB code:

[snip\

> and I need to that in Perl!!


Step 1: Learn VB

Step 2: Learn Perl

Step 3: Convert the VB code to Perl code


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sat, 15 Jan 2005 22:55:09 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: VB to Perl
Message-Id: <hbhGd.298$ul4.248@trnddc01>

Wes Groleau wrote:
>> Below is a chunk of VB code:
[...]
> defines what Ada/Pascal calls a record, C or C++ a struct

The most similar data structure in Perl would probably be a hash.

>> Dim Caps As WaveInCaps
>
> Creates one of those and names it Caps

my %Caps;

>> Call waveInGetDevCaps(0, VarPtr(Caps), Len(Caps))
>
> Calls a function and passes it some information
> about Caps.

Maybe
    waveInGetDevCaps(0, $Caps{VarPrt}, $Caps{Len});

jue 




------------------------------

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 V10 Issue 7655
***************************************


home help back first fref pref prev next nref lref last post