Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal L. Schwartz) Newsgroups: comp.lang.perl Subject: Re: Rank beginners question Message-ID: <1991May2.191645.23036@iwarp.intel.com> Date: 2 May 91 19:16:45 GMT References: <1991May2.173518.4194@cs.ucla.edu> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal L. Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 44 In-Reply-To: frazier@oahu.cs.ucla.edu (Greg Frazier) In article <1991May2.173518.4194@cs.ucla.edu>, frazier@oahu (Greg Frazier) writes: | Hi-howdy - | I am a beginner perl hack (obviously). I am trying | to get my script to manipulate some files in my directory. | This works | @foo = `ls *`; | but this does not work | @foo = `ls ~frazier`; | the error msg is | ~frazier not found | | I do not understand why the '*' gets expanded correctly but | '~frazier' does not. BTW, I am running cshell | ($ENV{'SHELL'}=/bin/csh). The man page for csh indicates that | '*' and '~[username]' are both examples of filename expansion, | so I would have assumed that if one was happening, the other | would too. I have tried various quotes and escapes to no | avail: | @foo = `ls '~frazier'`; | @foo = `ls \~frazier`; | @foo = `'ls ~frazier'`; | | Any and all responses appreciated. And, no, I do not want | to use $ENV{`HOME`}, 'cuz I'd like other people to be able | to run this script (and the files are in my directory). Backquoted strings are always interpreted with /bin/sh (thank gawwd!). You'd need to do something like this: $_ = 'ls ~frazier'; # suppose you want to execute this... s#~(\w*)# (@a = getpwnam($1 || $ENV{'USER'})) ? $a[7] : $& #eg; die $@ if $@; ## this replaces all the ~refs with what they really are. ## warning... it can get carried away, but it's a good quick cut @foo = `$_`; print "Just another Perl hacker," # with not quite enough time to be clever :-) -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/