[29889] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1132 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 19 14:09:40 2007

Date: Wed, 19 Dec 2007 11:09:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 19 Dec 2007     Volume: 11 Number: 1132

Today's topics:
        A problem with Perl 5.10.0 installation <rwxrxrx@gmail.com>
    Re: A problem with Perl 5.10.0 installation <rwxrxrx@gmail.com>
    Re: A problem with Perl 5.10.0 installation <joost@zeekat.nl>
    Re: A problem with Perl 5.10.0 installation <joost@zeekat.nl>
    Re: A problem with Perl 5.10.0 installation <abigail@abigail.be>
    Re: FAQ 4.3 Why isn't my octal data interpreted correct <brian.d.foy@gmail.com>
    Re: FAQ 4.3 Why isn't my octal data interpreted correct <RedGrittyBrick@SpamWeary.foo>
    Re: How to maintain hash relationship? <brt@rentrak.com>
    Re: How to maintain hash relationship? <krahnj@telus.net>
        PID of Service <bol@adv.magwien.gv.at>
    Re: PID of Service <thepoet_nospam@arcor.de>
    Re: PID of Service <bol@adv.magwien.gv.at>
    Re: Problem with Perl system() <Julie@nospam.com>
    Re: Problem with Perl system() <tadmc@seesig.invalid>
    Re: regex question about ?, *, and $1 <tadmc@seesig.invalid>
    Re: regex question about ?, *, and $1 vorticitywolfe@gmail.com
    Re: regex question about ?, *, and $1 <bik.mido@tiscalinet.it>
    Re: regex question about ?, *, and $1 <mritty@gmail.com>
    Re: regex question about ?, *, and $1 vorticitywolfe@gmail.com
    Re: regex question about ?, *, and $1 <peter@makholm.net>
    Re: regex question about ?, *, and $1 vorticitywolfe@gmail.com
        remove CR + trailing spaces <danfan46@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 19 Dec 2007 23:59:35 +0800
From: "Scott.zhou" <rwxrxrx@gmail.com>
Subject: A problem with Perl 5.10.0 installation
Message-Id: <fkbjk0$261$1@news.cn99.com>

when i run make tool, i got such problem

perl.c:(.text+0x47f2): undefined reference to `SOCKSinit'

AND i could not search SOCKSinit definition in /usr/include/*
how could i fix this problem


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

Date: Thu, 20 Dec 2007 00:03:02 +0800
From: "Scott.zhou" <rwxrxrx@gmail.com>
Subject: Re: A problem with Perl 5.10.0 installation
Message-Id: <fkbjqf$261$2@news.cn99.com>

Scott.zhou дµÀ:
> when i run make tool, i got such problem
> 
> perl.c:(.text+0x47f2): undefined reference to `SOCKSinit'
> 
> AND i could not search SOCKSinit definition in /usr/include/*
> how could i fix this problem
ps: I run Fedora 8 on my PC


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

Date: Wed, 19 Dec 2007 17:15:39 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: A problem with Perl 5.10.0 installation
Message-Id: <87ve6uy82c.fsf@zeekat.nl>

"Scott.zhou" <rwxrxrx@gmail.com> writes:

> when i run make tool, i got such problem
>
> perl.c:(.text+0x47f2): undefined reference to `SOCKSinit'
>
> AND i could not search SOCKSinit definition in /usr/include/*
> how could i fix this problem

Did you enable "SOCKS support" during the sh Configure stage?
It's disabled by default and I think you'd know if you need it.

I just did a 

$ sh Configure
 ( chose defaults for everything except that I enabled threads )
$ make
    .... (lots of output)
    Everything is up to date. Type 'make test' to run test suite.

Or did you mean something else by "run make tool"?

See also the INSTALL file.

HTH,
Joost.


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

Date: Wed, 19 Dec 2007 17:17:24 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: A problem with Perl 5.10.0 installation
Message-Id: <87r6hiy7zf.fsf@zeekat.nl>

Joost Diepenmaat <joost@zeekat.nl> writes:
> I just did a 
>
> $ sh Configure
>  ( chose defaults for everything except that I enabled threads )
> $ make
>     .... (lots of output)
>     Everything is up to date. Type 'make test' to run test suite.

That's on debian testing/unstable, by the way.

Joost.


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

Date: 19 Dec 2007 17:38:50 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: A problem with Perl 5.10.0 installation
Message-Id: <slrnfmilpa.ub8.abigail@alexandra.abigail.be>

                                        _
Scott.zhou (rwxrxrx@gmail.com) wrote on VCCXXIII September MCMXCIII in
<URL:news:fkbjk0$261$1@news.cn99.com>:
''  when i run make tool, i got such problem
''  
''  perl.c:(.text+0x47f2): undefined reference to `SOCKSinit'
''  
''  AND i could not search SOCKSinit definition in /usr/include/*
''  how could i fix this problem


It might help if you post the arguments to Configure, or, if you ran
configure interactively, the answers to the questions where you didn't
pick a default.



Abigail
-- 
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
 |perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
 |perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
 |perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;


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

Date: Wed, 19 Dec 2007 11:11:08 -0600
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 4.3 Why isn't my octal data interpreted correctly?
Message-Id: <191220071111083091%brian.d.foy@gmail.com>

In article <slrnfmg4dg.go9.hjp-usenet2@hrunkner.hjp.at>, Peter J.
Holzer <hjp-usenet2@hjp.at> wrote:

> > I still say that Perl numbers are decimal unless we say otherwise.
> 
> That's easy to disprove:
> 
> % perl -l -e 'for ($i = 0; $i != 1; $i += 0.1) { print $i }' 

I see Perl using the digits 0 to 9.

There are underlying implementation details based on the architecture,
but that's implementation. The language is not the processor or the
storage. That there is some round-off error because of the limitations
of computers doesn't change the fact that Perl is using the digits 0 to
9.

> > Perl will treat them as decimal
> 
> No. Perl treats *strings* as decimal when used in a numeric context.

No. Perl treats literal numbers as decimal. That's why we have other
ways to denote bases 2, 8, 16. When you type just 100, that's 10 base
10 groups of 10 base 10, not 8 or 64 or 256. The only exception I know
is in a \nnn sequence in a double quoted string context, which is
treated as octal.

It matters too, because some things in Perl take octal numbers. Ask
chmod, mkdir, and a few other things what a literal 755 is. You'll see
Perl uses it as base 10 and people get the wrong thing.

In the language called Perl, literal numbers are base 10 unless we say
otherwise. 

When you talk about binary, you're talking about computer storage.
That's something external to Perl. I'm just talking about Perl.


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

Date: Wed, 19 Dec 2007 17:57:21 +0000
From: RedGrittyBrick <RedGrittyBrick@SpamWeary.foo>
Subject: Re: FAQ 4.3 Why isn't my octal data interpreted correctly?
Message-Id: <47695b7e$0$13929$fa0fcedb@news.zen.co.uk>

brian d foy wrote:
> In article <slrnfmg4dg.go9.hjp-usenet2@hrunkner.hjp.at>, Peter J. 
> Holzer <hjp-usenet2@hjp.at> wrote:
> 
>>> I still say that Perl numbers are decimal unless we say 
>>> otherwise.
>> That's easy to disprove:
>> 
>> % perl -l -e 'for ($i = 0; $i != 1; $i += 0.1) { print $i }'
> 
> I see Perl using the digits 0 to 9.
[snip]
> When you talk about binary, you're talking about computer storage. 
> That's something external to Perl. I'm just talking about Perl.

You and Peter seem to be arguing at cross-purposes. I believe Peter was
objecting to the final words of this part of the FAQ:

>> Perl only understands octal and hex numbers as such when they occur
>>  as literals in your program. Octal literals in perl must start 
>> with a leading 0 and hexadecimal literals must start with a leading
>>  "0x". If they are read in from somewhere and assigned, no 
>> automatic conversion takes place. You must explicitly use "oct()" 
>> or "hex()" if you want the values converted to decimal.

If, as I think you say, Perl doesn't care whether the internal
representation of a number in perl (or some hypothetical other
implementation) is decimal or binary, it might be clearer to end that
paragraph thus:

    You must explicitly use "oct()" or "hex()" if you want the
    values converted from octal or hexadecimal representations.

If we accept that Perl is somehow independant of perl: If Perl has 
nothing to say about the base of $n in "my $n = 17 + 017 + 0x17;" it is 
nevertheless true that the result is represented exactly and that Perl's 
"print" function will convert it to a decimal representation unless we 
tell it otherwise.

Just my 0.02 worth.


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

Date: Wed, 19 Dec 2007 06:46:17 -0800 (PST)
From: Bill <brt@rentrak.com>
Subject: Re: How to maintain hash relationship?
Message-Id: <24e7aeef-bb8c-451a-a34e-1603e6ec32ca@i29g2000prf.googlegroups.com>

On Dec 17, 5:07 pm, Fred <itf...@cdw.com> wrote:
> I'm not sure if I'm phrasing the question correctly, but here goes -- In
> ...

Fred,
I've modified your original code to do what it sounds like you want it
to do.  You also mentioned returning a hash, so I included two ways of
doing that.  Enter a city on the command line and look at the code
near
the end of the main() "section".  You could also use a hash keyed on
the
city which pointed to an array of name records.
-Bill

#!/usr/local/bin/perl

use strict;
use warnings;

my %field_pos;
my %people;

%field_pos =
(
  'FIRST_NAME', 0,
  'LAST_NAME', 1,
  'CITY', 2,
);

# Save where __DATA__ starts in our script
# so we can get back there for sub-sequent
# reads (this must occur prior to the first
# read from <DATA>)
#
my $DATA_START_POS = tell(DATA);

# Altered original
#
while ( <DATA> )
{
    chomp;
    s/\s$//;
    my @data = split /\s*,\s*/;
    my $key = "$data[1], $data[0]";
    map { $people{$key}->{$_} = $data[$field_pos{$_}] } keys
%field_pos;
}

show_hash('people', \%people);

#-----------------------------

# Alternate version 1
#
my %people1 = get_data1();

show_hash('people1', \%people1);

#-----------------------------

# Alternate version 2
#
my %people2;
get_data2(\%people2);

show_hash('people2', \%people2);


# Show any people that live in the city entered on the command line
#
print "\n";
my $found = 0;
if ( $ARGV[0] )
{
    foreach my $key ( sort keys %people )
    {
        my $rec = $people{$key};
        next unless ( $ARGV[0] eq $rec->{CITY} );
        print "$rec->{FIRST_NAME} $rec->{LAST_NAME} lives in
$ARGV[0]\n";
        $found++;
    }
}

printf "\n%s in $ARGV[0]\n", ( $found )
                             ? sprintf "$found %s", ( $found == 1 ) ?
'person lives' : 'people live'
                             : "No one lives";

#END main()


sub get_data1
{
    my %rethash;

    # Rewind __DATA__ to its beginning
    #
    seek(DATA, $DATA_START_POS, 0);

    while ( <DATA> )
    {
        chomp;
        s/\s$//;
        my @data = split /\s*,\s*/;
        my $key = "$data[0] $data[1]";
        map { $rethash{$key}->{$_} = $data[$field_pos{$_}] } keys
%field_pos;
    }
    return(%rethash);
}


sub get_data2
{
    my($hashref) = @_;

    # Rewind __DATA__ to its beginning
    #
    seek(DATA, $DATA_START_POS, 0);

    while ( <DATA> )
    {
        chomp;
        s/\s//g;
        my @data = split /,/;
        my $key = "$data[1]$data[0]";
        map { $$hashref{$key}->{$_} = $data[$field_pos{$_}] } keys
%field_pos;
    }
    # Since $hashref is just the "address" of %people2, the
    # assignments we made were directly to %people2 so there's
    # nothing to return (although you could return something
    # like the number of records read)
}

sub show_hash
{
    my($title, $hashref) = @_;

    print "\n'$title' hash:\n";
    foreach my $key ( sort keys %$hashref )
    {
        my $rec = $$hashref{$key};
        printf "  %-20s: %-7s %-13s %s\n", $key, $rec->{FIRST_NAME},
$rec->{LAST_NAME}, $rec->{CITY};
    }
}

__DATA__
Fred, Flintstone, Bedrock
Wilma, Flintstone, Bedrock
Barney, Rubble, Moonrock



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

Date: Wed, 19 Dec 2007 16:44:00 GMT
From: "John W. Krahn" <krahnj@telus.net>
Subject: Re: How to maintain hash relationship?
Message-Id: <47694A41.85EC5F62@telus.net>

Bill wrote:
> 
> On Dec 17, 5:07 pm, Fred <itf...@cdw.com> wrote:
> > I'm not sure if I'm phrasing the question correctly, but here goes -- In
> > ...
> 
> Fred,
> I've modified your original code to do what it sounds like you want it
> to do.  You also mentioned returning a hash, so I included two ways of
> doing that.  Enter a city on the command line and look at the code
> near
> the end of the main() "section".  You could also use a hash keyed on
> the
> city which pointed to an array of name records.

[ SNIP ]

> # Altered original
> #
> while ( <DATA> )
> {
>     chomp;
>     s/\s$//;
>     my @data = split /\s*,\s*/;
>     my $key = "$data[1], $data[0]";
>     map { $people{$key}->{$_} = $data[$field_pos{$_}] } keys
> %field_pos;

You shouldn't use map in void context:

      $people{$key}->{$_} = $data[$field_pos{$_}] for keys %field_pos;

> }

[ SNIP ]

> printf "\n%s in $ARGV[0]\n", ( $found )
>                              ? sprintf "$found %s", ( $found == 1 ) ?
> 'person lives' : 'people live'
>                              : "No one lives";

No need to use printf and sprintf there:

print
    "\n",
    ( "$found person", "$found people", 'No one' )[ $found <=> 1 ],
    ' live',
    $found < 2 ? 's' : '',
    " in $ARGV[0]";



John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 19 Dec 2007 15:07:00 +0100
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: PID of Service
Message-Id: <1198073229.553486@proxy.dienste.wien.at>

Good day to all,

Given the name of a Win32 service, is there a way to find out its PID from a
Perl script?

I looked at Win32::Service and Win32::Daemon modules, but couldn't find a
way for this.

Kind greetings,

-- 
Ing Ferry Bolhar
Magistrat der Stadt Wien - MA 14
A-1010 Wien
E-Mail: ferdinand.bolhar-nordenkampf@wien.gv.at




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

Date: Wed, 19 Dec 2007 16:07:31 +0100
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: PID of Service
Message-Id: <476933b3$0$13111$9b4e6d93@newsspool2.arcor-online.net>

Ferry Bolhar wrote:
> Good day to all,
> 
> Given the name of a Win32 service, is there a way to find out its PID from a
> Perl script?
> 
> I looked at Win32::Service and Win32::Daemon modules, but couldn't find a
> way for this.

You can gather that info from the WMI (quick'n'dirty):
---------------------------------------------------------------------
#!/usr/bin/perl

use strict;
use warnings;
use DBI;
use Win32::OLE qw(in);

my $dbh = DBI->connect('dbi:WMI:');

my $sth = $dbh->prepare(<<WQL);
   SELECT * FROM Win32_Service WHERE Name = '$ARGV[0]'
WQL

$sth->execute();
if (my $row = $sth->fetchrow()) {
   printf( "%-20s - %10s %8i\n\t%s\n",
   	$row->Name, $row->State, $row->ProcessID, $row->PathName
   );
}
-----------------------------------------------------------------------

Greetings
-Chris


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

Date: Wed, 19 Dec 2007 19:41:33 +0100
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: PID of Service
Message-Id: <1198089703.215650@proxy.dienste.wien.at>

Christian Winter:

> You can gather that info from the WMI (quick'n'dirty):

[...]

Looks great! Does this work from other hosts as well?

Many thanks,

-- 
Ing Ferry Bolhar
Magistrat der Stadt Wien - MA 14
A-1010 Wien
E-Mail: ferdinand.bolhar-nordenkampf@wien.gv.at




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

Date: Wed, 19 Dec 2007 06:33:44 -0500
From: Julie <Julie@nospam.com>
Subject: Re: Problem with Perl system()
Message-Id: <4769018e$0$16153$4c368faf@roadrunner.com>

Doug Miller wrote:
> In article <47686516$0$1383$4c368faf@roadrunner.com>, Julie <Julie@nospam.com> wrote:
>> Never mind,  I answered my own question. >
> well, what was the answer?

see below

>> Julie wrote:
>>> I'm using Windows XP Pro and running Perl 5.8.8 under Cygwin.
>>>
>>> I have a Perl program that calls another Perl program using system().
>>>
>>> The driver program repeatedly calls the main Perl program.
>>>
>>> for ( my $i = 0 ; $i < $retries ; $i++
>>> {
>>>    for ( my $j = 0 ; $j < $num_devices ; $j++ )
>>>    {
>>>       system( "perl main.pl parm1 parm2 &" ) ;
>>>    }
>>>    sleep 60 ;  # never gets here
>>> }
>>>
>>> I put the call to system() within a loop and (almost) everything is fine.
>>>
>>> The only problem is that after the last call to system(), the outer loop 
>>> doesn't gain control.  The process seems to be hung.
>>> I've put warn statements everywhere in the driver program but that 
>>> hasn't yielded any clues.
>>>
>>> I know that main.pl is terminating because there's only one Perl process 
>>> running after the last call to system().
>>>
>>> It doesn't matter whether I run one or a hundred calls to system().
>>>
>>> **** Here's what's very interesting:   If I run main.pl under the Perl 
>>> debugger then press 'c' to continue (no breakpoints etc.),  then the 
>>> program behaves perfectly; control is passed to the outer loop after the 
>>> last system() call.
>>>
>>> I'm using strict, warning, diagnostics pragmas.  I've also tried main.pl 
>>> without the pragmas.
>>>
>>> What can I do to resolve this problem?
> 

I replaced all the 'print' statements with 'warn' statements to let me 
know what the program was doing.

I thought that I had added enough print/warn statements to inform me 
that the program was sleeping before its next iteration.

For whatever reason, when running the program under the debugger (not in 
step mode or with any watch or breakpoints but 'c' which ran the entire 
program), all the print statements are displayed.  When not running in 
debug mode, not all the print statements were being displayed.

Obviously, this is not a 'solution' but an artifact and I don't know if 
it's because I'm running under Cygwin.  I normally would have spend more 
time trying to resolve this issue on my own but I had a deadline.


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

Date: Wed, 19 Dec 2007 12:10:37 GMT
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Problem with Perl system()
Message-Id: <slrnfmi2co.q5o.tadmc@tadmc30.sbcglobal.net>

Julie <Julie@nospam.com> wrote:

> I replaced all the 'print' statements with 'warn' statements to let me 
> know what the program was doing.
>
> I thought that I had added enough print/warn statements to inform me 
> that the program was sleeping before its next iteration.
>
> For whatever reason, 


   Suffering from Buffering?

      http://perl.plover.com/FAQs/Buffering.html


> when running the program under the debugger (not in 
> step mode or with any watch or breakpoints but 'c' which ran the entire 
> program), all the print statements are displayed.  When not running in 
> debug mode, not all the print statements were being displayed.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Wed, 19 Dec 2007 12:10:37 GMT
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: regex question about ?, *, and $1
Message-Id: <slrnfmi1t2.q5o.tadmc@tadmc30.sbcglobal.net>

vorticitywolfe@gmail.com <vorticitywolfe@gmail.com> wrote:
> Alright, this is confusing me:
>
> $string = 2340Z 4SL -ABCD PS T1203045;


   perl -e '$string = 2340Z 4SL -ABCD PS T1203045;'
Bareword found where operator expected at -e line 1, near "2340Z"
        (Missing operator before Z?)
Number found where operator expected at -e line 1, near "Z 4"
        (Do you need to predeclare Z?)
Bareword found where operator expected at -e line 1, near "4SL"
        (Missing operator before SL?)
syntax error at -e line 1, near "2340Z "


> if $string =~ m/(-|\+)*(AB|YZ)*(EF|CD)*\s??(PL|PS|PT)*?/g{
>      print $1,$2,$3,$4;
> }


   perl -e 'if $string =~ m/(-|\+)*(AB|YZ)*(EF|CD)*\s??(PL|PS|PT)*?/g{
> print $1,$2,$3,$4;
> }'
syntax error at -e line 1, near "if $string "
Execution of -e aborted due to compilation errors.


> This works 


That is impossible.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Wed, 19 Dec 2007 04:22:11 -0800 (PST)
From: vorticitywolfe@gmail.com
Subject: Re: regex question about ?, *, and $1
Message-Id: <f4ccb226-1b83-4d79-b606-b13846278816@i29g2000prf.googlegroups.com>

On Dec 19, 12:10 pm, Tad J McClellan <ta...@seesig.invalid> wrote:
> vorticitywo...@gmail.com <vorticitywo...@gmail.com> wrote:
> > Alright, this is confusing me:
>
> > $string = 2340Z 4SL -ABCD PS T1203045;
>
>    perl -e '$string = 2340Z 4SL -ABCD PS T1203045;'
> Bareword found where operator expected at -e line 1, near "2340Z"
>         (Missing operator before Z?)
> Number found where operator expected at -e line 1, near "Z 4"
>         (Do you need to predeclare Z?)
> Bareword found where operator expected at -e line 1, near "4SL"
>         (Missing operator before SL?)
> syntax error at -e line 1, near "2340Z "
>
> > if $string =~ m/(-|\+)*(AB|YZ)*(EF|CD)*\s??(PL|PS|PT)*?/g{
> >      print $1,$2,$3,$4;
> > }
>
>    perl -e 'if $string =~ m/(-|\+)*(AB|YZ)*(EF|CD)*\s??(PL|PS|PT)*?/g{> print $1,$2,$3,$4;
> > }'
>
> syntax error at -e line 1, near "if $string "
> Execution of -e aborted due to compilation errors.
>
> > This works
>
> That is impossible.
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

correction
$string = "2340Z 4SL -ABCD PS T1203045";

forgot the quotes in the translation


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

Date: Wed, 19 Dec 2007 14:04:21 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: regex question about ?, *, and $1
Message-Id: <8j5im3d85hl3s7qcni16n8jelitgbkr35j@4ax.com>

On Wed, 19 Dec 2007 04:22:11 -0800 (PST), vorticitywolfe@gmail.com
wrote:

>> > Alright, this is confusing me:
>>
>> > $string = 2340Z 4SL -ABCD PS T1203045;
[snip]

>> --
>> Tad McClellan
>> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Alright: you did good not to top post, but no need to quote the entire
message you're replying to either. Not certainly the .sig, unless you
want to comment on it.

>correction
>$string = "2340Z 4SL -ABCD PS T1203045";
>
>forgot the quotes in the translation

There's a lesson in this: don't retype. Copy and paste instead. It's
also easier, ain't it?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 19 Dec 2007 06:02:32 -0800 (PST)
From: Paul Lalli <mritty@gmail.com>
Subject: Re: regex question about ?, *, and $1
Message-Id: <46bdbca2-389d-40aa-89e9-2591aef890e5@c4g2000hsg.googlegroups.com>

On Dec 19, 5:54 am, vorticitywo...@gmail.com wrote:
> Alright, this is confusing me:
>
> $string = 2340Z 4SL -ABCD PS T1203045;
>
> if $string =~ m/(-|\+)*(AB|YZ)*(EF|CD)*\s??(PL|PS|PT)*?/g{
>      print $1,$2,$3,$4;
>
> }
>
> This works like I want it returns values for $1,$2,$3 and $4

I completely fail to believe you.

$ perl -le'
if ("2340Z 4SL -ABCD PS T1203045" =~ m/(-|\+)*(AB|YZ)*(EF|CD)*\s??(PL|
PS|PT)*?/g) {
  print qq{1: "$1", 2: "$2", 3: "$3", 4: "$4"};
}
'
1: "", 2: "", 3: "", 4: ""

This is perl, v5.8.8 built for cygwin-thread-multi-64int

Paul Lalli


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

Date: Wed, 19 Dec 2007 06:19:05 -0800 (PST)
From: vorticitywolfe@gmail.com
Subject: Re: regex question about ?, *, and $1
Message-Id: <502401da-97f2-4fe9-a1e6-f013778f0e21@s8g2000prg.googlegroups.com>

Ok,

After carefully checking again, it works if the "*?" at the end is
removed.  That is why it is confusing. I guess that wasn't clear.  I
don't understand why the "*?" makes it not return the values for
$1,$2, etc. If it is in there, it returns something, but the values
are blank or undefined. So that makes me think it is matching it...




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

Date: Wed, 19 Dec 2007 14:38:13 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: regex question about ?, *, and $1
Message-Id: <873aty4une.fsf@hacking.dk>

vorticitywolfe@gmail.com writes:

> After carefully checking again, it works if the "*?" at the end is
> removed.  That is why it is confusing. I guess that wasn't clear.  I
> don't understand why the "*?" makes it not return the values for
> $1,$2, etc. If it is in there, it returns something, but the values
> are blank or undefined. So that makes me think it is matching it...

Yes, because in you original you try to match Zero or more instances
of something, followed by zero or more instances of something else,
followed by zero or more instances of yet another thing, and so on.

So what happens is that perl starts at the beginning of you string and
says: Yes I got zero instances of (-|+), I got zero instances on
(AB|YZ), I got zero instances of (EF|CD), I got zero spaces and, finaly
I got zero instances of (PL|PS|PT). So I got a match.

Removing the ending '*?' makes perl actually looking for something
such that it doesn't match the empty substring at the beginning of you
string.

//Makholm


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

Date: Wed, 19 Dec 2007 06:44:44 -0800 (PST)
From: vorticitywolfe@gmail.com
Subject: Re: regex question about ?, *, and $1
Message-Id: <fdbcbecb-afbe-4d75-8259-4caa90291f68@b40g2000prf.googlegroups.com>

Thank you Makholm

That answered my question perfectly! THANKS!



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

Date: Wed, 19 Dec 2007 19:08:25 GMT
From: "Dan van Ginhoven" <danfan46@hotmail.com>
Subject: remove CR + trailing spaces
Message-Id: <J_daj.1847$R_4.1399@newsb.telia.net>

Hi!

I had some files on my Linux server containing  Dos/Win style CRLF and also
trailing spaces on most lines.

I ran this one-liner perl on them:
cat localfn | perl -p -e "s/\r//;s/\s*$//;" > tempname
To my surprise both CR and LF was removed and I ended up with a file with
just one long line.

When I changed the one-liner to
cat localfn | perl -p -e "s/\r//;s/\s*$/\n/;" > tempname
it came out OK.

What am I missing?
Can any point me to the appropriate  FAQ or man page please.


/dg




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

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


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