[29477] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 721 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 6 14:10:08 2007

Date: Mon, 6 Aug 2007 11:09:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 6 Aug 2007     Volume: 11 Number: 721

Today's topics:
    Re: $hash($key) = undef vs = 1 <tzz@lifelogs.com>
        'localtime' question  PadgeA@gmail.com
    Re: 'localtime' question <shawnhcorey@magma.ca>
        (Re)announcing APL 2007 <mkent@acm.org>
    Re: (Re)announcing APL 2007 <paul@carlislegroup.com>
    Re: @arts <bik.mido@tiscalinet.it>
        Checking user's in passwd file <itfred@cdw.com>
    Re: Checking user's in passwd file <dummy@example.com>
    Re: Checking user's in passwd file <itfred@cdw.com>
    Re: Checking user's in passwd file <mritty@gmail.com>
    Re: Checking user's in passwd file <vilain@spamcop.net>
        copy all files <dhkblaszyk@zeelandnet.nl>
    Re: copy all files <admiralcap@gmail.com>
    Re: copy all files <admiralcap@gmail.com>
    Re: copy all files <dhkblaszyk@zeelandnet.nl>
    Re: copy all files <dummy@example.com>
    Re: copy all files <dhkblaszyk@zeelandnet.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 05 Aug 2007 08:06:48 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: $hash($key) = undef vs = 1
Message-Id: <m2fy2ynn9z.fsf@lifelogs.com>

On Fri, 3 Aug 2007 12:42:37 -0400 "~greg" <g_m@remove-comcast.net> wrote: 

~> my %Set =  ( 'a' =>'this is a long string', 'b'=>1, 'c'=>'', 'd'=>0, 'e'=>undef );
 ...
~> So, my thinking is, that undef might take up only the overhead,
~> and therefore be better than 1.

~> (If it saves space at all, then it's worth it to me,
~> since the sets I have in mind (about a dozen of them)
~> involve over 100000 elements each))

You may want to consider inversion lists.  Inversion lists work well if
you are just looking for yes/no answers and you have large clusters of
yes or no values.  So you can store your values in an array and scan
through it; lookup is slower but there's always a tradeoff in these
situations.  See my article at
http://www.ibm.com/developerworks/linux/library/l-cpinv.html or look up
Algorithm::InversionList on CPAN.

Bit vectors (perldoc -f vec) may be better for you, especially if you
don't have clusters of values.

Ted


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

Date: Sun, 05 Aug 2007 19:01:16 -0000
From:  PadgeA@gmail.com
Subject: 'localtime' question
Message-Id: <1186340476.271174.141750@q3g2000prf.googlegroups.com>

Using Linux the following code :

use POSIX qw(strftime);
my $now = strftime "%Y%m%e", localtime;

yields '20070805'

Under Windows the same code yields:

'200708'

Any ideas on how to get the day of the month included using Windows?



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

Date: Sun, 05 Aug 2007 15:11:16 -0400
From: "Mr. Shawn H. Corey" <shawnhcorey@magma.ca>
Subject: Re: 'localtime' question
Message-Id: <be3c8$46b6210c$d1d963ba$7785@PRIMUS.CA>

PadgeA@gmail.com wrote:
> Using Linux the following code :
> 
> use POSIX qw(strftime);
> my $now = strftime "%Y%m%e", localtime;
> 
> yields '20070805'
> 
> Under Windows the same code yields:
> 
> '200708'
> 
> Any ideas on how to get the day of the month included using Windows?
> 

Strange, both of them should be: 200708 5

If you want a leading zero on the day, use: '%Y%m%d'


-- 
Just my 0.00000002 million dollars worth,
  Shawn

"For the things we have to learn before we can do them, we learn by doing them."
  Aristotle


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

Date: Sun, 05 Aug 2007 23:54:09 -0400
From: Mike Kent <mkent@acm.org>
Subject: (Re)announcing APL 2007
Message-Id: <5hnkb3F3hus4jU1@mid.individual.net>


APL 2007 conference on Array Programming

     co-located with OOPSLA 2007


Sponsor:              ACM SIGAPL

Where:                Montreal

When:                 October 21 (tutorials)
                       October 22/23  (main conference program)

Keynote               Guy Steele
speaker:              Sun Microsystems Laboratories


Links:
     Info:             http://www.sigapl.org/apl2007.html
     Registration:     http://www.regmaster.com/conf/OOP07/oop07.pdf

     OOPSLA:           http://www.OOPSLA.org/oopsla2007


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

Date: Mon, 06 Aug 2007 06:20:30 -0700
From:  Paul Mansour <paul@carlislegroup.com>
Subject: Re: (Re)announcing APL 2007
Message-Id: <1186406430.744134.298400@x35g2000prf.googlegroups.com>

On Aug 5, 11:54 pm, Mike Kent <mk...@acm.org> wrote:
> APL 2007 conference on Array Programming
>
>      co-located with OOPSLA 2007
>
> Sponsor:              ACM SIGAPL
>
> Where:                Montreal
>
> When:                 October 21 (tutorials)
>                        October 22/23  (main conference program)


APL2007 Roll Call: Is anyone going to this?

I'm thinking about going, but I don't want to the only one to show up,
as in San Diego.




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

Date: Mon, 06 Aug 2007 13:56:46 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: @arts
Message-Id: <k03eb3tmmfo2ocp9k1jcfd6glu8losnfco@4ax.com>

On Fri, 3 Aug 2007 11:02:35 -0700, Keith Keller
<kkeller-usenet@wombat.san-francisco.ca.us> wrote:

>> But seriously, you're joking, aren't you?
>
>Yes, I was joking.  It must not have been a good joke, since here I am
>explaining that it was a joke.

Do not worry, it was not that bad. Perhaps it's me that I'm not that
good at understanding them and thus embarassingly putting people in
the position to explain them, especially in English, because English
is not my mother tongue. (But in this particular case, it's not that
relevant.)


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: Sun, 05 Aug 2007 10:54:37 -0400
From: Fred <itfred@cdw.com>
Subject: Checking user's in passwd file
Message-Id: <Js6dnUyP64QweSjbnZ2dnUVZ_saknZ2d@comcast.com>

I have a list of valid users that I need to cross reference to
the /etc/passwd files on various systems.  So lets suppose the
(shortened) list of valid users is:


John Doe
Susan Archer
Monty Python


Now let's say there's an entry in the /etc/passwd file for an
employee named George Smith who has left the company:

gsmith:cXU6Km8JDj:9446:9400:George Smith:/home/gsmith:/bin/bash


How would I determine if the George Smith user is invalid?



-Thanks




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

Date: Sun, 05 Aug 2007 16:47:43 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: Checking user's in passwd file
Message-Id: <Panti.93693$xk5.62119@edtnps82>

Fred wrote:
> I have a list of valid users that I need to cross reference to
> the /etc/passwd files on various systems.  So lets suppose the
> (shortened) list of valid users is:
> 
> 
> John Doe
> Susan Archer
> Monty Python
> 
> 
> Now let's say there's an entry in the /etc/passwd file for an
> employee named George Smith who has left the company:
> 
> gsmith:cXU6Km8JDj:9446:9400:George Smith:/home/gsmith:/bin/bash
> 
> 
> How would I determine if the George Smith user is invalid?

Call up the Human Resources or Payroll department and ask them if George Smith 
is still employed there.


John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Sun, 05 Aug 2007 13:33:22 -0400
From: Fred <itfred@cdw.com>
Subject: Re: Checking user's in passwd file
Message-Id: <e4ydnevCarV_lCvbnZ2dnUVZ_u_inZ2d@comcast.com>

On Sun, 05 Aug 2007 16:47:43 +0000, John W. Krahn wrote:
> How would I determine if the George Smith user is invalid?
> 
> Call up the Human Resources or Payroll department and ask them if George Smith 
> is still employed there.
> 
> 
> John



You're funny.


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

Date: Sun, 05 Aug 2007 10:45:30 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: Checking user's in passwd file
Message-Id: <1186335930.898417.279500@19g2000hsx.googlegroups.com>

On Aug 5, 10:54 am, Fred <itf...@cdw.com> wrote:
> I have a list of valid users that I need to cross reference to
> the /etc/passwd files on various systems.  So lets suppose the
> (shortened) list of valid users is:
>
> John Doe
> Susan Archer
> Monty Python
>
> Now let's say there's an entry in the /etc/passwd file for an
> employee named George Smith who has left the company:
>
> gsmith:cXU6Km8JDj:9446:9400:George Smith:/home/gsmith:/bin/bash
>
> How would I determine if the George Smith user is invalid?

Read the list of valid users into a hash.  Read the passwd file.
Parse out the user's name.  Query the hash to see if that user exists
in the hash.

What part of this are you having problems with?  What have you done so
far?

You'll get far better help in this group if you make an attempt first,
and post a short-but-complete script that demonstrates your best
attempt and how/why it doesn't meet your needs.

Here's some documentation you should probably read:
perldoc -f open
perldoc -f readline
perldoc -f split
perldoc -q contain

Paul Lalli



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

Date: Sun, 05 Aug 2007 11:32:05 -0700
From: Michael Vilain <vilain@spamcop.net>
Subject: Re: Checking user's in passwd file
Message-Id: <vilain-F553AA.11320505082007@comcast.dca.giganews.com>

In article <e4ydnevCarV_lCvbnZ2dnUVZ_u_inZ2d@comcast.com>,
 Fred <itfred@cdw.com> wrote:

> On Sun, 05 Aug 2007 16:47:43 +0000, John W. Krahn wrote:
> > How would I determine if the George Smith user is invalid?
> > 
> > Call up the Human Resources or Payroll department and ask them if George 
> > Smith 
> > is still employed there.
> > 
> > 
> > John
> 
> 
> 
> You're funny.

Actually, that's most of the time the definative answer in large 
companies.  They'll have records of who's still on the payroll.  If 
there's someone who manages contractors like the person that issues 
security badges, then your job is even easier.  Hopefully, there's some 
sort of process that a manager must "authorize" access to the systems 
and the building by signing something and revoke it when they leave.

Doing a password and software audit on machines I'm given control over 
is one of the first things I do.  If there's no way to determine who's 
authorized to use the systems, you've got bigger problems.  If you can't 
figure this out, print out a list and ask your manager to validate by 
hand.

-- 
DeeDee, don't press that button!  DeeDee!  NO!  Dee...





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

Date: Mon, 06 Aug 2007 10:31:42 +0200
From: Darius Blaszyk <dhkblaszyk@zeelandnet.nl>
Subject: copy all files
Message-Id: <pKadnS_8Y_3tQSvbnZ2dnUVZ8tijnZ2d@zeelandnet.nl>

Hi I would like to copy all files that have a certain extension from one 
directory to another.
Is there a 'simple' command that does this, or do I need to create a for 
each loop that checks the file extension and then extracts the filename 
and copies that to the destination directory?

How do you advise?

TIA Darius


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

Date: Mon, 06 Aug 2007 02:10:42 -0700
From: Matt Madrid <admiralcap@gmail.com>
Subject: Re: copy all files
Message-Id: <yKGdnSUOw6cPeCvbnZ2dnUVZ_g6dnZ2d@comcast.com>

Darius Blaszyk wrote:
> Hi I would like to copy all files that have a certain extension from one 
> directory to another.
> Is there a 'simple' command that does this, or do I need to create a for 
> each loop that checks the file extension and then extracts the filename 
> and copies that to the destination directory?

Yes and yes..

> 
> How do you advise?
> 

Fairly simple:

     while (</source_dir/*.ext>) {
         copy($_,"/dest_dir/");
     }

http://perldoc.perl.org/functions/glob.html
http://perldoc.perl.org/File/Copy.html

If you need to do it recursively it's a little more involved.
Look into File::Find for that.

http://perldoc.perl.org/File/Find.html

Matt M.







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

Date: Mon, 06 Aug 2007 02:19:08 -0700
From: Matt Madrid <admiralcap@gmail.com>
Subject: Re: copy all files
Message-Id: <b7WdnQM_r90ReivbnZ2dnUVZ_v3inZ2d@comcast.com>

Matt Madrid wrote:
> 
>     while (</source_dir/*.ext>) {
>         copy($_,"/dest_dir/");
>     }
> 

Oops. I forgot add:

use File::Copy;

copy() is a function exported by the File::Copy module.

Matt M.


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

Date: Mon, 06 Aug 2007 13:48:07 +0200
From: Darius Blaszyk <dhkblaszyk@zeelandnet.nl>
Subject: Re: copy all files
Message-Id: <vOKdnRdMLNfklyrbnZ2dnUVZ8qGdnZ2d@zeelandnet.nl>

Thanks Matt, that works! I was having problems with the copy command 
previously when I tried "/dest_dir/." and "/dest_dir/*.*" and 
"/dest_dir/*". But it seems I just don't need to add a wildcard after all.

One last question, you use "while (</source_dir/*.ext>)" to loop trough 
the files, is it possible to check for more extensions in the same while 
loop? I tried

while (</source_dir/*.ext>) || (</source_dir/*.txt>)

but that doesn't work. I would rather not peel the extension of the 
filename because it would clutter the script.
So is something like that possible or do I need to do the check inside 
the while and just loop through any file in the directory?

Cheers, Darius


Matt Madrid wrote:
> Matt Madrid wrote:
>>
>>     while (</source_dir/*.ext>) {
>>         copy($_,"/dest_dir/");
>>     }
>>
> 
> Oops. I forgot add:
> 
> use File::Copy;
> 
> copy() is a function exported by the File::Copy module.
> 
> Matt M.


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

Date: Mon, 06 Aug 2007 11:59:21 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: copy all files
Message-Id: <t2Eti.96477$xk5.19150@edtnps82>

Darius Blaszyk wrote:
> Thanks Matt, that works! I was having problems with the copy command 
> previously when I tried "/dest_dir/." and "/dest_dir/*.*" and 
> "/dest_dir/*". But it seems I just don't need to add a wildcard after all.
> 
> One last question, you use "while (</source_dir/*.ext>)" to loop trough 
> the files, is it possible to check for more extensions in the same while 
> loop? I tried
> 
> while (</source_dir/*.ext>) || (</source_dir/*.txt>)
> 
> but that doesn't work.

while ( </source_dir/*.{ext,txt}> )


John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Mon, 06 Aug 2007 14:34:22 +0200
From: Darius Blaszyk <dhkblaszyk@zeelandnet.nl>
Subject: Re: copy all files
Message-Id: <ieadndiAF_XNiCrbnZ2dnUVZ8vudnZ2d@zeelandnet.nl>

John W. Krahn wrote:
> while ( </source_dir/*.{ext,txt}> )

Thanks John, that was it.

Darius


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

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


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