[25469] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7714 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 31 00:05:32 2005

Date: Sun, 30 Jan 2005 21:05:09 -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           Sun, 30 Jan 2005     Volume: 10 Number: 7714

Today's topics:
    Re: Error in command line <rs.pai@sbi.co.in>
        ldap server can not replace the order of login, why? (jiing)
    Re: ldap server can not replace the order of login, why <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: ldap server can not replace the order of login, why <spamtrap@dot-app.org>
        Perl equivalent for Unix ps. Prab_kar@hotmail.com
    Re: Perl equivalent for Unix ps. <jkeen_via_google@yahoo.com>
        Perl help for Menue driver interface <saleee@tds.net>
    Re: Perl help for Menue driver interface <jkeen_via_google@yahoo.com>
    Re: Perl loops should use break, not last <gargoyle@no.spam>
    Re: Perl loops should use break, not last <abigail@abigail.nl>
    Re: Perl loops should use break, not last <abigail@abigail.nl>
    Re: Perl loops should use break, not last (Anno Siegel)
    Re: Perl loops should use break, not last <ask@me.com>
    Re: Perl loops should use break, not last <spamtrap@dot-app.org>
    Re: Perl loops should use break, not last <No_4@dsl.pipex.com>
    Re: Perl loops should use break, not last <No_4@dsl.pipex.com>
    Re: Regular Expression Question on /i <nospam-abuse@ilyaz.org>
        Regular expression question <wolf_gore@yahoo.com.au>
    Re: Regular expression question <toreau@gmail.com>
    Re: Regular expression question <sbryce@scottbryce.com>
    Re: Regular expression question <noreply@gunnar.cc>
    Re: Regular expression question <noreply@gunnar.cc>
    Re: Regular expression question <sbryce@scottbryce.com>
    Re: Regular expression question <wolf_gore@yahoo.com.au>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 30 Jan 2005 20:05:12 -0800
From: "Rajendra" <rs.pai@sbi.co.in>
Subject: Re: Error in command line
Message-Id: <1107144312.097460.13910@z14g2000cwz.googlegroups.com>

Thanks a lot for all the help and clarifications. 

Rajendra



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

Date: 30 Jan 2005 18:46:22 -0800
From: jiing.deng@gmail.com (jiing)
Subject: ldap server can not replace the order of login, why?
Message-Id: <b7b95676.0501301846.55dc8d17@posting.google.com>

<?php
$ldapServer="ldap://192.168.1.211";
$ldapPort="389";
$ldapconn=ldap_connect($ldapServer,$ldapPort);
$ldaprdn="uid=root, ou=People, dc=aitc, dc=com, dc=tw";
$ldappass="abcd";

   if($ldapconn){
	    echo "connect to ".$ldapServer." successfully \n<br>";
   }else{
      echo "can't connect to LDAP server!\n<br>";
   }
   if ($ldapconn) {
      // binding to ldap server to give update access
      $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass);
      // verify binding
      if ($ldapbind) {
          echo "LDAP binding successful...\n";
      } else {
          echo "LDAP binding failed...\n";
      }
   }
   //data preparation
   //I am not very sure what attribute should be filled
   $data["uid"]="tester";
   $data["cn"]="Tester 1";
   $data["objectclass"][0]="account";
   $data["objectclass"][1]="posixAccount";
   $data["objectclass"][2]="top";
   $data["userpassword"]="tester";
   $data["loginshell"]="/usr/local/bin/bash";
   $data["uidnumber"]=3100;
   $data["gidnumber"]=3100;
   $data["homedirectory"]="/home/tester"; 
   $data["gecos"]="Tester 1";
  
   // Before ldap_add(), should check the user already exists or not
   if(!ldap_add($ldapconn,"uid=tester, ou=People, dc=aitc, dc=com,
dc=tw", $data)){
     echo "There is a problem to create the account\n";
     echo "Please contact your administrator!\n";
     exit;
    }else{
     echo "account creation successfully";
    }
   ldap_close($ldapconn);
?>

I used ldapbrowser to connect LDAP server(openldap), and I can see all
the user&#65292;but I can not Add Entry&#65292;but I can Delete Entry
Then I wrote the php code above to add a new user tester&#65288;the
$data fields are all the fields of LDAP, but some fields were filled
by me randomly&#65292;like uidnumber&#21644;gidnumber&#65289;, but if
I do not fill those fields, it will occurs the following warning
message

Warning: ldap_add(): Add: Object class violation in
d:\AppServ\www\LDAP_test1.ph
p on line 74
There is a problem to create the account
Please contact your administrator!

But I found the biggest problem is : my ldap server can not replace
the login order, i.e, I want to build accounts/passwords in openldap
server, then users can use the account/password in ldap server and
login freebsd server. But when I use the above php code to create a
tester account, the user "tester" still can not use tester/tester to
login freebsd host, why? Could you tell me.

Thanks in advanced.

-jiing-


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

Date: Sun, 30 Jan 2005 18:57:11 -0800
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: ldap server can not replace the order of login, why?
Message-Id: <ndj0d2x9fl.ln2@goaway.wombat.san-francisco.ca.us>

On 2005-01-31, jiing <jiing.deng@gmail.com> wrote:
><?php
   ^^^

Perhaps you meant to post your question to a PHP and/or LDAP
newsgroup (neither of which are on-topic for a Perl newsgroup)?

--keith

-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
see X- headers for PGP signature information



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

Date: Sun, 30 Jan 2005 22:02:57 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: ldap server can not replace the order of login, why?
Message-Id: <5q-dnaj1iMZ8AmDcRVn-hA@adelphia.com>

jiing wrote:

> <?php

This is a Perl group, not a PHP group.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 30 Jan 2005 15:45:26 -0800
From: Prab_kar@hotmail.com
Subject: Perl equivalent for Unix ps.
Message-Id: <1107128726.646910.156670@c13g2000cwb.googlegroups.com>

Hi all,
Is there any Perl function which works like the Unix ps command?
I've looked through the manuals for Perl functions and couldnt find
anything similar in nature.

I'm rewriting a Bourne shell script in Perl and the sh script uses the
ps from a lot of different places, /usr/bin/ps sometimes, /usr/ucb/ps
other times. I wanted to rewrite in Perl to get over that, and in all
the examples I see, the Perl scripts use /usr/bin/ps or /usr/ucb/ps in
backticks or from system("<PATH>/ps").

Is there anyway I can use Perl's internal functions to identify/monitor
the process and stop/kill them?
I realize there's Proc::ProcessTable .pm for this, but I want my
distribution to include just the Perl script and have it do it all.
I'm working on Solaris, Perl 5.6.

Thanks for your time,
Prabh



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

Date: Mon, 31 Jan 2005 01:24:30 GMT
From: Jim Keenan <jkeen_via_google@yahoo.com>
Subject: Re: Perl equivalent for Unix ps.
Message-Id: <iNfLd.496$ya6.160@trndny01>

Prab_kar@hotmail.com wrote:
> Hi all,
> Is there any Perl function which works like the Unix ps command?
> I've looked through the manuals for Perl functions and couldnt find
> anything similar in nature.
> 

See the discussion here (which, unfortunately, rains on your parade):

http://search.cpan.org/~nwclark/perl-5.8.6/lib/Shell.pm#Caveats

jimk






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

Date: Sun, 30 Jan 2005 17:52:28 -0600
From: "perl_beginner" <saleee@tds.net>
Subject: Perl help for Menue driver interface
Message-Id: <41fd7023_3@newspeer2.tds.net>

I used perl for CLI on Cisco routers and few T1 access equipments and that
worked great.

I am running into problem when I want to use Perl for Menu driven interface
(Not GUI).
Once, for example, I telnet in to a network card and gets menu as a result,
I can not read/select anything in that menu using Perl.

I need some help on how to resolve this.
I would appreciate it.

Thanks,
Perl_beginner




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

Date: Mon, 31 Jan 2005 01:26:37 GMT
From: Jim Keenan <jkeen_via_google@yahoo.com>
Subject: Re: Perl help for Menue driver interface
Message-Id: <hPfLd.497$ya6.473@trndny01>

perl_beginner wrote:
> I used perl for CLI on Cisco routers and few T1 access equipments and that
> worked great.
> 
> I am running into problem when I want to use Perl for Menu driven interface
> (Not GUI).
> Once, for example, I telnet in to a network card and gets menu as a result,
> I can not read/select anything in that menu using Perl.
> 
Can you show us the Perl code you have attempted so far?


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

Date: Sun, 30 Jan 2005 23:12:30 GMT
From: gargoyle <gargoyle@no.spam>
Subject: Re: Perl loops should use break, not last
Message-Id: <yRdLd.4086$qJ3.2781@bignews1.bellsouth.net>

On 2005-01-30, A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
>> I think that's fairly logical,
>
> That is because you have grown used to it.

I grew used to it because the C book told me that's how it works.  It's
true that's arbitrary, and they could have gone either way.

I think they chose the most convenient path though.  Makes it easy to
write simple one-line statments and omit braces.  Stuff like that comes
up all the time in my code, but in Perl I'm bound to the { and } keys.
Ouch, did you hear my pinky scream out in pain?  It's in agony from all
those keypresses. ;-)

> But there is a language that depends on indentation to figure out what's 
> going on. It is Python.

I do not wish to convert to a bondage/S&M language. ;-)
  
> But your coding preferences are not at issue here.

I know it's about language design and all that.  So I'll not critisize
Larry's decision, whatever he goes with is probably for the best.


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

Date: 30 Jan 2005 23:21:40 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Perl loops should use break, not last
Message-Id: <slrncvqr04.a9.abigail@alexandra.abigail.nl>

gargoyle (gargoyle@no.spam) wrote on MMMMCLXX September MCMXCIII in
<URL:news:oDdLd.4059$qJ3.3242@bignews1.bellsouth.net>:
$$  On 2005-01-30, Abigail <abigail@abigail.nl> wrote:
$$ > elsif? elsif? In C? I don't think so.
$$  
$$  Well it's got 'else if' which is the same thing, no?
$$  But anyway that's all academic.  I was talking Perl code (that's why
$$  the vars have a $ in front of them :-}), and how sometimes a ?: can
$$  be used to omit braces.  Because the if/elsif/else don't work w/o them.


Well, you are the one comparing C to Perl, and saying how wonderful
C is that you can save two character strokes by, in some cases, omitting
the braces (well, it's really 1 character, because in Perl, you can
leave off the comma of the last statement in a block).

I'm just pointing out that your wonderful C doesn't have 'elsif'.



Abigail
-- 
#!/opt/perl/bin/perl -w
$\ = $"; $SIG {TERM} = sub {print and exit};
kill 15 => fork for qw /Just another Perl Hacker/;


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

Date: 30 Jan 2005 23:25:10 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Perl loops should use break, not last
Message-Id: <slrncvqr6m.a9.abigail@alexandra.abigail.nl>

gargoyle (gargoyle@no.spam) wrote on MMMMCLXX September MCMXCIII in
<URL:news:yRdLd.4086$qJ3.2781@bignews1.bellsouth.net>:
//  On 2005-01-30, A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
// >> I think that's fairly logical,
// >
// > That is because you have grown used to it.
//  
//  I grew used to it because the C book told me that's how it works.  It's
//  true that's arbitrary, and they could have gone either way.
//  
//  I think they chose the most convenient path though.  Makes it easy to
//  write simple one-line statments and omit braces.  Stuff like that comes
//  up all the time in my code, but in Perl I'm bound to the { and } keys.
//  Ouch, did you hear my pinky scream out in pain?  It's in agony from all
//  those keypresses. ;-)

If you want one-line statements, write:

    foo () if cond;

which not only saves you typing the braces, but also the parenthesis.

Or write it as:

    cond and foo ();

No braces either.

Furthermore, Perl saves your pinky as well, because it allows you to
omit some semi-colons.



Abigail
-- 
print v74.117.115.116.32, v97.110.111.116.104.101.114.32,
      v80.101.114.108.32, v72.97.99.107.101.114.10;


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

Date: 30 Jan 2005 23:40:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl loops should use break, not last
Message-Id: <ctjr8m$pr2$1@mamenchi.zrz.TU-Berlin.DE>

Abigail  <abigail@abigail.nl> wrote in comp.lang.perl.misc:
> Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMMCLXX
> September MCMXCIII in <URL:news:ctjbm6$h4n$2@mamenchi.zrz.TU-Berlin.DE>:
> ??  
> ??  Early compiler designs (Pascal, C, Algol) tended to ignore this ambiguity.
> ??  Later ones (Modula2, Perl, not sure about Algol68) decided to enforce
> ??  delimiters for this very reason.  That was progress, there's no reason
> ??  to go back behind it.
> 
> 
> Algol 68 didn't use delimiters around then/else blocks. Algol 68 uses
> if ... then ... else ... fi which solves the problem in a different way.

Oh, right, thanks for reminding me.

            od;
        fi;
    fi;

Maybe that's why the language never took off :)

It does show that the designers of Algol68, unlike those of Algol60, were
concerned about the ambiguity.

Anno


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

Date: Mon, 31 Jan 2005 00:14:21 -0000
From: "Jeremy Morton" <ask@me.com>
Subject: Re: Perl loops should use break, not last
Message-Id: <41fd785d$0$4566$fa0fcedb@news.zen.co.uk>

"Abigail" <abigail@abigail.nl> wrote in message 
news:slrncvqo37.a9.abigail@alexandra.abigail.nl...
> Jeremy Morton (ask@me.com) wrote on MMMMCLXX September MCMXCIII in
> <URL:news:41fd39a4$0$26027$fa0fcedb@news.zen.co.uk>:
> %%
> %% > One of the reasons 'last' isn't called 'break' is that 'last' isn't
> %% > the same as 'break'. 'break' breaks the current loop - while 'last'
> %% > takes an optional argument, indicating the top level loop that will
> %% > be exited.
> %%
> %%  Hang on, are you saying 'break' has a meaning in Perl?
>
> No, I did not.
>

The what did you mean when you said 'last' isn't the same as break?  AFAICT, 
Perl's 'last' is identical to C and other languages's 'break', assuming that 
break can take an optional argument specifying which level of block to break 
out of (which often, it can).


-- 
Best regards,
Jeremy Morton (Jez) 




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

Date: Sun, 30 Jan 2005 19:27:21 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Perl loops should use break, not last
Message-Id: <kuidnUq5_pr35mDcRVn-gA@adelphia.com>

Jeremy Morton wrote:

> The what did you mean when you said 'last' isn't the same as break? 

Perl's "last" isn't the same as C's "break".

> AFAICT, Perl's 'last' is identical to C and other languages's 'break',
> assuming that break can take an optional argument specifying which level
> of block to break out of (which often, it can).

No, it can't. Not according to the C99 standard, and not with any compiler
I'm familiar with.

Frankly, I don't understand what you're hoping to accomplish with this
debate anyway. Do you honestly think that the fundamental syntax of the
language is subject to change at this point? It's not, which renders the
argument moot. It no longer matters what it "should" have been - it is what
it is.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Mon, 31 Jan 2005 02:12:22 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: Perl loops should use break, not last
Message-Id: <95-dnXPOIPaZCWDcRVnysg@pipex.net>

Jeremy Morton wrote:
> 
> The what did you mean when you said 'last' isn't the same as break?  AFAICT, 
> Perl's 'last' is identical to C and other languages's 'break'  assuming that
> break can take an optional argument specifying which level of block to break 
> out of (which often, it can).

    But it can't in C, so it's not identical to that.

FWIW:  (straining my memory here) Prime has a system language (SPL) that 
was PL/1 based, and it had a last statement which *was identical* to Perl's 
(ie: it allowed you to say for which block this was the last statement).



-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


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

Date: Mon, 31 Jan 2005 02:32:54 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: Perl loops should use break, not last
Message-Id: <ItGdnVgQ3cRJBWDcRVnyiQ@pipex.net>

Big and Blue wrote:
> 
> FWIW:  (straining my memory here) Prime has a system language (SPL) that 
> was PL/1 based, and it had a last statement which *was identical* to 
> Perl's (ie: it allowed you to say for which block this was the last 
> statement).

    Retracting this (a brain cell has come back to life).  It actually had 
a "leave" statement rather than a "last".  What it didn't have, though, was 
a "break".

-- 
              Just because I've written it doesn't mean that
                   either you or I have to believe it.


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

Date: Mon, 31 Jan 2005 00:55:31 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Regular Expression Question on /i
Message-Id: <ctjvm3$1tml$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de>], who wrote in article <ctjj64$l7p$2@mamenchi.zrz.TU-Berlin.DE>:
> > It is unfortunate, that some of modifiers are actually parts of a REx,
> > while the others are part of the OP which uses the REx, but this is a
> > legacy design...

> I know better than to accuse you of making no sense, but please, in what
> *sense* are they part of the regex?  Textually they aren't.  That is what
> the user sees.

Assume that separation into "the REx" and "the operator which uses the
REx" makes some sense (one could say: it is just a script, and I do not
care what happens inside this script; it would be hard to discuss this
topic with such a person, right?  And in some situations this point of
view is very productive...).  

If we draw the separation line according to implementation, then the
modifiers 's', 'm', 'i', 'x' modify the match REx, while other
modifiers modify the operator which will do the match.  Of course,
infinitely many other ways to pass this line may be chosen; however,
one I choose is the only one which has some pseudo-objective ground.  ;-)

If you think so straight as you pretend ;-), try to spell out where
this 'm' belongs to in this example:

  print for split m(foo), qw(bar), -1;

Yours,
Ilya


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

Date: 30 Jan 2005 17:26:26 -0800
From: "ChocMonk" <wolf_gore@yahoo.com.au>
Subject: Regular expression question
Message-Id: <1107134786.568869.189540@f14g2000cwb.googlegroups.com>

Hello,
I have an array with contents as below (from a VB project file):
my @objs= ("Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0;
mscomctl.ocx\n",
"Object={31B58EFA-5E2E-4651-9454-2227ABB82B62}#6.7#0;
GridControls.ocx\n",
"Object={B9AA5EAF-A9B4-11D5-96CA-0010A4B15184}#1.0#0;
CompanyLogo.ocx\n",
"Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0; tabctl32.ocx\n",
"Object={CA8A9783-280D-11CF-A24D-444553540000}#1.3#0; pdf.ocx\n",
"Object={64EE12AF-3495-45BC-AC02-43C29DF43376}#9.1#0;
StandardControls.ocx\n",
"Object={86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0; mscomct2.ocx\n");

I populated the array from parsing a file with the following regexp:
my @objs = grep(/^Object=\{\w|\-*\}#\d+\.\d+#\d?; .+/,@str);

Now I'm cycling through the array trying to split it up such that for
the first string in the example above I get the following values:
my $crap = "Object="
my $guid ="{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}"
my $ver = "2.0"
my $rev = "0"
my $name = "mscomctl.ocx\n"

I tried the following which doesn't work:
for (@objs) {
chomp;
(my $crap, my $guid, my $ver, my $rev, my $name) =
/(^Object=)(\{\w|\-*\})#(\d+\.\d+)#(\d?); (.+)/;
}

WHat am I doing wrong? I thought clustering the subexpressions will
capture what I want..

Thanks!
Choc



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

Date: Mon, 31 Jan 2005 02:52:52 +0100
From: Tore Aursand <toreau@gmail.com>
Subject: Re: Regular expression question
Message-Id: <PbgLd.6736$IW4.143903@news2.e.nsc.no>

ChocMonk wrote:
> I have an array with contents as below (from a VB project file):
> my @objs= ("Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0;
> mscomctl.ocx\n",
> "Object={31B58EFA-5E2E-4651-9454-2227ABB82B62}#6.7#0;
> GridControls.ocx\n",
> "Object={B9AA5EAF-A9B4-11D5-96CA-0010A4B15184}#1.0#0;
> CompanyLogo.ocx\n",
> "Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0; tabctl32.ocx\n",
> "Object={CA8A9783-280D-11CF-A24D-444553540000}#1.3#0; pdf.ocx\n",
> "Object={64EE12AF-3495-45BC-AC02-43C29DF43376}#9.1#0;
> StandardControls.ocx\n",
> "Object={86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0; mscomct2.ocx\n");
> 
> I populated the array from parsing a file with the following regexp:
> my @objs = grep(/^Object=\{\w|\-*\}#\d+\.\d+#\d?; .+/,@str);
> 
> Now I'm cycling through the array trying to split it up such that for
> the first string in the example above I get the following values:
> my $crap = "Object="
> my $guid ="{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}"
> my $ver = "2.0"
> my $rev = "0"
> my $name = "mscomctl.ocx\n"
> 
> I tried the following which doesn't work:
> for (@objs) {
> chomp;
> (my $crap, my $guid, my $ver, my $rev, my $name) =
> /(^Object=)(\{\w|\-*\})#(\d+\.\d+)#(\d?); (.+)/;
> }
> 
> WHat am I doing wrong? I thought clustering the subexpressions will
> capture what I want..

No need to make it harder than it really is, I guess;

while ( <DATA> ) {
     chomp;
     if ( m,^(Object=)({.+})#(.+)#(.+); (.+), ) {
         print "$1\n$2\n$3\n$4\n$5\n\n";
     }
}

__DATA__
Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0; mscomctl.ocx
Object={31B58EFA-5E2E-4651-9454-2227ABB82B62}#6.7#0; GridControls.ocx
Object={B9AA5EAF-A9B4-11D5-96CA-0010A4B15184}#1.0#0; CompanyLogo.ocx
Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0; tabctl32.ocx
Object={CA8A9783-280D-11CF-A24D-444553540000}#1.3#0; pdf.ocx
Object={64EE12AF-3495-45BC-AC02-43C29DF43376}#9.1#0; StandardControls.ocx
Object={86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0; mscomct2.ocx


-- 
Tore Aursand <tore@aursand.no>
"Writing is a lot like sex. At first you do it because you like it.
  Then you find yourself doing it for a few close friends and people you
  like. But if you're any good at all, you end up doing it for money."
  (Unknown)


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

Date: Sun, 30 Jan 2005 18:58:12 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Regular expression question
Message-Id: <a_-dnfpPC44LDWDcRVn-oA@comcast.com>

ChocMonk wrote:

> I have an array with contents as below

<Array snipped>

> Now I'm cycling through the array trying to split it up such that for
> the first string in the example above I get the following values:
> my $crap = "Object="
> my $guid ="{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}"
> my $ver = "2.0"
> my $rev = "0"
> my $name = "mscomctl.ocx\n"
> 
> I tried the following which doesn't work:
> for (@objs) {
> chomp;
> (my $crap, my $guid, my $ver, my $rev, my $name) =
> /(^Object=)(\{\w|\-*\})#(\d+\.\d+)#(\d?); (.+)/;
> }

Regex matching returns true or false. It does not return a list of items 
matched.

You should try splitting the data. The code below assumes that $crap is 
really crap, that is, you don't intend to keep it. If you intend to keep 
it, you could easily append the '=' back on to it.

use strict;
use warnings;

my @objs= 
("Object={831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0;mscomctl.ocx\n",
"Object={31B58EFA-5E2E-4651-9454-2227ABB82B62}#6.7#0;GridControls.ocx\n",
"Object={B9AA5EAF-A9B4-11D5-96CA-0010A4B15184}#1.0#0;CompanyLogo.ocx\n",
"Object={BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0; tabctl32.ocx\n",
"Object={CA8A9783-280D-11CF-A24D-444553540000}#1.3#0; pdf.ocx\n",
"Object={64EE12AF-3495-45BC-AC02-43C29DF43376}#9.1#0;StandardControls.ocx\n",
"Object={86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0; mscomct2.ocx\n");

for (@objs)
{
	chomp;	
	my ($crap, $guid, $ver, $rev, $name) = split /[=#;] ?/;
	
	print "crap = $crap\n";
	print "guid = $guid\n";
	print "ver  = $ver\n";
	print "rev  = $rev\n";
	print "name = $name\n\n";
}



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

Date: Mon, 31 Jan 2005 02:53:34 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regular expression question
Message-Id: <365hv4F4ukbq4U1@individual.net>

ChocMonk wrote:
> 
> /(^Object=)(\{\w|\-*\})#(\d+\.\d+)#(\d?); (.+)/;

You need grouping to limit the effect of the alternation character.

     /(^Object=)(\{(?:\w|\-)*\})#(\d+\.\d+)#(\d?); (.+)/;
------------------^^^-----^

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


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

Date: Mon, 31 Jan 2005 02:57:13 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regular expression question
Message-Id: <365i60F4rqvevU1@individual.net>

Scott Bryce wrote:
> ChocMonk wrote:
>> 
>> for (@objs) {
>> chomp;
>> (my $crap, my $guid, my $ver, my $rev, my $name) =
>> /(^Object=)(\{\w|\-*\})#(\d+\.\d+)#(\d?); (.+)/;
>> }
> 
> Regex matching returns true or false.

Yes, in scalar context.

> It does not return a list of items matched.

Of course it does, if evaluated in list context (as in the example above).

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


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

Date: Sun, 30 Jan 2005 19:27:50 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Regular expression question
Message-Id: <bd-dnfBJRpEVCmDcRVn-3Q@comcast.com>

Gunnar Hjalmarsson wrote:

> Scott Bryce wrote:
>> It does not return a list of items matched.
> 
> Of course it does, if evaluated in list context (as in the example above).

I stand corrected.



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

Date: 30 Jan 2005 19:32:36 -0800
From: "ChocMonk" <wolf_gore@yahoo.com.au>
Subject: Re: Regular expression question
Message-Id: <1107142356.760601.46050@f14g2000cwb.googlegroups.com>

Man, regexps always catch me out, no matter how much I practice them,
especially ones with spaces or multiline strings.
Ah well, thanks a lot, people.



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

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 V10 Issue 7714
***************************************


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