[32828] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4093 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 11 03:09:38 2013

Date: Wed, 11 Dec 2013 00:09:04 -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, 11 Dec 2013     Volume: 11 Number: 4093

Today's topics:
        [RFC] Mysql::DBLink <jozefn@sonic.net>
    Re: [RFC] Mysql::DBLink <cwilbur@chromatico.net>
    Re: [RFC] Mysql::DBLink <gamo@telecable.es>
    Re: [RFC] Mysql::DBLink <rweikusat@mobileactivedefense.com>
    Re: fork/exec question <dave@invalid.invalid>
    Re: fork/exec question <dave@invalid.invalid>
    Re: fork/exec question <hjp-usenet3@hjp.at>
    Re: fork/exec question <dave@invalid.invalid>
    Re: fork/exec question <rweikusat@mobileactivedefense.com>
    Re: fork/exec question <dave@invalid.invalid>
        Linux.conf.au 2014 Perth <pdelfante@gmail.com>
    Re: Why is this sub removing newlines?? <derykus@gmail.com>
    Re: Why is this sub removing newlines?? <rweikusat@mobileactivedefense.com>
    Re: Why is this sub removing newlines?? <rweikusat@mobileactivedefense.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 8 Dec 2013 15:38:47 -0800 (PST)
From: Joseph Norris <jozefn@sonic.net>
Subject: [RFC] Mysql::DBLink
Message-Id: <62a78bdf-aa40-4ab5-ae72-ccce537dbfbf@googlegroups.com>

NAME
    Mysql::DBLink

SYNOPSIS
      use Mysql::DBLink;

DESCRIPTION
    Allows linking of two tables in a mysql database for one-to-many
    relationships. This module creates the link if it does not exist and
    then addes to to the link. It also allows retrival of data from linked
    table by key or by field and value. Please Note: Accepts database handle
    of already opened database as a parameter of new. This Package requires
    least one key in each table that will be linked with the following
    configuration:

                id int(10) unsigned NOT NULL auto_increment,
                PRIMARY KEY (`id`)

    Also included is a simple routine updateAdd which allows simple
    add/update to passed table.

  EXPORT
    None by default.

  Modules in this package
    1) Method: new - you must provide a valid database handle.

    Example: use Mysql::DBLinker

        my $dblinker = new Mysql::DBLinker($db);

    2) Method: bldLinker

    Method: bldLinker - to administer link tables between to tables for one
    to many relationships

    Example:

        my $args = {
            from_table => 'from_table_name',
            to_table => 'to_table_name',
            action => 'action to be done'
        };

 $dblinker->bldLinker($args);   # action=>'create' creates frmt_tot_lnk table
 $dblinker->bldLinker($args);   # action=>'drop'  drops frmt_tot_lnk table

my $name = $dblinker->bldLinker($args);   # action=>'get_name' returns the name of the lnk table

    3) Module: handleLinker

    Module: handleLinker - allows creation, deletion of linked records in
    the link table passed to it

      for example:
        my $args = {
            link_table => 'link_table_name',
            from_id => from_id,
            to_id => to_id,
            action => 'action to be done'
        };


      $dbliner->handleLinker(action=>'add',link_table=>$name,from_id=>20,to_id=>35);  
            will add a record with from pointer 20 and to pointer 35
      $dblinker->handleLinker(action=>'delete',link_table=>$name,from_id=>20,to_id=>35); 
            will delete the same record

      NOTE:  on add the code will not allow duplicate entries


in addition returns an array of hash records from the to table given the from table id


       for example:

       given this link table record

                    +----+--------+-------+
                    | id | frm_id | to_id |
                    +----+--------+-------+
                    |  4 |     20 |    35 | 
                    +----+--------+-------+
        
            my $args = {
                from_table => 'frmt',
                to_table => 'tot',
                action => 'get_name'
            };

      my $name = $dblinker->admLinker($args);  returns the name of the lnk table

            $args = {
                action => 'get_lnk_records',
                link_table => "$name",
                from_id => 20,
                sfield => 'firstname',
                svalue = 'joseph'
            }

            my $array_ptr = $dblinker->handleLinker($args); 

the code will go and get all records that have a frm_id = 20 then take the to_id and read all records in the to_table
with and id of 35, stuff them into an array of hashes and return the pointer to this array
            
if sfield has a valid field name in the to table the svalue is search for in that field

then code may be written in the calling script:

for my $v (@{$array_ptr}){
  print $v->{firstname};     # if firstname is a field in the to table of course
}

    4) updateAdd

    Method: updateAdd

    Example: my $action = 'update' or 'add'; my $id = the id of record to be
    updated (pr_id, p_id); my $id_field = the field name of the id of record
    to be updated); my $values = $d or pointer to record hash. my
 ($db_record_id) =
    $dblinker->updateAdd(action=>"$action",table=>"$table",
    update_id=>"$id",values="$d",id_field=$id_field);


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

Date: Mon, 09 Dec 2013 14:06:40 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: [RFC] Mysql::DBLink
Message-Id: <87bo0pg7y7.fsf@new.chromatico.net>

>>>>> "JN" == Joseph Norris <jozefn@sonic.net> writes:

    JN> DESCRIPTION Allows linking of two tables in a mysql database for
    JN> one-to-many relationships. 

Congratulations.  You've just reinvented foreign key constraints.

Here's a quarter.  Go buy yourself a real database and play a game of
Pac-Man with the change.

Charlton


-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: Mon, 09 Dec 2013 20:23:56 +0100
From: gamo <gamo@telecable.es>
Subject: Re: [RFC] Mysql::DBLink
Message-Id: <l855ci$obo$1@speranza.aioe.org>

El 09/12/13 20:06, Charlton Wilbur escribió:
>>>>>> "JN" == Joseph Norris <jozefn@sonic.net> writes:
>
>      JN> DESCRIPTION Allows linking of two tables in a mysql database for
>      JN> one-to-many relationships.
>
> Congratulations.  You've just reinvented foreign key constraints.
>
> Here's a quarter.  Go buy yourself a real database and play a game of
> Pac-Man with the change.
>
> Charlton
>

Oh! Is Postgres a real database then?

Thanks




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

Date: Tue, 10 Dec 2013 15:12:56 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: [RFC] Mysql::DBLink
Message-Id: <87haagagef.fsf@sable.mobileactivedefense.com>

Joseph Norris <jozefn@sonic.net> writes:
> NAME
>     Mysql::DBLink
>
> SYNOPSIS
>       use Mysql::DBLink;
>
> DESCRIPTION
>     Allows linking of two tables in a mysql database for one-to-many
>     relationships.

Generalizing this such that it also support many-to-many would be an
IMHO useful extension. 

>	This module creates the link if it does not exist and
>     then addes to to the link. It also allows retrival of data from linked
>     table by key or by field and value. Please Note: Accepts database handle
>     of already opened database as a parameter of new. This Package requires
>     least one key in each table that will be linked with the following
>     configuration:
>
>                 id int(10) unsigned NOT NULL auto_increment,
>                 PRIMARY KEY (`id`)
>
>     Also included is a simple routine updateAdd which allows simple
>     add/update to passed table.
>
>   EXPORT
>     None by default.
>
>   Modules in this package
>     1) Method: new - you must provide a valid database handle.
>
>     Example: use Mysql::DBLinker
>
>         my $dblinker = new Mysql::DBLinker($db);
>
>     2) Method: bldLinker
>
>     Method: bldLinker - to administer link tables between to tables for one
>     to many relationships
>
>     Example:
>
>         my $args = {
>             from_table => 'from_table_name',
>             to_table => 'to_table_name',
>             action => 'action to be done'
>         };
>
>  $dblinker->bldLinker($args);   # action=>'create' creates frmt_tot_lnk table
>  $dblinker->bldLinker($args);   # action=>'drop'  drops frmt_tot_lnk table
>
> my $name = $dblinker->bldLinker($args);   # action=>'get_name' returns the name of the lnk table

The idea to use a single top-level method which implements its own
internal call dispatching based on string arguments seems rather awkward
to me. Instead of passing an 'action' argument, the individual actions
should be methods of their own so that perl dispatches the calls.

>     3) Module: handleLinker
>
>     Module: handleLinker - allows creation, deletion of linked records in
>     the link table passed to it
>
>       for example:
>         my $args = {
>             link_table => 'link_table_name',
>             from_id => from_id,
>             to_id => to_id,
>             action => 'action to be done'
>         };
>
>
>       $dbliner->handleLinker(action=>'add',link_table=>$name,from_id=>20,to_id=>35);  
>             will add a record with from pointer 20 and to pointer 35
>       $dblinker->handleLinker(action=>'delete',link_table=>$name,from_id=>20,to_id=>35); 
>             will delete the same record
>
>       NOTE:  on add the code will not allow duplicate entries

If duplicates are supposed to be disallowed, it might make sense to use
a database constraint for that because the constraint will be enforced
regardless of the method being used to manipulate the data.



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

Date: Sun, 8 Dec 2013 10:27:28 +0000 (UTC)
From: "Dave Saville" <dave@invalid.invalid>
Subject: Re: fork/exec question
Message-Id: <fV45K0OBJxbE-pn2-6bVhc2SSEQ3F@paddington.bear.den>

On Sun, 8 Dec 2013 05:56:58 UTC, Ben Morrow <ben@morrow.me.uk> wrote:

Hi Ben

> 
> Quoth "Dave Saville" <dave@invalid.invalid>:
> > In C terms a fork/exec of foo execing bar, where both are executables,
> > will show in ps two processes foo and bar and IIRC the parent pid of 
> > bar will be foo's.
> > 
> > I have a perl script that forks and execs. 
> > 
> > my $pid = fork()
> > die "Can't fork $!" if ! defined $pid;
> > 
> > unless ( $pid )
> > {
> >   # child
> > 
> >   exec "mplayer.........
> > 
> > }
> > 
> > print "$pid\n";
> > 
> > ....
> > 
> > Assume $pid is 123 If I run a ps I get
> > 
> > pid ppid prog
> > 100 *** cmd
> > 101 100 perl
> > 123 100 perl
> > 124 123 sh
> > 125 124 sh
> > 126 125 mplayer
> > 
> > Which is not what I would have expected. 
> 
> You're using 1-arg exec (tut). This is roughly equivalent to

Assumption based on an incomplete line of code :-) But in ths case 
true.

> 
>     sub exec {
>         my ($cmd) = @_;
> 
>         if ($cmd =~ /\Q$&*(){}[]'";\\|?<>~`\n/) {
>             exec "sh", "-c", $cmd;
>         }
>         else {
>             exec split " ", $cmd;
>         }
>     }
> 
> that is: if using a shell will make a difference, run it with the shell,
> otherwise split on whitespace and run it directly. This is exactly the
> same behaviour as system(), where it more closely matches what a C
> programmer would expect, and it allows you to include shell redirections
> in your command. (And, in fact, you must have done so, or perl wouldn't
> have used the shell.)
> 

No redirections in the command given to exec.

> It's better in general to avoid this by using multi-arg system, which
> always runs the command directly. Obviously in that case you have to do
> any redirections yourself, between fork and exec; sometimes it's not
> worth it.

We have established in the past, although possibly not in this NG, 
that the OS/2 port often screws up passing parameters when not used in
1 arg mode. 

But it still leaves the original question - why is there still perl 
and a couple of sh's in the process chain? Or does perl exec never 
actually call C exec and just fake it? 
-- 
Regards
Dave Saville


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

Date: Sun, 8 Dec 2013 10:45:57 +0000 (UTC)
From: "Dave Saville" <dave@invalid.invalid>
Subject: Re: fork/exec question
Message-Id: <fV45K0OBJxbE-pn2-NmMIMtIrkKSY@paddington.bear.den>

On Sat, 7 Dec 2013 16:16:07 UTC, "Dave Saville" <dave@invalid.invalid>
wrote:

> In C terms a fork/exec of foo execing bar, where both are executables,
> will show in ps two processes foo and bar and IIRC the parent pid of 
> bar will be foo's.
> 
> I have a perl script that forks and execs. 
> 
> my $pid = fork()
> die "Can't fork $!" if ! defined $pid;
> 
> unless ( $pid )
> {
>   # child
> 
>   exec "mplayer.........
> 
> }
> 
> print "$pid\n";
> 
> ....
> 
> Assume $pid is 123 If I run a ps I get
> 
> pid ppid prog
> 100 *** cmd
> 101 100 perl
> 123 100 perl
> 124 123 sh
> 125 124 sh
> 126 125 mplayer
> 
> Which is not what I would have expected. 
> 
> I would have expected
> 
> 100 *** cmd
> 101 100 perl
> 123 101 mplayer
> 
> Or very close. Of course this could be another OS/2 oddity :-)


Just run this on a *nix box and I get, almost, what I expected.

1493 1405 bash
1593 1493 perl
1594 1593 sh -c mplayer
1595 1594 mplayer

Ben has explained where the sh comes from ( 1 arg exec ) so I guees it
is an OS/2 funny.
-- 
Regards
Dave Saville


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

Date: Sun, 8 Dec 2013 11:53:04 +0100
From: "Peter J. Holzer" <hjp-usenet3@hjp.at>
Subject: Re: fork/exec question
Message-Id: <slrnla8jsg.nfn.hjp-usenet3@hrunkner.hjp.at>

On 2013-12-08 10:27, Dave Saville <dave@invalid.invalid> wrote:
> On Sun, 8 Dec 2013 05:56:58 UTC, Ben Morrow <ben@morrow.me.uk> wrote:
>> Quoth "Dave Saville" <dave@invalid.invalid>:

[fork/exec on OS/2]

>> > Assume $pid is 123 If I run a ps I get
>> > 
>> > pid ppid prog
>> > 100 *** cmd
>> > 101 100 perl
>> > 123 100 perl
>> > 124 123 sh
>> > 125 124 sh
>> > 126 125 mplayer
>> > 
>> > Which is not what I would have expected. 
[...]
>> It's better in general to avoid this by using multi-arg system, which
>> always runs the command directly. Obviously in that case you have to do
>> any redirections yourself, between fork and exec; sometimes it's not
>> worth it.
>
> We have established in the past, although possibly not in this NG, 
> that the OS/2 port often screws up passing parameters when not used in
> 1 arg mode. 
>
> But it still leaves the original question - why is there still perl 
> and a couple of sh's in the process chain? Or does perl exec never 
> actually call C exec and just fake it? 

Does OS/2 even have an exec system call? I'm pretty sure it doesn't have
fork, so what ps shows you may not be real processes but threads.

	hp


-- 
   _  | Peter J. Holzer    | Fluch der elektronischen Textverarbeitung:
|_|_) |                    | Man feilt solange an seinen Text um, bis
| |   | hjp@hjp.at         | die Satzbestandteile des Satzes nicht mehr
__/   | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel


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

Date: Sun, 8 Dec 2013 17:11:00 +0000 (UTC)
From: "Dave Saville" <dave@invalid.invalid>
Subject: Re: fork/exec question
Message-Id: <fV45K0OBJxbE-pn2-JdgEm7dYVMKd@paddington.bear.den>

On Sun, 8 Dec 2013 10:53:04 UTC, "Peter J. Holzer" 
<hjp-usenet3@hjp.at> wrote:

<Snip>
> Does OS/2 even have an exec system call? I'm pretty sure it doesn't have
> fork, so what ps shows you may not be real processes but threads.

It has both - but fork is *really* slow and inefficient compared to 
*nix.
-- 
Regards
Dave Saville


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

Date: Sun, 08 Dec 2013 18:16:22 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: fork/exec question
Message-Id: <87txej8ayx.fsf@sable.mobileactivedefense.com>

"Dave Saville" <dave@invalid.invalid> writes:
> On Sun, 8 Dec 2013 10:53:04 UTC, "Peter J. Holzer" 
> <hjp-usenet3@hjp.at> wrote:
>
> <Snip>
>> Does OS/2 even have an exec system call? I'm pretty sure it doesn't have
>> fork, so what ps shows you may not be real processes but threads.
>
> It has both - but fork is *really* slow and inefficient compared to 
> *nix.

I haven't done anyting for or with OS/2 for a long time (17 - 18 years)
but I still remember that OS/2 has neither fork nor exec. The native
call is called DosExecPgm and perform this 'usual' create a new process
to run a different program functionality, cf

http://www.edm2.com/os2api/
http://www.edm2.com/os2api/Dos/DosExecPgm.html

EMX provides a fork call at the library level but it is not really
documented how this works. But considering the lack of OS-support, what
it will very likely do is use DosExecPgm to start a bootstrap program
making an actual of the process which called fork, similar to the way
fork used to work on UNIX(*) prior to virtual memory.






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

Date: Mon, 9 Dec 2013 10:02:21 +0000 (UTC)
From: "Dave Saville" <dave@invalid.invalid>
Subject: Re: fork/exec question
Message-Id: <fV45K0OBJxbE-pn2-dgunNvgMO23T@paddington.bear.den>

On Sun, 8 Dec 2013 18:16:22 UTC, Rainer Weikusat 
<rweikusat@mobileactivedefense.com> wrote:

> "Dave Saville" <dave@invalid.invalid> writes:
> > On Sun, 8 Dec 2013 10:53:04 UTC, "Peter J. Holzer" 
> > <hjp-usenet3@hjp.at> wrote:
> >
> > <Snip>
> >> Does OS/2 even have an exec system call? I'm pretty sure it doesn't have
> >> fork, so what ps shows you may not be real processes but threads.
> >
> > It has both - but fork is *really* slow and inefficient compared to 
> > *nix.
> 
> I haven't done anyting for or with OS/2 for a long time (17 - 18 years)
> but I still remember that OS/2 has neither fork nor exec. The native
> call is called DosExecPgm and perform this 'usual' create a new process
> to run a different program functionality, cf
> 
> http://www.edm2.com/os2api/
> http://www.edm2.com/os2api/Dos/DosExecPgm.html
> 
> EMX provides a fork call at the library level but it is not really
> documented how this works. But considering the lack of OS-support, what
> it will very likely do is use DosExecPgm to start a bootstrap program
> making an actual of the process which called fork, similar to the way
> fork used to work on UNIX(*) prior to virtual memory.

Hi Rainer 

Apologies - We now have a much later compiler than EMX, based on gcc 
4.4.6 and I assumed it's LIBC had an exec().  Never tried it actually 
but use fork a fair bit. A quick test on both EMX and the latter 
yields the same - a duplicated process tree running the "execed" 
program. You are correct about the way fork works - I said it was slow
:-)
-- 
Regards
Dave Saville


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

Date: Mon, 9 Dec 2013 23:28:42 -0800 (PST)
From: Paul Del Fante <pdelfante@gmail.com>
Subject: Linux.conf.au 2014 Perth
Message-Id: <acae9d72-3b6a-4d13-b854-705b7f8b7af9@googlegroups.com>

Hey guys, Don't forget we have http://Linux.conf.au 2014 in Perth WA.
Lots of Linux, Open Source, Free Software, Open Programming, Open Radio, Open Hardware talks and Linux people from around the world. 
We would love for you guys to come along.
http://lca2014.linux.org.au #lca2014


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

Date: Tue, 10 Dec 2013 03:44:53 -0800
From: Charles DeRykus <derykus@gmail.com>
Subject: Re: Why is this sub removing newlines??
Message-Id: <l86us6$d6e$1@speranza.aioe.org>

On 12/7/2013 6:06 AM, C.DeRykus wrote:
> On Saturday, December 7, 2013 5:49:21 AM UTC-8, C.DeRykus wrote:
>> On Saturday, December 7, 2013 4:34:44 AM UTC-8, Ben Bacarisse wrote:
>>> "C.DeRykus" <derykus@gmail.com> writes:
>>
>>>> On Thursday, December 5, 2013 1:56:46 PM UTC-8, John Black wrote:>
>>
>>>>> keep this in mind - I had wanted that trim function to not strip the
>>>>> newlines (and not add any either if there wasn't one).  Should not be
>>
>>>> Another option: a regex that'd handle any trailing newline:
>>>> $string  =~ s/ ^\s+ | \s+(?=\n|)$ //gx;
>>
>>> Surely this strips the newline?
>>
>> Indeed.  I was slipping off the end... I think,hope a redemptive tweak will do it:
>> $string =~ s/ ^s+ | \s++(?=\n) /gx;
>
> Sorry, more redemption is needed.
>

But I'm not quite ready to declare it unredeemable:

      $string =~ s/ ^\s+ | \s+(?=\n)$ | \s*[^\n\S]+$ //gx;


[ depending on flavor of white space you want ]


-- 
Charles DeRykus


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

Date: Tue, 10 Dec 2013 15:22:54 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Why is this sub removing newlines??
Message-Id: <87d2l4afxs.fsf@sable.mobileactivedefense.com>

Charles DeRykus <derykus@gmail.com> writes:
> On 12/7/2013 6:06 AM, C.DeRykus wrote:
>> On Saturday, December 7, 2013 5:49:21 AM UTC-8, C.DeRykus wrote:
>>> On Saturday, December 7, 2013 4:34:44 AM UTC-8, Ben Bacarisse wrote:
>>>> "C.DeRykus" <derykus@gmail.com> writes:
>>>
>>>>> On Thursday, December 5, 2013 1:56:46 PM UTC-8, John Black wrote:>
>>>
>>>>>> keep this in mind - I had wanted that trim function to not strip the
>>>>>> newlines (and not add any either if there wasn't one).  Should not be
>>>
>>>>> Another option: a regex that'd handle any trailing newline:
>>>>> $string  =~ s/ ^\s+ | \s+(?=\n|)$ //gx;
>>>
>>>> Surely this strips the newline?
>>>
>>> Indeed.  I was slipping off the end... I think,hope a redemptive tweak will do it:
>>> $string =~ s/ ^s+ | \s++(?=\n) /gx;
>>
>> Sorry, more redemption is needed.
>>
>
> But I'm not quite ready to declare it unredeemable:
>
>      $string =~ s/ ^\s+ | \s+(?=\n)$ | \s*[^\n\S]+$ //gx;

I may be missing something here, but what about

s/\s+?(?=\n)?$//


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

Date: Tue, 10 Dec 2013 15:27:05 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Why is this sub removing newlines??
Message-Id: <878uvsafqu.fsf@sable.mobileactivedefense.com>

Rainer Weikusat <rweikusat@mobileactivedefense.com> writes:
> Charles DeRykus <derykus@gmail.com> writes:
>> On 12/7/2013 6:06 AM, C.DeRykus wrote:
>>> On Saturday, December 7, 2013 5:49:21 AM UTC-8, C.DeRykus wrote:
>>>> On Saturday, December 7, 2013 4:34:44 AM UTC-8, Ben Bacarisse wrote:
>>>>> "C.DeRykus" <derykus@gmail.com> writes:
>>>>
>>>>>> On Thursday, December 5, 2013 1:56:46 PM UTC-8, John Black wrote:>
>>>>
>>>>>>> keep this in mind - I had wanted that trim function to not strip the
>>>>>>> newlines (and not add any either if there wasn't one).  Should not be
>>>>
>>>>>> Another option: a regex that'd handle any trailing newline:
>>>>>> $string  =~ s/ ^\s+ | \s+(?=\n|)$ //gx;
>>>>
>>>>> Surely this strips the newline?
>>>>
>>>> Indeed.  I was slipping off the end... I think,hope a redemptive tweak will do it:
>>>> $string =~ s/ ^s+ | \s++(?=\n) /gx;
>>>
>>> Sorry, more redemption is needed.
>>>
>>
>> But I'm not quite ready to declare it unredeemable:
>>
>>      $string =~ s/ ^\s+ | \s+(?=\n)$ | \s*[^\n\S]+$ //gx;
>
> I may be missing something here, but what about
>
> s/\s+?(?=\n)?$//

One thinhg I missed was a trailing newline without other whitespace in
front of it. Making this

s/\s*?(?=\n)?$//;

instead works with that as well (although this should surely be called a
questionable construct, given the number of ?s ...).



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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 4093
***************************************


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