[25168] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7417 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 18 06:13:06 2004

Date: Thu, 18 Nov 2004 03:05:08 -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           Thu, 18 Nov 2004     Volume: 10 Number: 7417

Today's topics:
        Active Directory login User (Armando)
    Re: Active Directory login User (replace z with h, spam protection)
    Re: Active Directory login User <wyzelli@yahoo.com>
    Re: Active Directory login User <ThomasKratz@REMOVEwebCAPS.de>
    Re: Adding a unique user name in a file <jurgenex@hotmail.com>
    Re: Adding a unique user name in a file <josef.moellers@fujitsu-siemens.com>
    Re: Adding a unique user name in a file <sam.wun@authtec.net>
    Re: Adding a unique user name in a file <josef.moellers@fujitsu-siemens.com>
    Re: Advice needed: threads and queues <vetler@gmail.com>
    Re: Array of Hashes ? <wyzelli@yahoo.com>
        authenticate a password (webmin) <jack@swamc.com>
    Re: croak conventions in methods? <tadmc@augustmail.com>
    Re: croak conventions in methods? <postmaster@castleamber.com>
        die and write to log file (justme)
    Re: Extract domain name <sam.wun@authtec.net>
        FAQ 8.14: How do I modify the shadow password file on a <comdog@panix.com>
    Re: First Perl Program (Michele Dondi)
    Re: First Perl Program <zen13097@zen.co.uk>
    Re: Help! Complex Pattern Extraction with Key/Value Pai <do-not-use@invalid.net>
    Re: Help! Complex Pattern Extraction with Key/Value Pai <uri@stemsystems.com>
    Re: hi,something about thread in perl <sam.wun@authtec.net>
    Re: How to get sytem/hardware information? (Akhila)
        newbie-ish question (Jack)
        script hangs waiting for key stroke (chris)
    Re: search.cgi <tadmc@augustmail.com>
    Re: search.cgi <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 17 Nov 2004 22:23:02 -0800
From: armando_torres_@msn.com (Armando)
Subject: Active Directory login User
Message-Id: <1022c506.0411172223.4aef11bd@posting.google.com>

Can someone help me with this problem.
Is there a way that I can find with Perl on what Windows machine a
Domain user account is logged in?


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

Date: Thu, 18 Nov 2004 08:51:00 +0100
From: "D. Marxsen" <detlef.marxsen@tdds-gmbz.de (replace z with h, spam protection)>
Subject: Re: Active Directory login User
Message-Id: <cnhnpm$kqh$1@news1.transmedia.de>

"Armando" <armando_torres_@msn.com> schrieb im Newsbeitrag
news:1022c506.0411172223.4aef11bd@posting.google.com...
> Is there a way that I can find with Perl on what Windows machine a
> Domain user account is logged in?

Sorry, I don't know much about WinDoze administrator stuff (what's the
difference between a user and a domain user?). Anyhow, try:

printf("Computer: %s\n",$ENV{'COMPUTERNAME'});


Cheers,
Detlef.


--
D. Marxsen, TD&DS GmbH
detlef.marxsen@tdds-gmbz.de (replace z with h, spam protection)




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

Date: Thu, 18 Nov 2004 09:31:13 GMT
From: "Peter Wyzl" <wyzelli@yahoo.com>
Subject: Re: Active Directory login User
Message-Id: <BZZmd.40263$K7.34241@news-server.bigpond.net.au>

"D. Marxsen" <detlef.marxsen@tdds-gmbz.de (replace z with h, spam 
protection)> wrote in message news:cnhnpm$kqh$1@news1.transmedia.de...
> "Armando" <armando_torres_@msn.com> schrieb im Newsbeitrag
> news:1022c506.0411172223.4aef11bd@posting.google.com...
>> Is there a way that I can find with Perl on what Windows machine a
>> Domain user account is logged in?
>
> Sorry, I don't know much about WinDoze administrator stuff (what's the
> difference between a user and a domain user?). Anyhow, try:
>
> printf("Computer: %s\n",$ENV{'COMPUTERNAME'});

Which happily prints the local host name...

try $ENV{'USERDOMAIN'} and $ENV{'USERNAME'},  They contain what you are 
asking for.

-- 
Wyzelli
print "I don't know\n"; 




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

Date: Thu, 18 Nov 2004 11:38:37 +0100
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: Active Directory login User
Message-Id: <419c7bac$0$17095$bb690d87@news.main-rheiner.de>

Armando wrote:
> Can someone help me with this problem.
> Is there a way that I can find with Perl on what Windows machine a
> Domain user account is logged in?

There are two principle ways depending on your setup.
If you are still using Netbios over TCPIP, the old Lanmanager calls will 
work and you will be able to use Win32::Lanman.

First get a list of computers with Win32::Lanman::NetServerEnum.
Either loop over all domain controllers and look at the output of 
Win32::Lanman::NetSessionEnum or loop over all workstations and get the 
logged on users with Win32::Lanman::NetWkstaUserEnum.
For details read the docs that come with the module.

Without the Lanmanager protocol you have to rely on the WMI and ADSI 
interfaces that you can use with Win32::OLE (See the Microsoft docs 
available on their website. But don't expect an easy solution. The classes 
are a real mess, I have never seen something uglier, ... oh wait yes I do: 
the Win32 API could win the competition).
Google for examples how to use WMI with perl. There should be at least 3 
threads from the last 2 months.

Thomas

-- 
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-


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

Date: Thu, 18 Nov 2004 06:14:39 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Adding a unique user name in a file
Message-Id: <j5Xmd.6408$J55.3567@trnddc06>

sam wrote:
> Is there any perl module I can use to read in a list of user names
> from a file and do a binary search on the list base on the user name,
> if the user name is not found, add this user name to the file?

You don't need a module for this. It's probably 15-20 lines of code only.

Also, why do a binary search? If you read the user names into a hash then 
you get an O(1) access instead of a O(log(n)) as with a binary search.

jue 




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

Date: Thu, 18 Nov 2004 08:50:46 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Adding a unique user name in a file
Message-Id: <cnhk46$srg$1@nntp.fujitsu-siemens.com>

J=FCrgen Exner wrote:
> sam wrote:
>=20
>>Is there any perl module I can use to read in a list of user names
>>from a file and do a binary search on the list base on the user name,
>>if the user name is not found, add this user name to the file?
>=20
>=20
> You don't need a module for this. It's probably 15-20 lines of code onl=
y.
>=20
> Also, why do a binary search? If you read the user names into a hash th=
en=20
> you get an O(1) access instead of a O(log(n)) as with a binary search.

Why the repeated reference to a hash? If I was given a user name to look =

up in a file, I'd step through the file entry-by-entry. If I find the=20
user, I'll process his entry, close the file and be done with it. If I=20
didn't find him/her, I'll have reached the end of file and, given the=20
proper open mode, append a record for the (new) user. No hash, no fancy=20
legwork, just plain coding.

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Thu, 18 Nov 2004 16:04:22 +0800
From: sam <sam.wun@authtec.net>
Subject: Re: Adding a unique user name in a file
Message-Id: <cnhmjl$a14$1@news.hgc.com.hk>

Josef Moellers wrote:

> Jürgen Exner wrote:
> 
>> sam wrote:
>>
>>> Is there any perl module I can use to read in a list of user names
>>> from a file and do a binary search on the list base on the user name,
>>> if the user name is not found, add this user name to the file?
>>
>>
>>
>> You don't need a module for this. It's probably 15-20 lines of code only.
>>
>> Also, why do a binary search? If you read the user names into a hash 
>> then you get an O(1) access instead of a O(log(n)) as with a binary 
>> search.
> 
> 
> Why the repeated reference to a hash? If I was given a user name to look 
> up in a file, I'd step through the file entry-by-entry. If I find the 
> user, I'll process his entry, close the file and be done with it. If I 
> didn't find him/her, I'll have reached the end of file and, given the 
> proper open mode, append a record for the (new) user. No hash, no fancy 
> legwork, just plain coding.
> 
Right, this is for small number of users.
To deal with large number of users, one would need to load all user 
records into memory when the system/server start up, and use hash/tree 
to speed up the search rather than using linear search.

Sam.


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

Date: Thu, 18 Nov 2004 09:22:54 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Adding a unique user name in a file
Message-Id: <cnhm06$7r2$1@nntp.fujitsu-siemens.com>

sam wrote:
> Josef Moellers wrote:
>=20
>> J=FCrgen Exner wrote:
>>
>>> sam wrote:
>>>
>>>> Is there any perl module I can use to read in a list of user names
>>>> from a file and do a binary search on the list base on the user name=
,
>>>> if the user name is not found, add this user name to the file?
>>>
>>>
>>>
>>>
>>> You don't need a module for this. It's probably 15-20 lines of code=20
>>> only.
>>>
>>> Also, why do a binary search? If you read the user names into a hash =

>>> then you get an O(1) access instead of a O(log(n)) as with a binary=20
>>> search.
>>
>>
>>
>> Why the repeated reference to a hash? If I was given a user name to=20
>> look up in a file, I'd step through the file entry-by-entry. If I find=
=20
>> the user, I'll process his entry, close the file and be done with it. =

>> If I didn't find him/her, I'll have reached the end of file and, given=
=20
>> the proper open mode, append a record for the (new) user. No hash, no =

>> fancy legwork, just plain coding.
>>
> Right, this is for small number of users.
> To deal with large number of users, one would need to load all user=20
> records into memory when the system/server start up, and use hash/tree =

> to speed up the search rather than using linear search.

You asked to "search on the list base on _the_user_name_", so I deduced=20
that you were having a go at the database with a single user name (e.g.=20
when adding a user to a system). If you need to batch-process several=20
user names in one go, then, obviously, a hash would be a suitable data=20
structure.

The size of the database would also play a role: loading a huge database =

into memory would require a lot of memory (which is cheap these days),=20
reading one record at a time would not, so that would involve a=20
classical time/space-tradeoff.

The next step, then, would be to consider converting your list of user=20
names into a database (eg using the DBM modules) and then working on=20
that rather than the more unstructured list of names.
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Thu, 18 Nov 2004 09:44:16 +0100
From: "Vetle Roeim" <vetler@gmail.com>
Subject: Re: Advice needed: threads and queues
Message-Id: <opshnjv2vpx7nu7z@quickfix.opera.com>

On Wed, 17 Nov 2004 18:37:35 -0600, Swartz <swartz@inbox.ru> wrote:

> Hi.
>
> From: "Vetle Roeim"
>  [...]
>
>> >
>> >         if ($song{$song_num}{locked}) {
>>
>>    Your hash contains strings, so what do you expect this to do?
> Forgive my ignorance, but so does Ben's (although its hash of hashes that
> contain strings)...

   The difference between Bens hash and yours is important. As you say; his  
hash contains hashes, while your hash contain strings.

   With your hash, $song{$song_num}{locked} won't work, because strings  
can't be addressed as hashes. With Bens hash, $song{$song_num}{locked}  
accesses the hash in the $song hash.

   If you had turned on strict ('use strict'), your script would have  
generated an error saying that you can't use strings as hash references.


> Now what do YOU expect this to do?

   I expect it not to work as you intended. Try this, for an example:

     my %hash = ( foo => 'bar' );
     $hash{foo}{locked} = 1;

     use Data::Dumper;
     print Dumper \%hash;

   As you can see by the output, the hash is not changed. If the hash is  
changed to contain hashes, it works more or less as intended:

     my %hash = ( foo => {'bar'} );
     $hash{foo}{locked} = 1;

     use Data::Dumper;
     print Dumper \%hash;


[...]
-- 
It's not a bug, it's the future.


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

Date: Thu, 18 Nov 2004 06:16:52 GMT
From: "Peter Wyzl" <wyzelli@yahoo.com>
Subject: Re: Array of Hashes ?
Message-Id: <o7Xmd.40060$K7.1953@news-server.bigpond.net.au>

"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message 
news:Xns95A47DA443544asu1cornelledu@132.236.56.8...
> sudhirx@gmail.com (Tom) wrote in
> news:f50c52fa.0411170859.ed4643f@posting.google.com:
>
>> Well, I am a beginner as far as perl is concerned.
>> Can some one point me that 'm doing is correct.
>> I have pasted below my hash and array using Data::Dumper()
>>
>> I am pushing Hash1, Hash2 in to an Array
>
> comp.lang.perl.mindreadres is down the hall to your right.
>
>> I don't see => when 'm priting the Array using Data::Dumper()
>
> Have you read
>
> perldoc perldsc

Actually, that reminds me.  It's probably time that doc got updated.  My 
copy (Perl 5.8.3) was written in 1996 and makes assertions about inability 
to write complex data representations to disk which have been well fixed by 
Storable.

Who would handle that?

-- 
Wyzelli
print "oh how nice\n"; 




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

Date: Thu, 18 Nov 2004 15:22:13 +0800
From: Jack <jack@swamc.com>
Subject: authenticate a password (webmin)
Message-Id: <cnhk4j$8of$1@news.hgc.com.hk>

Hi,

After have looked into the login code in webmin, I don't understand its 
password authentication in the session_login.cgi file.

The session_login.cgi file written with the following codes:

print "$text{'session_prefix'}\n";
print "<form action=$gconfig{'webprefix'}/session_login.cgi
method=post>\n";
				^^^^^^^^^^^^^^^^^^^^^^^^^^^
print "<input type=hidden name=page 
value='".&html_escape($in{'page'})."'>\n";
print "<table border width=40%>\n";
print "<tr $tb> <td><b>$text{'session_header'}</b></td> </tr>\n";
print "<tr $cb> <td align=center><table cellpadding=3>\n";
if ($gconfig{'realname'}) {
         $host = &get_system_hostname();
         }
else {
         $host = $ENV{'HTTP_HOST'};
         $host =~ s/:\d+//g;
         $host = &html_escape($host);
         }
print "<tr> <td colspan=2 align=center>",
       &text($gconfig{'nohostname'} ? 'session_mesg2' :
             $gconfig{'usermin'} ? 'session_mesg3' : 'session_mesg',
             "<tt>$host</tt>"),"</td> </tr>\n";
print "<tr> <td><b>$text{'session_user'}</b></td>\n";
print "<td><input name=user size=20 
value='".&html_escape($in{'failed'})."'></td> </tr>\n";
print "<tr> <td><b>$text{'session_pass'}</b></td>\n";
print "<td><input name=pass size=20 type=password></td> </tr>\n";
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
print "<tr> <td colspan=2 align=center><input type=submit 
value='$text{'session_login'}'>\n";

================ end of attachement =================

The password is submitted to the session_login.cgi file, but there is no 
perl code in the session_login.cgi file validate the password.

Does anyone know how does session_login.cgi in webmin validate the password?

I need to change the login module in webmin so that it has an option 
allow to enter Cyrus user name and password as well when creating new 
user. When this admin user login, it also login Cyrus admin server and 
somehow pass the reference of cyrus to another cyrus module, from there, 
the admin user can also manage email user accounts as well.

Thanks
Sam


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

Date: Wed, 17 Nov 2004 19:27:34 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: croak conventions in methods?
Message-Id: <slrncpnuk6.26n.tadmc@magna.augustmail.com>

John Bokma <postmaster@castleamber.com> wrote:

> @_ == x or croak 'usage $bla->bla( ... )';
> 
> Is there a style guide for the ... part, ie, 


> Anyone?


There is no Perl content in your question you know...


Found this:

   http://support.packeteer.com/documentation/packetguide/current/info/cli-conventions.htm

on the 1st page of results from  googling for "usage conventions".


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


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

Date: 18 Nov 2004 06:13:56 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: croak conventions in methods?
Message-Id: <Xns95A525CCD32Ccastleamber@130.133.1.4>

Tad McClellan wrote:

> John Bokma <postmaster@castleamber.com> wrote:
> 
>> @_ == x or croak 'usage $bla->bla( ... )';
>> 
>> Is there a style guide for the ... part, ie, 
> 
> 
>> Anyone?
> 
> 
> There is no Perl content in your question you know...

Have a coffee first next time :-D

> Found this:
> 
>    http://support.packeteer.com/documentation/packetguide/current/info
/
>    cli-conventions.htm 
> 
> on the 1st page of results from  googling for "usage conventions".

If I grep on 'usage: in C:\Perl I get 169 occurences.

e.g
:
lib\Net\NNTP.pm(228): @_ == 1 or croak 'usage: $nntp->help()';
lib\Net\NNTP.pm(238): @_ >= 2 or croak 'usage: $nntp->ihave( MESSAGE-ID
[, MESSAGE ])'; 
:

Does it now ring a bell or two?

I clearly stated in the subject: *croak* in *METHODS*
Where on Earth did you get that CLI idea from?

I mean, the part in the croak (the code I gave) was also a giveaway, or
did you think $bla-> is my CLI prompt? 

Reread before you post.

Back to my original question, is there a convention of specifying
parameters, especial optional parameters in a croak 'usage: ' in a
method. 

In for example:

sub send {
    @_ >= 2 && @_ <= 4
        or croak 'usage: $sock->send(BUF, [FLAGS, [TO]])';
    my $sock  = $_[0];
    my $flags = $_[2] || 0;
    my $peer  = $_[3] || $sock->peername;
:

sub recv {
    @_ == 3 || @_ == 4
        or croak 'usage: $sock->recv(BUF, LEN [, FLAGS])';
    my $sock  = $_[0];
    my $len   = $_[2];
    my $flags = $_[3] || 0;


(from IO::Socket)

the notation is inconsistent and confusing.

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: 18 Nov 2004 02:08:24 -0800
From: eight02645999@yahoo.com (justme)
Subject: die and write to log file
Message-Id: <c0837966.0411180208.69ca8ac1@posting.google.com>

hi

usually when opening a file, we should check whether it can be opened
open(FILE,"textfile.txt") or die "Cannot open for reading:$!\n";

how can i also pipe a error message to a log file ? Something like "tee" ?

thanks...


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

Date: Thu, 18 Nov 2004 15:40:27 +0800
From: sam <sam.wun@authtec.net>
Subject: Re: Extract domain name
Message-Id: <cnhl6q$9c7$1@news.hgc.com.hk>

Shabam wrote:

>>The problem is not well defined.
>>
>>For "http://www.tacp.toshiba.com/" do you want "tacp.toshiba.com" or just
>>"toshiba.com"?  For "http://story.news.yahoo.com", is "news" included or
> 
> not?
> 
>>You can't just use the last two components in all cases, such as
>>"http://www.toyota.co.jp" or "http://www.bbc.co.uk".
> 
> 
> What I would need is just the domain name part.  In this case it would be
> "toshiba.com" only.  No subdomains.  My domains will be simple
> (com/net/org), so complicated situations like "toyota.co.jp" wouldn't apply.
> 
> 
I m not an expert, but the following regex will apply:

$url = "http://www.abc.xyz.toy-0-ota.com";
($domain) = ($url =~ /http:\/\/.*\.([0-9a-zA-Z\-]+\.com|net|org)/);
print $domain . "\n";

Sam


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

Date: Thu, 18 Nov 2004 11:03:03 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 8.14: How do I modify the shadow password file on a Unix system?
Message-Id: <cnhvh7$d11$1@reader1.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

8.14: How do I modify the shadow password file on a Unix system?

    If perl was installed correctly and your shadow library was written
    properly, the getpw*() functions described in perlfunc should in theory
    provide (read-only) access to entries in the shadow password file. To
    change the file, make a new shadow password file (the format varies from
    system to system--see passwd for specifics) and use pwd_mkdb(8) to
    install it (see pwd_mkdb for more details).



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: 18 Nov 2004 01:40:40 -0800
From: bik.mido@gmail.com (Michele Dondi)
Subject: Re: First Perl Program
Message-Id: <bdabe82.0411180140.33b0759c@posting.google.com>

"J. Gleixner" <glex_nospam@qwest.invalid> wrote in message news:<2aLmd.9$ul1.35476@news.uswest.net>...

> my @parts = (split( ',', $_ ))[1..3];

  my @parts = split /,/, $_, 3;


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: 18 Nov 2004 10:25:39 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: First Perl Program
Message-Id: <419c78a2$0$27551$db0fefd9@news.zen.co.uk>

On 18 Nov 2004 01:40:40 -0800, Michele Dondi <bik.mido@gmail.com> wrote:
>  "J. Gleixner" <glex_nospam@qwest.invalid> wrote:
> 
> > my @parts = (split( ',', $_ ))[1..3];
> 
>    my @parts = split /,/, $_, 3;

These aren't equivalent.

$ cat test
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;

my $data = 'one,two,three,four';

my @parts = split /,/, $data, 3;
print Dumper( \@parts );

@parts = (split /,/, $data)[1..3];
print Dumper( \@parts );

$ perl test
$VAR1 = [
          'one',
          'two',
          'three,four'
        ];
$VAR1 = [
          'two',
          'three',
          'four'
        ];





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

Date: 18 Nov 2004 10:24:26 +0100
From: Arndt Jonasson <do-not-use@invalid.net>
Subject: Re: Help! Complex Pattern Extraction with Key/Value Pairs and Reg Exp?
Message-Id: <yzdekirbjcl.fsf@invalid.net>


"Andrew E. Kalman" <aek@respectmyprivacy.com> writes:
> John Bokma wrote:
> > aekalman wrote:
> >
> >>I'm really having difficulty with regular expressions -- perhaps
> >>someone can help?
> > And your *Perl* question is?
> >
> 
> Where's the best place to ask regexp questions, if not here?

If your programming environment is Unix, try comp.unix.programmer.

There is no group dedicated to regular expressions. There are many
versions of regular expressions, and the ones in Perl are among the
most powerful. A Perl answer may not work at all in 'sh', 'sed',
'grep' or 'make'. I think that asking a regular expression question
here in the hope of finding that Perl is the right tool wouldn't be
wrong, if you make it clear that that is the purpose of your
question.


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

Date: Thu, 18 Nov 2004 05:39:16 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Help! Complex Pattern Extraction with Key/Value Pairs and Reg Exp?
Message-Id: <x7llczlnr0.fsf@mail.sysarch.com>

>>>>> "AEK" == Andrew E Kalman <aek@respectmyprivacy.com> writes:

  AEK> John Bokma wrote:
  >> aekalman wrote:
  >> 
  >>> I'm really having difficulty with regular expressions -- perhaps
  >>> someone can help?
  >> And your *Perl* question is?
  >> 

  AEK> Where's the best place to ask regexp questions, if not here?

some group that discusses regexes. this is cl.perl.misc. regexes are in
many langs and tools. 

all that lang foo is better than perl crap is just regex envy with
everyone claiming pcre and lying as nothing is really compatible with
perl regexes but perl.

uri

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


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

Date: Thu, 18 Nov 2004 16:20:45 +0800
From: sam <sam.wun@authtec.net>
Subject: Re: hi,something about thread in perl
Message-Id: <cnhnic$akm$1@news.hgc.com.hk>

Ben Morrow wrote:

> Quoth XiaotingHua <x.t.hua@163.com>:
> 

> However, as you say, a perl thread is not a thread by any reasonable
> definition: it's a userland fork. Without copy-on-write, or any of the
> other optimizations the kernel can provide. The ithreads concept
> originated in a project to emulate fork on systems which don't support
> it, and IMHO on a system which supports fork you'd be *much* better off
> with that. You *may* find that if you can create all your threads at
> startup that over the course of a long-running program saving the
> context switches needed for multiprocess is a significant benefit over
> fork, but I doubt it; especially if you aren't forking hundereds of
> process but just ~1 per processor.
> 
I m more concern the required memory when dealing with million of 
processes that created by fork().

Sam.

> If you want to use the threads::shared interface while forking, see the
> forks module on CPAN.
> 
> Ben
> 


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

Date: 18 Nov 2004 00:56:24 -0800
From: akhilau@hotmail.com (Akhila)
Subject: Re: How to get sytem/hardware information?
Message-Id: <6358fb6c.0411180056.78df52bc@posting.google.com>

Thanks for the info given. it helped me to go in right direction.


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

Date: 18 Nov 2004 02:53:15 -0800
From: jack@yankeeboysoftware.com (Jack)
Subject: newbie-ish question
Message-Id: <bbd64220.0411180253.110ea247@posting.google.com>

I am confused about how I can detect if the function jack has returned
an UNDEFined value;

note that I don't want to catch the return from 'jack' in a single
variable @array, rather I want it to return the seperate values, as
indicated.

Is there a way to detect if 'jack' returns undef (or null or
whatever), without first catching it in an @array variable.

The code below produces this:
$ perl test
defined(@array) is deprecated at test line 14.
        (Maybe you should just omit the defined()?)
the return from jack() is 0, 3.14159, Lemmings, all of them!
$

but if I remove the 'defined' and change jack to return an 'undef', I
get this:
$ perl test
Useless use of private variable in void context at test line 8.
Useless use of private variable in void context at test line 8.
Useless use of private variable in void context at test line 8.
Use of uninitialized value in concatenation (.) or string at test line
16.
Use of uninitialized value in concatenation (.) or string at test line
16.
Use of uninitialized value in concatenation (.) or string at test line
16.
the return from jack() is , ,
$


////////////////////////////////////////////////////////////
use strict;
use warnings;

sub jack{
        my $int1 = 0;
        my $float1 = 3.14159;
        my $string = "Lemmings, all of them!";
        ($int1, $float1, $string);
};

my $num;
my $flt;
my $str;
if( defined(($num, $flt, $str) = jack)){
        print "the return from jack() is $num, $flt, $str \n";
}
else{
        print "return was undef";
}
////////////////////////////////////////////////////////////


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

Date: 18 Nov 2004 00:59:36 -0800
From: nadsinoz@hotmail.com (chris)
Subject: script hangs waiting for key stroke
Message-Id: <b8996f29.0411180059.e3aa7d@posting.google.com>

I am running the following script on perl, v5.8.4 built for
MSWin32-x86-multi-thread (activestate).  The script runs but seems to
hang every now and then and won't continue until I press enter.  E.g.:

Processing DE 200407
Processing DE 200408
>> Hang - Press [enter] <<
Processing DE 200409

Do I need to flush buffers or something?

Many thanks,

Chris


----------


#!/usr/bin/perl -w

use strict;
use DBD::ODBC;

use util::YYYYMM;

my $start = 200402;
my $end   = 200410;
my $range_list = range( $start, $end );

foreach my $opco ( qw[ IE UK DE IT GR ES ] ) {
	foreach my $yyyymm (@$range_list) {
		LOAD: {
			print "Processing $opco $yyyymm\n";
			my $dbh = DBI->connect('dbi:ODBC:XXXXX', 'XXXXX', 'XXXXX')
				or redo LOAD;
			my $sth = $dbh->prepare("exec m_run ( '$opco', $yyyymm );")
				or redo LOAD;
			$sth->execute or redo LOAD;
			$dbh->disconnect;
		}
	}
}
my $yyyymm_plus_one = yyyymm_add( $end );
my $sth = $dbh->prepare("exec m_run_report ( $yyyymm_plus_one );");
$sth->execute;


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

Date: Wed, 17 Nov 2004 19:39:08 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: search.cgi
Message-Id: <slrncpnv9s.26n.tadmc@magna.augustmail.com>

Ken Saunders <bnbliss@comcast.net> wrote:

> I'm writing a script to search through all of my html files and return
> the results of the query.  I have used an html form file in the past I
> want to integrate it all into one cgi file.  can someone help here is
> the code I've come up with.


Get it to run from the command line *first*.

Move it to the CGI environment after you think you have it working
on the command line.

Adopt a more heathful style of indenting.

Use here-docs instead of a bazillion print()s.

Understand what a function will do for you *before* you
call that function.


> print "Content-type: text/html\n\n";
> print "<HTML><HEAD>";
[snip]
> print header();
> print start_html();


Why are you printing 2 content types and 2 start tags?

Do you know what the functions you've called there will do for you?


>  stat $File::Find::name;


Why are you calling stat() here?

It is not doing whatever it is that you think it is doing...


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


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

Date: Thu, 18 Nov 2004 00:28:35 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: search.cgi
Message-Id: <slrncpog8j.2ss.tadmc@magna.augustmail.com>

Ken Saunders <bnbliss@comcast.net> wrote:

><form action="/cgi-bin/search.pl" method="post">
                              ^^^
                              ^^^

> The other is the search.cgi and is
                         ^^^^
                         ^^^^

One of these things is not like the other, 
one of these things just doesn't belong...


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


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

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


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