[29016] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 260 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 23 21:09:54 2007

Date: Fri, 23 Mar 2007 18:09:13 -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, 23 Mar 2007     Volume: 11 Number: 260

Today's topics:
    Re: Accessing all CGI input parameters via loop ? <spamtrap@dot-app.org>
        HTML::Mason and User site folders <macshaggy@carolina.rr.com>
    Re: HTML::Mason and User site folders <wahab-mail@gmx.de>
    Re: I dotn understand this error <spamtrap@dot-app.org>
        Need help with a Regex substitution <tester.paul@gmail.com>
    Re: Need help with a Regex substitution <thepoet_nospam@arcor.de>
    Re: Need help with a Regex substitution <devliegendehollander@attempt-at-not-applicable-domain-name.com>
    Re: Need help with a Regex substitution <kenslaterpa@hotmail.com>
    Re: Need help with a Regex substitution <wahab-mail@gmx.de>
    Re: On Java's Interface (the meaning of interface in co <spamtrap@dot-app.org>
    Re: parsing a tab delimited or CSV, but keep the delimi <lew@nospam.lewscanon.com>
    Re: parsing a tab delimited or CSV, but keep the delimi <jurgenex@hotmail.com>
    Re: parsing a tab delimited or CSV, but keep the delimi <lew@nospam.lewscanon.com>
    Re: parsing a tab delimited or CSV, but keep the delimi <jurgenex@hotmail.com>
    Re: Reading from fixed-length text file <poo@pee.com>
    Re: Reading from fixed-length text file <glex_no-spam@qwest-spam-no.invalid>
        time structure without shift <stoupa@practisoft.cz>
    Re: Truncating text from a string with beginning text f <google@markginsburg.com>
    Re: Truncating text from a string with beginning text f anno4000@radom.zrz.tu-berlin.de
    Re: Truncating text from a string with beginning text f <wahab-mail@gmx.de>
    Re: Truncating text from a string with beginning text f <wahab-mail@gmx.de>
    Re: Truncating text from a string with beginning text f <wahab-mail@gmx.de>
        Why can't we just change the signal disposition on syst <cdalten@gmail.com>
        win32 pxperl <florentin.ionescu@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 23 Mar 2007 18:15:29 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Accessing all CGI input parameters via loop ?
Message-Id: <m2ps6za9oe.fsf@local.wv-www.com>

"Paul Lalli" <mritty@gmail.com> writes:

> Have another read of
> perldoc CGI
> There are a lot of options that you may not be aware of yet.

Amen to that - I've been doing this since '95 or so, and I *still* find
options in CGI.pm I wasn't aware of.

The trick to mastering Perl is to realize that you can't. It's a constant
ongoing learning experience. :-)

sherm--

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


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

Date: 23 Mar 2007 16:45:22 -0700
From: "macshaggy" <macshaggy@carolina.rr.com>
Subject: HTML::Mason and User site folders
Message-Id: <1174693522.158549.8590@d57g2000hsg.googlegroups.com>

I maybe dense, which probably isn't that hard to believe, but I keep
getting this error when accessing a User's sites folder:

[Mason] Cannot resolve file to component: /Users/jbellew/Sites/
index.html (is file outside component root?) at /usr/local/lib/perl5/
site_perl/5.8.8/HTML/Mason/ApacheHandler.pm line 853.

I've commented in the past the Mason::Apachehandler config in
httpd.conf routines to make sure that Mason was having the issue and
it is. It's a basic config at this point but can someone just open my
eyes.

I'm also aware of what Mason is telling me but I can't wrap my brain
around what I should do.

Thanks
J

Sample of httpd.config:
PerlModule HTML::Mason::ApacheHandler
<FilesMatch "\.html$">
    SetHandler perl-script
    PerlHandler HTML::Mason::ApacheHandler
</FilesMatch>



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

Date: Sat, 24 Mar 2007 01:45:56 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: HTML::Mason and User site folders
Message-Id: <eu1snu$83g$1@mlucom4.urz.uni-halle.de>

macshaggy wrote:
> I maybe dense, which probably isn't that hard to believe, but I keep
> getting this error when accessing a User's sites folder:
> 
> [Mason] Cannot resolve file to component: /Users/jbellew/Sites/
> index.html (is file outside component root?) at /usr/local/lib/perl5/
> site_perl/5.8.8/HTML/Mason/ApacheHandler.pm line 853.
> 
> I've commented in the past the Mason::Apachehandler config in
> httpd.conf routines to make sure that Mason was having the issue and
> it is. It's a basic config at this point but can someone just open my
> eyes.
> 
> I'm also aware of what Mason is telling me but I can't wrap my brain
> around what I should do.
> 
> Thanks
> J
> 
> Sample of httpd.config:
> PerlModule HTML::Mason::ApacheHandler
> <FilesMatch "\.html$">
>     SetHandler perl-script
>     PerlHandler HTML::Mason::ApacheHandler
> </FilesMatch>

You need to set the "Mason Component root" for
the Apache process:
Example:

  PerlModule HTML::Mason::ApacheHandler
  ...
  PerlSetVar  MasonCompRoot    /Users/jbellew/Sites
  PerlSetVar  MasonDataDir     /var/cache/mason
  ...
  <FilesMatch "\.html$">
    SetHandler perl-script
    PerlHandler HTML::Mason::ApacheHandler
  </FilesMatch>
 ...


Regards

M.























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

Date: Fri, 23 Mar 2007 18:12:39 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: I dotn understand this error
Message-Id: <m2tzwba9t4.fsf@local.wv-www.com>

Michele Dondi <bik.mido@tiscalinet.it> writes:

> But all in all what I can stand the less is that sometimes it
> appears to want to massage what I write.

What GG does to messages isn't pleasant and relaxing. So:

s/massage/mangle/;

:-)

sherm--

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


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

Date: 23 Mar 2007 14:11:37 -0700
From: "Paul" <tester.paul@gmail.com>
Subject: Need help with a Regex substitution
Message-Id: <1174684297.473701.213500@l75g2000hse.googlegroups.com>

Hi there, I am updating a Perl script and am having difficulties
understanding a string substitution in one of the subroutines (I
didn't write it - I'm just trying to update it).  I'm still a novice
when it comes to Regular Expressions so I could use some help
understanding one particular regex.

Here are the 3 lines of interest:
---
1: time_line = "$1\/$2\/$3\"\t\"$4:$5 $6";
2: time_line =~ s/^0//;
3: time_line =~ s/(^\d+\/)0/\1/;
---

at line 1, the variable equals something like : "03/23/07\"  \"3:05
pm"
at line 2, I expect that the first '0' is removed, so the variable now
equals : "3/23/07\"  \"3:05 pm"

==> What does line 3 do??

I've tried guessing, but just can't figure it out.  Something about
repeating pattern of digits.. or not .. followed by a '0'?  Then..
dunno.  I got nothin.

Help!  Please!

TIA.  Paul.



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

Date: Fri, 23 Mar 2007 22:16:46 +0100
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: Need help with a Regex substitution
Message-Id: <460443b4$0$15946$9b4e6d93@newsspool4.arcor-online.net>

Paul wrote:
> Hi there, I am updating a Perl script and am having difficulties
> understanding a string substitution in one of the subroutines (I
> didn't write it - I'm just trying to update it).  I'm still a novice
> when it comes to Regular Expressions so I could use some help
> understanding one particular regex.
> 
> Here are the 3 lines of interest:
> ---
> 1: time_line = "$1\/$2\/$3\"\t\"$4:$5 $6";
> 2: time_line =~ s/^0//;
> 3: time_line =~ s/(^\d+\/)0/\1/;
> ---
> 
> at line 1, the variable equals something like : "03/23/07\"  \"3:05
> pm"
> at line 2, I expect that the first '0' is removed, so the variable now
> equals : "3/23/07\"  \"3:05 pm"
> 
> ==> What does line 3 do??
> 
> I've tried guessing, but just can't figure it out.  Something about
> repeating pattern of digits.. or not .. followed by a '0'?  Then..
> dunno.  I got nothin.

It strips away leading zeroes from the day field. In the
parenthesis is "start of string, followed by one or more digits,
followed by a slash".

-Chris


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

Date: Fri, 23 Mar 2007 22:23:04 +0100
From: De Vliegende Hollander <devliegendehollander@attempt-at-not-applicable-domain-name.com>
Subject: Re: Need help with a Regex substitution
Message-Id: <46044532$0$16536$e4fe514c@dreader27.news.xs4all.nl>

The sentient life form Paul posted the following:

> 3: time_line =~ s/(^\d+\/)0/\1/;
> ---
 ... 
> 
> ==> What does line 3 do??

(^\d+\/)

^ is start of line
\d+ is 1 or more digits
\/ is an escaped /, which is i.e. a /

what matches between the braces ( and ) gets put in $1, which is also
accessible as \1

so one or more digits from the start of the line and a / character are
matched and put in $1 (accessible via \1 too).

The 0 that follows in the regexp is outside the braces and not put in $1,
hence the \1 in the substitute part of the regexp only contains the digits
and /, without a 0 following, hence the is removed.

So it removes the 'second' zero in the string.


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

Date: 23 Mar 2007 14:30:04 -0700
From: "kens" <kenslaterpa@hotmail.com>
Subject: Re: Need help with a Regex substitution
Message-Id: <1174685404.337575.232830@p15g2000hsd.googlegroups.com>

On Mar 23, 5:11 pm, "Paul" <tester.p...@gmail.com> wrote:
> Hi there, I am updating a Perl script and am having difficulties
> understanding a string substitution in one of the subroutines (I
> didn't write it - I'm just trying to update it).  I'm still a novice
> when it comes to Regular Expressions so I could use some help
> understanding one particular regex.
>
> Here are the 3 lines of interest:
> ---

I assume by time_line you mean $time_line.

> 1: time_line = "$1\/$2\/$3\"\t\"$4:$5 $6";
> 2: time_line =~ s/^0//;

Use different separator besides the slash since there is a
slash in the pattern. For eample:
$time_line    =~ s {(^\d+/)0} {$1};

or combine lines 2 & 3:
$time_line    =~ s {^0?(\d+/)0?} {$1};

> 3: time_line =~ s/(^\d+\/)0/\1/;
> ---
>
> at line 1, the variable equals something like : "03/23/07\"  \"3:05
> pm"
> at line 2, I expect that the first '0' is removed, so the variable now
> equals : "3/23/07\"  \"3:05 pm"
>
> ==> What does line 3 do??
>
> I've tried guessing, but just can't figure it out.  Something about
> repeating pattern of digits.. or not .. followed by a '0'?  Then..
> dunno.  I got nothin.
>
> Help!  Please!
>
> TIA.  Paul.

As Christian pointed out, line 3 removes the leading zero from the
'day' field in the date.

HTH, Ken



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

Date: Fri, 23 Mar 2007 22:34:20 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Need help with a Regex substitution
Message-Id: <eu1hgo$4hr$1@mlucom4.urz.uni-halle.de>

Paul wrote:
> ---
> 1: time_line = "$1\/$2\/$3\"\t\"$4:$5 $6";
> 2: time_line =~ s/^0//;
> 3: time_line =~ s/(^\d+\/)0/\1/;
> 
> ==> What does line 3 do??

time_line =~ s{(^ \d+ /) 0}{$1}x;

Aside from the correct explanations above,
a \1 on the right side of a regex is now
considered almost always wrong.

See perldoc perlre (Warning on \1 vs $1)


Regards

M.


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

Date: Fri, 23 Mar 2007 18:30:05 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: On Java's Interface (the meaning of interface in computer programing)
Message-Id: <m2lkhna902.fsf@local.wv-www.com>

Lew <lew@nospam.lewscanon.com> writes:

> But if Xah were being trollish, why didn't they jump on my response
> and call me names?

Xah never replies to the threads he starts. At least, I've never known him
to do so.

> I still think that analysis of the original post is a useful exercise
> to learn Java.

Maybe so - I don't know enough Java to comment on that. But there's nothing
useful to cross-posting the original to a fistful of non-Java lists.

> The more subtle Xah or other
> minions of Satan get in their presentations, the more interesting the
> forensic exercise to dig out the truth.

The truth is that Xah wants to start an argument. He cross-posts for that
reason, so that the "forensic exercise" you're speaking of then becomes an
argument among proponents of the various languages about which language is
closer to the "truth".

Don't take my word for it though - check Google Groups. You'll find he's
been doing this for a long time.

sherm--

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


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

Date: Fri, 23 Mar 2007 17:28:28 -0400
From: Lew <lew@nospam.lewscanon.com>
Subject: Re: parsing a tab delimited or CSV, but keep the delimiter
Message-Id: <rvKdnXR0oMHh25nbnZ2dnUVZ_h_inZ2d@comcast.com>

Jürgen Exner wrote:
> Sideswipe wrote:
>> I need to parse either a CSV or a Tab delimited file, BUT I need to
>> keep the delimiting token -- I am parsing these files as generated
>> from excel and the user expects them to process EXACTLY as it appears
>> in the spreadsheet.
> 
> Text::CSV should do the job quite nicely for regular CSV files.

Are you referring to <http://www.hxtt.com/text.html>?

-- Lew


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

Date: Fri, 23 Mar 2007 22:19:29 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: parsing a tab delimited or CSV, but keep the delimiter
Message-Id: <RnYMh.316$5E3.201@trndny01>

Lew wrote:
> Jürgen Exner wrote:
>> Sideswipe wrote:
>>> I need to parse either a CSV or a Tab delimited file, BUT I need to
>>> keep the delimiting token -- I am parsing these files as generated
>>> from excel and the user expects them to process EXACTLY as it
>>> appears in the spreadsheet.
>>
>> Text::CSV should do the job quite nicely for regular CSV files.
>
> Are you referring to <http://www.hxtt.com/text.html>?

No, why would I?
Of course I am referring to the module Text::CSV (or one of its cousins): 
http://search.cpan.org/search?query=text%3A%3Acsv&mode=all

jue 




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

Date: Fri, 23 Mar 2007 18:32:18 -0400
From: Lew <lew@nospam.lewscanon.com>
Subject: Re: parsing a tab delimited or CSV, but keep the delimiter
Message-Id: <G6idnW9cv9TuyJnbnZ2dnUVZ_v-tnZ2d@comcast.com>

Jürgen Exner wrote:
> Lew wrote:
>> Jürgen Exner wrote:
>>> Sideswipe wrote:
>>>> I need to parse either a CSV or a Tab delimited file, BUT I need to
>>>> keep the delimiting token -- I am parsing these files as generated
>>>> from excel and the user expects them to process EXACTLY as it
>>>> appears in the spreadsheet.
>>> Text::CSV should do the job quite nicely for regular CSV files.
>> Are you referring to <http://www.hxtt.com/text.html>?
> 
> No, why would I?

There were so many that came up when I googled that I just picked one at 
random, on the basis that it was eight out of the first ten sites that popped 
up in my search.

> Of course I am referring to the module Text::CSV (or one of its cousins): 
> http://search.cpan.org/search?query=text%3A%3Acsv&mode=all

Of course! I should have /known/ that it was one of the other 68790 hits, 
instead of the one that was eight out of the first ten.

-- Lew


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

Date: Fri, 23 Mar 2007 22:38:01 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: parsing a tab delimited or CSV, but keep the delimiter
Message-Id: <dFYMh.48$fA2.35@trndny02>

Lew wrote:
> Jürgen Exner wrote:
>> Lew wrote:
>>> Jürgen Exner wrote:
>>>> Sideswipe wrote:
>>>>> I need to parse either a CSV or a Tab delimited file, BUT I need
>>>>> to keep the delimiting token -- I am parsing these files as
>>>>> generated from excel and the user expects them to process EXACTLY
>>>>> as it appears in the spreadsheet.
>>>> Text::CSV should do the job quite nicely for regular CSV files.
>>> Are you referring to <http://www.hxtt.com/text.html>?
>>
>> No, why would I?
>
> There were so many that came up when I googled that I just picked one
> at random, on the basis that it was eight out of the first ten sites
> that popped up in my search.
>
>> Of course I am referring to the module Text::CSV (or one of its
>> cousins): http://search.cpan.org/search?query=text%3A%3Acsv&mode=all
>
> Of course! I should have /known/ that it was one of the other 68790
> hits, instead of the one that was eight out of the first ten.

Well, sorry, but when you are talking Perl, then CPAN is the one and only 
repository for modules. There may be others, there may even be commercial 
ones. But CPAN is just plain the default and nobody would assume otherwise 
unless you mention a different source explicitely.

jue 




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

Date: Fri, 23 Mar 2007 16:30:10 -0400
From: DB <poo@pee.com>
Subject: Re: Reading from fixed-length text file
Message-Id: <p7ydnRmqZ6RPpZnbnZ2dnUVZ_vGinZ2d@adelphia.com>

Ok I've made some progress, I think I just need some syntax help. I
think I need to start this thread fresh though to avoid confusion.

I need to read lines from an ASCII flat file in the following format :

                             0 to   3 - code  (length= 4)
                             4 to  23 - number        (length=20)
                            24 to  53 - description        (length=30)
                            54 to  61 - p1         (length= 8)
                            70 to  77 - p2       (length= 8)
                           103 to 122 - New number         (length=20)
                           123 to 123 - flag          (length= 1)


Some of the lines however do not have the last two fields and end at
position 77. Here's an example line of the file which will no doubt wrap
in this post:

PQ  AMERICAN SERIES     CATFISH                          0.000
 0.000                         L11115              2

Now in another script, I was reading in comma-separated values from a
file like this:

#################################
# reading data in from file
my (@AoA);
 while ( <> ) {
     chomp;
     push @AoA, [ split /,/ ];
 }
#################################

and I want to do the same thing with this fixed-length data. Jurgen was
correct that unpack() was not a good solution.

Here is what I'm trying, which fails. I'm guessing it is a stupid sytnax
problem. Can someone assist?

#################################
# reading data in from file
my (@AoA);
 while ( <> ) {
     chomp;
     my $line_length=length($_);

if ($line_length=124) {
     push @AoA, [(
     substr($_, 0, 4),
     substr($_, 4, 20),
     substr($_, 24, 30),
     substr($_, 54, 8),
     substr($_, 70, 8),
     substr($_, 103, 20),
     substr($_, 123, 1),
)];
}

if ($line_length=78) {
     push @AoA, [(
     substr($_, 0, 4),
     substr($_, 4, 20),
     substr($_, 24, 30),
     substr($_, 54, 8),
     substr($_, 70, 8),
     "                    ",  # add twenty spaces
     " ",                     # add one space
)];
}

 }
#############################


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

Date: Fri, 23 Mar 2007 15:28:39 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Reading from fixed-length text file
Message-Id: <46044687$0$504$815e3792@news.qwest.net>

DB wrote:

> Here is what I'm trying, which fails. I'm guessing it is a stupid sytnax
> problem. Can someone assist?

First, you should state what, exactly, fails.

> 
> #################################
> # reading data in from file
> my (@AoA);
my @AoA;

>  while ( <> ) {
>      chomp;
>      my $line_length=length($_);
> 
> if ($line_length=124) {
use ==

'=' does the assignment.

>      push @AoA, [(
>      substr($_, 0, 4),
>      substr($_, 4, 20),
>      substr($_, 24, 30),
>      substr($_, 54, 8),
>      substr($_, 70, 8),
>      substr($_, 103, 20),
>      substr($_, 123, 1),
> )];
> }
> 
> if ($line_length=78) {
use ==
>      push @AoA, [(
>      substr($_, 0, 4),
>      substr($_, 4, 20),
>      substr($_, 24, 30),
>      substr($_, 54, 8),
>      substr($_, 70, 8),
>      "                    ",  # add twenty spaces
>      " ",                     # add one space
> )];
> }

You could also ignore the length and if there's data there,
use it, otherwise have a default value.

	...
	substr($_, 70, 8),
	substr($_, 103, 20) || ' ' x 20,
	substr($_, 123, 1)  || ' ',


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

Date: Sat, 24 Mar 2007 01:23:19 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: time structure without shift
Message-Id: <eu1r25$dh7$1@ns.felk.cvut.cz>

I have time in seconds and want to get time structure of this time but 
without shift to local time.
The time is say $mytime=1174703700 and @time=localtime($time) give me some 
array, but in another time zone this give another values in this array.
Is the way to get time array without time shift? I mean some like 
@time=nolocaltime($time)
-- 

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail 
from another non-spammer site please.)




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

Date: 23 Mar 2007 13:15:46 -0700
From: "Mark" <google@markginsburg.com>
Subject: Re: Truncating text from a string with beginning text from another string
Message-Id: <1174680945.936949.61650@y80g2000hsf.googlegroups.com>

On Mar 23, 10:44 am, "Mark" <goo...@markginsburg.com> wrote:
> >From a line of arbitrary text, possibly followed by some amount of
>
> text from the beginning of the string ' Reference #\d+', where \d+
> represents one or more digit characters, I want to output the line
> without the ending ' Reference...' string.  For example, the input line
> 'some arbitrary text Refer' would become 'some arbitrary text'.
>

Thanks to all who responded and offered ideas.  Anno's post was
especially interesting.

- M



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

Date: 23 Mar 2007 21:12:43 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Truncating text from a string with beginning text from another string
Message-Id: <56iu6bF28vvs2U1@mid.dfncis.de>

Mark <google@markginsburg.com> wrote in comp.lang.perl.misc:
> On Mar 23, 10:44 am, "Mark" <goo...@markginsburg.com> wrote:
> > >From a line of arbitrary text, possibly followed by some amount of
> >
> > text from the beginning of the string ' Reference #\d+', where \d+
> > represents one or more digit characters, I want to output the line
> > without the ending ' Reference...' string.  For example, the input line
> > 'some arbitrary text Refer' would become 'some arbitrary text'.
> >
> 
> Thanks to all who responded and offered ideas.  Anno's post was
> especially interesting.

Thanks.  Since you mention it, the sub definition can be slightly
simplified:

    {
        my $fix = ' Reference #';
        my @parts = map substr( $fix, 0, $_), 1 .. length $fix;

        sub rem_ref {
            my $str = shift;
            $str =~ s/$_$// and return $str for @parts, "$fix\\d+";
            return $str;
        }
    }

Anno


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

Date: Fri, 23 Mar 2007 20:22:59 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Truncating text from a string with beginning text from another string
Message-Id: <eu1dai$3c2$1@mlucom4.urz.uni-halle.de>

Mark wrote:
> From a line of arbitrary text, possibly followed by some amount of
> text from the beginning of the string ' Reference #\d+', where \d+
> represents one or more digit characters, I want to output the line
> without the ending ' Reference...' string.  For example, the input line
> 'some arbitrary text Refer' would become 'some arbitrary text'.
> 
> Here are two programs that seem to do what I want, but they seem
> overly complicated for this task.  I'm looking for a simpler solution,
> possibly by using a better regular expression than I have chosen in my
> first sample code.

After making the wrong turn first,
I think this can't be solved very
much different from your solution.

The Regex can be an incremental one
(as was shown already by others) or a
sequence of alternations (as you tried).

One could rewrite it somehow 'different',
as a "split", like:

    use strict;
    use warnings;
    no warnings 'qw';

    my @end = qw{R e f e r e n c e \\s # \\d+};
    my $reg = '('.(join '|',map join('',@$_),map[@end[0..$_]],0..$#end).')$';

    while( <DATA> ) {
       chomp;
       print "[$_->[0]]\n\t[$_->[1]]\n"  for
          map [$_->[0]||'undef', $_->[1]||'undef'],
            [split /$reg/]
    }

__DATA__
 ...

Aside from the regex construction (which can be commented
properly ;-), this should be quite readable.


Regards

M.


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

Date: Fri, 23 Mar 2007 20:28:37 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Truncating text from a string with beginning text from another string
Message-Id: <eu1eh9$3mt$1@mlucom4.urz.uni-halle.de>

Mirco Wahab wrote:
> One could rewrite it somehow 'different',
> as a "split", like:
> 
>    use strict;
>    use warnings;
>    ...
>    [split /$reg/]
>    ...

 ...
reg and output slightly modified to match yours:


    ...
    no warnings 'qw';

    my @end = qw{R e f e r e n c e \\s # \\d+};
    my $reg = '\s+('.(join '|',map join('',@$_),map[@end[0..$_]],0..$#end).')$';

    while( <DATA> ) {
       chomp;
       print "in : >$_<\n";
       print "out: >", (split /$reg/)[0], "<\n"
    }
    ...

Regards

M.


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

Date: Fri, 23 Mar 2007 20:31:07 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Truncating text from a string with beginning text from another string
Message-Id: <eu1gga$472$2@mlucom4.urz.uni-halle.de>

Mirco Wahab wrote:
>    ...
>    [split /$reg/]
>    ...


regex/output simplified and slightly modified
to match yours:

    ...
    no warnings 'qw';
    my @end = qw{R e f e r e n c e \\s # \\d+};

    my $reg = '\s+('.(join'|',map join('',@end[0..$_]),0..$#end).')$';

    while( <DATA> ) {
       chomp;
       print "in : >$_<\n";
       print "out: >", (split /$reg/)[0], "<\n"
    }
    ...

Regards

M.


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

Date: 23 Mar 2007 17:50:51 -0700
From: "grocery_stocker" <cdalten@gmail.com>
Subject: Why can't we just change the signal disposition on system()?
Message-Id: <1174697451.777317.299150@p15g2000hsd.googlegroups.com>

This is taken from documentation:

 Since "SIGINT" and "SIGQUIT" are ignored during the execution of
"system", if you expect your program to
               terminate on receipt of these signals you will need to
arrange to do so yourself based on the return
               value.

                   @args = ("command", "arg1", "arg2");
                   system(@args) == 0
                        or die "system @args failed: $?"

               You can check all the failure possibilities by
inspecting $? like this:

                   if ($? == -1) {
                       print "failed to execute: $!\n";
                   }
                   elsif ($? & 127) {
                       printf "child died with signal %d, %s coredump
\n",
                           ($? & 127),  ($? & 128) ? 'with' :
'without';
                   }
                   else {
                       printf "child exited with value %d\n", $? >> 8;
                   }

Why can't we just trap the signal and have it exit? Ie like
           sub sig {
               exit;
           }

           $SIG{INT} = \&sig;


Chad



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

Date: 23 Mar 2007 14:26:51 -0700
From: "Florentin" <florentin.ionescu@gmail.com>
Subject: win32 pxperl
Message-Id: <1174685211.134464.226600@p15g2000hsd.googlegroups.com>


Which is the new URL for the  perl distribution for Windows pxperl ?

Thank you.



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

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


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