idiomatics v. Use English - was Re: ascertain current username
On Friday, August 16, 2002, at 08:01 , George Schlossnagle wrote: > drieux wrote: >> I have my nagging doubts about >> >> use English; >> >> when coding in perl... > > What are your nagging doubts in particular? [..] p0: besides the fact that it just is a fun gag to pull step back, read it again, have a small chuckle say with the rest of the folks 'drieux, get therapy'; p1: a part of the issue: I think it's akin to my on going debate with myself about such things as use Config; my $os_name = $Config{osname}; vice my $os_name = $^O; and where is one 'more readable' as opposed to 'being idiomatic' - a topic I am still mulling. The former obliges me to go through the whole WhoHa of doing a 'use foo' - which is rather long, tedious and annoying, when you step your way through it in the perl debugger whereas the later does not go through the Gagillion steps merely to get the one thing one is looking for p2: To code in line, or go_sub(@beat_state); This of course is part and parcel of the whole 'code re-usability' dialog point - with whether or not one should be coding with an eye on the 'common bits' that really should be going into a perl module at some point... hence where is one safely in the this is just a script and when has one fallen off the wagon into the reality this is a software development process and hence it should be dealt with like all other RealCode[tm] using the full on breadth of the idioms of the coding language... p3: the "whole line-noise style trend" angst Given that I come from a sed/awk background to begin with, perchance I am less affected as to what is and what is not 'line noise' concern about 'special characters' and/or 'special token sequences'. but I can, and do, appreciate your concern. things get 'way funky' way too fast in the regular expression portion of any language - and perl is no exception. The peculiar part is that perl was developed to resolve the 'complexity' of developing and maintaining /bin/sh + awk + sed + grep + and as such it picked up their weirdness on top of everything else. p4: internalizing a language's idioms So at one level there is an advantage of 'speaking the native idiom'. That's how I got my head around the 'original ones' - as well as wandering off the cliff with gawk before those features were available 'everywhere' in nawk There is the added advantage in perl that we can all do the perldoc perlvar to check and see if a thing means what we mean it to mean. given that I have learned down this path that I can not do #!/usr/bin/perl -w use strict; my %man_opt = ( darwin => "man -c ", solaris => "man - ", freebsd => "man -P cat ", linux => "man -P cat ", ); my $man_cmd = $man_opt{ "$^0" }; print $man_cmd . "\n"; but need to 'interpolate it' first with say: my $osname = "$^O"; # shorter than going the old way through use config my $man_cmd = $man_opt{ $osname }; I consider the misadventure at least worth the waltz... ciao drieux --- p0.1 - given as I have code samples up on my webPages where the variable names are in english, and the content is in spanish and german - languages I have not used since '74 and '76 respectively - I have some 'issues' with the 'cultural imperialism' of the use english that we have just visited the 'unicode' discussion because the typography of other languages are not a part of ascii there are some 'globalization' angsts we as a community need to be better engaged in... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ascertain current username
drieux wrote: > > > I have my nagging doubts about > > use English; > > when coding in perl... What are your nagging doubts in particular? I find use English variable names to be far less magical and far more intuitive than the hsort versions. I realize that goes against the whole line-noise style trend, but what are your other issues with it? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ascertain current username
On Friday, August 16, 2002, at 01:22 , Rus Foster wrote: > On Fri, 16 Aug 2002 [EMAIL PROTECTED] wrote: > >> Hello, >> does anybody know a possibility how to ascertain the current User (User >> Id, >> Username) ? [..] > use English; > print $UID; > print $GID; > perldoc perlvar will lead you to the other traditional ways my $uid = $<; my $e_uid = $>; my $gid = $(; my $e_gid = $); I have my nagging doubts about use English; when coding in perl... and as john has mentioned perldoc -f getpwuid or you can play with the perldoc POSIX if that makes you feel happier ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ascertain current username
On Aug 16, Rus Foster said: >On Fri, 16 Aug 2002 [EMAIL PROTECTED] wrote: > >> Hello, >> does anybody know a possibility how to ascertain the current User (User Id, >> Username) ? >> I thougt of using a module but couldn't find one. > >Have you tired parsing the output from the commands "id -h" and "id -u"? Perl is not the shell. You shouldn't have to spawn (OS-specific!) programs every time you want to get information from the system. For example, directory listings can be done with glob() or readdir() -- there's no need to call `ls` or `dir`. Perl puts the current user ID in $< (or $UID if you're using the English module). You can get information about that user ID from the getpwuid() function. perldoc -f getpwuid -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ascertain current username
Stefan Haberer wrote: > > Hello, Hello, > does anybody know a possibility how to ascertain the current User (User Id, > Username) ? I thougt of using a module but couldn't find one. my $username = getpwuid $<; perldoc perlvar perldoc -f getpwuid John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ascertain current username
use id and awk ie to get just user name USERNAM=`id | awk -F"(" '{print $2}' | awk -F")" '{print $1}'` # Messy but works everywhere -Original Message- From: Rus Foster [mailto:[EMAIL PROTECTED]] Sent: 16 August 2002 09:20 To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: ascertain current username On Fri, 16 Aug 2002 [EMAIL PROTECTED] wrote: > Hello, > does anybody know a possibility how to ascertain the current User (User Id, > Username) ? > I thougt of using a module but couldn't find one. Have you tired parsing the output from the commands "id -h" and "id -u"? Rgds Rus -- http://www.fsck.me.uk - Rant wibble wave http://shells.fsck.me.uk - Hosting and stuff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The information contained in or attached to this email is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are not authorised to and must not disclose, copy, distribute, or retain this message or any part of it. It may contain information which is confidential and/or covered by legal professional or other privilege (or other rules or laws with similar effect in jurisdictions outside England and Wales). The views expressed in this email are not necessarily the views of Centrica plc, and the company, its directors, officers or employees make no representation or accept any liability for its accuracy or completeness unless expressly stated to the contrary. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ascertain current username
On Fri, 16 Aug 2002 [EMAIL PROTECTED] wrote: > Hello, > does anybody know a possibility how to ascertain the current User (User Id, > Username) ? > I thougt of using a module but couldn't find one. > > > greetings > Stefan > Or following up on my own post (which is bad) just found out you could just do... use English; print $UID; print $GID; doh Rus -- http://www.fsck.me.uk - Rant wibble wave http://shells.fsck.me.uk - Hosting and stuff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ascertain current username
On Fri, 16 Aug 2002 [EMAIL PROTECTED] wrote: > Hello, > does anybody know a possibility how to ascertain the current User (User Id, > Username) ? > I thougt of using a module but couldn't find one. Have you tired parsing the output from the commands "id -h" and "id -u"? Rgds Rus -- http://www.fsck.me.uk - Rant wibble wave http://shells.fsck.me.uk - Hosting and stuff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ascertain current username
hi, use system('users') on unix systems to get the name of all users currently logged on that machine. u can also use system('whoami') to know from whose login the script is being executed (i.e. u urself). - Get a bigger mailbox -- choose a size that fits your needs. http://uk.docs.yahoo.com/mail_storage.html
RE: ascertain current username
If you're on a Win32 system, you can use the standard Win32 module. perldoc Win32 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, August 16, 2002 10:13 AM To: [EMAIL PROTECTED] Subject: ascertain current username Hello, does anybody know a possibility how to ascertain the current User (User Id, Username) ? I thougt of using a module but couldn't find one. greetings Stefan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]