[22182] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4403 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 14 18:06:19 2003

Date: Tue, 14 Jan 2003 15:05:11 -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           Tue, 14 Jan 2003     Volume: 10 Number: 4403

Today's topics:
        ActiveState's perl compiler errors or warning? <mark.seger@hp.com>
        ANNOUNCE: Mail::Transport::Dbx 0.01 <tassilo.parseval@post.rwth-aachen.de>
    Re: command-line args style flags from a file <bongie@gmx.net>
    Re: Flushing the Output Stream (Tad McClellan)
    Re: How to delete leading&trailing spaces&tabs at once? <bongie@gmx.net>
        Image::Magick for Activestate 5.8.0 (Win32) <ericm@I_HATE_SPAM@vertical.com>
    Re: Image::Magick for Activestate 5.8.0 (Win32) <nospam@noos.fr>
    Re: Image::Magick for Activestate 5.8.0 (Win32) <ericm@I_HATE_SPAM@vertical.com>
    Re: My, our, etc. <jpagnew@vcu.edu>
        Need to address myself <threepio23@yahoo.com>
    Re: Need to address myself (Peter J. Acklam)
    Re: Need to address myself (Tad McClellan)
        newbie: chapter 4 exercise Llama book <eriz00@yahoo.com>
    Re: newbie: chapter 4 exercise Llama book <mbudash@sonic.net>
    Re: overriding subroutines <april@typhoon.xnet.com>
    Re: parsing problem (Anno Siegel)
    Re: parsing problem <uri@stemsystems.com>
    Re: parsing problem (Randal L. Schwartz)
    Re: parsing problem <fm_duendeBASURA@yahoo.com>
    Re: parsing problem <uri@stemsystems.com>
    Re: Perl command line processing, Windows/dos style ? <bik.mido@tiscalinet.it>
    Re: Perl command line processing, Windows/dos style ? <bongie@gmx.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 14 Jan 2003 17:02:46 -0500
From: Mark Seger <mark.seger@hp.com>
Subject: ActiveState's perl compiler errors or warning?
Message-Id: <3E248906.628CA44E@hp.com>

I recently downloaded a trial copy of the developers kit to try out the
program that turns a perl script into a 'freestanding' program you can
run on any system even if it doesn't have perl on it.  The only problem
is when I try to build something using a module that I had to load, I
get errors about case mismatches.  For example, the following showed up
when trying to use Dave Roth's  EventLog::Message module.  The thing to
note is the resultant program seemed to run fine making me this this is
more of a warning than an error, but in any event I'd sure like to know
what is really going on so I could work around it.  I don't feel too
comfortable seeing this kind of thing and the documentation wasn't very
helpful...

Here's my 2 line script, bug.pl (if I just use EventLog, it doesn't
generate any errors):

use Win32::EventLog;
use Win32::EventLog::Message;

and here's what happened when I try to compile it:

D:\test>perlapp bug.pl
PerlApp 5.0.3 build 503
Copyright (C) 1998-2002 ActiveState Corp. All rights reserved.
Evaluation license for Mark Seger <mark.seger@hp.com> (Expires:
2003-01-23)

Win32\EventLog\Message.pm:
        error: Case mismatch between module and file name
        refby: bug.pl
        file: C:\Perl\site\lib\Win32\EventLog\Message.PM
auto\Win32\EventLog\Message\Message.dll:
        error: Case mismatch between module and file name
        refby: C:\Perl\site\lib\Win32\EventLog\Message.PM
        file: C:\Perl\site\lib\auto\Win32\EventLog\Message\Message.DLL

-mark






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

Date: Mon, 13 Jan 2003 08:06:58 +0000 (GMT)
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: ANNOUNCE: Mail::Transport::Dbx 0.01
Message-Id: <3e2479df$1_6@news.teranews.com>

I am proud to announce the arrival of Mail::Transport::Dbx on the CPAN.
A modified excerpt from the PODs:

NAME
       Mail::Transport::Dbx - Parse Outlook Express mailboxes

SYNOPSIS
        use Mail::Transport::Dbx;

        my $dbx = Mail::Transport::Dbx->new("box.mbx");
    
        for my $i (0 .. $dbx->msgcount - 1) {
            my $msg = $dbx->get($i) or
                print $dbx->errstr, next;
            print $msg->subject;
            ...
        }

DESCRIPTION
    Mail::Transport::Dbx gives you platform independent access to Outlook
    Express' dbx files. Extract subfolders, messages etc. from those or use
    it to convert dbx archives into a more portable format (such as standard
    mbox format).

    It is an XS-wrapper around the LibDBX and comes with its own patched
    version of it to make it run on big-endian machines as well. It is
    eventually going to be used by Mail::Box to add means to work with
    Outlook Express data.

COPYRIGHT AND LICENSE
    Copyright 2003 by Tassilo von Parseval

    This library is free software; you can redistribute it and/or modify
    it under the same terms as Perl itself.
        
The current distribution has been tested on various machines, including
FreeBSD, Linux (both byteorders), Solaris (gcc) and Mac OS X.

Unfortunately the underlying LibDBX wont yet compile on Solaris' legacy
compiler ucbcc.  Work is under way to circumvent this limitation along
with tests on Win32.

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;




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

Date: Tue, 14 Jan 2003 22:56:20 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: command-line args style flags from a file
Message-Id: <1067493.27ZDSdSMKy@nyoga.dubu.de>

Kevin Newman wrote:

> "Harald H.-J. Bongartz" <bongie@gmx.net> wrote in message
> news:<1601609.3xdfVSxWaW@nyoga.dubu.de>...
>>   getopts('...F:', \%Options);  # get command line options
>>   if ($Options{F}) {    # there is a "-F do_flags.txt"
>>       open (OPTFILE, "<$Options{F}")
>>         or die "cannot open option file: $!";
>>       while (<OPTFILE>) {
>>           my %LocalOptions = %Options; # inherit global options
>>           @ARGV = split;
>>           getopts(..., \%LocalOptions); # analyze one line of options
>>           do_something_with_options (\%LocalOptions);
>>       }
>>       close OPTFILE;
>>   } else {
>>    do_something_with_options (\%Options);
>>   }
>> 
>> (untested)
>> 
>> Of course, when using this trivial method you won't get the quoting
>> capabilities of the shell, i.e. your do_flags.txt should not contain
>>         -c -o "Output File With Blanks.o"
>> or something like that.
>> 
> 
> I like this too (see the reply to Ben Morrow).  BTW, can you describe
> a non trivial method to handle filenames with spaces?  

Tad gave an answer on that one already.

> Also, what is
> inherit global options?

In the while loop, I use a local hash %LocalOptions to parse the options
from OPTFILE, but before I initialize it with the global options, i.e.
those options the script was started with.  Ben does this using
        my %all_opts = (%cmd_opts, %file_opts);
but the result will be the same (options not mentioned in the current
line of OPTFILE but defined in %LocalOptions will retain their value
even after getopts()).  Of course, these %LocalOptions must be
re-initialized on every loop cycle, or it would accumulate all options
from all lines...

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
"The rule on staying alive as a program manager is to give 'em a number
or give 'em a date, but never give 'em both at once."



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

Date: Tue, 14 Jan 2003 14:27:17 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Flushing the Output Stream
Message-Id: <slrnb28sl5.8a6.tadmc@magna.augustmail.com>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Chucky  <chuck.carson@syrrx.com> wrote in comp.lang.perl.misc:
>> 
>> 
>> Much thanks kind sir. Actually used less bandwidth than the other nitwit 
>> who replied.

> So long.


ditto.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 14 Jan 2003 23:15:18 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: How to delete leading&trailing spaces&tabs at once?
Message-Id: <2201793.OK9stcseV2@nyoga.dubu.de>

ZZT wrote:
> Bernard El-Hagin wrote:
> 
>> s/[ \t]+$//;
>> s/^[ \t]+//;
> 
> thanks! thats perfect :)

Is there a reason you don't want to use \s?

Ciao,
        Harald
--
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
An idea is not responsible for the people who believe in it.


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

Date: Tue, 14 Jan 2003 19:56:01 GMT
From: Eric McDaniel <ericm@I_HATE_SPAM@vertical.com>
Subject: Image::Magick for Activestate 5.8.0 (Win32)
Message-Id: <Xns930379674E4FCooheehoohahah@207.225.159.6>


I need to use the Image::Magick module with ActiveState Perl 5.8.0 (Win32) 
and I am running into problems.

I am having no luck building the Image::Magick module on my Win32 system, 
and the binaries that I have been able to find only seem to support Perl 
5.6.0.

Has anyone out there already solved this problem? Are there binaries 
somewhere that you can point me to?

I am cursing the 5.6 -> 5.8 binary incompatibility "feature" right now...

Thanks.

-Eric


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

Date: Tue, 14 Jan 2003 21:38:17 +0100
From: "Pascal HOARAU" <nospam@noos.fr>
Subject: Re: Image::Magick for Activestate 5.8.0 (Win32)
Message-Id: <3e247534$0$7630$79c14f64@nan-newsreader-02.noos.net>

bWluZSBpcyB3b3JraW5nDQp5b3Ugc2hvdWxkIGluc3RhbGwgSW1hZ2VNYWdpY2stNS41LjItUTgt
d2luMmsuZXhlDQoNCiJFcmljIE1jRGFuaWVsIiA8ZXJpY21ASV9IQVRFX1NQQU1AdmVydGljYWwu
Y29tPiBhIOljcml0IGRhbnMgbGUgbWVzc2FnZSBkZSBuZXdzOiBYbnM5MzAzNzk2NzRFNEZDb29o
ZWVob29oYWhhaEAyMDcuMjI1LjE1OS42Li4uDQo+IA0KPiBJIG5lZWQgdG8gdXNlIHRoZSBJbWFn
ZTo6TWFnaWNrIG1vZHVsZSB3aXRoIEFjdGl2ZVN0YXRlIFBlcmwgNS44LjAgKFdpbjMyKSANCj4g
YW5kIEkgYW0gcnVubmluZyBpbnRvIHByb2JsZW1zLg0KPiANCj4gSSBhbSBoYXZpbmcgbm8gbHVj
ayBidWlsZGluZyB0aGUgSW1hZ2U6Ok1hZ2ljayBtb2R1bGUgb24gbXkgV2luMzIgc3lzdGVtLCAN
Cj4gYW5kIHRoZSBiaW5hcmllcyB0aGF0IEkgaGF2ZSBiZWVuIGFibGUgdG8gZmluZCBvbmx5IHNl
ZW0gdG8gc3VwcG9ydCBQZXJsIA0KPiA1LjYuMC4NCj4gDQo+IEhhcyBhbnlvbmUgb3V0IHRoZXJl
IGFscmVhZHkgc29sdmVkIHRoaXMgcHJvYmxlbT8gQXJlIHRoZXJlIGJpbmFyaWVzIA0KPiBzb21l
d2hlcmUgdGhhdCB5b3UgY2FuIHBvaW50IG1lIHRvPw0KPiANCj4gSSBhbSBjdXJzaW5nIHRoZSA1
LjYgLT4gNS44IGJpbmFyeSBpbmNvbXBhdGliaWxpdHkgImZlYXR1cmUiIHJpZ2h0IG5vdy4uLg0K
PiANCj4gVGhhbmtzLg0KPiANCj4gLUVyaWM=



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

Date: Tue, 14 Jan 2003 22:56:53 GMT
From: Eric McDaniel <ericm@I_HATE_SPAM@vertical.com>
Subject: Re: Image::Magick for Activestate 5.8.0 (Win32)
Message-Id: <Xns930398114D5BAooheehoohahah@207.225.159.6>

"Pascal HOARAU" <nospam@noos.fr> wrote in
news:3e247534$0$7630$79c14f64@nan-newsreader-02.noos.net: 

> mine is working
> you should install ImageMagick-5.5.2-Q8-win2k.exe
> 
> "Eric McDaniel" <ericm@I_HATE_SPAM@vertical.com> a écrit dans le
> message de news: Xns930379674E4FCooheehoohahah@207.225.159.6... 
>> 
>> I need to use the Image::Magick module with ActiveState Perl 5.8.0
>> (Win32) and I am running into problems.
>> 
>> I am having no luck building the Image::Magick module on my Win32
>> system, and the binaries that I have been able to find only seem to
>> support Perl 5.6.0.
>> 
>> Has anyone out there already solved this problem? Are there binaries 
>> somewhere that you can point me to?
>> 

It's actually not the installation of ImageMagick binaries that is the 
problem, but the Image-Magick.ppd. When I run "ppm install Image-
Magick.ppd", the response I get is:

Error: no suitable installation target found for package Image-Magick.

I am able to install other packages with ppm, so I assume this message 
indicates that the Image-Magick.ppd I have is only for 5.6.0 (although 
nothing in the ppd file seems to indicate that).



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

Date: Tue, 14 Jan 2003 14:50:22 -0500
From: Jim Agnew <jpagnew@vcu.edu>
Subject: Re: My, our, etc.
Message-Id: <3E2469FE.BC9461BF@vcu.edu>

Benjamin Goldberg wrote:
> 
> Richard S Beckett wrote:
> [snip]
> > my $entry = $frame -> Entry (
> >           -validatecommand => \&valid_routine,
> >           -invalidcommand => sub {
> >                print "invalid entry, try again\n";
> >                $entry -> focus;}
> >           ) -> pack ();
> 
> Change to either:
> 
> my $entry = $frame -> Entry(
>           -validatecommand => \&valid_routine,
>           -invalidcommand => [ sub {
>                print "invalid entry, try again\n";
>                shift() -> focus;}, Ev('W') ]
>           ) -> pack ();
> 
> Or:
> 
> my $entry; $entry = $frame -> Entry(
>           -validatecommand => \&valid_routine,
>           -invalidcommand => sub {
>                print "invalid entry, try again\n";
>                $entry -> focus;},
>           ) -> pack ();
> 
> (The first form is prefferred, since it avoids a circular reference
> loop, which could hinder later garbage collection).
> 
> [both code pieces are untested]
> 

how would that cause a circular reference?  I'd think the second form
would be "cleaner"..??

Jim


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

Date: Tue, 14 Jan 2003 19:45:18 +0000 (UTC)
From: "Jimbo" <threepio23@yahoo.com>
Subject: Need to address myself
Message-Id: <b01pce$ilt$1@sparta.btinternet.com>

Does anyone know how to write a regular expression that will accept all ways
of addressing myself?




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

Date: Tue, 14 Jan 2003 20:56:02 +0100
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: Need to address myself
Message-Id: <el7f5wvh.fsf@online.no>

"Jimbo" <threepio23@yahoo.com> wrote:

> Does anyone know how to write a regular expression that will
> accept all ways of addressing myself?

How do you address yourself?  Mister?  Sir?  Jimbo?

Peter

-- 
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;


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

Date: Tue, 14 Jan 2003 14:32:18 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Need to address myself
Message-Id: <slrnb28sui.8a6.tadmc@magna.augustmail.com>

Jimbo <threepio23@yahoo.com> wrote:

> Does anyone know how to write a regular expression that will accept all ways
> of addressing myself?


   /.*/s


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 14 Jan 2003 22:52:02 +0300
From: Eri Mendz <eriz00@yahoo.com>
Subject: newbie: chapter 4 exercise Llama book
Message-Id: <3e246a62@news.sahara.com.sa>

hi to all,

im stumped how to get total of numbers using <STDIN>. This is in
exercise 1 chapter 4 of Llama book 3rd ed:

#!/usr/bin/perl -w
use strict;

## filename: total_sub.pl
## description: create subroutine &total and calculate sum of elements of
# @fred array; pp 72 chap4 Llama book 3rd ed.

my @fred = qw{1 3 5 7 9};
my $fred_total = &total(@fred);
sub total{
    my($sum) = shift @_;    # assign 1st element to $sum
    foreach (@_){	    # get rest of elements and
	$sum += $_;	    # add to $sum
    }
    return $sum;
}
print "The total of \@fred is $fred_total.\n";
##
#
print "Enter at least 2 numbers separated by space: ";
chomp(my $input = <STDIN>);
my @barney = $input;
my $user_total = &total(@barney);
print "The total of those numbers is $user_total.\n"; 

== output ==
The total of @fred is 25.
Enter at least 2 numbers separated by space: 1 3 5 7 9
The total of those numbers is 1 3 5 7 9.
== output ==

how can i make total() get the sum of <STDIN>? I know i have deviated
from the solution found in the back of the book. Please bear with my
newbiness, just another newbie here wanting to learn Perl.

-- 
Have a nice day,
Eri Mendz
Using Slrn 0.9.7.4 [2002-03-13]
Linux 2.4.19-16mdk i686

"We invented a new protocol and called it Kermit, after Kermit the Frog,
star of "The Muppet Show." [3]



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

Date: Tue, 14 Jan 2003 20:08:16 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: newbie: chapter 4 exercise Llama book
Message-Id: <mbudash-31196F.12081414012003@typhoon.sonic.net>

In article <3e246a62@news.sahara.com.sa>, Eri Mendz <eriz00@yahoo.com> 
wrote:

> hi to all,
> 
> im stumped how to get total of numbers using <STDIN>. This is in
> exercise 1 chapter 4 of Llama book 3rd ed:
> 
> #!/usr/bin/perl -w
> use strict;
> 
> ## filename: total_sub.pl
> ## description: create subroutine &total and calculate sum of elements of
> # @fred array; pp 72 chap4 Llama book 3rd ed.
> 
> my @fred = qw{1 3 5 7 9};
> my $fred_total = &total(@fred);
> sub total{
>     my($sum) = shift @_;    # assign 1st element to $sum
>     foreach (@_){	    # get rest of elements and
> 	$sum += $_;	    # add to $sum
>     }
>     return $sum;
> }
> print "The total of \@fred is $fred_total.\n";
> ##
> #
> print "Enter at least 2 numbers separated by space: ";
> chomp(my $input = <STDIN>);
> my @barney = $input;
> my $user_total = &total(@barney);
> print "The total of those numbers is $user_total.\n"; 
> 
> == output ==
> The total of @fred is 25.
> Enter at least 2 numbers separated by space: 1 3 5 7 9
> The total of those numbers is 1 3 5 7 9.
> == output ==
> 
> how can i make total() get the sum of <STDIN>? I know i have deviated
> from the solution found in the back of the book. Please bear with my
> newbiness, just another newbie here wanting to learn Perl.

my @barney = split /\s+/, $input;

hth-


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

Date: Tue, 14 Jan 2003 21:24:28 +0000 (UTC)
From: Dina April <april@typhoon.xnet.com>
Subject: Re: overriding subroutines
Message-Id: <b01v6c$ao2$1@flood.xnet.com>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:

: If you change "require 'test2.pl'" to "use test2", test2.pl will be
: read at compile time and the local definition will be in effect.

: Anno

That did it (after renaming test2.pl to test2.pm), thanks!

dave
--
David S. April                  Syclo LLC
april@syclo.com                 1250 S Grove Av - Suite 304
(847) 842-0320                  Barrington, IL 60010
http://www.soasoas.com/april/

"Paradise is exactly like where you are right now, only much, much
*better*."
    - Laurie Anderson


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

Date: 14 Jan 2003 19:20:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: parsing problem
Message-Id: <b01ntn$seo$1@mamenchi.zrz.TU-Berlin.DE>

monkeys paw  <fm_duendeBASURA@yahoo.com> wrote in comp.lang.perl.misc:
> I want a regex to parse the following:
> 
> "first saturday of every month"
>  
> or
> 
> "first saturday in january"

Why insist in a single regex?  As you say, you have a parsing problem.
A regex is a text recognition tool, which is only part of the parsing
problem.  As your attempt demonstrates, a regex gets unwieldy when
stretched beyond its limits.  

Parse::RecDescent will allow you to generate a parser with little
effort, using regexes for token recognition where they're good at
while making the logic (where they're not so good at) explicit.

> Please help with the following which isn't
> quite there:

If you must construct a single regex, do it piece-wise.  Define partial
expressions (using qr//) that can be tested independently.  Then put
them together by interpolating them into a larger regex.  Repeat, if
necessary.  The final regex will be as big, or bigger, than the one you're
constructing, but the construction process will be smoother and clearer.

[monster regex snipped]

Anno


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

Date: Tue, 14 Jan 2003 19:39:58 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: parsing problem
Message-Id: <x7y95no702.fsf@mail.sysarch.com>

>>>>> "mp" == monkeys paw <fm_duendeBASURA@yahoo.com> writes:

  mp> "first saturday of every month"
  mp> "first saturday in january"

  mp> Please help with the following which isn't
  mp> quite there:

not a bad try so far. i found a few bugs and it would seem to work. it
needs to more thoroughly tested.

  mp>     if ( $frequency =~
  mp>        m!

	m!^

i added anchors as the end one helps with verifying the months. they can
be dropped if you want to grab this from larger strings.


  mp>        (
  mp>        (?:
  mp>            (?:
  mp>                (?:
  mp>                    (?:\d+
  mp>                        (?:
  mp>                            ST |
  mp>                            ND |
  mp>                            RD |
  mp>                            TH
  mp>                        )
  mp>                    )      |
  mp>                    FIRST  |
  mp>                    SECOND |
  mp>                    THIRD  |
  mp>                    FOURTH |
  mp>                    FIFTH  |
  mp>                    LAST
  mp>                 )
  mp>                 \s*,?\s*
  mp>            )+
  mp>        )
  mp>        \s+
  mp>        (?:
  mp>            (?:  SUN              |
  mp>                 MON              |
  mp>                 TUES?            |
  mp>                 WED(?:NES)?      |
  mp>                 THU(?:RS)?       |
  mp>                 FRI              |
  mp>                 SAT(?:UR)?
  mp>            )
  mp>            (?:DAY)?
  mp>        )
  mp>        \s+
  mp>        (?:OF EVERY MONTH     |

since you are in /x mode, those spaces are not being matched.

	(?:OF\s+EVERY\s+MONTH     |


  mp>            (?: \s+IN\s+ 

the previous major regex ended in \s+ so you can't have another \s+
following it.

           (?: IN\s+ 



  mp>                (?: 
  mp>                    JAN(?:UARY)?   |
  mp>                    FEB(?:RUARY)?  |
  mp>                    MAR(?:CH)?     |
  mp>                    APR(?:IL)?     |
  mp>                    MAY            |
  mp>                    JUNE?          |
  mp>                    JULY?          |
  mp>                    AUG(?:UST)?    |
  mp>                    SEP(?:TEMBER)? |
  mp>                    OCT(?:OBER)?   |
  mp>                    NOV(?:EMBER)?  |
  mp>                    DEC(?:EMBER)?
  mp>                )
  mp>                \s*,?\s*
  mp>            )+
  mp>        )

i changes the regex to match IN JAN, DECEMBER. you had it so IN was
required before each month. 

           (?: IN\s+ 
               (?: 
		  (?: 
		      JAN(?:UARY)?   |
		      FEB(?:RUARY)?  |
		      MAR(?:CH)?     |
		      APR(?:IL)?     |
		      MAY            |
		      JUNE?          |
		      JULY?          |
		      AUG(?:UST)?    |
		      SEP(?:TEMBER)? |
		      OCT(?:OBER)?   |
		      NOV(?:EMBER)?  |
		      DEC(?:EMBER)?
		  )
                  \s*,?\s*
		)+




  mp>        )
  mp>        !x) 

you didn't make it case insensitive so add /i to that.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


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

Date: 14 Jan 2003 11:54:36 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: parsing problem
Message-Id: <867kd7qzgj.fsf@red.stonehenge.com>

>>>>> "monkeys" == monkeys paw <fm_duendeBASURA@yahoo.com> writes:

monkeys> I want a regex to parse the following:
monkeys> "first saturday of every month"
 
monkeys> or

monkeys> "first saturday in january"

If you want to make semantic sense of it as well, and not just
parse it, skip forward directly to Date::Manip, already in the CPAN.

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 14 Jan 2003 20:22:50 GMT
From: monkeys paw <fm_duendeBASURA@yahoo.com>
Subject: Re: parsing problem
Message-Id: <uk_U9.51077$Dn.9495@sccrnsc03>

Thanks Uri, works like a champ!

Uri Guttman wrote:

>>>>>> "mp" == monkeys paw <fm_duendeBASURA@yahoo.com> writes:
> 
>   mp> "first saturday of every month"
>   mp> "first saturday in january"
> 
>   mp> Please help with the following which isn't
>   mp> quite there:
> 
> not a bad try so far. i found a few bugs and it would seem to work. it
> needs to more thoroughly tested.
> 



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

Date: Tue, 14 Jan 2003 20:40:31 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: parsing problem
Message-Id: <x7u1gbo474.fsf@mail.sysarch.com>

>>>>> "mp" == monkeys paw <fm_duendeBASURA@yahoo.com> writes:

  mp> Thanks Uri, works like a champ!

but heed all the other advice you got here. Date::Manip can handle that
format already and when building large regexes, it is best to build them
from smaller pieces with qr//.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


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

Date: Tue, 14 Jan 2003 23:32:20 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl command line processing, Windows/dos style ?
Message-Id: <1v882v8aokdf92jmc6h63uvcp6m0eb7jj6@4ax.com>

On Tue, 14 Jan 2003 04:58:55 +0100, "Harald H.-J. Bongartz"
<bongie@gmx.net> wrote:

>I want to add that common shells (here under Linux) can do different
>things if a match fails, and this may even depend on configuration.

[...]

>So, bash will (per default) happily hand over a non-matching asterisk to
>the called program, while the tcsh (per default) issues an error.

I want to add that it depends on an option too. Bash can be instructed
to "expand" a non matching pattern to an empty string instead...


Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


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

Date: Tue, 14 Jan 2003 23:48:17 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Perl command line processing, Windows/dos style ?
Message-Id: <1338408.RdlHtGs6Dv@nyoga.dubu.de>

Michele Dondi wrote:
> On Tue, 14 Jan 2003 04:58:55 +0100, "Harald H.-J. Bongartz"
> <bongie@gmx.net> wrote:
> I want to add that common shells (here under Linux) can do different
> things if a match fails, and this may even depend on configuration.
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[...]
> I want to add that it depends on an option too. Bash can be instructed
> to "expand" a non matching pattern to an empty string instead...

Read my posting again and see the (empty) result when setting
"shopt -s nullglob". ;-)

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
++$sheep while !$asleep;


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

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.  

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


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