[30599] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1842 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 7 09:10:13 2008

Date: Sun, 7 Sep 2008 06:09:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 7 Sep 2008     Volume: 11 Number: 1842

Today's topics:
    Re: Any GUI Toolkit Suggestions? (fidokomik\)
    Re: Any GUI Toolkit Suggestions? <zentara@highstream.net>
        array of arrays to hash of hashes <jeff@simstech.net>
    Re: array of arrays to hash of hashes <mark.clementsREMOVETHIS@wanadoo.fr>
        Cartesian to lat and lon <vk4tec@people.net.au>
    Re: Cartesian to lat and lon <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: Complex (for me) reference deconstruction <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: EPIC and "my" variables haytona@yahoo.com
    Re: FAQ 7.16 How do I create a static variable? <xemoth@gmail.com>
    Re: FAQ 7.16 How do I create a static variable? <rvtol+news@isolution.nl>
        new CPAN modules on Sun Sep  7 2008 (Randal Schwartz)
    Re: Perl Strings vs FileHandle <someone@example.com>
    Re: subprocesses lifecycle <whynot@pozharski.name>
    Re: XML::Twig doctype and entity handling <hjp-usenet2@hjp.at>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 7 Sep 2008 03:22:57 +0200
From: "Petr Vileta \(fidokomik\)" <stoupa@practisoft.cz>
Subject: Re: Any GUI Toolkit Suggestions?
Message-Id: <g9vb47$1lir$1@adenine.netfront.net>

Hal Vaughan wrote:
> I've been programming in Perl for about 7 years and in Java, with
> Swing, for about 4 years, so I'm used to some GUI programming, but I
> have not done any in Perl yet.  I thought there was a GUI Perl
> programming newsgroup, but I can't find it, so I'm asking here.
>
> I need to write a GUI program that will basically send streams of data
> through a TCP socket depending on what button is pressed in a GUI
> window.

I want to recommend you Perl/Tk. If you want to see an example then you can 
download my freeware GRPING from my site http://www.practisoft.cz?download+en
You can download Windows or Linux version. The second one (GRPING_1_2.TAR.GZ) is 
a source code and you can study a Tk by examples ;-)
-- 
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail.
Send me your mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>


-- Posted on news://freenews.netfront.net - Complaints to news@netfront.net --


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

Date: Sun, 07 Sep 2008 07:59:45 -0400
From: zentara <zentara@highstream.net>
Subject: Re: Any GUI Toolkit Suggestions?
Message-Id: <5bg7c4dpt0jjpk5s3n4a2ksfgpkchfbklc@4ax.com>

On Sat, 06 Sep 2008 16:25:12 GMT, Hal Vaughan <hal@halblog.com> wrote:


>The tough parts is that the user will need to be able to add more panels,
>like a card layout in Java Swing.  There'll be a drop-down or combo list
>where the user can pick which panel they want to use or to make a new one. 
>Then, on each different panel, they can pick where to add buttons and
>specify the size and color of the button (or possibly pick from a list of
>Thanks!

It sounds like the perfect job for the Notebook widget. Both Tk and Gtk2
have them.  Tk is easier to learn, while Gtk2 is a bit more advanced and
difficult to master.


zentara

-- 
I'm not really a human, but I play one on earth.
http://zentara.net/Remember_How_Lucky_You_Are.html 


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

Date: Sat, 06 Sep 2008 17:21:54 -1000
From: Jeff <jeff@simstech.net>
Subject: array of arrays to hash of hashes
Message-Id: <NradnYnofKdO1V7VnZ2dnUVZ_ovinZ2d@hawaiiantel.net>

Hi all,

I have a category / subcategory file that looks like this

cereal
cereal:cold:cheerios
cereal:cold:corn flakes
cereal:hot:oatmeal
cereal:hot:cream of wheat
bread
bread:dakine sweet bread
bread:wheat
bread:white

 ......  Anyway you get the picture

I read the file in and place into array of arrays

open FILE, "$file";
my @file = (<FILE>);
close FILE;

my @a;
foreach (@file){
	my @line = split ':', $_;
	push (@a, \@line);
}

I want to put this into a hash of hashes where the last element would be 
equal to 1.  something like this
$cereal->{cold}->{cheerios} =1;
or $bread->{wheat} = 1;

if later on down the line the file changes so that there is more 
subcategories, the 1 would be replaced by a new hash like this

$cereal->{cold}->{cheerios}->{regular} =1;
$cereal->{cold->{cheerios}->{honeynut} = 1;

I'm having trouble writing a function to do this.
Any help or ideas would be appreciated


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

Date: Sun, 07 Sep 2008 07:27:46 +0000
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: array of arrays to hash of hashes
Message-Id: <48c38272$0$851$ba4acef3@news.orange.fr>

Jeff wrote:
> Hi all,
>
> I have a category / subcategory file that looks like this
>
> cereal
> cereal:cold:cheerios
> cereal:cold:corn flakes
> cereal:hot:oatmeal
> cereal:hot:cream of wheat
> bread
> bread:dakine sweet bread
> bread:wheat
> bread:white
>
> ...... Anyway you get the picture
>
> I read the file in and place into array of arrays
>
> open FILE, "$file";
> my @file = (<FILE>);
> close FILE;
>
> my @a;
> foreach (@file){
> my @line = split ':', $_;
> push (@a, \@line);
> }
>
> I want to put this into a hash of hashes where the last element would be
> equal to 1. something like this
> $cereal->{cold}->{cheerios} =1;
> or $bread->{wheat} = 1;
>
> if later on down the line the file changes so that there is more
> subcategories, the 1 would be replaced by a new hash like this
>
> $cereal->{cold}->{cheerios}->{regular} =1;
> $cereal->{cold->{cheerios}->{honeynut} = 1;
>
> I'm having trouble writing a function to do this.
> Any help or ideas would be appreciated
The most obvious way of doing it is to use a recursive function (google 
"recursion") to walk the data structure each time a new item is inserted 
(ie for each new line). You probably want something a bit like this 
(insert_item is the recursive function, if that isn't obvious):

mark@hermes:~$ cat cereal.pl
#!/usr/bin/perl
#
use warnings;
use strict;

use Data::Dumper;

my $root = {};

while(my $line = <DATA> ){
     chomp $line;
     my @items = split /:/,$line;

     insert_item( $root, @items );
}

print Dumper $root;

sub insert_item {
     my $current = shift;
     my $nextkey = shift;
     my @items = @_;

     if(@items){
         my $newsubtree;
         if(ref $current->{$nextkey}){
             $newsubtree = $current->{ $nextkey };
         }else{
             $newsubtree = {};
             $current->{ $nextkey } = $newsubtree;
         }
         insert_item( $newsubtree, @items );
     }else{
         $current->{ $nextkey } = 1;
     }
}

__END__
cereal
cereal:cold:cheerios
cereal:cold:corn flakes
cereal:hot:oatmeal
cereal:hot:cream of wheat
bread
bread:dakine sweet bread
bread:wheat
bread:white
mark@hermes:~$ perl cereal.pl
$VAR1 = {
           'bread' => {
                        'white' => 1,
                        'wheat' => 1,
                        'dakine sweet bread' => 1
                      },
           'cereal' => {
                         'cold' => {
                                     'cheerios' => 1,
                                     'corn flakes' => 1
                                   },
                         'hot' => {
                                    'cream of wheat' => 1,
                                    'oatmeal' => 1
                                  }
                       }
         };


Mark



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

Date: Sun, 7 Sep 2008 13:37:10 +1000
From: "Andrew Rich" <vk4tec@people.net.au>
Subject: Cartesian to lat and lon
Message-Id: <48c34c6a$1_1@news.peopletelecom.com.au>

Hello

I have had success going from lat and lon to bearing and distance from a 
known point.

Now I have a need to go the other way.

Given a known point, and given the bearing and distance, calculate the lat 
and lon.

Ideas ?

Maybe there is a module that does this ?

Andrew 




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

Date: Sun, 07 Sep 2008 09:28:46 +0000
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: Cartesian to lat and lon
Message-Id: <48c39ece$0$881$ba4acef3@news.orange.fr>

Andrew Rich wrote:
> Hello
>
> I have had success going from lat and lon to bearing and distance from a
> known point.
>
> Now I have a need to go the other way.
>
> Given a known point, and given the bearing and distance, calculate the lat
> and lon.
>
> Ideas ?
>
> Maybe there is a module that does this ?
search.cpan.org

Mark


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

Date: Sun, 07 Sep 2008 07:05:19 +0000
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: Complex (for me) reference deconstruction
Message-Id: <48c37d2f$0$921$ba4acef3@news.orange.fr>

John W. Krahn wrote:
> Mark Clements wrote:
>> Tad J McClellan wrote:
>>> sjcampbl@gmail.com<sjcampbl@gmail.com> wrote:
>>>> Ok, I think I understand. Thanks for the help.
>>>>
>>>> So...
>>>>
>>>> for $r (@{$t->{rows}}) {
>>>>
>>>> {rows} is a hash key within a hash referenced by $t
>>>> $t->{rows} contains an array reference
>>>> @{$t->{rows}} de-references this array reference, returning an actual
>>>> array
>>>
>>> Almost.
>>>
>>> It does not return an actual array. It returns a list.
>>>
>>> See:
>>>
>>> perldoc -q difference
>>>
>>> What is the difference between a list and an array?
>>>
>> Hmmm... OK - I've read the faq above and it says:
>>
>> "
>> An array has a changeable length. A list does not. An array is
>> something you can push or pop, while a list is a set of values.
>> "
>>
>> But you *can* pop etc a dereferenced arrayref.
>>
>> mark@hermes:~$ perl -Mstrict -Mwarnings -le 'my $c=[qw(a b c)];print
>> pop @{$c}; print "@{$c}"'
>> c
>> a b
>> mark@hermes:~$
>>
>> So - the snippet of code above initializes an arrayref, and then pops
>> its dereferenced value. According to the faq this would make the
>> deferenced value an array since I can pop it.
>>
>> Am I missing something?
>
> In the example @{$t->{rows}} *is* an array, which in list context
> *returns* a list.
OK - got it. That's pretty subtle :)

Thanks,

Mark


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

Date: Sun, 7 Sep 2008 02:45:50 -0700 (PDT)
From: haytona@yahoo.com
Subject: Re: EPIC and "my" variables
Message-Id: <7980ca9c-77a3-434f-898b-6b5533c7da48@o40g2000prn.googlegroups.com>

On Aug 1, 7:08 pm, rupert <rup...@web-ideas.com.au> wrote:
> Perl PadWalker v1.7 installed via CPAN

Since you're on ubuntu, try installing the packaged version of
padwalker, rather than building it from CPAN. Theoretically they
should be the same but there are a lot of variables in how you may
have compiled it from CPAN, (ie did you do it as a normal user or as
root?, if non-root then it probably won't work with eclipse as the
paths for the local user install will not be automatically included by
eclipse).

The package to install is: libpadwalker-perl


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

Date: Sat, 6 Sep 2008 15:58:24 -0700 (PDT)
From: Owen <xemoth@gmail.com>
Subject: Re: FAQ 7.16 How do I create a static variable?
Message-Id: <083fa1f7-c2a9-4ca3-bbae-05dead660b7c@x16g2000prn.googlegroups.com>

On Sep 7, 12:45=A0am, brian d  foy <brian.d....@gmail.com> wrote:
> In article
> <ae2aac97-af13-449b-8c71-5d92ee03c...@b30g2000prf.googlegroups.com>,
>
> Owen <xem...@gmail.com> wrote:
> > Why would you want to do this? Would not a global variable suffice?
> > Or put another way, how would using a global variable fail but a
> > static variable fulfil a requirement.
>
> One of your biggest tasks as a programmer is to limit the action of any
> one bit of code to the smallest scope possbile so it only affects what
> it should affect, and nothing else. That's true regardless of the
> language you use.

Thank you, I don't have Perl-5.10, and on this 5.8.8. perldoc -f state
produces nothing

So it's time to install another Perl


Thank you

Owen


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

Date: Sun, 7 Sep 2008 14:39:46 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: FAQ 7.16 How do I create a static variable?
Message-Id: <ga0p9p.g8.1@news.isolution.nl>

Owen schreef:

> I don't have Perl-5.10, and on this 5.8.8. perldoc -f state
> produces nothing
>
> So it's time to install another Perl

It always is,
but there are plenty of ways to create a static variable in a previous
Perl too.
Examples:

Alternative-1:

    { my $static;

      sub a_sub_using_static {
          # ...
      }
    }

The $static lives in in the "private environment" of the sub.



Alternative-2:

    sub a_sub_containing_a_static {
        my $static if 0;
        # ...
    }

The $static is properly created at compile time, but never reset at run
time.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Sun, 7 Sep 2008 04:42:22 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Sep  7 2008
Message-Id: <K6t6EM.Mot@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Badger-0.02
http://search.cpan.org/~abw/Badger-0.02/
Perl Application Programming Toolkit 
----
CPAN-Indexer-Mirror-0.01
http://search.cpan.org/~adamk/CPAN-Indexer-Mirror-0.01/
Creates the mirror.yml and mirror.json files 
----
CPAN-Reporter-1.17
http://search.cpan.org/~dagolden/CPAN-Reporter-1.17/
Adds CPAN Testers reporting to CPAN.pm 
----
CPAN-Test-Dummy-Perl5-Make-FailConfigRequires-1.00
http://search.cpan.org/~dagolden/CPAN-Test-Dummy-Perl5-Make-FailConfigRequires-1.00/
CPAN Test Dummy 
----
Catalyst-Plugin-InflateMore-0.1.26
http://search.cpan.org/~pjfl/Catalyst-Plugin-InflateMore-0.1.26/
Inflates symbols in application config 
----
CatalystX-ListFramework-Builder-0.35
http://search.cpan.org/~oliver/CatalystX-ListFramework-Builder-0.35/
Instant AJAX web front-end for DBIx::Class, using Catalyst 
----
Config-Extend-MySQL-0.03
http://search.cpan.org/~saper/Config-Extend-MySQL-0.03/
Extend your favourite .INI module to read MySQL configuration file 
----
DBIx-Array-0.09
http://search.cpan.org/~mrdvt/DBIx-Array-0.09/
This modules is a wrapper around DBI with array interfaces 
----
Data-CloudWeights-0.2.65
http://search.cpan.org/~pjfl/Data-CloudWeights-0.2.65/
Calculate values for an HTML tag cloud 
----
Data-SimplePaginator-0.4.0
http://search.cpan.org/~jbuhacoff/Data-SimplePaginator-0.4.0/
data pagination without assumptions (I think) 
----
ExtUtils-Depends-0.301
http://search.cpan.org/~tsch/ExtUtils-Depends-0.301/
Easily build XS extensions that depend on XS extensions 
----
ExtUtils-MakeMaker-6.45_01
http://search.cpan.org/~mschwern/ExtUtils-MakeMaker-6.45_01/
Create a module Makefile 
----
FFI-1.04
http://search.cpan.org/~gaal/FFI-1.04/
Perl Foreign Function Interface 
----
Games-Risk-0.4.2
http://search.cpan.org/~jquelin/Games-Risk-0.4.2/
classical 'risk' board game 
----
Games-Risk-0.5.0
http://search.cpan.org/~jquelin/Games-Risk-0.5.0/
classical 'risk' board game 
----
HTML-Accessors-0.1.37
http://search.cpan.org/~pjfl/HTML-Accessors-0.1.37/
Generate HTML elements 
----
HTML-FormWidgets-0.1.75
http://search.cpan.org/~pjfl/HTML-FormWidgets-0.1.75/
Create HTML form markup 
----
HTML-Formulate-0.12
http://search.cpan.org/~gavinc/HTML-Formulate-0.12/
module for producing/rendering HTML forms 
----
HTML-Tabulate-0.30
http://search.cpan.org/~gavinc/HTML-Tabulate-0.30/
HTML table rendering class 
----
HTML-WikiConverter-DokuWikiFCK-0.24
http://search.cpan.org/~turnermm/HTML-WikiConverter-DokuWikiFCK-0.24/
A WikiConverter Dialect supporting the FCKeditor in DokuWiki 
----
IPC-SRLock-0.1.70
http://search.cpan.org/~pjfl/IPC-SRLock-0.1.70/
Set/reset locking semantics to single thread processes 
----
Kephra-0.3.10_2
http://search.cpan.org/~lichtkind/Kephra-0.3.10_2/
crossplatform, GUI-Texteditor along perllike Paradigms 
----
MooseX-ClassAttribute-0.06
http://search.cpan.org/~drolsky/MooseX-ClassAttribute-0.06/
Declare class attributes Moose-style 
----
Net-Ping-Network-1.55
http://search.cpan.org/~angerstei/Net-Ping-Network-1.55/
Perl extension for blah blah blah 
----
Net-PingFM-0.1
http://search.cpan.org/~draxil/Net-PingFM-0.1/
Interact with ping.fm from perl 
----
Sleep-0.0.4
http://search.cpan.org/~stuifzand/Sleep-0.0.4/
A library for making REST web applications. 
----
Tcl-0.97
http://search.cpan.org/~vkon/Tcl-0.97/
Tcl extension module for Perl 
----
Test-Reporter-1.50
http://search.cpan.org/~dagolden/Test-Reporter-1.50/
sends test results to cpan-testers@perl.org 
----
Test-Reporter-1.51_01
http://search.cpan.org/~dagolden/Test-Reporter-1.51_01/
sends test results to cpan-testers@perl.org 
----
Test-Simple-0.81_01
http://search.cpan.org/~mschwern/Test-Simple-0.81_01/
Basic utilities for writing tests. 
----
Test-UniqueTestNames-0.02
http://search.cpan.org/~heumann/Test-UniqueTestNames-0.02/
Make sure all of your tests have unique names 
----
Text-ASCIITable-TW-v0.03
http://search.cpan.org/~alec/Text-ASCIITable-TW-v0.03/
add TW support for Text::ASCIITable 
----
Text-TEI-Markup-1.0
http://search.cpan.org/~aurum/Text-TEI-Markup-1.0/
a transcription markup syntax for TEI XML 
----
Text-Template-Simple-0.54_02
http://search.cpan.org/~burak/Text-Template-Simple-0.54_02/
Simple text template engine 
----
WWW-AtMovies-TV-v0.03
http://search.cpan.org/~alec/WWW-AtMovies-TV-v0.03/
retrieve TV information from http://www.atmovies.com.tw/ 
----
WWW-NioTV-v0.03
http://search.cpan.org/~alec/WWW-NioTV-v0.03/
retrieve TV information from http://www.niotv.com/ 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: Sat, 06 Sep 2008 23:08:56 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Perl Strings vs FileHandle
Message-Id: <c4Ewk.70362$hx.1243@pd7urf3no>

shadabh wrote:
> Hi all,
> 
> Just wanted to run this through Perl gurus to see if fit is correct?.
> 
> I have a file that could possibly be 1GB in variable length EBCDIC
> data. I will read the file as EBCDIC data and based on some criteria
> split it into 100 different files which will add up to the 1GB. This
> way a particular copy book can be applied to easy of the split files.
> 
> The approach I am using is a filehandle ( IO::FileHandle and
> $Strings), substr and write out to 100 different files after applying
> the 'logic'. I will use two routine, one to read and one to write, I
> have tested this out with 100MB file and it works fine. The question
> though is there a memory limit to this, as we are using strings to
> break the files. Or is there an alternative way to do this?
> 
> Comments, suggestions, improvements and alternatives will really help
> to design the code. thanks

You have to show us what "this" is first.  It is kind of hard to make 
comments, suggestions, improvements and alternatives to something that 
we cannot see.


John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Sat, 06 Sep 2008 22:38:56 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: subprocesses lifecycle
Message-Id: <gr2bp5xlun.ln2@carpet.zombinet>

Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
*SKIP*

> It doesn't (at least not during a close which I believe we are talking
> about here - of course since Perl is a general purpose programming
> language, perl can be made to wait on just about anything). A close on a
> filehandle created with "open(... '...|')" waits for the child process
> to terminate. If the child process forks again and terminates (as
> C.DeRykus) suggested, close returns immediately, as expected.

Positive, now I see the light.  I've just checked all the cases:

=item parent doesn't wait

=item [1]

implicit close

=item [2]

explicit close with child has forked

=back

=item parent waits

=item [1]

reading from pipe

=item [2]

explicit close with child hasn't forked.

=back

=back

There's no difference if lexicals or globals were used, forking was made
with C<open $x, '-|', $command;>.  Thanks, now I feel much better.

> I don't see where "C.DeRykus clearly showed double fork doesn't help".
> On the contrary, I very clearly showed that it does help in a previous
> posting.

That was noise.  Please ignore.

>> That happens when writer (I intentionally say 'writer' but 'child',
>> because it can be child of B<init> (since double fork)) intentionally
>> closes pipe or just terminates.

> When the writer closes the pipe, the reader will get an EOF indication.

As Peter J. Holzer clearly showed, there's no problems closing pipes, no
reading from pipe granted.  So that's not parent-child problem.  That's
reader-writer problem.

BTW, it's not about Hans, it's about Matthieu.

-- 
Torvalds' goal for Linux is very simple: World Domination


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

Date: Sat, 6 Sep 2008 21:12:23 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: XML::Twig doctype and entity handling
Message-Id: <slrngc5lgs.pu8.hjp-usenet2@hrunkner.hjp.at>

["Followup-To:" header set to comp.lang.perl.misc.]
On 2008-09-04 23:11, Zed Pobre <zed@resonant.org> wrote:
> I'm writing a program that needs to extract a clump of XML metadata
> stored inside of a noncompliant HTML file and then perform a number of
> operations on that metadata.  (Specifically, for those curious, this
> is part of a Mobipocket .prc to IPDF .epub ebook converter.)
>
> The HTML file in question has no doctype declaration, and XHTML
> entities may be found in the metadata portion.  In particular, &copy;
> is the first entity that XML::Parser will choke on in my current test
> data.
>
> Could someone please provide me with an example of how to get
> XML::Twig to recognize XHTML entities?

Just prepend a declaration. For example here is a snippet from one of my
scripts which deals with a similar situation:

        while ($lines[0] =~ /\s*<use /) {
            shift @lines;
        }
        my $encoding = "utf-8";
        if ($lines[0] =~ / charset=["'](.*?)["']/) {
            $encoding=$1
        }
        my $text = join('', (
                                "<?xml version='1.0' encoding='$encoding' ?>\n",
                                "<!DOCTYPE protokoll SYSTEM 'http://www.luga.at/dtd/protokoll.dtd'\n",
                                "  [\n",
                                "    <!ENTITY euro '&#8364;'>\n",
                                "    <!ENTITY mdash '&#8212;'>\n",
                                "    <!ENTITY rArr  '&#8658;'>\n",
                                "  ]\n",
                                ">\n",
                                 @lines
                             )   
                        );

This first strips off a few extra lines (which start with "<use "), then
extracts the encoding from the first remaining line and then prepends an
XML declaration with the encoding and a doctype declaration with a few
entities.

	hp


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1842
***************************************


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