Re: Eval, the $ string, backslash escaping, and the adventures thereof An XY problem is when you want to do X, but you ask how to do Y instead, because you've decided that Y is the best way to accomplish X. -- Mark Jason Dominus (at comp.lang.perl.misc) % Re: problem beim splitten (plain) * Joerg Plate wrote in de.comp.lang.perl.misc: >Wie wäre es mit: > > $string = q(131500); substr($string,4,0)=":"; substr($string,2,0)=":"; Was ja so viel anders ist, als mein wesentlich lesbareres substr$z=>$_=>0=>':'for 2,5; Fragezeichen. -- Bjoern Hoehrmann (at de.comp.lang.perl.misc) % Re: Novice surprise Just don't create a file called -rf. :-) -- Larry Wall (at comp.lang.perl) % Re: one-line summations in perl. Hey, I had to let awk be better at *something*... :-) -- Larry Wall (at comp.lang.perl) % Re: Array modification rules (?) Perl itself is usually pretty good about telling you what you shouldn't do. :-) -- Larry Wall (at comp.lang.perl) % Re: Help with pattern recognition On Wed, 30 Jan 2002 23:20:15 GMT, Tad McClellan wrote: > Tassilo v. Parseval wrote: >> if (/\E$my_variable\Q/) > > The other way around: > > if (/\Q$my_variable\E/) Hmmh, must be a virus tormenting Germany remembering Find::File in a previous post not long ago. :-) Tassilo -- Tassilo v. Parseval (at comp.lang.perl.misc) % Re: script for report of 2 year old files Jürgen Exner wrote: > You should really have a close look at Find::File $_ = "You should really have a close look at Find::File\n"; s/(\w+)::(\w+)/$2::$1/; print; :-) -- Tad McClellan (at comp.lang.perl.misc) % Re: Script Critique Markus Dreyer wrote in comp.lang.perl.misc: >> if (SMonth eq 01) {ServerMonth="january";} > > The operator eq compares strings. 01 is not a string but a number And 09 is a syntax error. -- Rafael Garcia-Suarez (at comp.lang.perl.misc) % Re: script for report of 2 year old files >>>>> "Jürgen" == Jürgen Exner writes: Jürgen> You should really have a close look at Find::File And an even closer look at File::Find. :-) -- Randal L. Schwartz (at comp.lang.perl.misc) % Re: How to guarantee process ID stays with web connection Joe Moschak bravely attempted to attach 69 electrodes of knowledge to the nipples of comp.lang.perl.misc by saying: >How can I >make it so that each time I invoke my script from a given web session I get >the same PID instead of a different one? Easy. Put this line at the beginning of your script, and create a wrapper that runs it in a loop until it gets the "correct" pid. die "Please sir, may I have another PID?\n" if $$ != $Wanted_Pid; ;o) -- Teh (at comp.lang.perl.misc) % Re: Can someone recommend a beginner's book on Perl? >>>>> "Jeff" == Jeff Zucker writes: Jeff> Hmm, maybe you should have waited until the book came out to learn. Jeff> It would have been so much easier to learn then. But writing the book Jeff> might have been a bit more difficult if you'd done it in that order. Not if I get a visit from Professor Emmet Brown. print "Just another Perl hacker," # the original one, that is... -- Randal L. Schwartz (at comp.lang.perl.misc) % Re: c2perl In article , Jonas Nilsson wrote: > Is there a c to perl source convertor? Yes. It's called a programmer. -- Bernard El-Hagin (at comp.lang.perl.misc) % Re: How to open browser window without browser menubar, toobar, etc. Jerry wrote: > I want to send a response to a new pop-up browser window with no > menubar, toolbar, location features. > This is easy to do in the client browser with javascript using > window.open but how is it done in perl? Q: I want to talk to someone 3,000 miles away. This is easy to do with a telephone, but how is it done with a coffee mug? A: It isn't done with a coffe mug, use the telephone. -- Jeff Zucker (at comp.lang.perl.misc) % Re: Prob with symbolic reference to obj method stored in array mjd@plover.com (Mark Jason Dominus) writes: > In article , > Trahojen wrote: > >$stupid_obj->&$methods[0] > >or > >$stupid_obj->$methods[0]->() > > > >I prefer the latter one, it's art. > > They're both syntax errors. So it's abstract art then ;) -- Joe Schaefer (at comp.lang.perl.misc) % Re: open (MYFILE,"file1") doesn't work On Tue, 26 Feb 2002 14:27:04 +0100, Josef Möllers wrote: > Bernard El-Hagin wrote: >> >> On Tue, 26 Feb 2002 11:32:33 +0100, Josef Möllers >> wrote: > >> > Bernahrd already wrote what might be wrong. >> ^^^^^^^^ >> >> Who? :) > > I'm sorry. I seem to be having some timing problems between my left hand > and my right hand lately. I'ev nevre dha taht rpobelm mysefl. -- Bernard El-Hagin (at comp.lang.perl.misc) % Re: What do I edit Perl code with??? >> On 31 Jan 2002 16:11:22 -0800, >> yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) said: > Uri Guttman (uri@stemsystems.com) wrote: >> : i use cat. > as in $ cat > finished_file.pl > ? > Must require a lot of careful planning before hand. Uri is the result of a genetics experiment involving the cloning of Niklaus Wirth and Edsgar Dijkstra. Nothing else makes sense. :-) -- Tony Curtis (at comp.lang.perl.misc) % Re: What do I edit Perl code with??? "Malcolm Dew-Jones" wrote in message news:3c59dd2a@news.victoria.tc.ca... > Uri Guttman (uri@stemsystems.com) wrote: > : i use cat. > > as in > $ cat > finished_file.pl 'Real programmers use "cat > a.out" ' -- Jürgen Exner (at comp.lang.perl.misc) % Re: Good Windows editor for Perl In article <3cda4910$1@isls-news.wmin.ac.uk>, Ross Clement wrote: > Hi. What would people recommend as the best freeware editor for Perl > development on windows. It doesn't need to be Perl specific, just 'convenient'. > > At present I'm using MS-DOS 'edit', so anything better than that will > be a boost. What chair would you recommend as the best for Perl development? At present I'm using the floor, so anything better than that will be a boost. -- Bernard El-Hagin (at comp.lang.perl.misc) % Re: who took my question away and why? peter pilsl [comp.mail.sendmail] : > AvA wrote: > > The communists did it, I'm sure. > > They do it all the time. > Lately they've stolen 3GB of my new 80GB-hardrive too !!! That was your cat, posting to usenet when you are off getting coffee. -- Suresh Ramasubramanian (at comp.lang.perl.misc) % Re: cgi.pm code Accurately describing a problem is the first step to solving it. "Doesn't work" is the vaguest description imaginable. What should the program do that it does not? What is the program doing that it shold not? For example, I expect this code to replace "\n" with "
" in the values of some chosen CGI parameters. Instead, it leaves them untouched, and adds another parameter named "$thingy" whose value is always 4294967295. That's something to work with. | foreach $thingy(@display_items){ | param('$thingy' => ~ s/\n/
/g); | } -- Jay Tilton (at comp.lang.perl.misc) % Re: "perlfreak", "i love perl", "perllover" or...??? How about: package Perl; use less Python; use less TCL; use less VB; use less Java; use less Javascript; use less Shell; use less DebuggingTime; use less Memory; use less Effort; use less MaintenanceCost; use less PerSeatLicenseFees; use less Unportability; use less OfYourOwnCodeAndMoreOfTheCPAN; 1; :-) -- Randal L. Schwartz (at comp.lang.perl.misc) % Re: weird behaviour > # Variable Declarations > local ($usage, $arg, $option, %options, %describe, ) = (); local() does not declare variables. Putting a comment in front saying "Variable Declarations" won't alter this fact. -- Brian McCauley (at comp.lang.perl.misc) % Re: Beatles Perl Given the code snippets below, I can only conclude that the Fab Four were very early JAPHs: sub marine { 'yellow' } $we->can(work_it_out); time - 60 * 60 * 24; $she ne 'sweet' join('', @us), time() / $me; $week = 8 * 60 * 60 * 24; use LWP::Simple; get 'back'; my $life = 'you'; no where 'man'; perl -lane '$1 / 100' push @She::ISA, 'Woman'; print "strawberry fields\n" while 1; 1 + 1 + 1 == 3 Too bad Mrs. Wall didn't name him Russell instead of Larry, because then we would know who the "Wall, Russ" is. (good for me that you can't throw rotting vegetables via Usenet...) One of their titles appears verbatim in Subject headers all too frequently here: Subject: Help! Like, it's true Man! The Beatles were so connected to everything that you can find them everywhere. All you have to do is look hard enough :-) -- Tad McClellan (at comp.lang.perl.misc) % Re: Best Spam Mailer Module Test wrote: >What is the best spam mailer module for spam mails It is not possible to send mail using Perl. -- Tad McClellan (at comp.lang.perl.misc,comp.lang.perl.modules) % Re: FAQ: How do I find yesterday's date? PerlFAQ Server wrote: > 4.16: How do I find yesterday's date? sleep( - 24 * 60 * 60 ); $yesterday = time; -- Benjamin Goldberg (at comp.lang.perl.misc) % Re: Enclose double letters in quotes (last one for today!) On Mon, 09 Sep 2002 12:11:57 +0100, John W. Krahn wrote: > Anno Siegel wrote: >> >> "Teach a man to fish and he may feed himself. Give a man a fish and >> he'll ask you if you could please cook it for him while you're at it." >> >> ...and do the dishes afterwards. > > Give a man a fish and you feed him for a day. Teach a man to fish and he > spends all his time in the basement tying flies and neglecting his > personal hygiene. Light a man a fire and he'll be warm for a day. Throw a man on a fire and he'll be warm for the rest of his life. -- Dave Cross (at comp.lang.perl.misc) % Re: FAQ: How do I find yesterday's date? Benjamin Goldberg wrote: > PerlFAQ Server wrote: >> 4.16: How do I find yesterday's date? > > sleep( - 24 * 60 * 60 ); > $yesterday = time; Better yet: $yesterday = time; sleep(24*60*60); -- Steffen Mueller (at comp.lang.perl.misc) % Re: [fwd from comp.lang.python] Re: Python 2 ideas [Re: access functions vs. directly setting Tom Christiansen writes: : This is a bug in the Netscape web server. It looks for a valid HTTP : header on a merged stderr and stdout. This is fundamentally broken, : and not our fault. The Golden Gate wasn't our fault either, but we still put a bridge across it. Larry -- Larry Wall (at perl.porters-gw) % Re: Failed pipe open always exits? : Larry, any plans to teach Perl how to handle in/output redirection without : resorting to /bin/sh? Its easy enough to write in Perl so it may not be : worth adding (like better-than-csh globbing). Down that path lies madness. On the other hand, the road to hell is paved with melting snowballs. Larry -- Larry Wall (at comp.lang.perl) % Re: Octal chmod status What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against? -- Larry Wall (at comp.lang.perl) % Re: Version of id(1). That's not short. This is short: :-) #!/usr/bin/perl @n=('pwu','grg');sub n{local($n)=eval"get$n[$_[1]]id(\$_[0])";$n&&"($n)";}sub nm {$a-$b;}@gr=split(' ',$();$g=shift(@gr);$\="\n";print"uid=$<",&n($<)," gid=",$g, &n($(,1),(" euid=$>".&n($>))x($),(" egid=".$)+0 .&n($),1))x($(!=$)), (" groups=".join(',',sort nm grep(($_.=&n($_,1))||1,@gr)))x($#gr>=0); Though I'll admit readability suffers slightly... Larry -- Larry Wall (at comp.lang.perl) % Re: Counting characters with unix utilities Although the Perl Slogan is There's More Than One Way to Do It, I hesitate to make 10 ways to do something. :-) -- Larry Wall (at comp.lang.perl) % Re: unpack and endianness Because . doesn't match \n. [\0-\377] is the most efficient way to match everything currently. Maybe \e should match everything. And \E would of course match nothing. :-) -- Larry Wall (at comp.lang.perl) % Re: wishlist: current line number variable The only disadvantage I see is that it would force everyone to get Perl. Horrors. :-) -- Larry Wall (at comp.lang.perl) % Re: Bugs in -P and -I handling And don't tell me there isn't one bit of difference between null and space, because that's exactly how much difference there is. :-) -- Larry Wall (at comp.lang.perl) % Re: Need help with Perl : I find this a nice feature but it is not according to the documentation. : Or is it a BUG? Let's call it an accidental feature. :-) -- Larry Wall (at comp.lang.perl) % Re: Perl scripts sought : Can someone tell me just what Perl ***is***? I've seen lots of talk about it, : none of which gives the slightest idea what it actually is. Just like that : Satanic Verses book -- lots of news coverage, but no one actually gives a clue : what it's about or why certain groups are outraged by it. Certain groups outraged by perl? I hope not. Gulp... Anyway, you asked for it. I could go on all day about what perl is and bore you to tears. I'll attempt to restrain myself. Perl is a language that partially sacrifices one aspect of "Unix philosopy" (namely the toolbox approach) in order to collect many other aspects of "Unix philosophy" into one spot. Perl is a language for C programmers who want to do shellish, sedish and awkish things without having to write a spaghetti bowl full of pipes and obscure Unix commands. The toolbox approach has its place, but sometimes the solution in Perl is more readable than the corresponding solution in shell. I like it, but then, I'm just a little biased on that subject. :-) For more info, here's the hype paragraph from perl 3.0 (alpha). (Note that 3.0 isn't released yet--2.0 didn't handle binary data or dbm files.) Perl is a interpreted language optimized for scanning arbi- trary text files, extracting information from those text files, and printing reports based on that information. It's also a good language for many system management tasks. The language is intended to be practical (easy to use, effi- cient, complete) rather than beautiful (tiny, elegant, minimal). It combines (in the author's opinion, anyway) some of the best features of C, sed, awk, and sh, so people familiar with those languages should have little difficulty with it. (Language historians will also note some vestiges of csh, Pascal, and even BASIC-PLUS.) Expression syntax corresponds quite closely to C expression syntax. Unlike most Unix utilities, perl does not arbitrarily limit the size of your data--if you've got the memory, perl can slurp in your whole file as a single string. And the hash tables used by associative arrays grow as necessary to prevent degraded performance. Perl uses sophisticated pattern matching techniques to scan large amounts of data very quickly. Although optimized for scanning text, perl can also deal with binary data, and can make dbm files look like associative arrays (where dbm is available). Setuid perl scripts are safer than C programs through a dataflow tracing mechanism which prevents many stupid security holes. If you have a problem that would ordinarily use sed or awk or sh, but it exceeds their capabilities or must run a little fas- ter, and you don't want to write the silly thing in C, then perl may be for you. There are also translators to turn your sed and awk scripts into perl scripts. Perl 2.0 was distributed in comp.sources.unix. You can also ftp it from jpl-devvax.jpl.nasa.gov (128.149.8.43) at patchlevel 18. Version 3.0 will be available Real Soon Now, depending on how the Magellan shuttle launch (and my little part in it) goes. Well, that's enough for now, I think. Oh, to answer the question in the original article, one place to get sample perl scripts is in the perl distribution itself. Look in the eg subdirectory. Also, the regression tests are all written in perl. So is the sed-to-perl translator. Larry Wall lwall@jpl-devvax.jpl.nasa.gov -- Larry Wall (at comp.sources.d,comp.misc) % Re: Nuclear Weapons (UF vom Sontag) Perl ist der geglückte Versuch, einen braindump direkt ausführbar zu machen. -- Lutz Donnerhacke (at de.alt.sysadmin.recovery) % Re: Verrückte Perlhacks -- $|++;@_=map{chr(ord($_)-$|)}split//,"Kvtu!bopuifs!Qfsm!Ibdlfs-";$\="\r";@a=qw(< ^ > v);$§="_"x25;until($§!~m~_~){$o=int(rand 28)+65;next if$s{$o}++;$o==91?$o=44 :($o==92?$o=32:0);$g=chr$o;for(0..24){if($_[$_]=~m)$g)i){for$m(@a,$_[$_]){substr $§,$_,$|,$m;print$§;select$/,$/,$/,0.1}}}print$§}print$/ #http://tinita.de -- Tina Mueller (at de.comp.lang.perl.misc) % Re: Total Beginner >>>>> "SuperGumby" == SuperGumby writes: SuperGumby> OH, and reading this group daily (if only it wasn't quite so busy). SuperGumby> PS Why does it appear perl programmers are so damned obsessed with SuperGumby> oneliners, I'm feeling as if I'm gonna be ostracised for commenting and SuperGumby> structuring,,, maybe I'll know why in a few months :-) Because Perl's so durn easy to use we got time to play around impressing each other. :) -- Randal L. Schwartz (at comp.lang.perl.misc) % Re: RFC- DESTROY Part of what's confusing the issue is that DESTROY is a verb. It was done that way by analogy to FETCH and STORE, but the use of a verb is unfortunate, in retrospect. I should have named it something like YOU_ARE_ABOUT_TO_BE_SHOT_DO_YOU_HAVE_ANY_LAST_WORDS. -- Larry Wall (at perl.porters-gw) % Re: Idea: $^New : OK. Still, it'd be nice to get anonymous scalars somehow. The Huffman encoding of that is do{\my$x}. -- Larry Wall (at perl.porters-gw) % Re: grep/map in void context The argument against using an operator for other than its primary purpose strikes me the same as the old argument that you shouldn't have sex for other than procreational purposes. Sometimes side effects are more enjoyable than the originally intended effect. -- Larry Wall (at perl.porters-gw) % Bestimmtes Element im array loeschen Man kann natuerlich so lange poppen und das was dabei herauskommt auffangen und spaeter wieder hineinpushen, bis das gesuchte herauskommt -- Crian (at http://board.perl-community.de/cgi-bin/ikonboard/ikonboard.cgi?s=;act=Post;CODE=02;f=6;t=1022) % Re: Kuchen "Josef Möllers" wrote... >Ruchard Wagner wrote: > > >> Backen >> > As usual, TMTOWTDI, also, you do not write which cake, so we can't > really help, can we? I prefer the OO approach, that way you can just slot in a new baking method as needed.There's a great interface on CPAN called Cake::Baker that's a god-send for the culinary inept like myself (it's very much like the DBI interface). -- Matt Garrish (at comp.lang.perl.misc) % Re: Remove first character in a string? David Bouman wrote: > Koos Pol wrote: > >> chip() should make a fine opposite to chop() I find myself removing >> a first char regularly. > > Nah, that would imply having an opposite to chomp() as well, sub pmohc { # the anti-chomp $_[0] .= $/; } :-) -- Tad McClellan (at comp.lang.perl.misc) % Re: Why, oh why have I read "Perl 6 essentials"??? Uri Guttman wrote: >>>>>> "GS" == Garry Short writes: > > GS> Just on a casual note, because the more I read, the more impatient > GS> I get, are there any estimated timescales on when Perl6 will be > GS> available? > > next christmas (for some definition of christmas). So then, that would be: any('christmas') ? -- Tad McClellan (at comp.lang.perl.misc) % Re: [Golf] Querzahl Christian Lackas writes: > >>$ perl -le'$_=shift;1while s/(.)(.)/$1+$2/eg;print' 123456789 > > perl -le'$_=pop;$_=eval until!s/\B/+/g;print' 123456789 > perl -le'$_=pop().eval,until!s/\B/+/g;print' 123456789 > > Ich denke aber, dass alle beteiligten obigen Vorschlag gelten lassen, oder? Ist ja alles ganz eindrucksvoll. Wozu aber all die Verrenkungen, nur um an die Querziffer zu kommen? perl -le'print 1+(-1+pop)%9' 123456789 -- Mona Wuerz (at comp.lang.perl.misc) % Re: k operator in REGEX?? Abigail writes: > perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / > % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %; > BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}' I think my brain is melting. -- Charlton Wilbur (at comp.lang.perl.misc) % Re: shorten expression Jeff 'japhy' Pinyan wrote on MMMDCV September MCMXCIII in : )) On Tue, 15 Jul 2003, ZZT wrote: )) )) >is there a way to shorten this expression? )) > )) >$host=~/^(\S*)\s*/; $host=$1; )) )) Well, as it stands, even if the regex FAILS, $host will be set to whatever )) $1 was before the regex. But the only string on which the regexp can fail is a string that doesn't have a beginning. Now, in perl6, with lazy evaluation, we might be able to construct strings without an end. But how do I make a string without a beginning? -- Abigail (at comp.lang.perl.misc) % Re: The perl CD bookshelf Dave wrote: > I've lost my copy of "The perl CD bookshelf", any suggestions on what > I can do? Did you check your refrigerator already? According to a study a surprisingly large number of people find their lost TV remotes in the frigde. Maybe your book went the same way? -- Jürgen Exner (at comp.lang.perl.misc) % Re: shutdown or reboot computer Jochen Friedmann (jochen.friedmann2 (at) de.bosch.com) wrote on MMMDCLXVII September MCMXCIII in : __ Oh, sorry __ __ the OS is Win2000 or WinnNT Oh, fastest way to shutdown Win2000 from Perl that I know is: print "\t\t\b\b\b\b\b\b\b\b\b\b\b\b" while 1; Although this might be fixed with some patch. -- Abigail (at comp.lang.perl.misc) %