[28799] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 43 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 17 23:21:08 2007

Date: Wed, 17 Jan 2007 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 17 Jan 2007     Volume: 11 Number: 43

Today's topics:
    Re: convert Vbscript to Perl code <jgibson@mail.arc.nasa.gov>
        Extracting Message body from email using POP3Client Eadmund@letterbee.com
        I/O open() <mmccaws@comcast.net>
    Re: I/O open() <spamtrap@dot-app.org>
    Re: I/O open() <mritty@gmail.com>
    Re: I/O open() <novafyre@hotmail.com>
    Re: I/O open() <someone@example.com>
    Re: include file? <spamtrap@dot-app.org>
    Re: Map Windows from Unix <m@remove.this.part.rtij.nl>
    Re: Module for user preferences ~/. file <news@lawshouse.org>
    Re: Net::SSH::Perl make test fails <stahl.karl@gmail.com>
    Re: parse body mime message <mritty@gmail.com>
    Re: parse body mime message <mark.clementsREMOVETHIS@wanadoo.fr>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 17 Jan 2007 12:13:14 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: convert Vbscript to Perl code
Message-Id: <170120071213140395%jgibson@mail.arc.nasa.gov>

In article <873b6a6uie.fsf@mithril.chromatico.net>, Charlton Wilbur
<cwilbur@chromatico.net> wrote:

> Indeed; I have a stuffed toy tiger that I explain Objective-C
> programming problems to, and the act of explaining them solves them
> most of the time.  I don't see why the same tactic wouldn't work in
> Perl, except that I rarely have Perl problems that require deep
> thought.  Domain problems that need to be expressed in Perl, yes....
> 
> I expect the tiger will go on strike when 10.5 is released.

<http://www.thisplaceisazoo.com/products/leopard.html#D1841>

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: 17 Jan 2007 10:25:32 -0800
From: Eadmund@letterbee.com
Subject: Extracting Message body from email using POP3Client
Message-Id: <1169058332.914517.303630@s34g2000cwa.googlegroups.com>

Hi,

I'm using pop3Client to succeessfully extract e-mail from my mail
server, BUT depending on the format (ie plain text, richt text or HTML)
that they are sent, I end up with a body that requres "massaging" with
regular expressions to get a clean message. I am concerned that
different systems will send me mails wilh "slightly" different formats
and wont work with my tidy routines.

Question: Has anyone got any code or can recomend a  module that will
extrcat a "clean message body" from  the email regardless of format /
system sent from?

Ta

Eadmund

Eadmund@letterbee.com



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

Date: 17 Jan 2007 11:13:39 -0800
From: "mmccaws2" <mmccaws@comcast.net>
Subject: I/O open()
Message-Id: <1169061219.054055.170820@s34g2000cwa.googlegroups.com>

Hi

I'm trying to understand the I/O open function better.  I got the test
script to work, but I not sure if the syntax is standard.  Could
someone explain the syntax option, or point to a link, for using open
to run OS commands.

use strict;
	my $line;


	open (NS_COMMAND, 'nslookup -type=soa wa.gov. ns1.six.net. |')
		or die "Ooops, $!";
		my $count=1;
		 while ($line = <NS_COMMAND>) {
		 	chomp($line);
			print "$count $line\n";
			$count++;
		}
		close NS_COMMAND;

i plan to morph this test script into a routine that runs through of
list of nslookup options.  Also, since this will be finally ran on
[u|li]nux environment then any suggestions specific to the OS would be
greatful

Oh I need a perl/regex script that filters level 8 interference out of
getting work done.  Best suggestion gets a embroidery patch with that
script on it.

Mike



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

Date: Wed, 17 Jan 2007 14:30:08 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: I/O open()
Message-Id: <m2lkk14fjz.fsf@Sherm-Pendleys-Computer.local>

"mmccaws2" <mmccaws@comcast.net> writes:

> I'm trying to understand the I/O open function better.

Have you read "perldoc perlopentut"?

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: 17 Jan 2007 11:32:01 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: I/O open()
Message-Id: <1169062321.392061.256980@q2g2000cwa.googlegroups.com>

mmccaws2 wrote:
> I'm trying to understand the I/O open function better.  I got the test
> script to work, but I not sure if the syntax is standard.  Could
> someone explain the syntax option, or point to a link, for using open
> to run OS commands.

perldoc -f open
perldoc perlopentut
perldoc perlipc

>
> use strict;

Good!

> 	my $line;

 ... not so good.  Declare your variables in the shortest scope
possible.  It will help immensely in debugging your scripts.

> 	open (NS_COMMAND, 'nslookup -type=soa wa.gov. ns1.six.net. |')
> 		or die "Ooops, $!";

This code is perfectly syntactically valid, but it's not the best.  At
the very least, you should be using lexical filehandles, rather than
global barewords.  That way, they're subject to strictures, two
independent pieces of code that use the same filehandle name can't
interphere with each other, and they're automatically closed when the
scope ends.

open my $NS_COMMAND, 'nslookup -type=soa wa.gov. ns1.six.net. |') or
die "...";

These days, it's also preferred to use the three-argument form of open,
rather than specifying the mode within the filename (or program name,
in the case of open() for IPC)

open my $NS_COMMAND, '-|', 'nslookup', '-type=soa wa.gov.',
'ns1.six.net.' or die "...";

(note that this doesn't really have any effect on your specific case,
but it's best to use the best practice always, to get into the habbit.
It can affect things greatly when you eventually go to open a file
named by a variable whose value was read from the user...)

> 		my $count=1;

This variable is pointless, as Perl already defines $. for you...

> 		 while ($line = <NS_COMMAND>) {

Here, btw, is where $line should have been defined.

> 		 	chomp($line);
> 			print "$count $line\n";

Why are you chomping only to print a newline at the end anyway?

> 			$count++;
> 		}

Taking into account these changes, your loop becomes:

while (my $line = <$NS_COMMAND>) {
  print "$. $line";
}

> 		close NS_COMMAND;
>
> i plan to morph this test script into a routine that runs through of
> list of nslookup options.  Also, since this will be finally ran on
> [u|li]nux environment then any suggestions specific to the OS would be
> greatful

No, that's not what you want.  You should be asking for suggestions
that are platform-agnostic, not simply programs that are not tailored
to other operating systems.  The above code is indeed platform
independent.

Paul Lalli



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

Date: Wed, 17 Jan 2007 13:43:34 -0700
From: Mark Donovan <novafyre@hotmail.com>
Subject: Re: I/O open()
Message-Id: <C1D3D886.937A%novafyre@hotmail.com>

On 1/17/07 12:13, "mmccaws2" <mmccaws@comcast.net> wrote:

>  [snip]
> 
> i plan to morph this test script into a routine that runs through of
> list of nslookup options.  Also, since this will be finally ran on
> [u|li]nux environment then any suggestions specific to the OS would be
> greatful
> 

Instead of the nslookup command, the Net::DNS module from CPAN might work
for you. See http://www.net-dns.org/

Here's Net::DNS doing the same thing as your nslookup command.

===
use Net::DNS;
use Data::Dumper; # not required, used to show what query returns

my $res = Net::DNS::Resolver->new(
  nameservers => [qw(ns1.six.net)],
);
my $query = $res->query('wa.gov', 'SOA') or
  die "query failed: $res->errorstring";
($query->answer)[0]->print;
print Dumper($query->answer);
===

This prints:

wa.gov.    2711    IN    SOA    disdns1.wa.gov. bruceh.dis.wa.gov. (
                    200701073    ; Serial
                    10800    ; Refresh
                    3600    ; Retry
                    604800    ; Expire
                    86400 )    ; Minimum TTL
$VAR1 = bless( {
                 'minimum' => 86400,
                 'serial' => 200701073,
                 'ttl' => 2711,
                 'mname' => 'disdns1.wa.gov',
                 'name' => 'wa.gov',
                 'rdata' => '<raw packet data>',
                 'retry' => 3600,
                 'refresh' => 10800,
                 'rdlength' => 43,
                 'type' => 'SOA',
                 'class' => 'IN',
                 'expire' => 604800,
                 'rname' => 'bruceh.dis.wa.gov'
               }, 'Net::DNS::RR::SOA' );

-- 




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

Date: Wed, 17 Jan 2007 22:05:08 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: I/O open()
Message-Id: <o4xrh.158006$YV4.101059@edtnps89>

Paul Lalli wrote:
> mmccaws2 wrote:
>> 
>>	open (NS_COMMAND, 'nslookup -type=soa wa.gov. ns1.six.net. |')
>>		or die "Ooops, $!";
> 
> This code is perfectly syntactically valid, but it's not the best.  At
> the very least, you should be using lexical filehandles, rather than
> global barewords.  That way, they're subject to strictures, two
> independent pieces of code that use the same filehandle name can't
> interphere with each other, and they're automatically closed when the
> scope ends.
> 
> open my $NS_COMMAND, 'nslookup -type=soa wa.gov. ns1.six.net. |') or
> die "...";
> 
> These days, it's also preferred to use the three-argument form of open,
> rather than specifying the mode within the filename (or program name,
> in the case of open() for IPC)
> 
> open my $NS_COMMAND, '-|', 'nslookup', '-type=soa wa.gov.',
                                                   ^
That's not going to work with that space character in there.

> 'ns1.six.net.' or die "...";

Either use a single string:

open my $NS_COMMAND, '-|', 'nslookup -type=soa wa.gov. ns1.six.net.' or die "...";

Or a list with no whitespace:

open my $NS_COMMAND, '-|', 'nslookup', '-type=soa', 'wa.gov.', 'ns1.six.net.'
or die "...";




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: Wed, 17 Jan 2007 13:40:58 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: include file?
Message-Id: <m2wt3l4htx.fsf@Sherm-Pendleys-Computer.local>

avlee <xx@wp.pl> writes:

> I have some perl files with some basic fucntions which i would like to use.
> It's just simple functions (not modules)
>
> I wanted to use them in my next perl script.
> How could i do that ?

Make them into modules. Modules can contain simple functions too, they're not
just for classes & methods.

Have a look at:

    perldoc perlmod
    perldoc perlmodstyle

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Wed, 17 Jan 2007 20:44:21 +0100
From: Martijn Lievaart <m@remove.this.part.rtij.nl>
Subject: Re: Map Windows from Unix
Message-Id: <pan.2007.01.17.19.44.21.112731@remove.this.part.rtij.nl>

On Wed, 17 Jan 2007 08:02:31 -0600, Andrew DeFaria wrote:

> Martijn Lievaart wrote:
>> On Tue, 16 Jan 2007 19:27:27 -0600, Andrew DeFaria wrote:
>>> It's pretty funny that you don't recognize that that's pretty much 
>>> the same thing!
>> Well, there is a slight difference. Samba exports smb mounts, a cifs 
>> capable kernel imports smb mounts. Small difference. Big impact.
>>
>> Please try to follow your own advice, install samba on a non cifs 
>> capable kernel and try to mount a remote share from a Windows PC. Now 
>> try the same without samba on a cifs capable kernel. The first won't 
>> work, the second
>> will.
> I'm not sure what you mean by a "cifs" capable kernel. 

The fact that you don't know what a cifs capable kernel is shows the depth
of your knowledge.

> I've used Samba 
> to mount a remote share from a Windows PC and it worked just fine.

Are you dense or lying deliberately?

To all others. Not only is Mr DeFaria anti social and gives bad advice, he
will also not admit to being wrong. Not that we didn't know already.

M4
-- 
Redundancy is a great way to introduce more single points of failure.



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

Date: Wed, 17 Jan 2007 17:18:38 +0000
From: Henry Law <news@lawshouse.org>
Subject: Re: Module for user preferences ~/. file
Message-Id: <1169054309.17133.0@damia.uk.clara.net>

traggatt@gmail.com wrote:

> Does anyone know a module which will store/retreive user preferences
> into a ~/.scriptprefs type file (e.g. like ~/.bashrc)?

I use a simple XML file for this, and XML::Simple to read it in and save 
it back.

-- 

Henry Law            Manchester, England


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

Date: 17 Jan 2007 11:22:45 -0800
From: "Ishmael" <stahl.karl@gmail.com>
Subject: Re: Net::SSH::Perl make test fails
Message-Id: <1169061765.218980.239760@l53g2000cwa.googlegroups.com>

Apparently, this error is not fatal, since I went ahead and installed
the module, and everything seems to be working.



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

Date: 17 Jan 2007 09:30:17 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: parse body mime message
Message-Id: <1169055017.430955.118490@q2g2000cwa.googlegroups.com>

jcharth@hotmail.com wrote:
> Hello I am downloading a mime from a web server using lwp
> my $fullpage = $ua->request($req)->as_string;
> then i was trying to extract the text body of the mesage using MIME
> tools but i cant seem get this to work
> when i do
> $parser->parse_data($fullpage)
> i get
> Can't use string ("MIME::Parser") as a HASH ref while "strict refs" in
> use at /usr/lib/perl5/site_perl/5.8.0/MIME/Parser.pm line 279.
>
> not sure what i am doing wrong

Neither are we, and it's pretty hard to guess without seeing the
*actual* code.  I refuse to believe that those two simple lines are
enough to cause the error.  Please post a SHORT but COMPLETE script
that demonstrates the error you're having.   Also, please read the
Posting Guidelines for this group, which would have told you to do that
in the first place.

Paul Lalli



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

Date: Wed, 17 Jan 2007 22:00:09 +0100
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: parse body mime message
Message-Id: <45ae8e78$0$5100$ba4acef3@news.orange.fr>

jcharth@hotmail.com wrote:
> Hello I am downloading a mime from a web server using lwp
> my $fullpage = $ua->request($req)->as_string;
> then i was trying to extract the text body of the mesage using MIME
> tools but i cant seem get this to work
> when i do
> $parser->parse_data($fullpage)
> i get
> Can't use string ("MIME::Parser") as a HASH ref while "strict refs" in
> use at /usr/lib/perl5/site_perl/5.8.0/MIME/Parser.pm line 279.
> 
> not sure what i am doing wrong
> thanks.
> 
How have you created $parser?

use strict;
use warnings;

use MIME::Parser;

my $parser = MIME::Parser->new();

would be usual (see perldoc MIME::Parser).

Have you done something like:

mark@owl:~$ cat testmimeparser.pl
use strict;
use warnings;

use MIME::Parser;

my $parser = "MIME::Parser";

$parser->parse_data("this is not a test");
mark@owl:~$ perl testmimeparser.pl
Can't use string ("MIME::Parser") as a HASH ref while "strict refs" in 
use at /usr/share/perl5/MIME/Parser.pm line 279.

As Paul says, you need to check out the posting guidelines - you haven't 
given us much to go on.

Mark


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

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


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