[29277] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 521 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 15 18:09:49 2007

Date: Fri, 15 Jun 2007 15: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           Fri, 15 Jun 2007     Volume: 11 Number: 521

Today's topics:
    Re: I think I want to use of mmap and perlio <ts@dionic.net>
    Re: Massive Memory Structures QoS@domain.invalid
    Re: Massive Memory Structures xhoster@gmail.com
    Re: Massive Memory Structures  ruu@cwcom.net
    Re: Massive Memory Structures jgraber@ti.com
        Need regex <conversar@gmail.com>
    Re: Need regex <RedGrittyBrick@SpamWeary.foo>
    Re: Perl script to identify corrupt mbox messages? <rvtol+news@isolution.nl>
    Re: Perl script to identify corrupt mbox messages? <tuxedo@mailinator.net>
    Re: perl vs C for CGI <rvtol+news@isolution.nl>
        question about sorting syntax <corn29@excite.com>
    Re: question about sorting syntax <glex_no-spam@qwest-spam-no.invalid>
    Re: question about sorting syntax <mritty@gmail.com>
    Re: question about sorting syntax <dummy@example.com>
    Re: Simplify Variable Number of Regex Groups <wcitoan@NOSPAM-yahoo.com>
    Re: Simplify Variable Number of Regex Groups <xicheng@gmail.com>
        Template <kwan.jingx@gmail.com>
    Re: Template  krakle@visto.com
    Re: Template <kwan.jingx@gmail.com>
        Try Catch with Assert Statement  Bpejman@gmail.com
    Re: Try Catch with Assert Statement <noreply@invalid.net>
        using regex to select line matches <nadabadan@gmail.com>
    Re: using regex to select line matches (Steven M. O'Neill)
    Re: using regex to select line matches <noreply@gunnar.cc>
    Re: Win32: How to quit perl script during log off autom <lambik@kieffer.nl>
    Re: Writing row at a time in Excel using OLE <gimme_this_gimme_that@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 15 Jun 2007 20:20:09 +0100
From: Tim S <ts@dionic.net>
Subject: Re: I think I want to use of mmap and perlio
Message-Id: <4672e669$0$643$5a6aecb4@news.aaisp.net.uk>

Mark Seger wrote:


> So the question is, it is possible to open my mmap file, perform some
> operation on it and hold onto the memory?  My intent would then be to do
> a long sleep.
> 
> In addition to trying to figure out how mmap works because it does seem
> to be useful, I also wonder if anyone can suggest a better way to grab
> some memory and if not, so be it.
> 
> -mark

Hi

Simpler:

malloc() and mlock().

HTH

Tim


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

Date: Fri, 15 Jun 2007 18:55:44 GMT
From: QoS@domain.invalid
Subject: Re: Massive Memory Structures
Message-Id: <QgBci.13$bn6.5@trnddc03>


ruu@cwcom.net wrote in message-id:  <1181930945.169202.130560@g4g2000hsf.googlegroups.com>

[snip]
>
>On Jun 13, 4:44 pm, r...@cwcom.net wrote:
>> OK - I was under the impression that perl running on a 64 bit OS,
>> compiled for said 64 bit OS would be able to handle data structures in
>> memory greater than 4G in size.  I've tried this with a couple of OS's
>> (Solaris on sparc, Solaris on x86_64) with both packaged and compiled
>> versions of perl with identical results - as soon as I hit 4G with my
>> script, I get an out of memory error and the script dies.
>>
>> I'm pretty sure I don't have a ulimit issue, since more or less
>> everything is unlimited, and other programs run by the same user can
>> access over 4G of ram quite happily.
>>
>> Two questions:
>>
>> 1) Is it possible to access a structure over 4G with perl running on
>> Solaris?
>> 2) If so, what options do I need to compile in to make this happen.
>>
>> Dave

[paste] (please dont top-post)
>
>No-one knows?  Not even a "if you have to use more than 4G of memory,
>you don't know what you are doing" reply?
>
>Dave
>

Sounds like a Sun issue, have you tried accessing their knowledge base?
Unfortuantly i havent got 4 GB of memory to test this on my OS.
Perhaps this is not a Perl question at all;
did you try this using another programming language?




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

Date: 15 Jun 2007 19:48:18 GMT
From: xhoster@gmail.com
Subject: Re: Massive Memory Structures
Message-Id: <20070615154823.881$6l@newsreader.com>

ruu@cwcom.net wrote:
> On Jun 13, 4:44 pm, r...@cwcom.net wrote:
> > OK - I was under the impression that perl running on a 64 bit OS,
> > compiled for said 64 bit OS would be able to handle data structures in
> > memory greater than 4G in size.  I've tried this with a couple of OS's
> > (Solaris on sparc, Solaris on x86_64) with both packaged and compiled
> > versions of perl with identical results - as soon as I hit 4G with my
> > script, I get an out of memory error and the script dies.
> >
> > I'm pretty sure I don't have a ulimit issue, since more or less
> > everything is unlimited, and other programs run by the same user can
> > access over 4G of ram quite happily.

I thought there was a discussion here several months ago, but I can't find
it now.  It seems like the conclusion was that with Solaris you have
to start an executable in a certain way in order to get it to work with
more than 4G of memory, and apparently Perl isn't by default started in
that way.  It seems like there was some kind of "extended attribute",
like some super chmod command, you could run on the perl binary file to
tell it to start up in that special way in the future.  I didn't pay much
attention, because I don't use Solaris much, so this is all kind of fuzzy.
Maybe a Solaris specific group would know more.


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Fri, 15 Jun 2007 13:48:59 -0700
From:  ruu@cwcom.net
Subject: Re: Massive Memory Structures
Message-Id: <1181940539.135541.249280@o61g2000hsh.googlegroups.com>

On Jun 15, 2:55 pm, Q...@domain.invalid wrote:
> r...@cwcom.net wrote in message-id:  <1181930945.169202.130...@g4g2000hsf.googlegroups.com>
>
> [snip]
>
>
>
>
>
> >On Jun 13, 4:44 pm, r...@cwcom.net wrote:
> >> OK - I was under the impression that perl running on a 64 bit OS,
> >> compiled for said 64 bit OS would be able to handle data structures in
> >> memory greater than 4G in size.  I've tried this with a couple of OS's
> >> (Solaris on sparc, Solaris on x86_64) with both packaged and compiled
> >> versions of perl with identical results - as soon as I hit 4G with my
> >> script, I get an out of memory error and the script dies.
>
> >> I'm pretty sure I don't have a ulimit issue, since more or less
> >> everything is unlimited, and other programs run by the same user can
> >> access over 4G of ram quite happily.
>
> >> Two questions:
>
> >> 1) Is it possible to access a structure over 4G with perl running on
> >> Solaris?
> >> 2) If so, what options do I need to compile in to make this happen.
>
> >> Dave
>
> [paste] (please dont top-post)
>
>
>
> >No-one knows?  Not even a "if you have to use more than 4G of memory,
> >you don't know what you are doing" reply?
>
> >Dave
>
> Sounds like a Sun issue, have you tried accessing their knowledge base?
> Unfortuantly i havent got 4 GB of memory to test this on my OS.
> Perhaps this is not a Perl question at all;
> did you try this using another programming language?

I got a perl error (which I will concede may well have originated as
an OS error), and I have run other applications (written in C++
specifically) right up to 20+G of memory with no issues (I'm sorry - I
have a number of servers with 64G of RAM - its not my fault).  I was
really hoping for someone to say "This definitely isn't a general perl
thing, because I have done this on my Linux box".  I can take this up
with Sun directly, but chances are they are going to blame Perl, so I
was hoping to have some kind of answer as to if it was even possible.

Dave



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

Date: 15 Jun 2007 13:28:06 -0500
From: jgraber@ti.com
Subject: Re: Massive Memory Structures
Message-Id: <yvnvedpax8p.fsf@famous02.dal.design.ti.com>


ruu@cwcom.net writes:
> No-one knows?  Not even a "if you have to use more than 4G of memory,
> you don't know what you are doing" reply?
> Dave
> 
> On Jun 13, 4:44 pm, r...@cwcom.net wrote:
> > OK - I was under the impression that perl running on a 64 bit OS,
> > compiled for said 64 bit OS would be able to handle data structures in
> > memory greater than 4G in size.  I've tried this with a couple of OS's
> > (Solaris on sparc, Solaris on x86_64) with both packaged and compiled
> > versions of perl with identical results - as soon as I hit 4G with my
> > script, I get an out of memory error and the script dies.
> >
> > I'm pretty sure I don't have a ulimit issue, since more or less
> > everything is unlimited, and other programs run by the same user can
> > access over 4G of ram quite happily.
> >
> > Two questions:
> >
> > 1) Is it possible to access a structure over 4G with perl running on
> > Solaris?
> > 2) If so, what options do I need to compile in to make this happen.
> >
> > Dave

Possibly if you follow the steps in the posting guidelines,
such as posting a runnable short program that demonstrates the problem,
your post will both  overcome the work-threashold-limit 
and also pass the "sounds interesting" threshold
so that one of the few people here who have not only 
the knowledge, ability, experience,  but also the resource (4G solaris machine)
to check it out on their system, and if it works,  to post their configuration.

Our workgroup has been moving away from Solaris boxes
and toward Linux running on AMD Opterons, for 4G/8G/16G memory setups,
so even if you posted an example, I wouldn't have the ability to try it on 
a suitable Solaris machine.

-- 
Joel


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

Date: Fri, 15 Jun 2007 13:57:49 -0700
From:  Benton <conversar@gmail.com>
Subject: Need regex
Message-Id: <1181941069.288849.31100@c77g2000hse.googlegroups.com>

Hi there,

Please excuse me if this is not the right place to ask for a regex, if
so, please kindly point me in the right direction.

I need a regex for a Master Airway Bill which is like this:

123 4567 8900
653 5342 5362
847 7654 9087

Simply put: 3 digits {one space } 4 digits {one space} 4 digits.

Thanks for any help,

-Benton



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

Date: Fri, 15 Jun 2007 22:21:37 +0100
From: RedGrittyBrick <RedGrittyBrick@SpamWeary.foo>
Subject: Re: Need regex
Message-Id: <xKWdnclcapR9n-7bnZ2dnUVZ8sOonZ2d@bt.com>

Benton wrote:
> I need a regex for a Master Airway Bill which is like this:
> 
> 123 4567 8900
> 653 5342 5362
> 847 7654 9087
> 
> Simply put: 3 digits {one space } 4 digits {one space} 4 digits.

\d{3} \d{4} \d{4}


You would probably benefit from reading
perldoc perlre


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

Date: Fri, 15 Jun 2007 22:22:27 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Perl script to identify corrupt mbox messages?
Message-Id: <f4v3nt.1c8.1@news.isolution.nl>

Tuxedo schreef:

> I'm trying to repair a gigantic mbox file that appears to have been
> corrupted in that it displays only 17 of the most recent and total
> 3087 messages contained in the actual file.

Consider formail, it is on about every *ix system. 

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: Fri, 15 Jun 2007 23:34:24 +0200
From: Tuxedo <tuxedo@mailinator.net>
Subject: Re: Perl script to identify corrupt mbox messages?
Message-Id: <f4v0l0$vi3$01$1@news.t-online.com>

> Consider formail, it is on about every *ix system.

Sounds good but unfortunately the mbox belongs to a company which would not 
consider anything better than their crap Windows system!



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

Date: Fri, 15 Jun 2007 22:36:09 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: perl vs C for CGI
Message-Id: <f4v4ap.1bc.1@news.isolution.nl>

Peter J. Holzer schreef:

> A string written as a here document always
> contains simple "\n" characters as line endings regardless of whether
> the source file contained CRLFs or LF and whether it's executed on
> Windows or Unix.


And so it should. That \n is a metacharacter (line separator) that,
depending on platform and binmode, can become CR+LF again when written
out.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Fri, 15 Jun 2007 12:14:20 -0700
From:  Adam Sandler <corn29@excite.com>
Subject: question about sorting syntax
Message-Id: <1181934860.191622.71010@o61g2000hsh.googlegroups.com>

Hello,

On a few pages on the net I've seen this snip of code:

my @sorted=map  { substr($_,4) }
           sort
           map  { pack("LA*",tr/eE/eE/,$_) } @words;

In the few pages I've seen, which all have the same snip of code(word
for word in fact), none of the pages explain the parameters passed to
pack().  My question is, and perldoc -pack and Googling the "LA" don't
help, what does "LA*" mean?

Thanks!



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

Date: Fri, 15 Jun 2007 14:29:19 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: question about sorting syntax
Message-Id: <4672e88f$0$496$815e3792@news.qwest.net>

Adam Sandler wrote:

Actually it's a question about pack, not sorting.

[...]
> for word in fact), none of the pages explain the parameters passed to
> pack().  My question is, and perldoc -pack and Googling the "LA" don't
> help, what does "LA*" mean?

Didn't perldoc -pack give you an error?

perldoc -f pack


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

Date: Fri, 15 Jun 2007 12:47:46 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: question about sorting syntax
Message-Id: <1181936866.892284.18960@n2g2000hse.googlegroups.com>

On Jun 15, 3:14 pm, Adam Sandler <cor...@excite.com> wrote:

> Subject: question about sorting syntax

You do not have a question about sort.  You have a question about
pack().  Paring your problem down to get at the heart of your question
will greatly help get you good responses in technical newsgroups like
this one.

> On a few pages on the net I've seen this snip of code:
>
> my @sorted=map  { substr($_,4) }
>            sort
>            map  { pack("LA*",tr/eE/eE/,$_) } @words;
>
> In the few pages I've seen, which all have the same snip of code(word
> for word in fact), none of the pages explain the parameters passed to
> pack().

None?  Not even the documentation for pack()?

> My question is, and perldoc -pack and Googling the "LA" don't
> help, what does "LA*" mean?

Presumably, you meant `perldoc -f pack`, right?  I beg to differ with
the assessment that the parameters are not explained in that document:

perldoc -f pack
     pack TEMPLATE,LIST
             Takes a LIST of values and converts it into a string
             using the rules given by the TEMPLATE.
             ...
             The TEMPLATE is a sequence of characters that give
             the order and type of values, as follows:
             ...
                 A   A text (ASCII) string, will be space padded.
             ...
                 L   An unsigned long value.
                       (This 'long' is _exactly_ 32 bits)
             ...
             *       Each letter may optionally be followed by a
                     number giving a repeat count.  ...
                     the pack function
                     will gobble up that many values from the
                     LIST.  A "*" for the repeat count means to
                     use however many items are left

Okay.  So now we know what the format is doing.  It's going to look at
the list of values passed to pack(), and create from it a string where
the first four bytes (32 bits) will be the first value converted to a
Long, and the reminder of the bytes will be an ASCII representation of
the remainder of the values.

So now, what are the remaining values passed to pack?  Well first we
have the expression 'tr/eE/eE'.  You can read the docs yourself in
perldoc perlop, but basically this counts the number of "e" and "E"
characters in $_.  So if $_ contained "End of the line", then this
expression would return 3.  The final argument is $_ itself.

This tells us that in this example, the first value for pack will be
3, and the remaining value will be "End of the line".  The L converts
the 3 to a four-byte representation of the number 3, and the A* simply
treats "End of the line" as a string, which it already is.

So let's see it in action:
$ perl -MData::Dumper -le'
$Data::Dumper::Useqq = 1;
$str = pack("LA*", 3, "End of the line");
print Dumper($str);
'
$VAR1 = "\0\0\0\3End of the line";

The L converted the number 3 to the four-byte string "\0\0\0\3", and
the A* kept "End of the line" as "End of the line"

This string is then sorted amongst all the other likewise conversions
of the strings in @words, and then the first four bytes - the
"\0\0\0\3" part is returned into @sorted.

I would be very curious to see where this code originated.  I'm almost
of the belief that it would have to be an obfuscated Perl contest...

Hope this helps,
Paul Lalli





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

Date: Fri, 15 Jun 2007 20:38:27 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: question about sorting syntax
Message-Id: <7NCci.22984$kY6.19269@edtnps82>

Paul Lalli wrote:
> 
> This tells us that in this example, the first value for pack will be
> 3, and the remaining value will be "End of the line".  The L converts
> the 3 to a four-byte representation of the number 3, and the A* simply
> treats "End of the line" as a string, which it already is.
> 
> So let's see it in action:
> $ perl -MData::Dumper -le'
> $Data::Dumper::Useqq = 1;
> $str = pack("LA*", 3, "End of the line");
> print Dumper($str);
> '
> $VAR1 = "\0\0\0\3End of the line";
> 
> The L converted the number 3 to the four-byte string "\0\0\0\3", and
> the A* kept "End of the line" as "End of the line"
> 
> This string is then sorted amongst all the other likewise conversions
> of the strings in @words, and then the first four bytes - the
> "\0\0\0\3" part is returned into @sorted.
> 
> I would be very curious to see where this code originated.  I'm almost
> of the belief that it would have to be an obfuscated Perl contest...

You must have a big-endian CPU because on my little-endian CPU (Intel) using 
the "L" format converts the number 3 to "\3\0\0\0" which means that any counts 
above 255 will not be sorted correctly:

$ perl -le'print unpack "L", $_ for sort map pack( "L", $_ ), qw/ 65537 65536 
65535 65534 256 256 255 5 4 3 2 1 /'
65536
256
256
1
65537
2
3
4
5
65534
255
65535


However, if you use the "N" format it should work on any platform:

$ perl -le'print unpack "N", $_ for sort map pack( "N", $_ ), qw/ 65537 65536 
65535 65534 256 256 255 5 4 3 2 1 /'
1
2
3
4
5
255
256
256
65534
65535
65536
65537



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: Fri, 15 Jun 2007 21:08:39 GMT
From: "W. Citoan" <wcitoan@NOSPAM-yahoo.com>
Subject: Re: Simplify Variable Number of Regex Groups
Message-Id: <slrnf75vup.27g.wcitoan@wcitoan-via.verizon.net>

Tad McClellan wrote:
> 
>  So you need a bit of code to insert the underscores before matching:
> 
>     s#(.*) \[note:(??{ (local $_=$1)=~tr/ /_/; $_})]#[$1]#;

That seems ideal for my needs.  I knew code could go on the RHS, but I
never realized it could go on the LHS.

I appreciate the suggestions from the others as well.

Thanks,

- W. Citoan
-- 
"Bother," said Pooh, "Eeyore, ready two photon torpedoes and lock phasers
on the Heffalump. Piglet, meet me in transporter room three.  Christopher
Robin, you have the bridge."
-- Anonymous


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

Date: Fri, 15 Jun 2007 21:09:46 -0000
From:  Xicheng Jia <xicheng@gmail.com>
Subject: Re: Simplify Variable Number of Regex Groups
Message-Id: <1181941786.733107.13340@u2g2000hsc.googlegroups.com>

On Jun 15, 8:20 am, Mirco Wahab <wahab-m...@gmx.net> wrote:
> W. Citoan wrote:
> > I need to reformat portions of text.  The patterns I am matching and
> > their replacements are as follows:
>
> > word1 [note:word1]                          --> [word1]
> > word1 word2 [note:word1_word2]              --> [word1 word2]
> > word1 word2 word3 [note:word1_word2_word3]  --> [word1 word2 word3]
>
> > Any ideas?  Am I missing something obvious?
>
> Thats not *that* obvious. After Johns and Tads
> working solutions, I'll put another one:
>
> ==>
>
> use strict;
> use warnings;
>
> my @data = (
> 'keep word1 [note:word1] as is',              # --> [word1]
> 'word1 word2 [note:word1_word2]',             # --> [word1 word2]
> 'word1 word2 word3 [note:word1_word2_word3]'  #  --> [word1 word2 word3]
> );
>
>  print
>    join "\n",
>      map {
>        my ($v) = /(?<=\[note:).+?(?=\])/g; # extract bracketed text
>       (my $w=$v) =~ y/_/ /;                # prepare match in front of [..]
>        s/(?<=$w\s\[)note:$v(?=\])/$w/;     # substitute the brackets if match
>     } @data;
>
> <==

the following might be easier to read:

echo 'word1 [note:word1]
word1 word2 [note:word1_word2] site site site
site site word1 word2 word3 [note:word1_word2_word3] site
word1 word2 [note:not_word] site
' | perl -wpe '
   if (/(\s\[note:(.*?)\])/) {
      my $x = $1;  (my $y = $2) =~ tr/_/ /;
      s/\Q$y$x/[note:$y]/;
   }
'
[note:word1]
[note:word1 word2] site site site
site site [note:word1 word2 word3] site
word1 word2 [note:not_word] site


Regards,
Xicheng



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

Date: Fri, 15 Jun 2007 13:35:36 -0700
From:  kwan <kwan.jingx@gmail.com>
Subject: Template
Message-Id: <1181939736.205155.283120@w5g2000hsg.googlegroups.com>

I used Mason for the template for my webserver, I have a very basic
knowledge for the Mason. Do everyone who have experience in template
for dynamic and complicated web site.

thank you



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

Date: Fri, 15 Jun 2007 14:56:28 -0700
From:  krakle@visto.com
Subject: Re: Template
Message-Id: <1181944588.486987.308080@k79g2000hse.googlegroups.com>

On Jun 15, 3:35 pm, kwan <kwan.ji...@gmail.com> wrote:
> I used Mason for the template for my webserver, I have a very basic
> knowledge for the Mason. Do everyone who have experience in template
> for dynamic and complicated web site.
>
> thank you

What do you want?
What are you asking?



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

Date: Fri, 15 Jun 2007 15:00:57 -0700
From:  kwan <kwan.jingx@gmail.com>
Subject: Re: Template
Message-Id: <1181944857.326762.296700@q66g2000hsg.googlegroups.com>

On Jun 15, 4:56 pm, kra...@visto.com wrote:
> On Jun 15, 3:35 pm, kwan <kwan.ji...@gmail.com> wrote:
>
> > I used Mason for the template for my webserver, I have a very basic
> > knowledge for the Mason. Do everyone who have experience in template
> > for dynamic and complicated web site.
>
> > thank you
>
> What do you want?
> What are you asking?

You dont understand english?



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

Date: Fri, 15 Jun 2007 12:30:26 -0700
From:  Bpejman@gmail.com
Subject: Try Catch with Assert Statement
Message-Id: <1181935826.321004.289620@k79g2000hse.googlegroups.com>

Hi Everyone,

Can someone please shed some light on this Try and Catch issue that
I'm running into?  I would highly appreciate any help and/or
guidance.  I've researched the web thoroughly and still no luck.  I
need to know exactly what libs I need to import into my program to be
able to do the below statement (as done similarly in Python).

sub foo {
    try {
        assert (0);

    } catch {
        print "Caught assertion error\n";
    };
}

Now, I've used all of the below libraries but unfortunately
"assert(0);" does not jump into the catch {} scope.  It simply exists
the program from there where in other languages, assert always raises
an exception which is caught by except{} or catch{} statement.

use Carp::Assert;
use Test::Harness::Assert;
use Error;

I do not want to use Eval and if ($@) since I cannot return any values
from within Eval.  For example, the following will not work for me:

print foo();  #does not print any of the return codes from function
foo since they reside within the eval.

sub foo {
    eval {
        assert (1);
        return 1;
    };
    if ($@) {
        print "oops";
        return 0;
    }
}

Thanks everyone!!!
Bobby



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

Date: Fri, 15 Jun 2007 14:18:53 -0700
From: Ala Qumsieh <noreply@invalid.net>
Subject: Re: Try Catch with Assert Statement
Message-Id: <1nDci.4068$c06.3403@newssvr22.news.prodigy.net>

 Bpejman@gmail.com wrote:

> I do not want to use Eval and if ($@) since I cannot return any values
> from within Eval.  For example, the following will not work for me:

Yes you can. From 'perldoc -f eval':

               In both forms, the value returned is the value of the last
               expression evaluated inside the mini-program; a return state-
               ment may be also used, just as with subroutines.  The expres-
               sion providing the return value is evaluated in void, scalar,
               or list context, depending on the context of the eval itself.


> print foo();  #does not print any of the return codes from function
> foo since they reside within the eval.

The return value of foo() is different from the return value of your eval
block. You'll need to save the return value of your eval, and make it the
return value of your sub. Something like this:

> sub foo {
>     eval {

my $evalReturn = eval {

>         assert (1);
>         return 1;
>     };
>     if ($@) {
>         print "oops";
>         return 0;
>     }

  return $evalReturn;

> }
> 



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

Date: Fri, 15 Jun 2007 13:21:53 -0700
From:  nadabadan <nadabadan@gmail.com>
Subject: using regex to select line matches
Message-Id: <1181938913.383440.185600@p77g2000hsh.googlegroups.com>

Hi,
     How do you select all lines that don't start with a particular
word? For example,

^[^d].*$

selects all lines that doesn't start with the letter d. But how I
select all lines that doesn't start with the word "date". I tried
^[^date].*$  but this selects all lines that doesn't start with d, a,
t or e.

- Nada



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

Date: Fri, 15 Jun 2007 20:25:29 +0000 (UTC)
From: steveo@panix.com (Steven M. O'Neill)
Subject: Re: using regex to select line matches
Message-Id: <f4usjp$cvu$1@reader2.panix.com>

nadabadan  <nadabadan@gmail.com> wrote:
>Hi,
>     How do you select all lines that don't start with a particular
>word? For example,
>
>^[^d].*$
>
>selects all lines that doesn't start with the letter d. But how I
>select all lines that doesn't start with the word "date". I tried
>^[^date].*$  but this selects all lines that doesn't start with d, a,
>t or e.

Like this?

while (<>) {
   next if /^date/;
   #do other stuff
}

-- 
Steven O'Neill                                  steveo@panix.com
Brooklyn, NY                        http://www.panix.com/~steveo


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

Date: Fri, 15 Jun 2007 23:45:14 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: using regex to select line matches
Message-Id: <5dgfokF33e9p2U1@mid.individual.net>

nadabadan wrote:
>      How do you select all lines that don't start with a particular
> word? For example,
> 
> ^[^d].*$
> 
> selects all lines that doesn't start with the letter d. But how I
> select all lines that doesn't start with the word "date". I tried
> ^[^date].*$  but this selects all lines that doesn't start with d, a,
> t or e.

For most practical purposes, Steven's solutions is probably sufficient. 
This is a regex that may be a more direct answer to your question:

     /^(?!date)/

Please read about "Extended Patterns" in "perldoc perlre".

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Fri, 15 Jun 2007 20:15:35 +0200
From: "Lambik" <lambik@kieffer.nl>
Subject: Re: Win32: How to quit perl script during log off automatically ?
Message-Id: <4672d6fd$0$37736$5fc3050@dreader2.news.tiscali.nl>


"Peter Sobisch" <petersob@gmx.net> wrote in message
news:f4uj73$k0c$2@online.de...
> Please try to call perl code inside CtrlHandler and tellme how :-)
> Actually I expected I can do this using Win32::API::Callback(),
> but I can't get it work :-( See my another posting.

The other posting seem to have more promise. What i sugested isn't all that
either.

use threads;
my $thread = threads->create(sub { &exitNicely if (`code.exe` =~
/Ctrl-Shutdown event/)});





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

Date: Fri, 15 Jun 2007 12:21:56 -0700
From:  "gimme_this_gimme_that@yahoo.com" <gimme_this_gimme_that@yahoo.com>
Subject: Re: Writing row at a time in Excel using OLE
Message-Id: <1181935316.163814.102090@d30g2000prg.googlegroups.com>

Any solution that doesn't use write_row isn't inserting the data a row
at a time.

Did you perldoc Spreadsheet::WriteExcel ?


 @array      = ('awk', 'gawk', 'mawk');
 $array_ref  = \@array;

#stuff row of data starting from A1:
 $worksheet->write_row(0, 0, $array_ref);

# The above example is equivalent to:
$worksheet->write(0, 0, $array[0]);
$worksheet->write(0, 1, $array[1]);
$worksheet->write(0, 2, $array[2]);

# which is equivalent to
   $worksheet->write_row('A1', $array_ref);

# even better yet is to write N by M at a time:

 @eec =  (
                ['maggie', 'milly', 'molly', 'may'  ],
                [13,       14,      15,      16     ],
                ['shell',  'star',  'crab',  'stone']
            );

  $worksheet->write_row('A1', \@eec);




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

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


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