[29836] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1079 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 29 03:14:14 2007

Date: Thu, 29 Nov 2007 00:14:07 -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           Thu, 29 Nov 2007     Volume: 11 Number: 1079

Today's topics:
    Re: parsing a mbox file in PERL <mc79@cse.buffalo.edu>
    Re: parsing a mbox file in PERL <ben@morrow.me.uk>
    Re: retrieving news messages <source@netcom.com>
    Re: Side effects of overloading quotes "" <koszalekopalek@interia.pl>
    Re: SvUOK always fails on 64bit platform <u8526505@gmail.com>
        writing to a notepad in perl <rajendra.prasad@in.bosch.com>
    Re: writing to a notepad in perl <jurgenex@hotmail.com>
    Re: writing to a notepad in perl <sanjeeb25@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 28 Nov 2007 21:11:46 -0500
From: Madhusudhanan Chandrasekaran <mc79@cse.buffalo.edu>
To: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: parsing a mbox file in PERL
Message-Id: <Pine.SOL.4.56.0711282107360.20761@pollux.cse.buffalo.edu>

Thanks for the response. It's like pandoras box,
more emerge. I get the following message that
Mail::Header is missing. But I cannot install
it for some weird reason -- The exact error I get
is as:

/bin/tar: MailTools-2.01: time stamp 2007-11-28 04:48:57 is
253591.077197246 s in the future
Removing previously used /home/mc79/.cpan/build/MailTools-2.01

  CPAN.pm: Going to build M/MA/MARKOV/MailTools-2.01.tar.gz

WARNING: LICENSE is not a known parameter.
Checking if your kit is complete...
Looks good
'LICENSE' is not a known MakeMaker parameter name.
Writing Makefile for Mail
make: Warning: File `Makefile.PL' has modification time 2.5e+05 s in the
future
Makefile out-of-date with respect to Makefile.PL
Cleaning current config before rebuilding Makefile...
/usr/bin/make -f Makefile.old clean > /dev/null 2>&1
/usr/bin/perl Makefile.PL "INSTALLDIRS=site"
WARNING: LICENSE is not a known parameter.
Checking if your kit is complete...
Looks good
'LICENSE' is not a known MakeMaker parameter name.
Writing Makefile for Mail
==> Your Makefile has been rebuilt. <==
==> Please rerun the /usr/bin/make command.  <==
false
make: *** [Makefile] Error 1
  /usr/bin/make  -- NOT OK
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible



How would one get around these?

Thanks,
_Madhu

On Wed, 28 Nov 2007, Jim Gibson wrote:

> In article <Pine.SOL.4.56.0711281938240.20060@pollux.cse.buffalo.edu>,
> Madhusudhanan Chandrasekaran <mc79@cse.buffalo.edu> wrote:
>
> > Hi,
> >
> > I am trying to parse a mbox file and extract the message's
> > body. I am using Mail::MboxParser for this purpose. In my
> > source code, I have
> >
> >
> >  my $mb = Mail::MboxParser->new('some_mailbox',
> >                                 decode     => 'ALL',
> >                                  parseropts => $parseropts);
> >
> > with the $parseropts initialized. However, it gives me the
> > following error message:
> >
> > Can't locate object method "new" via package "MIME::Parser" at
> > /usr/local/share/perl/5.8.8/Mail/MboxParser/Mail.pm line 513.
> >
> > I've MIME::Parser installed and it does seem to have a new method.
> >
> > Any pointers appreciated.
>
> What versions are you running? Have you tried upgrading to the latest?
>
> Lines 511-515 of Mail::MboxParser.pm are as follows:
>
>
>         if (! defined $Parser) {
>             eval { require MIME::Parser; };
>             $Parser = new MIME::Parser; $Parser->output_to_core(1);
>             $Parser->extract_uuencode($self->{ARGS}->{uudecode});
>         }
>
> ... and it looks like the code is not checking if the "require
> MIME::Parser" worked :^(
>
> Make sure MIME::Parser is installed properly. Try putting
>
>   warn("No MIME::Parser $@") if $@;
>
> after the eval.
>
> --
> Jim Gibson
>
>  Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
>     ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
>                 http://www.usenet.com
>

--------------------------------------------------
All in all I'm just another brick in the FIREWALL.



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

Date: Thu, 29 Nov 2007 03:25:35 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: parsing a mbox file in PERL
Message-Id: <f2o125-m75.ln1@osiris.mauzo.dyndns.org>

[quoting fixed. please don't top-post]

Quoth Madhusudhanan Chandrasekaran <mc79@cse.buffalo.edu>:
> On Wed, 28 Nov 2007, Jim Gibson wrote:
> > In article <Pine.SOL.4.56.0711281938240.20060@pollux.cse.buffalo.edu>,
> > Madhusudhanan Chandrasekaran <mc79@cse.buffalo.edu> wrote:
> > >
> > > Can't locate object method "new" via package "MIME::Parser" at
> > > /usr/local/share/perl/5.8.8/Mail/MboxParser/Mail.pm line 513.
> > >
> > > I've MIME::Parser installed and it does seem to have a new method.
> >
> > Lines 511-515 of Mail::MboxParser.pm are as follows:
> >
<snip>
> >
> > ... and it looks like the code is not checking if the "require
> > MIME::Parser" worked :^(
> >
> > Make sure MIME::Parser is installed properly. Try putting
> >
> >   warn("No MIME::Parser $@") if $@;

This isn't in general a very safe construction. There are too many ways
(destructors, signal handlers, etc.) in which $@ can get messed up.
Better is to make sure the eval returns true, and test for that:

    eval {
        require MIME::Parser;
        1;      # 5.8.0 has a bug where require in eval can return false
    } or warn "No MIME::Parser: $@";

Of course, if something untoward happens the error message will be
wrong, but that's better than failing to catch the error at all.

> > after the eval.
>
> Thanks for the response. It's like pandoras box,
> more emerge. I get the following message that
> Mail::Header is missing. But I cannot install
> it for some weird reason -- The exact error I get
> is as:
> 
> /bin/tar: MailTools-2.01: time stamp 2007-11-28 04:48:57 is
> 253591.077197246 s in the future

Your computer's clock is wrong. make depends on having the clock at
least approximately right, so you will need to fix this.

<snip>
> ==> Your Makefile has been rebuilt. <==
> ==> Please rerun the /usr/bin/make command.  <==
> false

MakeMaker is asking you to re-run make: if you do, it's possible it will
work correctly this time. It's probably better to fix your clock,
though.

Ben



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

Date: Wed, 28 Nov 2007 23:03:22 -0800
From: David Harmon <source@netcom.com>
Subject: Re: retrieving news messages
Message-Id: <13ksp20d0m9g2c5@corp.supernews.com>

On Thu, 05 Jul 2007 12:25:20 -0700 in comp.lang.perl.misc, Joe Smith
<joe@inwap.com> wrote,
>   my $nntp = Net::NNTP->new('newsgroups.comcast.net', { Debug => 1} );
>   die "Unable to create NNTP object" unless $nntp;
>
>You have got to get those two statements working before proceeding
>any further.

It appears to me, that style of passing arguments to Net::NNTP->new
cannot work.  I see this code in Net/NNTP.pm:

sub new
{
 my $self = shift;
 my $type = ref($self) || $self;
 my ($host,%arg);
 if (@_ % 2) {
   $host = shift ;
   %arg  = @_;
 } else {
   %arg = @_;
   $host=delete $arg{Host};
 }


The above looks wrong to me; I think it ought to be more like

 if (not (@_ % 2)) {

However, I'm still something of a Perl newbie, and am not quite sure
of all that I am looking at here.  It appears that the constructor
fails to pick up the Host argument, but then it goes on to look for
the NNTPSERVER environment variable and use that, as documented.  
I guess that everyone who got it to work had some such luck.

What do you all think?


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

Date: Wed, 28 Nov 2007 22:18:59 -0800 (PST)
From: Koszalek Opalek <koszalekopalek@interia.pl>
Subject: Re: Side effects of overloading quotes ""
Message-Id: <5d65c5cf-f1ed-4c40-a4a1-4e7f73993ecc@l1g2000hsa.googlegroups.com>

On Nov 28, 9:16 pm, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:


> Don't comment out code in your posting. That makes it hard to figure out
> exactly what code you ran.

Ok.

> > sub new ()

> Don't specify prototypes for methods:

Sure.

> So, here is a reworked example. I did change method names to my liking:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> package Obj;
>
> use Scalar::Util qw( refaddr );
>
> use overload
>     q{""}  => \&to_string,
>     'bool' => \&to_bool,
>     q{0+}  => \&to_val,
>     q{==}  => \&is_identical,
> ;
>
> sub new { bless {} => shift }
>
> sub to_string { q{} }
>
> sub to_bool { defined shift }
>
> sub to_val { refaddr shift }
>
> sub is_identical { refaddr shift == refaddr shift }
>
> package main;
>
> my $obj1 = Obj->new;
> my $obj2 = Obj->new;
>
> ### PROBLEM 1 ###
>
> print( $obj1 ? "true\n" : "false\n" );
>
> ### PROBLEM 2 ###
>
> print( $obj1 == $obj2 ? "same\n" : "different\n" );
>
> __END__


Thank you.
That works beautifully.

A.


> --
> A. Sinan Unur <1...@llenroc.ude.invalid>
> (remove .invalid and reverse each component for email address)
> clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>



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

Date: Wed, 28 Nov 2007 23:47:53 -0800 (PST)
From: cyl <u8526505@gmail.com>
Subject: Re: SvUOK always fails on 64bit platform
Message-Id: <46372675-8f8c-4703-9d68-e135639c5ea0@d27g2000prf.googlegroups.com>

On 11$B7n(B24$BF|(B, $B>e8a(B1$B;~(B20$BJ,(B, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth cyl <u8526...@gmail.com>:
> > 0 - 0x7fffffff                            false
> > 0x80000000 - 0xffffffff             true
>
> 0x7fffffff here is the largest value that fits into a 32bit IV.
>
> > 64bit
> > (in perl)                                (SvUOKreturn value)
> > 0-0xffffffff                               false
>
> 0xffffffff easily fits into a 64bit IV, so that's what perl uses. If you

I thought 0xffffffff should be the max value of unsigned integer on
either 32 bit or 64 bit platform. Is this correct? Actually the
problem comes from the SWIG (http://www.swig.org) implementation. I
post the generated code below.

On 64bit platform, when I pass values larger than 0x7fffffff to
TestInt, the function SWIG_AsVal_unsigned_SS_long at the bottom will
be called with parameter ST(0). Since SvUOK returns false, SvIV is
used to convert the value. In this case, values latger than 0x7fffffff
become negative and an OverflowError is thrown. I'm wondering what
changes should I make to correct this problem. Will there be any
problem if I call SvUV directly without any type check?

XS(_wrap_TestInt) {
  {
    unsigned int arg1 ;
    unsigned int result;
    unsigned int val1 ;
    int ecode1 = 0 ;
    int argvi = 0;
    dXSARGS;

    if ((items < 1) || (items > 1)) {
      SWIG_croak("Usage: TestInt(unsigned int);");
    }
    ecode1 = SWIG_AsVal_unsigned_SS_int SWIG_PERL_CALL_ARGS_2(ST(0),
&val1);
    if (!SWIG_IsOK(ecode1)) {
      SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '"
"TestInt" "', argument " "1"" of type '" "unsigned int""'");
    }
    arg1 = (unsigned int)(val1);
    result = (unsigned int)TestInt(arg1);
    ST(argvi) = SWIG_From_unsigned_SS_int
SWIG_PERL_CALL_ARGS_1((unsigned int)(result)); argvi++ ;

    XSRETURN(argvi);
  fail:

    SWIG_croak_null();
  }
}

SWIGINTERN int
SWIG_AsVal_unsigned_SS_int SWIG_PERL_DECL_ARGS_2(SV * obj, unsigned
int *val)
{
  unsigned long v;
  int res = SWIG_AsVal_unsigned_SS_long SWIG_PERL_CALL_ARGS_2(obj,
&v);
  if (SWIG_IsOK(res)) {
    if ((v > UINT_MAX)) {
      return SWIG_OverflowError;
    } else {
      if (val) *val = (unsigned int)(v);
    }
  }
  return res;
}

SWIGINTERN int
SWIG_AsVal_unsigned_SS_long SWIG_PERL_DECL_ARGS_2(SV *obj, unsigned
long *val)
{
  if (SvUOK(obj)) {
    if (val) *val = SvUV(obj);
    return SWIG_OK;
  } else  if (SvIOK(obj)) {
    long v = SvIV(obj);
    if (v >= 0) {
      if (val) *val = v;
      return SWIG_OK;
    } else {
      return SWIG_OverflowError;
    }
  } else {
    int dispatch = 0;
    const char *nptr = SvPV(obj, PL_na);
    if (nptr) {
      char *endptr;
      unsigned long v = strtoul(nptr, &endptr,0);
      if (errno == ERANGE) {
	errno = 0;
	return SWIG_OverflowError;
      } else {
	if (*endptr == '\0') {
	  if (val) *val = v;
	  return SWIG_Str2NumCast(SWIG_OK);
	}
      }
    }
    if (!dispatch) {
      double d;
      int res = SWIG_AddCast(SWIG_AsVal_double
SWIG_PERL_CALL_ARGS_2(obj,&d));
      if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) {
	if (val) *val = (unsigned long)(d);
	return res;
      }
    }
  }
  return SWIG_TypeError;
}


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

Date: Thu, 29 Nov 2007 10:02:09 +0530
From: "rajendra" <rajendra.prasad@in.bosch.com>
Subject: writing to a notepad in perl
Message-Id: <filfcb$149$1@news4.fe.internet.bosch.com>

Hello All,

Whenever we want to write some content to a text file, we open that file and
write in that file as shown below:

open(f,">test.txt");
print f "This is test";

But there a way I can write a text file in fonts i.e some content in BOLD
letters and some in italised  etc using perl functions.





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

Date: Thu, 29 Nov 2007 04:46:12 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: writing to a notepad in perl
Message-Id: <our3j.20293$ht1.12739@trndny01>

rajendra wrote:
> But there a way I can write a text file in fonts i.e some content in
> BOLD letters and some in italised  etc using perl functions.

Sure. You can output HTML or TeX or PostSript or RTF or PDF or whatever 
format you are thinking about. Do you have something specific in mind? Then 
just do a search on CPAN and chances are pretty good that you will find a 
module that supports that format.

jue 




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

Date: Wed, 28 Nov 2007 21:42:05 -0800 (PST)
From: sanjeeb <sanjeeb25@gmail.com>
Subject: Re: writing to a notepad in perl
Message-Id: <1fbe5514-1b04-4826-9ab8-0738ba56f537@e25g2000prg.googlegroups.com>

On Nov 29, 9:46 am, "J=FCrgen Exner" <jurge...@hotmail.com> wrote:
> rajendra wrote:
> > But there a way I can write a text file in fonts i.e some content in
> > BOLD letters and some in italised  etc using perl functions.
>
> Sure. You can output HTML or TeX or PostSript or RTF or PDF or whatever
> format you are thinking about. Do you have something specific in mind? The=
n
> just do a search on CPAN and chances are pretty good that you will find a
> module that supports that format.
>
> jue

Check Win32::OLE in capn to suit most of the formatting stuffs.


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

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


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