[19939] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2134 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 14 18:11:16 2001

Date: Wed, 14 Nov 2001 15:10:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005779414-v10-i2134@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 14 Nov 2001     Volume: 10 Number: 2134

Today's topics:
    Re: Performance issues related to $&, $` and $' (Mark Jason Dominus)
    Re: ranged arrays <tsee@gmx.net>
    Re: ranged arrays <djberge@qwest.com>
    Re: ranged arrays (Mark Jason Dominus)
    Re: ranged arrays <tsee@gmx.net>
    Re: ranged arrays <tsee@gmx.net>
    Re: Returning peer information with IO:Sockets ? nobull@mail.com
    Re: scripting microsoft excel in perl? <ocscwar@h-after-ocsc.mit.edu>
    Re: scripting microsoft excel in perl? <bart.lateur@skynet.be>
    Re: socket buffering even with $| set nobull@mail.com
        socket can't be opend, filerights? <michael.stuttgart@gmx.de>
    Re: socket can't be opend, filerights? <usenet@stirfried.vegetable.org.uk>
    Re: stacked if statements <mgjv@tradingpost.com.au>
    Re: Trees, Memory mgt and GC in perl 5.005_3 <temp133@hotmail.com>
        Unicode Conversion <robin_corcoran@3b2.com>
    Re: Unicode Conversion (Mark Jason Dominus)
    Re: web page editing with browser <mikesl@wrq.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 14 Nov 2001 21:24:23 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Performance issues related to $&, $` and $'
Message-Id: <3bf2e106.6d7e$209@news.op.net>

In article <3BF2B989.C611942F@pop900.gsfc.nasa.gov>,
Michael Witkowski  <witkowsk@pop900.gsfc.nasa.gov> wrote:
>"Avoid $& and its two buddies, $` and $'. Any
>occurrence in your program causes all matches
>to save the searched string for possible future
>reference. (However, once you've blown it, it
>doesn't hurt to have more of them.)"
>
>First, does any of this apply to matched groups
>(ie $1, $2 etc)? 

It does, in some ways.

Here's the deal.  To maintain $`, $&, and $' takes time.  If you don't
use these variables anywhere in your program, Perl sees that it
doesn't need to maintain them, so it *doesn't* maintain them, and that
makes all the regexes in your program run faster.

But as soon as you use $& anywhere, *all* the regexes in your program
get slower, because Perl has no way to know at compile time which
regex might produce the value that it later used in $&.

In particular, if you a module uses $&, it slows down every regex in
every program that uses the module.

Regexes with parentheses in them are slower than regexes without
parenthese, because Perl has to maintain the values of $1 and the
rest.  This takes about the same amount of time as maintaining $&.

The difference is that using parentheses in one regex does *not*
affect the others.  Perl sees that one regex has parentheses and
another does not.  The regex with parentheses is indeed slow, but that
doesn't affect the one with no parentheses; it is still just as fast.

>Second, how global is the "blown it" clause on
>using the $[`'&] variables.   If I blow it in a
>procedure does it blow it all over my program or
>is it limited to that procedure?  

Everywhere.  Consider:

        $string =~ /pattern/;
        # 100 lines omitted
        if (something) { foo() }

        sub foo {
          print $&;
        }

/pattern/ must be compiled to maintain the $& information, because you
might call foo() later and print out the contents of $&.  So /pattern/
will run more slowly than if you were not planning to print out $&.

>Also, does the "blown it" clause apply to all subsequent matches
>regardless of their use of the $[`'&] variables?

The problem is that there is no way for Perl to tell which matches
correspond to uses of $&.  You can only know that at run time.
Consider the example above.  If 'something' is true, $& is needed; if
not, it isn't.  'something' might depend on the phase of the moon or
on a user response.  Even though the pattern match is 103 lines away
from the $&, you can't know that it isn't involved until it's too
late.

>Performance is becoming quite important to my
>project right now so any info on this or other items
>(not obvious in the manuals) would be appreciated.

Stay away from $&. You can get almost the same effect:

        #instead of this:
        $target =~ /pattern/;   
        print "$` $& $'\n";

        #use this:
        $target =~ /^(.*?)(pattern)(.*)$/s;   
        print "$1 $2 $3\n";

This is just as slow as using $` $& $', but it does not slow down the
*other* regexes in your program.


-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Wed, 14 Nov 2001 20:22:37 +0100
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: ranged arrays
Message-Id: <9sug8o$nlp$07$1@news.t-online.com>

"Logan Shaw" <logan@cs.utexas.edu> schrieb im Newsbeitrag
news:9suc2g$cqv$1@charity.cs.utexas.edu...
| In article <9su1ms$c5u$00$1@news.t-online.com>,
|
| If you can live with having a different syntax, you can could simply
| define a class that does bounded arrays.  The fact that recent versions
| of Perl have lvalue subroutines make that syntax a lot less ugly.
|
| You should be able to code it so that usign it looks something like
| this:
|
| use BoundedArray;
|
| $ba = BoundedArray->new(-5, 50);
|
| $ba->at(-3) = 17;
| print $ba->at(-3), "\n";
|
| Handling slices of the bounded array will be a little bit trickier, but
| I think even that can be done if you define a function that returns an
| lvalue array, and if that lvalue array is not the internal storage
| itself but an array that happens to be tied back to your object.

Worse yet, how would you realize a decent syntax for multi-dimensional
BoundedArray's?

use BoundedArray;

$ba = BoundedArray->new(-5, 50);

$ba->at(-3)         = BoundedArray->new(5,13);
$ba->at(-3)->at(10) = "This is horrible\n";

while ( 'eternity' ) {
   print $ba->at(-3)->at(10);
}

If this even works at all...

Steffen
--
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;print"\n";$o=$_;push@o,substr($o,$_*8,
8)for(0..24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\n";$i++}#st_m





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

Date: Wed, 14 Nov 2001 14:12:01 -0600
From: "Mr. Sunblade" <djberge@qwest.com>
Subject: Re: ranged arrays
Message-Id: <zaAI7.190$J13.110697@news.uswest.net>

"Steffen Müller" <tsee@gmx.net> wrote in message
news:9sue21$30a$06$3@news.t-online.com...
<big snip>
> | Another approach, which is a gross hack, is to create contexts on the
> | fly in which to set $[ and create your arrays.  Since this is so
> | thoroughly evil, I will speak about it no more.  (I'm not sure it's
> | even really possible.  "perldoc perlvar" says it's a compiler directive
> | now, and it "cannot influence the behavior of any other file", which
> | means little to me since in my mind files don't "behave".)
>
> That is so evil I haven't wasted more than... umm... one thought on it.
> Really, no more.

Hopefully I haven't misinterpreted "create contexts on the fly", but....

Have you considered the 'Want' module by Robin Houston?  Also available on
CPAN.  Much more flexible that *just* lvalue subs.  This module was a
God-send for me when trying to resolve a way to do method-chaining and
return different values based on context.

Regards,

Mr. Sunblade





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

Date: Wed, 14 Nov 2001 21:10:28 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: ranged arrays
Message-Id: <3bf2ddc2.6d2c$d6@news.op.net>

In article <9su1ms$c5u$00$1@news.t-online.com>,
Steffen Müller <tsee@gmx.net> wrote:
>    This and most of the rest work fine, but there's something that makes
>the whole attempt futile: Instead of passing negative index values to the
>appropriate methods, perl translates them to non-negatives the way we're
>used to with arrays starting at 0 by using FETCHSIZE.

Yes, that's a drag, isn't it?  As i recall this came up on p5p at a
time and a decision to make it work the way it does was taken.  That
is, it was not an oversight.

I was about to say:
        The nearest thing I know to a workaround is to use a tied hash instead.

But then I thought of a trick:

        tie @a => 'T';

        print "1: $a[1]\n";
        print "-1: $a[-1]\n";
        print "large: $a[2**30-1]\n";
        print "large: $a[-2**30]\n";

        package T;

        sub MAX () {2**31}

        sub TIEARRAY {
          return bless []  => 'T';
        }

        sub FETCHSIZE {
          return MAX;
        }

        sub FETCH {
          my ($s, $n) = @_;
          if ($n >= 2**30) {
            $n = $n - MAX;
          }
          # Now do something with $n
          print "FETCH called for index ($n)\n";
          return $n;
        } 


This seems to work really well, as long as you don't need indices
outside the range of 31-bit integers.

Do I get the prize?




-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Wed, 14 Nov 2001 22:41:36 +0100
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: ranged arrays
Message-Id: <9suoe8$n7a$01$1@news.t-online.com>

"Mark Jason Dominus" <mjd@plover.com> schrieb im Newsbeitrag
news:3bf2ddc2.6d2c$d6@news.op.net...
| In article <9su1ms$c5u$00$1@news.t-online.com>,
| Steffen Müller <tsee@gmx.net> wrote:
| >    This and most of the rest work fine, but there's something that makes
| >the whole attempt futile: Instead of passing negative index values to the
| >appropriate methods, perl translates them to non-negatives the way we're
| >used to with arrays starting at 0 by using FETCHSIZE.
|
| Yes, that's a drag, isn't it?  As i recall this came up on p5p at a
| time and a decision to make it work the way it does was taken.  That
| is, it was not an oversight.

I was careful not to shout BUG if it might be just the wanted behaviour.
Seems like I was right. :)

| But then I thought of a trick:
|
|         tie @a => 'T';

[snip test]

|         package T;
|
|         sub MAX () {2**31}

[snip TIEARRAY]

|         sub FETCHSIZE {return MAX;}
|
|         sub FETCH {
|           my ($s, $n) = @_;
|           if ($n >= 2**30) {
|             $n = $n - MAX;
|           }
[...]
|           return $n;
|         }
|
| This seems to work really well, as long as you don't need indices
| outside the range of 31-bit integers.
|
| Do I get the prize?

Yes, as long as you don't:

foreach (@a) {
   print $_,',';
}

The foreach uses FETCHSIZE, doesn't it?
Maybe I'm missing some point.

Steffen
--
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;$o=$_;push@o,substr($o,$_*8,8) for(0..
24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\r";$i++};print"\n"#stm





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

Date: Wed, 14 Nov 2001 22:46:05 +0100
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: ranged arrays
Message-Id: <9suoln$nak$06$1@news.t-online.com>

"Steffen Müller" <tsee@gmx.net> schrieb im Newsbeitrag
news:9suoe8$n7a$01$1@news.t-online.com...

[...]

| Yes, as long as you don't:
|
| foreach (@a) {
|    print $_,',';
| }
|
| The foreach uses FETCHSIZE, doesn't it?
| Maybe I'm missing some point.

Sorry for replying to myself, but I wanted to note that:
- I'm not missing the point that in your example, there is never a value
assigned to the internal array and
- I'm not missing the point that that's not possible without STORE either.

Steffen
--
$_=q;0cb212c210b0bb010c0113bb0c410c0b516c0bb3d212c2b0b0b016b6cb2b2c21010c0
b41110b3bba0e0c0d2c4b2b6bc013d2c0d0b01012b0b0;;s/\n//g;s/(\d)/$1<2?$1:'0'x
$1/ge;s/([a-f])/'1'x(ord($1)-97)/ge;$o=$_;push@o,substr($o,$_*8,8) for(0..
24);for(@o){print"\0"x(26-$i).chr(oct('0b'.($_)))."\r";$i++};print"\n"#stm





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

Date: 14 Nov 2001 19:49:13 +0000
From: nobull@mail.com
Subject: Re: Returning peer information with IO:Sockets ?
Message-Id: <u9u1vxjfpi.fsf@wcl-l.bham.ac.uk>

"Scott" <thechile@ntlworld.com> writes:

> Does anyone know if its possible to return peer info using IO:sockets. I
> know that if you just use UNIX sockets you can call getpeername and
> sockaddre_in etc.. to get the client ip and port number but i can't find any
> info on this with the perl module??

Try looking to the word 'getpeername' in the dcoumentation of
IO::Socket.

BTW handles created using the IO:: modules can still be used with the
builtin IO functions in Perl.  There's a builtin function in Perl that
gives access to the Unix getpeername() system call - guessing it's
name is left as an exercise for the reader.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 14 Nov 2001 16:40:02 -0500
From: Omri Schwarz <ocscwar@h-after-ocsc.mit.edu>
Subject: Re: scripting microsoft excel in perl?
Message-Id: <octsnbh3ubx.fsf@no-knife.mit.edu>

sniper <tnt.wade@verizon.net> writes:

> Please forgive me, but I am brand new to linux and perl (but already love 
> them and want to learn!).  I was wondering if there are any sites with 
> simple examples on how to script microsoft excel in perl?  Thanks in 
> advance.
> 
> sniper

Start with the archives of tpj.com
-- 
Omri Schwarz --- ocscwar@mit.edu ('h' before war) 
Timeless wisdom of biomedical engineering: "Noise is principally
due to the presence of the patient." -- R.F. Farr


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

Date: Wed, 14 Nov 2001 22:09:55 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: scripting microsoft excel in perl?
Message-Id: <caq5vt47tt804aido2i5g8s5en36rk71t1@4ax.com>

sniper wrote:

>Please forgive me, but I am brand new to linux and perl (but already love 
>them and want to learn!).  I was wondering if there are any sites with 
>simple examples on how to script microsoft excel in perl?  Thanks in 
>advance.

Not on Linux, I'd think. On Windows, provided you have Excel, you can
control it using Win32::OLE. There are some samples in the Win32 OLE FAQ
on
<http://aspn.activestate.com/ASPN/Reference/Products/ActivePerl/faq/Windows/ActivePerl-Winfaq12.html>

There are modules to read and write Excel files without Excel itself:
Spreadsheet::WriteExcel and Spreadsheet::ParseExcel (see CPAN,
<http://search.cpan.org/search?mode=module&query=Excel>).

Ooh and I found this FAQ on the web:
<http://homepage.tinet.ie/~jmcnamara/perl/PerlExcelFaq.html>. It looks
really great.

-- 
	Bart.


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

Date: 14 Nov 2001 19:56:11 +0000
From: nobull@mail.com
Subject: Re: socket buffering even with $| set
Message-Id: <u9r8r1jfdw.fsf@wcl-l.bham.ac.uk>

mau@beatles.cselt.it (Maurizio Codogno) writes:

> I am playing with sockets, but I still cannot unbuffer the output.

Output?  

There's no socket _output_ in the code you posted, only socket input.

> I read about the autoflush parameter, but it seems that it's doing
> nothing at all.
 
The autoflush parameter effects only output.

Anyhow the buffering in question is not in Perl's IO or C's IO or the
OS but in your program.

> print <$client>;

The reads _all_ input from the input stream $client until EOF an
condition and then prints it to the output stream.

For details see documentation of the <> operator.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 14 Nov 2001 20:39:25 +0100
From: "Michael" <michael.stuttgart@gmx.de>
Subject: socket can't be opend, filerights?
Message-Id: <9suhsh$gcj$1@news.online.de>

I have following problem:
A Webmailprogram uses perl Modul POP3Client.pm . Until a few days ago all
worked fine. Now it stopped working. Normal POP3 and SMTP works.
I recognized that opening a scoket through IO::Socket::INET->new fails. with
the message 'no rights' (mesage translated, original german)
There are no further messages in log.

When i run a little Testscript with the same functionality in the shell as
normal User it although dont works, as root the script works.
As normal user The conection with telnet localhost 110 works too.

In last time i changed the rights of some files in /etc to not world
readable. I think thats the problem, but i don't come closer to the real
problem.

Has anyone a tip which file i should give the world read rights again or how
i can solve the problem

OS: Suse Linux 7.2


--






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

Date: 14 Nov 2001 20:29:42 +0000
From: Tim Haynes <usenet@stirfried.vegetable.org.uk>
Subject: Re: socket can't be opend, filerights?
Message-Id: <86k7wt6qq1.fsf@potato.vegetable.org.uk>

"Michael" <michael.stuttgart@gmx.de> writes:

[snip]
> In last time i changed the rights of some files in /etc to not world
> readable. I think thats the problem, but i don't come closer to the real
> problem.

D'oh.

> Has anyone a tip which file i should give the world read rights again or
> how i can solve the problem

strace will tell you exactly which files it can't open.

Check /etc/{resolv.conf,hosts,nsswitch.conf}.

~Tim
-- 
   20:29:06 up 7 days, 22:27, 17 users,  load average: 0.04, 0.07, 0.08
piglet@stirfried.vegetable.org.uk |River of millions flow downstream
http://piglet.is.dreaming.org     |A golden highway to the sea of dreams


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

Date: Wed, 14 Nov 2001 22:38:43 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: stacked if statements
Message-Id: <slrn9v5skd.6ia.mgjv@verbruggen.comdyn.com.au>

On Wed, 14 Nov 2001 13:30:37 GMT,
	Mark Jason Dominus <mjd@plover.com> wrote:
> In article <slrn9v3t23.6ia.mgjv@verbruggen.comdyn.com.au>,
> Martien Verbruggen  <mgjv@tradingpost.com.au> wrote:
>>These ones get interpreted at run time:
>>
>>  $foo =~ 'pattern';
> 
><ilya>
> It does not.
> 
> Hope this helps,
></ilya>

You're right.

$pat = '\w';
$string =~ $pat;

does get compiled at runtime.

  $string =~ '\w';

and even

  $foo =~ ('\w' . '\w');

do not.

Is this some special case/optimisation where a constant string[1] as the
right hand side of the =~ operator always gets treated as a search
pattern? Or is a string not an expression, according to Perl? Or is
the documentation incomplete?

Martien

[1] or an expression that can be resolved to be a constant string at
compile time, maybe. Deparse seems to suggest (if I interpret this
correctly) that this translation happens at compile time:

$ perl -MO=Deparse -e '$foo =~ ("\\w" . "\\w")'
$foo =~ /\w\w/;
-e syntax OK

-- 
                                | 
Martien Verbruggen              | If at first you don't succeed, try
Trading Post Australia Pty Ltd  | again. Then quit; there's no use
                                | being a damn fool about it.


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

Date: Wed, 14 Nov 2001 12:15:53 -0800
From: "Arvin Portlock" <temp133@hotmail.com>
Subject: Re: Trees, Memory mgt and GC in perl 5.005_3
Message-Id: <9sujds$2i9q$1@agate.berkeley.edu>

Thank you Georges,

I did a lot of searching and checking on this issue but couldn't find
anything definitive. Some people say you only need to worry about
"external" references, i.e. those references which are available through
variable names or external data structures to the rest of the program.
Break those and the data structure eats itself up like a burning fuse
(a nice simile). Others seemed to have a more ambiguous view.

Anyway, I guess now I'm confused by what exactly is meant by
an external reference and why I would want or need to iterate through
my data structure deleting references to parent nodes, or why you
feel this might be easiest. All of my nodes are referenced as my
variables within subroutines. So when the program finishes they
should all pass out of scope. Only the root remains. Only the root
is accessible to the outside world. There seems to me to be a bit
of danger in this assumption, the user of the module assumes the
burden, but assuming that is actually the case, would undef'ing the
root be sufficient? Or do the references from one node to another
constitute external references? Yes, they are definitely circular but
are not "exposed." I may end up providing a subroutine which
explicitely iterates through the tree and deletes things, but now I'm
curious what is meant by external reference and whether deleting the
root would work if it is all that remains "exposed to the outside."


Logan Shaw <logan@cs.utexas.edu> wrote in message
news:9sslda$8qo$1@charity.cs.utexas.edu...
> In article <9sru20$1af3$1@agate.berkeley.edu>,
> Arvin Portlock <temp133@hotmail.com> wrote:
> >My question is how do I clean up the previous tree? I would simply undef
> >the root node but each node has a reference to its parent as well as
> >references to its siblings and its children.  I assume perl's GC relies
on
> >reference counting and since each node may have two references pointing
> >to it, nothing will get cleaned up.
>
> Almost.  It's not because the nodes have two references[1].  It's
> because there is a cycle.  (Your "tree" is not technically a tree.
> It's a directed graph with cycles.)
>
> The minimum you have to do to get Perl's garbage collector to clean up
> any data structure is to remove external references to it (through
> other data structures and through variable names bound to something in
> it) and break all cycles within it.  In your case, the easiest way to
> do this is to break the link from each child to its parent.  Then
> you'll have a true tree, and when you break the link to the root, the
> rest of it will fall like dominoes.
>
> There's some documentation on garbage collection in Perl available via
> "perldoc perlobj" if you want it.  It's under a heading called
> "Two-Phased Garbage Collection".
>
>   - Logan
>
> [1]  Here's an example of a data structure that will be fully
>      garbage collected even though $x's value has more than one
>      reference to it:
>
> my $root;
>
> {
>     my $x = 42;
>
>     $root = [ [ \$x ], [ \$x ] ];
>     # now three references to $x exist, one through its
>     # name and the other two through this data structure.
> }
>
> # now two references to $x exist.
>
> $root = undef;
>
> # $x has been reclaimed here
> --
> "In order to be prepared to hope in what does not deceive,
>  we must first lose hope in everything that deceives."
>
>                                           Georges Bernanos




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

Date: Wed, 14 Nov 2001 16:13:50 -0500
From: "Robin Corcoran" <robin_corcoran@3b2.com>
Subject: Unicode Conversion
Message-Id: <s7BI7.61$I8.76471@news.uswest.net>

Hello,

I have an input file which is encoded in UTF-16. I would like to convert it
to UTF-8.

I searched at CPAN and found a number of modules, but I can't figure out
which one might do what I want. Does anyone have any thoughts/suggestions? I
would appreciate it  if anyone can give me a push in the right direction.

Thanks,

Robin




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

Date: Wed, 14 Nov 2001 21:30:38 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Unicode Conversion
Message-Id: <3bf2e27e.6d9c$69@news.op.net>

In article <s7BI7.61$I8.76471@news.uswest.net>,
Robin Corcoran <robin_corcoran@3b2.com> wrote:
>I have an input file which is encoded in UTF-16. I would like to convert it
>to UTF-8.

I suggest you have a look at

        http://www.iki.fi/jhi/perlunitut.pod

I think it should be possible to use the 'Encode' module's 'from_to'
function, or perhaps something like:

        open IN, "<:utf16", $input  or die...
        open OUT, ">:utf8", $output or die...
        print OUT while <IN>;

Warning: I have never done anything like this.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Wed, 14 Nov 2001 20:08:53 GMT
From: Michael Slass <mikesl@wrq.com>
Subject: Re: web page editing with browser
Message-Id: <m3zo5pm7xt.fsf@thneed.na.wrq.com>

ip@dot-solutions.net (Ifan Payne) writes:

>Thank you for the lead. Is there anything online that you know of
>
>Ifan
>> 
>> >Could anyone suggest a free PERL script that enables editing of web
>> >pages via a browser? I am looking for a way for users to edit/add
>> >information to their web pages with thier browsers.

Sounds like you want a wiki.

If you don't find a perl-based solution _that works for you_, you
might want to check out
http://www.wiki.org



-- 
Mike


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

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 2134
***************************************


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