[27052] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8960 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 16 00:05:51 2006

Date: Wed, 15 Feb 2006 21:05:05 -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, 15 Feb 2006     Volume: 10 Number: 8960

Today's topics:
    Re: Best way for -h option for script to run perldoc on <edh@example.com>
    Re: How to stop perl from exiting when stat($_)->size f <peter@nospam.com>
        Need help about Build_MatchMany_Function ! <sonet.all@msa.hinet.net>
        Nordic Perl Workshop 2006 - Call for Papers (Reminder) <npw2006-talks@perlworkshop.no>
        XML::Simple oddity <rob@nowhere.com>
    Re: XML::Simple oddity <glex_no-spam@qwest-spam-no.invalid>
    Re: XS - Variable creation <nospam-abuse@ilyaz.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 16 Feb 2006 03:03:16 +0100
From: Ed Hennig <edh@example.com>
Subject: Re: Best way for -h option for script to run perldoc on itself?
Message-Id: <ba3d60c18dc0fd88cdb0a6397cf5b8ce@msgid.frell.theremailer.net>

Uri Guttman <uri@stemsystems.com> wrote:

> >>>>> "EH" == Ed Hennig <edh@example.com> writes:
> 
>   EH> What's the best or correct way to get a Perl program to handle the -h
>   EH> option (through getopts) by outputting its own perldoc documentation
>   EH> to the terminal?
> 
>   EH> exec("perldoc " . $0) if ( $option{h} );
> 
> there are modules that can do that for you. search cpan for pod stuff.

If

  exec("perldoc", $0) if ($option{h});

works fine, why make things more complicated than necessary? 

What are the advantages of using the CPAN POD modules when all I want
is to show something that looks like a man page?




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

Date: Thu, 16 Feb 2006 00:56:29 +0100
From: "Peter Juuls" <peter@nospam.com>
Subject: Re: How to stop perl from exiting when stat($_)->size fails
Message-Id: <43f3bfa2$0$47026$edfadb0f@dread15.news.tele.dk>

"Peter Juuls" <peter@nospam.com> wrote in message 
news:43f35bcd$0$46979$edfadb0f@dread15.news.tele.dk...
> I don't want the script to exit, instead I want to ignore the "bad" file 
> and
> continue with the next file. I have tried to do tests on file-existence
> BEFORE the stat->size is executed, to prevent perl from exiting, but 
> nothing
> seems to work.
>
> How can I prevent the script from exiting? (ActiveStatePerl587 on
> Windows2000)

Thanks for your tips, everyone, I have replaced my old code with this code

use File::stat ;
 .....
my $st=stat($_);
if (defined $st) {
  $bytes=$st->size;
  };

This is an improvement, the script no longer exits when stat($_) fails for a 
single file. It just skips the "bad" file, and that is what I want.
Still, I don't quite understand why it fails on a valid filename (I DO know 
the file exists and is not accessed in other parts of my script or by other 
programs), it happens seldomly, though, only once for several millions 
files. A tip pointed out that this code gives me the real error message, so 
I will use it to get to the bottom of the problem.

(stat($_) or die $!)->size;


Best regards
Peter Juuls 




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

Date: Thu, 16 Feb 2006 11:19:26 +0800
From: "sonet" <sonet.all@msa.hinet.net>
Subject: Need help about Build_MatchMany_Function !
Message-Id: <dt0r3r$2a6$1@netnews.hinet.net>

I am tesing the code from
http://perl.apache.org/docs/general/perl_reference/perl_reference.html#Compiled_Regular_Expressions .
But it seem have some problem ,and i can not slove it by myself.
Sometime ,I got the result "Use of uninitialized value in concatenation (.)
or string at (eval 1) line 1, <HANDLE> line 101."


#you can got notspam.lst FROM
http://se2.program.com.tw/Portal_images/notspam.lst
#!/usr/local/perl
use warnings;
my $i   = 0;
my $nsi = 0;
my @test;
open( HANDLE, 'notspam.lst' );
while (<HANDLE>)
{
 $_ =~ s/\r|\n| //g;
 if ( $_ ne '' && $_ !~ m/\#/ )
 {
  $test[ $nsi++ ] = $_;
 }
}
close(HANDLE);
my $result = expr_build(@test);
open( HANDLE, 'notspam.lst' );
while (<HANDLE>)
{
 $_ =~ s/\r|\n| //g;
 if ( $_ ne '' && $_ !~ m/\#/ )
 {
  if ( !&$result("$_") )
  {
   print $_ . '=>no' . "\n";
   sleep(5);
  } else
  {
   print $_ . '=>yes' . "\n";
  }
 }
}

sub expr_build
{
 my @R      = @_;
 my $expr   = join '||', map { "\$_[0]=~/\$R[$_]/oi" } ( 0 .. $#R );
 my $subref = eval "sub { $expr }";
 return $subref;
}




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

Date: Wed, 15 Feb 2006 23:24:44 GMT
From: Lars Haugseth <npw2006-talks@perlworkshop.no>
Subject: Nordic Perl Workshop 2006 - Call for Papers (Reminder)
Message-Id: <87wtfw19z4.fsf@durin.larshaugseth.com>

Just a quick note to inform people that the deadline for submissions
of talks to the Nordic Perl Workshop 2006 is approaching.

The workshop will be held in Oslo, Norway, on the 15th and 16th
of June, 2006. The main topic of this year's workshop is
"Managing Complexity."

The deadline for talk submissions has been set to March 1st.

For further information, please visit our homepage at
http://oslo.pm.org/npw2006/papers.shtml

With regards,
-- 
Lars Haugseth
Assistant Program Manager
Nordic Perl Workshop 2006


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

Date: Wed, 15 Feb 2006 23:21:30 GMT
From: Rob <rob@nowhere.com>
Subject: XML::Simple oddity
Message-Id: <_HOIf.21029$_S7.8255@newssvr14.news.prodigy.com>

Hi,

I just found out that in my xml file, if I have one
ELEMENT with an ATTRIBUTE, the XML::Simple treats the
ATTRIBUTE as an ELEMENT....so:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE site-catalog SYSTEM "xml_header.dtd">
<site-catalog>
   <site>
       <name>VNC</name>
          <header>
            <date id = "2006-01-04T23:14:23">
               <fullname>UNKN                  </fullname>
               <domes>NONE</domes>
               <lat>UNKN</lat>
            </date>
          </header>
   </site>
</site-catalog>

here, the DATA::Dumper prints:
$VAR1 = {
           'site' => {
                       'name' => 'VNC',
                       'header' => {
                                     'date' => {
                                               'lat' => 'UNKN',
                                               'domes' => 'NONE',
                                               'id' => '2006-01-04T23:14:23',
                                               'fullname' => 'UNKN                  ',
                                             }
                                   }
                     }
         };



But, if I have 2 ELEMENTS w/ATTRIBUTES,

<?xml version="1.0" standalone="no"?>
<!DOCTYPE site-catalog SYSTEM "xml_header.dtd">
<site-catalog>
   <site>
       <name>VANCOUVER</name>
          <header>
            <date id = "2005-10-07T10:14:30">
               <fullname>UNKN                  </fullname>
               <domes>NONE</domes>
               <lat>UNKN</lat>
            </date>
            <date id = "2006-01-04T23:14:23">
               <fullname>UNKN                  </fullname>
               <domes>NONE</domes>
               <lat>UNKN</lat>
            </date>
          </header>
   </site>
</site-catalog>

In this case, the DATA::Dumper prints:
$VAR1 = {
           'site' => {
                       'name' => 'VANCOUVER',
                       'header' => {
                                     'date' => {
                                               '2005-10-07T10:14:30' => {
                                                                        'lat' => 'UNKN',
                                                                        'domes' => 'NONE',
                                                                        'fullname' => 'UNKN',
                                                                      },
                                               '2006-01-04T23:14:23' => {
                                                                        'lat' => 'UNKN',
                                                                        'domes' => 'NONE',
                                                                        'fullname' => 'UNKN'
                                                                      }
                                             }
                                   }
                     }
         };


How can I get the XML::Simple to print like the 2nd
case if I have the xml like the first case?
 ...thanx for any suggestions...


--Rob


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

Date: Wed, 15 Feb 2006 18:08:16 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: XML::Simple oddity
Message-Id: <TnPIf.38$_t6.907@news.uswest.net>

Rob wrote:

> How can I get the XML::Simple to print like the 2nd
> case if I have the xml like the first case?
> ...thanx for any suggestions...

Start with the documentation.

perldoc XML::Simple

"ForceArray => 1 # in - important

        This option should be set to '1' to force nested elements
	to be represented as arrays even when there is only one.
	...
"



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

Date: Thu, 16 Feb 2006 01:01:41 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: XS - Variable creation
Message-Id: <dt0itl$1ru3$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Ferry Bolhar
<bol@adv.magwien.gv.at>], who wrote in article <1140019162.239592@proxy.dienste.wien.at>:
> Hi perl-folk,
> 
> given a scalar value in XS code, I want to make this value visible from Perl
> Scripts
> (I want to create a scalar variable) in a (perhaps not-yet-existent) name
> space. Is
> there a function for this? Or do I have to create to required data
> structures (stash
> entries, globs) by hand?
> 
> I havn't found anything in perlxs & perlxstut about this. Some other ideas
> where
> to look?

 perldoc perlguts

Find "Creating new variables"

get_sv(): TRUE argument will create.

Hope this helps,
Ilya


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

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 V10 Issue 8960
***************************************


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