Re: Linux World?
> Does anyone know if we are getting a booth this year? Looks like it is time to be requesting .ORG pavillion space. > Last year was a > great time. > Learned a lot... Indeed! > This year I'd love to know early so I can decide whether to ask my boss > to pay my way... (unlikely he'll say yes...).. I've already asked my boss ... I expect to be there for the full conference, but would be glad to help at a booth a little, same as last year, if it can be made to happen. -- /"\ Bill Ricker N1VUX [EMAIL PROTECTED] \ / http://world.std.com/~wdr/ X Member of the ASCII Ribbon Campaign Against HTML Mail / \ ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: extract string -- TIMTOWTDI
> On 1/10/06, Paul Lussier <[EMAIL PROTECTED]> wrote: > > > perl -ne 'split ","; $_ = $_[2]; s/(^")|("$)//g; print if m/univ/;' < > > > abc.txt > def.txt > > Egads! That's a literal start at a Perl "bring the grep sed and cut-or-awk into one process", but it's not maximally Perl-ish. It is also inefficient, it does the side-effecting "" removal before discarding non-univs. It is a literal translation of a `cut | sed | grep` pipe, not of the `cut|grep|sed` pipe shown earlier. Of coures, if the requirements allowed it, a `grep|cut|sed` pipe would be the best shell impelementation -- but that relies upon knowning all 'univ' are in the desired column, which we haven't been granted. If it weren't for the desire to drop the quotes, Perl couldn't beat Cut's golf-score (key stroke count) on this one anyway, but we can try to optimize expressivity while saving two of three process forks. The Perl Motto is TIMTOWTDI: There Is More Than One Way TO Do It. (We've already seen that this is often true for BASH too.) This is usually a good thing, as often some are better for some requirements than for others. For generalness in real code, I'd like to explicitly ignore the header line on this sort of CSV file: $perl -F, -lane 'next if $.==1 or $F[-1] !~/univ/; print $F[-1]=~m/"(.*)"/;' univ of Vermont univ of Penn univ of south Florida $ As with one prior posting, the '-naF,' args cause Perl to auto-split on ',' into @F on each line. I normally used '-F, -lane' on one-liners, since it's memorable. The '$.==1 or' is not strictly required since the top line of the sample file had "school" not "university" for the column head, but it it had "university or school" or "school/univ" on line 1, would be required. $F[-1] is Perl's equivalent to AWK's NF, referring to the last column, instead of by number. (By number is notoriously error prone with 0-based field counting). $F[-2] means last-but-one, etc, too, and you can slice with them as @F[-6..-2] . Rather than remove the "" with s/"//g, I've captured what's between them and printed that. We can make more use of -F ... we'll split on all the punctuation. $ perl -F'/^"|","|"$/' -lane 'next if $.==1 or $F[-1] !~/univ/i; print $F[-1]' schools.txt univ of Vermont univ of Penn univ of south Florida $ Of course, some CSV files the ""'s are optional. In qhich case we can do $perl -F'/^"|"?\s*,"?|"$/' -lane 'next if $.==1 or $F[-1] !~/univ/i; print $F[-1]' schools.txt univ of Vermont univ of Penn univ of south Florida $ Alternatively, to print **any** quoted phrase containing univ, whether in last column or not, using the commas .. $perl -F, -lane 'for (@F){s/"//g; print if /univ/i}' schools.txt univ of Vermont univ of Penn univ of south Florida $ or ignoring the commas, just uses the quotes to capture between quotes, but only if there's a univ between. I started sneaking in a /i flag to be case insensitive above, and I'll continue here ... $perl -lane 'print for m{ " ( [^"]*? univ [^"]* ) " }xig' schools.txt univ of Vermont univ of Penn univ of south Florida $ [the ? isn't required but it should help efficiency.] or $ perl -lane 'print for grep {/univ/i} m{"([^"]*)"}g' schools.txt univ of Vermont univ of Penn univ of south Florida There's also a CPAN module or two for processing CSV files that handles the commas and quotes in CSV files ... http://search.cpan.org/search?query=Text%3A%3ACSV&mode=all Your Linux distro should have Text::CSV_XS as a apt/yum/rpm/... module option, or grab it from CPAN and build. (It has an XS => .c module, so is ripping fast, but has to be make'd.) None of this is seriously obfuscatory golfing, but if someone wanted to say darn the cost of forking new processes off bash, 'awk/cut|grep|sed' is easier to read, well, I won't argue that it's easier for him/her to read, and they should do it that way -- unless they need to tune for performance. -- /"\ Bill Ricker N1VUX [EMAIL PROTECTED] \ / http://world.std.com/~wdr/ X Member of the ASCII Ribbon Campaign Against HTML Mail / \ ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: set default file permissions for a directory
Oh, I should add to my own comment - > So, SCP gets you (777 minus profile:umask) unless you use scp -p. The -p of course sets the permissions to what they were on the source file, ignoring user UMASK (subject probably to the SYSTEM umask?). Per man scp, -p Preserves modification times, access times, and modes from the original file. Note that -o lets you set any .ssh/config parameter on scp commandline. -- /"\ Bill Ricker N1VUX [EMAIL PROTECTED] \ / http://world.std.com/~wdr/ X Member of the ASCII Ribbon Campaign Against HTML Mail / \ ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: set default file permissions for a directory
> From: Numberwhun [snip] > when you ar[e] specifying where you want to transfer to you > need to spe[c]ify the following: > user@:/directory/on/other/machine Just tO be precise, any of the source file(s) or the target can be prefixed by either '[EMAIL PROTECTED]:' or 'host:' . User defaults to $USER or $LOGNAME. Multiple source files (on possibly multiple hosts) can be specified as with cp(1), but better have unique file.ext names if from multiple dirs or hosts (as with cp(1)). If the target isn't an existing directory, it's taken as the filename (as with cp(1)), so it's safer to say $ scp file [EMAIL PROTECTED]:/directory/on/other/machine/. or $ scp file [EMAIL PROTECTED]:/directory/on/other/machine/file to avoid surprises. > If you don't put the users it will default to using the user you are on > the local machine but will ask you for the password. If you have a default identity in ~/.ssh on the local host and that default identity is in the remote host:~/.ssh/authorized_keys (or ~/.ssh/authorized_keys2) scp like ssh will not prompt for remote password. It may prompt for passphrase for your local private key, if ssh-agent hasn't already unlocked it and if the identity isn't passphrase-free (normal for BatchMode but not for use in untrusted environments or with portable devices!) > If you don't > transfer certain files as the correct user, then permissions are not > correctly set. As previously stated, SETUID and SETGID (u+s, g+s) on the directory controls the UID and GID of new files. On Linux, Solaris, VMS, and WinNT/XP, the POSIX ACEs (Access Control Elements) implementation of Access Control Lists (ACLs) can specify default permissions for new files in a directory. (AIX and probably other early adopters of CMW ACLs lack this, alas.) > I would say the .profile(s) are read and used. Easily verified by adding "echo PROFILE" to your .profile or .cshrc as appropriate -- yes. So, SCP gets you (777 minus profile:umask) unless you use scp -p. -- /"\ Bill Ricker N1VUX [EMAIL PROTECTED] \ / http://world.std.com/~wdr/ X Member of the ASCII Ribbon Campaign Against HTML Mail / \ ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: Programming Language History [was Re: F/OS & the blind ]
Jeff Kinz wrote: > Quiz answer: > First Machine mentioned is the "704". Correct per memory and Google. If no one spelled it out yet the memory Lisp has of the IBM 704 machine code are the operations on 'cons' cells 'car' and 'cdr'. CAR=Contents of Address Register. CDR=Contents of Decrement Register. > Not the 7404 that I was thinking. > (If there even ever was a "7404" for that matter.) Google reports the IBM 7404 was the Graphical Output option for the 7090/7094 family (tranistor version of 709, piloted by "Stretch" 7030). So 7404's would likely have been around MIT in the early days of Lisp too, as the CTSS system was a 7090 (progenitor of Multics and thesis to ITS's antithesis, the synthesis of which was Emacs). http://www.multicians.org/thvv/7094.html -- /"\ Bill Ricker N1VUX [EMAIL PROTECTED] \ / http://world.std.com/~wdr/ X Member of the ASCII Ribbon Campaign Against HTML Mail / \ ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Python, Lisp, and other languages
Python <[EMAIL PROTECTED]> wrote > As a confirmed python nut, The email name was a bit of a warning, but I appreciate the explicit disclosure. My own Pythonesque nuttiness is confined to the capitalized form, as in the BBC series. I'm a Perl Monger, and was an awk addict before that. The Camel-Spotting sketch is right up in the canon with Parrot, Lumberjack, Blackmail, and the Twin Peaks of Mt. Kilimanjaro. I sympathize with Guido's choice of naming honoree, if not in syntactic "sugar". > I could not resist tossing another URL onto > the thread. > http://norvig.com/python-lisp.html > (Peter Norvig is Google's Director of Research) Most of his comments apply equally well to Perl, of course. (Barring the three-way religious issue of punctuation.) I'll reply with an URL for the book and website that describes how to do really lisp style stuff in Perl, including stuff that's hard in Python -- http://hop.perl.plover.com/ Peter Norvig is honest in the python link above to admit the real failings of even modern Python in doing what Lisp does well -- <> Readonly closures are fine for "pure functional" write-once programming, but (outside academe) that's not the real winner Lisp style. For implementing truly reusable APIs, closures are essential, as MJD's Higher Order Perl (HOP above) shows -- including modifiable closures. Besides Lisp, Perl and Ruby may be the only languages with general purpose read/write closures. Having to do an extra indirection of one sort or another in the closure to have write-access to the contents of its closed variable means Python is technically equivalent "strength" but loses something important in expressiveness -- the expressiveness is what Lisp wins on. <> With Filter::Simple, Perl has a facility of distressingly similar power to Lisp Macros, but without even less grounding in tokenization. Using Filter::Simple isn't as simple as Lisp macros, but simpler than accessing the Python Parse tree. Some marvelous magic has been created with Perl Filter::Simple. > I do realize that language debates can last forever since different > folks place different values on different features while also facing > different challenges and situations. Indeed. Another trope is comparing the old original or standard version of the other language to the latest or enhanced version of their favorite. (If I compared Perl 6 to Python 2.0, I'd obviously be cheating.) Cheers, -- /"\ Bill Ricker N1VUX [EMAIL PROTECTED] \ / http://world.std.com/~wdr/ X Member of the ASCII Ribbon Campaign Against HTML Mail / \ http://use.perl.org/~n1vux/ ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: Debian flamewar (was: Can I bother you with another Linux question?)
> > After all, Debian is *perfect*. >Despite that being a very common belief, it really isn't true. The question is, will it be the DCC or Ubuntu that perfects it? >After all, the "vrms" program isn't run automatically after a Debian > install and at each user login. Until that happens, Debian really cannot be > considered "perfect". :-) That's a bit much. Only need to run it after each dpkg or apt-get install. But instead, 'apt-get install vrms' adds vrms to cron ... -- /"\ Bill Ricker N1VUX [EMAIL PROTECTED] \ / http://world.std.com/~wdr/ X Member of the ASCII Ribbon Campaign Against HTML Mail / \ ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss