[17438] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4858 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 9 18:05:59 2000

Date: Thu, 9 Nov 2000 15:05:17 -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: <973811116-v9-i4858@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 9 Nov 2000     Volume: 9 Number: 4858

Today's topics:
    Re: [Way OT] Re: OOP and information hiding (Jerome O'Neil)
    Re: Any way to send a Win-Message to WINNT from Perlscr <carvdawg@patriot.net>
    Re: Backtick problems on Windows98 hydsys@my-deja.com
    Re: Freshman parameter question <xarbosa@yahoo.com>
        getting a list of files like in @ARGV <adridder@freemail.nl>
    Re: getting a list of files like in @ARGV (Gwyn Judd)
    Re: getting a list of files like in @ARGV <kims@emmerce.com.au>
    Re: getting a list of files like in @ARGV <ianb@ot.com.au>
        Handling Postcode Ranges <peter.sundstrom@eds.com>
    Re: Handling Postcode Ranges <W.Hielscher@mssys.com>
    Re: Hash assignments in loops? <ianb@ot.com.au>
    Re: Help needed with dereferencing in multihash j_f9@my-deja.com
    Re: HELP Winows NT Mail::Sender <olthoff@multiboard.com>
        Help with if(file_exists) <phallicity_2000@yahoo.com>
    Re: Help with if(file_exists) <joe+usenet@sunstarsys.com>
    Re: Help with if(file_exists) <godoy@conectiva.com>
    Re: how do i ask for input? <brondsem@my-deja.com>
    Re: how to remove unprintable chars with Perl script coughlan@gothaminteractive.com
    Re: I do not Understand Perl Formats viscido@u.washington.edu
        IO::File::new_tmpfile() amcfarla@my-deja.com
    Re: mail & MIME <peter.sundstrom@eds.com>
    Re: Mail mapping from "ÄÜÖ ?1" -> "ÿso-8859-1Q?C4DCD6?" <bjoern@hoehrmann.de>
    Re: Mail mapping from "ÄÜÖ ?1" -> "ÿso-8859-1Q?C4DCD6?" <elijah@workspot.net>
        my() changes result of function -- why?  <neil@utstat.utoronto.ca>
    Re: my() changes result of function -- why? (Colin Watson)
    Re: my() changes result of function -- why? <joe+usenet@sunstarsys.com>
    Re: my() changes result of function -- why? <joe+usenet@sunstarsys.com>
    Re: Net::Telnet & Net::Ping nodo70@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 09 Nov 2000 19:21:33 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: [Way OT] Re: OOP and information hiding
Message-Id: <1PCO5.516$te1.149893@news.uswest.net>

tjla@guvfybir.qlaqaf.bet (Gwyn Judd) elucidates:

>>The dialoge between Abigail and Damian is exactly the kind of
>>thing that keeps me reading c.l.p.m. 
> 
> Their's wasn't, mine was. Fair enough?

Ah!  Gatcha...


-- 
"Civilization rests on two things: the discovery that fermentation 
produces alcohol, and the voluntary ability to inhibit defecation.  
And I put it to you, where would this splendid civilization be without 
both?" --Robertson Davies "The Rebel Angels" 


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

Date: Thu, 09 Nov 2000 17:39:08 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: Any way to send a Win-Message to WINNT from Perlscript?
Message-Id: <3A0B278C.FF1CAA64@patriot.net>

matthias,

There is a difference between sending a Win32 Popup message, and
sending a message to an application that runs on NT...which do you want?

Matthias Marks wrote:

> Hallo,
>
> I want to send a Message to an application running under NT.
> Does anybody know a functionmodule to send a WinMessage ??
>
> --
>           MFG Matthias Marks
>
> mmarks@gfma.de oder priv. M.Marks@gmx.de
>
> P.S.: Wirf Deinen Lendenschurz nicht fort,
>       wenn Du ein neues Kleid bekommen hast !
>
>       Sprichwort aus dem Kongo

--
Q: Why is Batman better than Bill Gates?
A: Batman was able to beat the Penguin.




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

Date: Thu, 09 Nov 2000 22:48:41 GMT
From: hydsys@my-deja.com
Subject: Re: Backtick problems on Windows98
Message-Id: <8uf9k7$l9o$1@nnrp1.deja.com>

Peter,

I have seen the same problem and in some cases the culprit seems to be Norton
Antivirus - if it is set to scan ALL files rather than just specified file
types the problem crops up. Solution was simply to have Norton only scan
nominated file types.

I am now struggling with the same problem where they are not running Norton -
something else is obviously doing the same thing - any help would be
appreciated. Here they are running McAfee, but even when disabled the problem
still occurs

Peter Heweston
HYDSYS Pty Ltd


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 9 Nov 2000 20:45:41 +0100
From: "xarbosa" <xarbosa@yahoo.com>
Subject: Re: Freshman parameter question
Message-Id: <973798974.509019@perla.rotterdam.luna.net>

Thanks group,

I realise I should have been more clear with the description, but Michael
got it right, I am passing %volume% from a Windows2000 CMD file.

It is highly appreciated so thanks again,

    Xarbos..

"xarbosa" <xarbosa@yahoo.com> wrote in message
news:973714038.213017@perla.rotterdam.luna.net...
> First of all, Perl is cool.
> I just started Perl 2 days ago and find it amazing that my 53K Visual
Basic
> app is now about 8 lines of pure Perl pleasure.
>
> Anyway, here's the question:
>
> App1 runs the .PL script so that it can generate some things.
> However, variable %VOLUME% is defined in App1 and I want to send this
> variable to the .PL script so that I can use it as say $volume.
>
> How ?!?
>
> I have looked all over (the book, Perl.com, CPAN.org) but all I can find
are
> the switches and they don't make a lot of sense to me.
>
> Please help and TIA.
>                                  Xarbos.
>
>




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

Date: Thu, 9 Nov 2000 22:55:32 +0100
From: "arno" <adridder@freemail.nl>
Subject: getting a list of files like in @ARGV
Message-Id: <OlbvlfpSAHA.314@net025s>

if I start my script with *.LOG on the command line I get all the filenames
ending with .LOG expanded in @ARGV
q:
How can I get a list with filenames from a scalar with the value of *.LOG

adridder@freemail.nl





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

Date: Thu, 09 Nov 2000 22:32:45 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: getting a list of files like in @ARGV
Message-Id: <slrn90m9g8.5jv.tjla@thislove.dyndns.org>

I was shocked! How could arno <adridder@freemail.nl>
say such a terrible thing:
>if I start my script with *.LOG on the command line I get all the filenames
>ending with .LOG expanded in @ARGV
>q:
>How can I get a list with filenames from a scalar with the value of *.LOG

Well assuming the list is separated by spaces you could do:

@filenames = split /\s+/, $list;

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
A narcissist is someone better looking than you are.
		-- Gore Vidal


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

Date: Fri, 10 Nov 2000 09:39:25 +1000
From: "Kim Saunders" <kims@emmerce.com.au>
Subject: Re: getting a list of files like in @ARGV
Message-Id: <8uf934$v5$1@thebe.syd.dav.net.au>

> if I start my script with *.LOG on the command line I get all the
> filenames ending with .LOG expanded in @ARGV q: How can I get a list
> with filenames from a scalar with the value of *.LOG

Sounds like you're using unix of some description...

How about:

$files = `echo *.LOG`;
@files = split / /, $files;

They may or may not have been the answer you are looking for. The
non-shell way to do it would be to use opendir, readdir, etc to get ALL
the files, then see if they match.

KimS



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

Date: Fri, 10 Nov 2000 09:01:14 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: getting a list of files like in @ARGV
Message-Id: <3A0B1EAA.6749B46@ot.com.au>

arno wrote:

> if I start my script with *.LOG on the command line I get all the filenames
> ending with .LOG expanded in @ARGV
> q:
> How can I get a list with filenames from a scalar with the value of *.LOG

The function you are looking for is "glob".

Try

  man perlfunc

and search for "glob". Apparently you need to hold your nose to do the
following, but you could also try:

  perldoc -f glob


Regards,


Ian




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

Date: Fri, 10 Nov 2000 09:30:42 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Handling Postcode Ranges
Message-Id: <8uf1ne$qgc$1@hermes.nz.eds.com>

I'm looking for an efficient way of handling postcode ranges in reasonably
large files (20Mb).  I need to return a number of the postcode range
sequence.  For example:

0000-1000    return 1
1001-2000    return 2
2001-2500    return 3
 ...

The postcode ranges will vary depending on the file being processed, so I
need to initialise the postcode ranges from a configuration file.

The postcodes will range from 0 to 9999.  I was thinking about initialising
a hash for the entire range, but it seems overkill to initialise 10,000
values.

Suggestions on how to handle it will be greatfully accepted.




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

Date: Thu, 09 Nov 2000 23:14:40 +0100
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: Re: Handling Postcode Ranges
Message-Id: <3A0B21D0.156CA15B@mssys.com>

Peter Sundstrom wrote:
> I'm looking for an efficient way of handling postcode ranges in reasonably
> large files (20Mb).  I need to return a number of the postcode range
> sequence.  For example:
> 
> 0000-1000    return 1
> 1001-2000    return 2
> 2001-2500    return 3
> ...
> 
> The postcode ranges will vary depending on the file being processed, so I
> need to initialise the postcode ranges from a configuration file.

(I don't see the relevance of the 20Mb-File, so I hope I didn't miss the
point of your problem.)
Assumtions:
- no two ranges have any element in common
- all postcodes are elements of a range
- the ranges are in an "ascending order"

Then one way to do it is to save the upper bounds of each range in an
array at the index representing the range-id. Something like:

use strict;

open FH, "p_ranges.txt"  or  die "Sorry: $!";
my @upper_bound;
while ( <FH> ) {
   /(\d{4})-(\d{4})\s*return\s*(\d+)/  or next;
   
   $upper_bound[$3] = $2;
}

All what's left to do is to bsearch (or linear search ?!) the array
@upper_bound for the least array-index whose element is greater than
your actual postcode.

> The postcodes will range from 0 to 9999.  I was thinking about initialising
> a hash for the entire range, but it seems overkill to initialise 10,000
> values.
But my solution seems to be even a bigger overkill. The code presented
above yields an advantage of about 3 MBytes compared to populating a
hash with 10000 numbers.
So why wasting additional memory and time for writing (or "use"ing) a
search function while not profiting form an "efficent", free hash
lookup?!

> Suggestions on how to handle it will be greatfully accepted.
My suggestion: Use a hash.

Cheers
	Wolfgang


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

Date: Fri, 10 Nov 2000 08:46:01 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: Hash assignments in loops?
Message-Id: <3A0B1B19.DF4098E2@ot.com.au>

gelshocker@my-deja.com wrote:

> Hi,
>
> For some reason I can't seem to populate hashes in a loop block. For
> example, I have a forloop that splits @lines into 2 elements, assigning
> the elements as key/value into a %hash.

This bit is unclear. How are the values stored in the list?

> Doesn't work: I only get one $hash, being the last elements from
> @lines. Tried the Cookbook but no examples of hash assignments in a
> loop block. And I missing something?

Yes. You are assigning a key-value pair to the whole list (if my ESP is
working - evidence would make this sort of thing easier).

I interpreted your question to mean that you wanted to assign sequential
pairs in the list to a hash, rather than splitting individual elements,
which is very easy, and doesn't require a loop:

#!/usr/bin/perl -w

use strict;

my @list = ("key1", "value1", "key2", "value2", "key3", "value3");
my %hash = @list;

print "KEYS: ", join(", ", keys(%hash)), "\n";
print "Value of key2: ", $hash{'key2'}, "\n";
$hash{"key7"} = "fred";

print "KEYS: ", join(", ", keys(%hash)), "\n";

__END__


If nobody has yet answered your question, please provide more information.
Show us what you did, and give an example of the result you want.

Regards,


Ian




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

Date: Thu, 09 Nov 2000 22:19:18 GMT
From: j_f9@my-deja.com
Subject: Re: Help needed with dereferencing in multihash
Message-Id: <8uf7ss$jpo$1@nnrp1.deja.com>

You're right, of course.  The subject line was badly phrased.

Greetings,
FT

In article <u9puk5av79.fsf@wcl-l.bham.ac.uk>,
  nobull@mail.com wrote:
> j_f9@my-deja.com writes:
>
> > Subject: Help needed with dereferencing in multihash
>
> Actually you need help localising problems.  Your problem is nothing
> to do with hashes or references.
>
> Try:
>
> print 0555;
>
> What do you see?
>
> Now do you understand?
>
> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 9 Nov 2000 15:44:03 -0500
From: "Darryl Olthoff" <olthoff@multiboard.com>
Subject: Re: HELP Winows NT Mail::Sender
Message-Id: <8uf2ak$okn$1@panther.uwo.ca>

> I am using the following from cpan.
>         use Mail::Sender;
>
>         $sender = new Mail::Sender {smtp => 'mail.yourdomain.com', from =>
> 'your@address.com'};
>         $sender->MailFile({to => 'some@address.com', subject => 'Here is
the
> file',
>                        msg => "I'm sending you the list you wanted.",
>                            file => 'filename.txt'});


You could always use Net::SMTP;  I believe that it is installed with
ActivePerl, if not use ppm and install the libnet package.

$s = Net::SMTP->new($mailserver);
$s->mail('admin@domain.com');
$s->to($user1);
$s->to($user2);
$s->data;
$s->datasend('To: user1@whereever.com, user2@anotherplace.com\n");
$s->datasend("From: me@here.com\n");
$s->datasend("Subject: this is my subject\n\n");
$s->datasend("This is my message body\n");
$s->dataend;
$s->quit;

Darryl




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

Date: Thu, 09 Nov 2000 21:04:00 GMT
From: Phallicity <phallicity_2000@yahoo.com>
Subject: Help with if(file_exists)
Message-Id: <8uf3fp$fjb$1@nnrp1.deja.com>

I am trying to check the existance of a file.  The cgi script is being
run from www.somepage.com/cgi-bin/test/prog.cgi.  I want prog.cgi to
test for the existance of file www.somepage.com/junk/more/me.gif.  Can
someone tell me how to write the if statement?  I have tried: if
(/junk/more/me.gif) {...}  but I get an error from the server when I
try to run this.

Thanks in advance

--
Phallicity

"He must have a huge Schwanstucker!"
-Young Frankenstein


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 09 Nov 2000 16:15:02 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Help with if(file_exists)
Message-Id: <m3puk4alux.fsf@mumonkan.sunstarsys.com>

Phallicity <phallicity_2000@yahoo.com> writes:

> I am trying to check the existance of a file. 

% man perlfunc

or, horrors

% perldoc perlfunc

look for -e

-- 
Joe Schaefer


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

Date: 09 Nov 2000 19:47:04 -0200
From: Jorge Godoy <godoy@conectiva.com>
Subject: Re: Help with if(file_exists)
Message-Id: <kp1ywkvmw7.fsf@dagon.conectiva>

On Thu, 09 Nov 2000, phallicity_2000@yahoo.com wrote:
> I am trying to check the existance of a file.  The cgi script is
> being run from www.somepage.com/cgi-bin/test/prog.cgi.  I want
> prog.cgi to test for the existance of file
> www.somepage.com/junk/more/me.gif.  Can someone tell me how to write
> the if statement?  I have tried: if (/junk/more/me.gif) {...}  but I
> get an error from the server when I try to run this.


There are several flags to check files: if they exist, if they are
block files, if they are symlinks, if they are executable, etc. 

You can see all of these and a few more at perlfunc's man page. 


See you,
-- 
Godoy. <godoy@conectiva.com>

Departamento de Publicações       Conectiva S.A.
Publishing Department             Conectiva Inc.


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

Date: Thu, 09 Nov 2000 22:05:54 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: how do i ask for input?
Message-Id: <8uf73r$j4q$1@nnrp1.deja.com>



http://www.perl.com has all the documetation, I use it much more than
on my local computer.

In article <J_BO5.2624$Nw6.7728@news.iol.ie>,
  "EM" <me@privacy.net> wrote:
> perldoc doesnt seem to work
> when i type perldoc perlop i get this (yes it repeats 3 times)
>
> D:\Perl\bin>perldoc perlop
> Can't spawn "command.com": No such file or directory at perldoc.bat
line
> 383.
> Can't spawn "command.com": No such file or directory at perldoc.bat
line
> 383.
> Can't spawn "command.com": No such file or directory at perldoc.bat
line
> 383.
>
> the line at 383 is
> last if system("$pager $tmp") == 0;
>
> whats the problem?
>
> Eric
>
> "jason" <elephant@squirrelgroup.com> wrote in message
> news:MPG.1474c1c1271e080198988b@localhost...
> > EM wrote ..
> > >I am using activeperl on windows
> > >how do i ask for user input
> >
> > there are a number of ways .. the simplest is to use angle brackets
> > around STDIN .. take a look at the perlop section of the manual
under
> > "I/O Operators" for some examples
> >
> >   perldoc perlop
> >
> > >like say i make a program that ask for a password
> > >and i make a prompt "Please enter password:"
> > >how do i allow the user to put in his password and put it in
$password
> >
> > for specifics about password inputs .. take a look at the Perl FAQ
by
> > typing the following at the command prompt
> >
> >   perldoc -q password
> >
> > for more information on the perldoc utility type the following at
the
> > command prompt
> >
> >   perldoc perldoc
> >
> > --
> >   jason -- elephant@squirrelgroup.com --
>
>

--
Dave Brondsema


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 09 Nov 2000 21:41:49 GMT
From: coughlan@gothaminteractive.com
Subject: Re: how to remove unprintable chars with Perl script
Message-Id: <8uf5mr$hoc$1@nnrp1.deja.com>

I'm trying to swap out all Ctrl chars with the string $$.

I tried s/[[:^print:]]/$$/g;  and it didn't work.

tr/\x20-\x7e//cd;  does kill the ctrl characters, but

s/\x20-\x7e/$$/cd; did not work either.

What am I missing - haven't found it in the man yet.

TIA,

Mike C



In article <MPG.144d5db99ccbb76098ae20@nntp.hpl.hp.com>,
  Larry Rosler <lr@hpl.hp.com> wrote:
> In article <39E25037.EEDA60FB@acm.org> on Mon, 09 Oct 2000 16:09:43 -
> 0700, John W. Krahn <krahnj@acm.org> says...
> > This should work:
> >
> > s/[:^print:]//g;
>
> Perhaps you think it 'should work', but it doesn't (it needs another
set
> of square brackets), as you could have found out trivially by trying
it
> before posting it, or even by checking it out in perlre.
>
>   This should work:
>
>   s/[[:^print:]]//g;
>
> The POSIX 'print' class includes the four whitespace control
characters
> "\t" "\n" "\f" "\r", which is different from the C isprint() class.
I
> haven't been able to find a definitive reference on the Web to the
> definitions of the POSIX character classes; without such a definition
or
> a reference to it, the Perl documentation is incomplete.
>
> ----------------------------------------------------------------------
-
>
> If locale-dependent issues aren't involved, then the following is
much
> faster.  The four whitespace control characters can be included if
> desired:
>
>   tr/\x20-\x7e//cd;
>
> Or, to save keystrokes,
>
>   tr/ -~//cd;
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 09 Nov 2000 12:35:28 -0800
From: viscido@u.washington.edu
Subject: Re: I do not Understand Perl Formats
Message-Id: <m3snp0yjcf.fsf@fiddler.u.washington.edu>

john_s_brown@my-deja.com writes:

> I have read through Programming Perl (3rd edition) chapter number 7,
> which tells about Perl Formats. But still I don't understand even the
> basics.
> 

A fine set of examples and explanations is available in the O'reilly
book "Learning Perl" by Randal Schwartz & Tom Chritiansen. I'd bet
after reading their stuff on formats (Ch. 11) you wouldn't have any
trouble. 

> 
> For example, I have no idea what are all these >>>>> and <<<<<
> characters in the code and how can one assign a value to a variable
> found inside a format!

Each "<" stands for a space, < is left justify, and > is right
justify. So, @<<<<< is a 6-space left-justified word, while @>>>>> is
a 6-space right-justified word. The "@" is the "start the word here"
symbol, and counts as the first space or character. If the word is
longer than the number of spaces allocated, it's chopped off. If it's
shorter, the space is filled in as the justification scheme would
dictate. So, if your format is @<<<<<<, then the word "hi" would look
like this:
hi

While if it's @>>>>>>, the word would look like this:
     hi

and finally, if the word were "Supercalifragelisticexpialodocious"
instead, it would look like this, in @<<<<< format:
Superc

The rest of the word, being too long to fit into that cell of the
format, would be chopped off.

Formats can do lots and lots of useful stuff, including wrapping text,
extending to multiple lines, and so on. Ch. 11 of "Learning Perl"
should help you understand these things.

Hope this helps.

Steve

-- 
Steven Viscido [viscido@u.washington.edu]
Department of Zoology, Box 351800 Kincaid Hall
University of Washington
Seattle, WA 98195	Tel: 206-221-6904


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

Date: Thu, 09 Nov 2000 20:23:51 GMT
From: amcfarla@my-deja.com
Subject: IO::File::new_tmpfile()
Message-Id: <8uf14f$dbt$1@nnrp1.deja.com>

I'm trying to use Spreadsheet::WriteExcel.  I kept getting an error
message that IO::File::new_tmpfile() was failing.  I tried calling
new_tmpfile() explicitly, which also failed, but I couldn't see any
more detail as to why it failed.

Please give me some suggestions as to why it might have failed.  I am
running on NT 4.0 SP 6.  My environment has defined TMP and TEMP.
Where is the new_tmpfile() function defined--where can I look at the
code so I can track down what is going wrong?

Thanks.

Andrew


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 10 Nov 2000 09:42:10 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: mail & MIME
Message-Id: <8uf2cu$rk2$1@hermes.nz.eds.com>


Bertrand Vallé <bertrand.valle@travelprice.com> wrote in message
news:3A0AC800.17CF6209@travelprice.com...
> James Taylor wrote:
>
> > In article <3A0ABA92.B039A1B8@travelprice.com>, Bertrand Vallé
> > <URL:mailto:bertrand.valle@travelprice.com> wrote:
> > >
> > > i really need your help, i don't know how to encode a .html file into
> > > MIME format in order to send it vie mail after ..
> >
> > There was a thread about this recently with subject "Emailing
formatted".
> > I suggested MIME::Lite and Peter Sundstrom added the suggestion of
> > using MIME::Lite::HTML.
> thx
>
> but where i can find some informations about this class ?
> is it in originally package of perl ?

http://search.cpan.org/search?dist=MIME-Lite




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

Date: Thu, 09 Nov 2000 20:22:19 +0100
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Re: Mail mapping from "ÄÜÖ ?1" -> "ÿso-8859-1Q?C4DCD6?"
Message-Id: <3a0df467.1789122@news.bjoern.hoehrmann.de>

* Eli the Bearded wrote in de.comp.lang.perl.misc:
>> >Does anybody konws a module (CPAN) which allows me
>> >to convert "=?iso-8859-1?Q?=C4=DC=D6_=3F1" back to "ÄÜÖ"?
>
>I looked for one a few weeks ago and found nothing.

As I replied in the german perl newsgroup, there is MIME::Words which
provides the basic interface to recode MIME encoded words back to some
abitrary character set / encoding (see below).

>So this is legal:
>
>From: =?utf-8?q?Elijah_Gri=EF=AC=83n?= <elijah@workspot.net>
>
>It has my surname with unicode FB03 (latin small ligature ffi).

I like this one:
  From: bjoern@hoehrmann.de (=?UTF-8?B?QmrDtnJuIEjDtmhybWFubg==?=)

It's supposed to be perfectly readable ;-)

I've written the following small script to convert MIME encoded words
within a scalar to UTF-8:

#!perl -w
#
# MIME::Words::decode_mimewords_to_utf8()
# Copyright (c) 2000 by Björn Höhrmann

use MIME::Words qw(:all);
use Unicode::Map8;

# One small example

print &decode_mimewords_to_utf8('=?UTF-8?B?QmrDtnJuIEjDtmhybWFubg==?=');

sub decode_mimewords_to_utf8
{
    my $enc = shift;
    my $result;

    foreach (decode_mimewords($enc)) {
        my($string, $charset) = (@$_[0], @$_[1]);
        $charset = defined $charset ? uc $charset : 'ISO-8859-1';

        if (uc $charset eq 'UTF-8' or !defined $charset) {
            $result .= $string;
        } else {
            my $map = Unicode::Map8->new($charset) or die $!;
            $result .= $map->tou($string)->utf8;
        }
    }
    return $result;
}
-- 
Björn Höhrmann ^ mailto:bjoern@hoehrmann.de ^ http://www.bjoernsworld.de
am Badedeich 7 ° Telefon: +49(0)4667/981ASK ° http://bjoern.hoehrmann.de
25899 Dagebüll # PGP Pub. KeyID: 0xA4357E78 # http://learn.to/quote +{i}
 ..weaving a secure, well-formed, standard compliant WWW for =everyone=..


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

Date: 9 Nov 2000 20:45:56 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Mail mapping from "ÄÜÖ ?1" -> "ÿso-8859-1Q?C4DCD6?"
Message-Id: <eli$0011091532@qz.little-neck.ny.us>

In comp.lang.perl.misc, Bjoern Hoehrmann  <derhoermi@gmx.net> wrote:
> * Eli the Bearded wrote in de.comp.lang.perl.misc:
> >> >Does anybody konws a module (CPAN) which allows me
> >> >to convert "=?iso-8859-1?Q?=C4=DC=D6_=3F1" back to "ÄÜÖ"?
> >I looked for one a few weeks ago and found nothing.
> As I replied in the german perl newsgroup, there is MIME::Words which
> provides the basic interface to recode MIME encoded words back to some
> abitrary character set / encoding (see below).

Oh, fun. I've just installed it.

> I've written the following small script to convert MIME encoded words
> within a scalar to UTF-8:
> 
> #!perl -w
> #
> # MIME::Words::decode_mimewords_to_utf8()
> # Copyright (c) 2000 by Björn Höhrmann
> 
> use MIME::Words qw(:all);
> use Unicode::Map8;

Does this really need Unicode::Map8? It fails 'make test' on my
system, and your code seems to run fine with that line commented
out.

A problem with MIME::Words, though is this, from the docs:

	[MIME::Words] does not comply with the RFC-1522 rules
	regarding the use of encoded words in message headers.

Which presumably means that it would decode my second example:

From: Eli the Bearded <elijah-=?utf-8?q?=E2=98=DA?=@workspot.net>

Which is does not have an encoded word in it. (The syntax is that
of an encoded word, but encoded words are forbidden in that 
context, so it must just be coincidental.)

Elijah
------
encoded his UTF-8 by hand since Unicode::Map8 seems broken


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

Date: Thu, 9 Nov 2000 20:14:18 GMT
From: Neil Montgomery <neil@utstat.utoronto.ca>
Subject: my() changes result of function -- why? 
Message-Id: <3A0B059A.C21ED69@utstat.utoronto.ca>

I wrote a program that needed to do various things with matrices of
numbers, including writing these matrices to files. Some code follows
below, stripped down to the bare essentials of the problem, so I
realize that my code does not follow best practices.

wmatrix1 works, but wmatrix2 does not (it prints a single \n to the
file "f2".

I would be interested in learning why this happens, when the two
functions look rather similar, except that I used my() in the first
one.

while (<>) {
    push @matrix, [ split ];
}

wmatrix1("f1", \@matrix);
wmatrix2("f2", \@matrix);

sub wmatrix1 {
    my ($mat) = $_[1];
    open(WRITEFILE,">$_[0]");
    foreach $array_ref (@$mat) {
        print WRITEFILE "@$array_ref\n";
    }
    close(WRITEFILE);
}

sub wmatrix2 {
    open(WRITEFILE,">$_[0]");
    foreach $array_ref (@$_[1]) {
        print WRITEFILE "@$array_ref\n";
    }
    close(WRITEFILE);
}
__END__

Regards,
Neil


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

Date: 9 Nov 2000 21:59:38 GMT
From: cjw44@flatline.org.uk (Colin Watson)
Subject: Re: my() changes result of function -- why?
Message-Id: <8uf6oa$3nl$1@riva.ucam.org>

Neil Montgomery <neil@utstat.utoronto.ca> wrote:
>wmatrix1 works, but wmatrix2 does not (it prints a single \n to the
>file "f2".
>
>I would be interested in learning why this happens, when the two
>functions look rather similar, except that I used my() in the first
>one.
[...]
>    foreach $array_ref (@$mat) {
[...]
>    foreach $array_ref (@$_[1]) {

You've got your syntax slightly mixed up here.

Normally, a dereferencing operation is like ${expression},
@{expression}, or whatever. However, in order to reduce the number of
braces you need to type, Perl lets you leave them out sometimes.
Specifically, if the expression is just a simple scalar variable like
$foo, you can use $$foo or @$foo instead of ${$foo} or @{$foo}.

However, if the expression is more complicated than that, then you can't
use this piece of syntactic sugar. @$_[1] is really @{$_}[1], and means
"treat $_ as a reference to an array, and take the array slice [1] of
that array". You should use @{$_[1]} instead.

See 'perldoc perlref' for more details.

-- 
Colin Watson                                     [cjw44@flatline.org.uk]
"Master," I complained, "the programmer who wrote this code is lazy!
It's a simple bug and yet he's done nothing about it." My Master asked
me, "Why, then, have you not fixed it yourself?" I was then enlightened.


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

Date: 09 Nov 2000 17:20:37 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: my() changes result of function -- why?
Message-Id: <m3hf5gaitm.fsf@mumonkan.sunstarsys.com>

Neil Montgomery <neil@utstat.utoronto.ca> writes:

> wmatrix1 works, but wmatrix2 does not (it prints a single \n to the
> file "f2".
> 
> I would be interested in learning why this happens, when the two
> functions look rather similar, except that I used my() in the first
> one.

Great question, Neil.  Have you tried running your code segment with
warning flags enabled?  I modified it a little, so try it out and 
tell me what you think is happening.

#!/usr/bin/perl -wT

while (<DATA>) {
     push @matrix, [ split ];
}

wmatrix1("f1", \@matrix);
wmatrix2("f2", \@matrix);
 
sub wmatrix1 {
    my ($mat) = $_[1];
    open(WRITEFILE,">$_[0]");
    foreach $array_ref (@$mat) {
        print WRITEFILE "@$array_ref\n";
    }
    close(WRITEFILE);
}

sub wmatrix2 {
    open(WRITEFILE,">$_[0]");
    foreach $array_ref (@$_[1]) {
        print WRITEFILE "@$array_ref\n";
     }
    close(WRITEFILE);
}

__DATA__

Here is my file.
It gets read into @matrix.
Each word becomes a new item.

__END__

-- 
Joe Schaefer



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

Date: 09 Nov 2000 17:22:48 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: my() changes result of function -- why?
Message-Id: <m3d7g4aipz.fsf@mumonkan.sunstarsys.com>

cjw44@flatline.org.uk (Colin Watson) writes:

> Normally, a dereferencing operation is like ${expression},
> @{expression}, or whatever. However, in order to reduce the number of
> braces you need to type, Perl lets you leave them out sometimes.
> Specifically, if the expression is just a simple scalar variable like
> $foo, you can use $$foo or @$foo instead of ${$foo} or @{$foo}.
> 
> However, if the expression is more complicated than that, then you can't
> use this piece of syntactic sugar. @$_[1] is really @{$_}[1], and means
> "treat $_ as a reference to an array, and take the array slice [1] of
> that array". You should use @{$_[1]} instead.
> 

You beat me to the punchline ;)

-- 
Joe Schaefer


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

Date: Thu, 09 Nov 2000 19:00:44 GMT
From: nodo70@my-deja.com
Subject: Re: Net::Telnet & Net::Ping
Message-Id: <8ues8n$90s$1@nnrp1.deja.com>

Thanks for your quick response Martien.

>
> And I changed it to do udp pings, because I didn't feel like becoming
> root to test this.
>
What do you mean by saying above?  UDP PING?  Excuse myself if I am
just being idiot here.

Thanks,
Nodo

> Martien
> --
> Martien Verbruggen              |
> Interactive Media Division      |
> Commercial Dynamics Pty. Ltd.   | What's another word for Thesaurus?
> NSW, Australia                  |
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4858
**************************************


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