drieux, et al -- ...and then drieux said... % % On Tuesday, June 4, 2002, at 03:17 , David T-G wrote: % [..] % > % >You should be able to split on colons... % > % > [zero] [5:16pm] ~> perl -e 'foreach $p \ % > (split (/:/,$ENV{PATH})){print "$p\n"}' % % first off my complements on the skank - although you know and I know
Why, thank you ! % the fine person wanted something more on the order of % % my @pathElements = split(/:/, $ENV{PATH}); % % foreach my $elem (@pathElements ) { % print "I see \$elem <$elem> in your PATH\n"; % } How lovely. See, I knew there was someone here who could say it better. I said it first, though :-) I'm just happy I came up with the right split grammar; it took me three tries! % ... % since the person clearly wants to effectively use this in a % real perl script and not merely.... Well, yeah, probably, but we still haven't covered where he's getting the PATH and what he's doing with it... If it's, say, a single pass through to look for a particular directory (but why separate instead of just m// I wonder in that case, so ...) instead of something where he'll need to store the path dirs for later, then it seems quite valid to spit through the elements and iterate them without storing them in an array in the meantime. Doesn't it? % % > /home/davidtg/local/Linux-2.4.5-i686/bin ... % > /usr/games % % no one puts 'games' in their PATH line any more.... No? But why?! :-) % ... % > /usr/dt/bin % > /opt/sw/rvplayer5.0b3 % % I don't mean to be crass here or anything David - but is % it just me or have you become a bit cluttered in your PATH Yes, I have; it comes from too little time to really straighten things out. % element - and should seriously think about resolving whether % you are on a linux box or a solaris box and hence set your % path element accordingly... It really is not that difficult % a trick to do... But if you can set it once and have it work everywhere then it must be great! :-) % % try something like % % setenv ARCH `perl -MConfig -e 'print $Config{osname}'` Hmmm... Hadn't noticed that one before. Still, firing up perl every time I start a shell might be a little painful. % % or which ever your KULT fave login world is, and then sort % out which path thingies belong where - ala % % if( $ARCH == "sgi" ) then Ahhh! If/elseif trees! Ick! ... % Please just because you are about to go mental is no % reason to keep cluttering up all your shells with the % fact that you have zoned out.... % % show some back bone man.... Heh... I'll show you backbone, just as soon as I get around to it... I'm going to need a ~/local tree that is populated for Linux 2.2 and 2.4, FreeBSD 4.5, Solaris 1.x, 2,x, and 8, and perhaps cygwin, with at least Linux and Solaris on multiple chip architectures. Thanks to my handy dandy $MYOS $MYMAJ $MYMIN $MYCHIP, though, it will all work out nicely. Once I get it done. Yeah, really. % % besides it will help your FNG's as they go % % "uh dude, like I ripped off your .login and .cshrc files % uh, and like why do you, uh do......" Heh. On the one hand, nobody takes my env files because they're too scary. On the other hand, they (the real ones, not this out-of-date play copy that has been neglected) are ready to drop in place to provide a system-wide group-aware environment for users which provides everything the business deems necessary but still allows the user freedom to screw it up (er, customize it). *That* part I have pretty much down; it's almost a shrink-wrapped product. % % { ok, so like as if my .login and .cshrc files have not bloated % over the mumble, mumble, mumble years..... } Same here! That's another project; when I write a perl script (or some other parser) to go through and take the aliases that I want and spit them out both in tcsh and bash format, I'll probably do some pruning, too. All in my copious free time between midnight and three AM... % % ciao % drieux l8r :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
msg25427/pgp00000.pgp
Description: PGP signature