― Jonathan Williams (ex machina), Friday, 8 November 2002 16:40 (twenty-three years ago)
― nathalie (nathalie), Friday, 8 November 2002 16:50 (twenty-three years ago)
C and Assembly is the true way.
― Mr Noodles (Mr Noodles), Friday, 8 November 2002 16:53 (twenty-three years ago)
― michael (michael), Friday, 8 November 2002 16:56 (twenty-three years ago)
― Sarah (starry), Friday, 8 November 2002 17:14 (twenty-three years ago)
― Jonathan Williams (ex machina), Friday, 8 November 2002 17:17 (twenty-three years ago)
― Sarah (starry), Friday, 8 November 2002 17:19 (twenty-three years ago)
― Mr Noodles (Mr Noodles), Friday, 8 November 2002 18:24 (twenty-three years ago)
― Jonathan Williams (ex machina), Friday, 8 November 2002 18:29 (twenty-three years ago)
― Dan Perry (Dan Perry), Friday, 8 November 2002 19:00 (twenty-three years ago)
― Mr Noodles (Mr Noodles), Friday, 8 November 2002 19:29 (twenty-three years ago)
― Jonathan Williams (ex machina), Friday, 8 November 2002 19:38 (twenty-three years ago)
(I wrote a quine once for a programming assignment, I sweated blood over getting it to be exact char-for-char and was very proud of it, and then the tutor went, "What is this gibberish? You were only supposed to call your source code 'bla' and get it to cat the file 'bla', you idiot." I don't know if he realised that it did actually display its own source code as the question requested, I suspect he thought it was just a mass of random junk. Weep.)
ANYWAY, I am getting really smug and proud about being pitiful clueless dozeluser now, it might mean that nobody will give me a job and it might be crushing to admit that not only am I too nerdy to integrate into normal society but that I am entirely shit at the only thing I ever thought I might be any good at and no geeks want to know me either (and most of them are better with Real People too), but at least I'm not as tiresomely sanctimonious as some of the rabid linux advocates I've had to endure bitching through their 1337th conversation of the day about IP ranges, car engines or how k-rad they are for getting linux to run on a really shit old computer but how they really need to buy the newest shiniest most expensive gadgets out there anyway.
Although - on the strength of this post alone and in general too - I am pretty damn tiresomely sanctimonious and bitchy and I'm getting worse every day so, uh, please, please, someone kill me soon. (Yes, indie sceeeenes make me feel the same way too; no, quoting records on Teenbeat doesn't mean that any of them want anything to do with me either, and I can't even go, "oh well, they're all beardy and scary loners so NER," because, well, they aren't, but look at me. No, don't, it makes me nervous. Shyly coy and nervous, get in the sli*BANG* *innards spray everywhere*)
― Rebecca, mixing like a monkey, don't be coy and jumpy (reb), Friday, 8 November 2002 20:06 (twenty-three years ago)
Perl is all very well at what it does, but is such an ugly, nasty kludge it makes Fortran 77 look like a sensibly designed language in comparison. Haskell smacks down ML variants in any fite ever as well(if I'm refereeing anyhow)
― RickyT (RickyT), Friday, 8 November 2002 23:40 (twenty-three years ago)
R3PR4Z3|\|T.
PS J0R /-\LL 0\/\/|\|3|)
― N0RM4N PH4Y, Friday, 8 November 2002 23:58 (twenty-three years ago)
― N0RM4N PH4Y, Saturday, 9 November 2002 00:00 (twenty-three years ago)
― N0RM4N PH4Y, Saturday, 9 November 2002 00:02 (twenty-three years ago)
I often think of *xn*tters who might enjoy Ask A Drunk (I assume M Morris, whose return I was pleased to see, has been on both), and I was tempted to link from the euphemisms thread to the f*ce p*jama page, but then I remembered how scared I'd be if anyone of the people I was thinking of actually did turn up.
I will not be ontopic, dammit. Otherwise I will remember either that there's a very simple perl script that I should've done months ago and haven't and now I can't remember all the very basic perl I learnt last time or how much I hate my ex and his perl t-shirts and the fact he's probably infinitely happier than I am at any given moment. [Talking of obfuscated languages, someone needs to write a syntax-highlighting either-or matcher for my posts, they must be unreadable.]
(Though I have been quoted on perl mailing lists, hahaha. But unsurprisingly not for perl gurudom, just an offhand moment of angst that bizarrely and embarrassingly ended up in a proper perl guru's sig.)
― Rebecca (reb), Saturday, 9 November 2002 00:20 (twenty-three years ago)
PH34R TEH N0RM4N SK!LLZ... PH4Y R0X0RZ J00R PUNY B0X3N, F3WLIOZ~$%^*)~
Erm, yes. Where was I? w00t, an' all that.
― Rebecca (reb), Saturday, 9 November 2002 00:27 (twenty-three years ago)
― RickyT (RickyT), Saturday, 9 November 2002 01:09 (twenty-three years ago)
― Dave Fischer, Saturday, 9 November 2002 01:24 (twenty-three years ago)
R, I know what you mean about *xn*tt*rs and FAD. I'd be verrrry worried about any of the pedant mob turning up here, even if a C*l*n B*tch*l*r versus combined mass of ILX intellect might be v.funny.
― RickyT (RickyT), Saturday, 9 November 2002 01:38 (twenty-three years ago)
As for "the greatest", well, I do like C. I'm not too familiar with x86 Assembler, but 6800 assembler is pretty nice. (I wrote a Nintendo game with it once) Whoever said Haskell is good in any way should perish in a firey inferno. I'm a firm believer that you're only pitiful if you can't pick up whatever language you need to do the job.
Rebecca, knowing that you're a) female, b) able to code, and c) able to code in Brainfuck, makes you extremely attractive. To me at least. God, I suck.
― Andrew (enneff), Saturday, 9 November 2002 02:13 (twenty-three years ago)
― RickyT (RickyT), Saturday, 9 November 2002 02:28 (twenty-three years ago)
Not only that, but you have to do mental hurdles to put yourself into the 'Haskell Mindset' - procedural/imperitive/oo languages more closely mirror my mental process.
― Andrew (enneff), Saturday, 9 November 2002 03:26 (twenty-three years ago)
Somehow I suspect "occasionally taking about 300 times longer than should be necessarily to kludge together broken Visual Basic and running in fear from real languages" doesn't sound very attractive at all. In fact, I have yet to think of anything about me that does. But why do I correct people who'll never meet me anyway? Ahem. YES I am the world's greatest and not a feeble braindead dropout who can't get a job at all. I am also stunningly beautiful and fascinating and fun to be around, which is why my entire life consists solely of sitting around all alone boring people to death on the internet. Mmm CATCH.
― Rebecca (reb), Saturday, 9 November 2002 03:32 (twenty-three years ago)
― ron (ron), Saturday, 9 November 2002 03:35 (twenty-three years ago)
― Rebecca (reb), Saturday, 9 November 2002 03:45 (twenty-three years ago)
'grok' means 'understand', basically.
― Andrew (enneff), Saturday, 9 November 2002 04:44 (twenty-three years ago)
― Queen G (Queeng), Saturday, 9 November 2002 10:02 (twenty-three years ago)
I am also stunningly beautiful and fascinating and fun to be around
At least two of these are true.
― Graham (graham), Saturday, 9 November 2002 15:04 (twenty-three years ago)
why can't i be a master programming genius? why why why why why???
― sand.y, Saturday, 9 November 2002 21:29 (twenty-three years ago)
― RickyT (RickyT), Saturday, 9 November 2002 22:44 (twenty-three years ago)
(For those who don't already know: programming is a significant part of my job, too, but I am not fool enough to think it makes me cool.)
― Martin Skidmore (Martin Skidmore), Saturday, 9 November 2002 23:17 (twenty-three years ago)
Sod off. If ilxor was written in Haskell, the server would have keeled over and died a long, long time ago. The efficiency benefits of Assembler over C are quite small, whereas those of C over Haskell are massive. Just out of interest, what do you actually use Haskell for?
― Andrew (enneff), Sunday, 10 November 2002 02:00 (twenty-three years ago)
― Graham (graham), Sunday, 10 November 2002 20:58 (twenty-three years ago)
"Bloody build processes!"
er
"I really think I am being underpaid!"
"ERROR REDO FROM START!"
Back to the photocopying then.
― Sarah (starry), Monday, 11 November 2002 10:31 (twenty-three years ago)
― kingfish maximum overdrunk (Kingfish), Wednesday, 18 May 2005 04:04 (twenty years ago)
― lyra (lyra), Wednesday, 18 May 2005 04:24 (twenty years ago)
― kingfish maximum overdrunk (Kingfish), Wednesday, 18 May 2005 04:29 (twenty years ago)
― Ed (dali), Wednesday, 18 May 2005 05:03 (twenty years ago)
― kingfish maximum overdrunk (Kingfish), Wednesday, 18 May 2005 05:22 (twenty years ago)
m.
― msp (mspa), Wednesday, 18 May 2005 05:22 (twenty years ago)
not if you have active state installed, you can just run it locally. i learnt perl on my win98 box. (or doesn't windows come with a command line anymore?).
(i'd install cygwin so at least you don't have to suffer the dos command line)(i'd also learn php rather than perl, you still have all the associative arrays and stuff but the syntax is easier)(the other big problem that i've seen people have with all this stuff is knowing how to edit files (using text editor, not some wysiwysg thing) and where the files actually are (because windows abstracts this too much, encourages you to stick them all on the same disk as the operating system = madness))
― koogs (koogs), Wednesday, 18 May 2005 06:59 (twenty years ago)
If you really want a shell account and don't want to set up and administer a linux box yourself (not too hard, but securing it at the start can be a bitch), I'll recommend itshosted.com -they provide web hosting space, but you can get ssh access to it and goof around. The big advantage then is that they have to worry about all the security patches, not you.
― lyra (lyra), Wednesday, 18 May 2005 13:23 (twenty years ago)
cygwin + active state perl are a bit iffy together if i recall. path issues perhaps? active state perl wanting windows paths and cygwin bash wanting *nix style paths. use google and double check before you pull your hair out. if i'm on my xp box, i usually just use the dos command line. it sucks, yes, but sometimes you do what you have to do. i run fedora on another machine, but it's cumbersome sometimes to have to use remote tools, etc. (yeah yeah yeah, i know there are a gajillion work arounds like samba+ssh... if i spent more time hackin perl i might care.)
my personal top 5 favorite (aka most used) perl things to know:1. regular expressions and those sed/awk like operators2. hashes and lists and combinations of those two things (LoL and HoL and LoH, etc etc)3. split/join/string manip functions4. HEREDOCUMENTS5. pushpopshiftunshiftsplice array manip fuctions
i use all of those things in almost every perl script i write.m.
― msp (mspa), Wednesday, 18 May 2005 13:50 (twenty years ago)
Doesn't cygwin come with its own version of Perl anyway? It's probably not in the default install, but I think it's in there somewhere.
― caitlin (caitlin), Wednesday, 18 May 2005 14:12 (twenty years ago)
the only reason i like here docs is that if you've got extensive text to output, it's so much more trivial than a ton of prints, so much more efficient than string building, etc etc.
but yeah, probably the biggest source of errors ever.
i'm curious tho, any suggestions for handy ways not to use here docs? if there's a wiser solution, please share.m.
― msp (mspa), Wednesday, 18 May 2005 14:25 (twenty years ago)
― Gravel Puzzleworth (Gregory Henry), Wednesday, 18 May 2005 14:28 (twenty years ago)
The main reason I don't like them, I guess, is that they mess up the auto-formatting in Emacs Perl mode. See also: output formats (which I've generally found more useful, but have the same problem).
― caitlin (caitlin), Wednesday, 18 May 2005 14:28 (twenty years ago)
― Ken L (Ken L), Wednesday, 18 May 2005 14:31 (twenty years ago)
― msp (mspa), Wednesday, 18 May 2005 14:36 (twenty years ago)
― Casuistry (Chris P), Wednesday, 18 May 2005 15:44 (twenty years ago)
― jaymc (jaymc), Wednesday, 18 May 2005 15:45 (twenty years ago)
― msp (mspa), Wednesday, 18 May 2005 16:08 (twenty years ago)
</fucking hipster programmer elite, and this "l33t" garbage is for children. shuh>
― donut fucking programming hipsterfuck (donut), Wednesday, 18 May 2005 16:19 (twenty years ago)
― koogs (koogs), Wednesday, 18 May 2005 16:23 (twenty years ago)
Perl is great to learn, and it won't be waste of time ever, but as far as conventional web jobs go, not too many of them use Perl heavily on a regular basis. There are major exceptions.. Amazon.com for instance. If Perl is used in anything at this point, it's mainly with PHP/MySQL stuff.. and even then, programming language marriage last as long as human marriages do i.e. not too long.
I do actually recommend at least a cursory book on Javascript and a book on CSS, as both of those get used heavily in web development these days (if the goal is to get a web development job). Just keep in mind that every permutation of browser X platform is going to behave different for each basic use of CSS or Javascript.. The O'Reilly books do a pretty good job at keeping up to date with these little gotchas, if you always get the latest edition of these books.
But those gotchas are not going to go away anytime soon, so get used to them. Knowing the gotchas is more than half the battle, in many cases.
Also, some cursory book on XML would be helpful.. or even just a good XML tutorial. It's becoming used in almost every application, no matter how vague the purpose. It's also easy as fuck to learn if you already know HTML (which, retrogressively, is an instance of XML anyway)
Sure, there is ASP, PHP, etc. but I think these are best referred to online than being purchased, as learning the above will prepare you to learn these guys pretty damn quickly.
Actually, if you enjoy programming languages, you'll find almost any web programming language easy.
Getting into a career of tech development, my recommendation is to take courses in C++... NOT C#, C++. It's VERY important to learn what pointers are. People are graduating from Comp Sci programs without knowing what a pointer is.. this is a problem for this specific career path, IMHO.
er, who said anything about writing web pages? some of us actually use perl for reports and file munging.
You're absolutely correct. However, given that Perl is great for manipulating/evaluating text and regular expressions, and given that the standard for web programming are text based atoms, Perl is often said in the same breath as web programming.
― donut debonair (donut), Wednesday, 18 May 2005 16:28 (twenty years ago)
― msp (mspa), Wednesday, 18 May 2005 16:29 (twenty years ago)
― donut debonair (donut), Wednesday, 18 May 2005 16:33 (twenty years ago)
perl just has wide ranging abilities and in *nix land, i'd rather use perl over c, c++, and java. (well, depends on the app i guess.) but for many things, perl just gets you much farther, much faster.
i find it hard to believe comp sci grads aren't learning about pointers. that's a crime. even tho i've barely ever used one in my professional career, that's still a level of ignorance about how things work below that seems shameful. everybody should have to slave through at least one semester of assembly language and/or C/C++. if not more than one semester!m.
― msp (mspa), Wednesday, 18 May 2005 16:40 (twenty years ago)
The obvious use of output formats is to format plain-text tables, but you can use them for other things to. The first thing that comes to mind out of what I've done with them myself: producing invoice emails.
The most recent sizeable thing I've been doing with Perl has been all about Win32::OLE - reading data from a Lotus Notes database and creating an Excel workbook containing reports on the data.
― caitlin (caitlin), Wednesday, 18 May 2005 17:56 (twenty years ago)
yeah... it's non-default, but it's there.the only reason i like here docs is that if you've got extensive text to output, it's so much more trivial than a ton of prints, so much more efficient than string building, etc etc.
i'm curious tho, any suggestions for handy ways not to use here docs? if there's a wiser solution, please share.
Do you know how to use qq() and qw()? Instead of my $stuff =
― lyra (lyra), Thursday, 19 May 2005 02:22 (twenty years ago)
instead of my $stuff = < <ENDsomethingsomethingEND
you can use qq like so:
my $stuff = qq(somethingsomething else);
― lyra (lyra), Thursday, 19 May 2005 02:25 (twenty years ago)
― Rufus 3000 (Mr Noodles), Thursday, 19 May 2005 02:35 (twenty years ago)
perl will always be helpful because you will always have big stupid documents with semi-regularly formatted text where you need to extract and munge it in simple but bizarre ways to make it usable.
i'm going to be working on a project li ke that tomorrow -- grabbing lotsa stuff from similar but somewhat distinct static html documents and throwing it into sql so it can be served up all dynamic and pretty-like. so a perlscript that i write once and use once is still way better than crawling through that whole mess by hand.3
― Sterling Clover (s_clover), Thursday, 19 May 2005 02:39 (twenty years ago)
― Sterling Clover (s_clover), Thursday, 19 May 2005 02:40 (twenty years ago)
― lyra (lyra), Thursday, 19 May 2005 02:48 (twenty years ago)
― Stormy Davis (diamond), Thursday, 19 May 2005 03:05 (twenty years ago)
And I really like Perl a lot. Oh, that reminds me that I downloaded Scheme recently! Not that I really have time to learn it, so much.
― Casuistry (Chris P), Thursday, 19 May 2005 05:55 (twenty years ago)
Do you know how to use qq() and qw()?
i know qq and qw but have generally used it only when i'm quoting and double quoting in the text too much.
i miss emacs. even with a linux box, i've been in windows land too long... (and somewhat stuck with visual studios and textpad and so on.)
i rarely fuss with set ups. too many tools, not enough time to tweak them. (because i obviously spend too much damned time on message boards! doh!)
i need to write a bot to post for me here so i can get my shit in order. lwp...
I downloaded Scheme recently
scheme is cool. our intro to cis class (the first core class in the cis dept) was almost all scheme. it's a shame i haven't touched it since. i'd be interested to see what's come of it and lisp in recent years now that lisp especially has gotten all trendy/cool in some circles. unfortunately, it's all libraries that really affect whether or not i get to play with something.m.
― msp (mspa), Thursday, 19 May 2005 07:12 (twenty years ago)
It does work on Windows too, you know. I use it for all my Perl-on-Windows developing.
― caitlin (caitlin), Thursday, 19 May 2005 10:28 (twenty years ago)
i may have to download it anyway though.m.
― msp (mspa), Thursday, 19 May 2005 12:55 (twenty years ago)
unfortunately, they also wanyt $36 to use their compiler resources...
anybody know anyplace else? most of the places i've checked from here:
http://www.ductape.net/~mitja/freeunix.shtml
aren't accepting new accounts right now...
― kingfish maximum overdrunk (Kingfish), Friday, 20 May 2005 03:31 (twenty years ago)
― A homunculus of Darby Crash, .... created for the purposes of *EVIL* (ex machina, Friday, 20 May 2005 05:14 (twenty years ago)
― kingfish maximum overdrunk (Kingfish), Friday, 20 May 2005 05:58 (twenty years ago)
― lyra (lyra), Friday, 20 May 2005 14:10 (twenty years ago)
ouch! back in the day, they didn't charge. used to have an account with them 5 or 6 years ago.m.
― msp (mspa), Friday, 20 May 2005 14:15 (twenty years ago)
this is bringing back bad memories of 5+ years ago, repeatedly editing thru my .cshrc file...
― kingfish maximum overdrunk (Kingfish), Saturday, 21 May 2005 04:36 (twenty years ago)
― koogs (koogs), Saturday, 21 May 2005 16:52 (twenty years ago)
― Mr. Snrub (Mr. Snrub), Saturday, 21 May 2005 18:32 (twenty years ago)
― caitlin (caitlin), Saturday, 21 May 2005 18:43 (twenty years ago)
use Strict;scoping rulesOO
― jw, Saturday, 21 May 2005 18:44 (twenty years ago)
― caitlin (caitlin), Saturday, 21 May 2005 21:27 (twenty years ago)
I wish I knew. Maybe if could forget some perl I could remember useful stuff, like where in the parking garage I parked my car last night.
― lyra (lyra), Sunday, 22 May 2005 00:10 (twenty years ago)
― Casuistry (Chris P), Sunday, 22 May 2005 07:19 (twenty years ago)
― caitlin (caitlin), Sunday, 22 May 2005 08:29 (twenty years ago)
― lyra (lyra), Sunday, 22 May 2005 15:40 (twenty years ago)
haha, DID YOU KNOW: that the perl people are trying to AUTOMATE perl5-%gt;6 conversion of code?
Perl6 will be cool because of the parrot VM. I wonder if someone is working on getting gcc to target it as well....?
― A homunculus of Darby Crash, .... created for the purposes of *EVIL* (ex machina, Sunday, 22 May 2005 16:41 (twenty years ago)
― caitlin (caitlin), Sunday, 22 May 2005 19:38 (twenty years ago)
― k/l (Ken L), Wednesday, 20 July 2005 16:59 (twenty years ago)
― k/l (Ken L), Wednesday, 20 July 2005 20:31 (twenty years ago)
― mikef (mfleming), Wednesday, 20 July 2005 20:34 (twenty years ago)
split;
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Wednesday, 20 July 2005 20:37 (twenty years ago)
― kingfish (Kingfish), Wednesday, 20 July 2005 20:38 (twenty years ago)
― k/l (Ken L), Wednesday, 20 July 2005 20:41 (twenty years ago)
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Wednesday, 20 July 2005 20:48 (twenty years ago)
In any case, if you need to provide an EXPR to split, you're forced to give it a pattern, aren't you?
split /PATTERN/, $foobar
If you give it " " for the /PATTERN/, it behaves properly. Other things might give a spurious extra first field because of leading whitespace, leave on carriage returns, newlines, etc.
― k/l (Ken L), Wednesday, 20 July 2005 21:01 (twenty years ago)
If you give it " " for the /PATTERN/, it behaves properly. Other things might give a spurious extra first field because of leading whitespace, leave on carriage returns, newlines, etc.Err isn't it *the other way around?*
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Wednesday, 20 July 2005 21:03 (twenty years ago)
― k/l (Ken L), Wednesday, 20 July 2005 21:16 (twenty years ago)
split , EXPR
But see also page 796.
― k/l (Ken L), Wednesday, 20 July 2005 21:21 (twenty years ago)
Heh. Write once, get assigned to another project, pretend you are deaf when you hear 'point release' coming your way.
I write most of my regexen with | as a delimiter, good one to use if you always are parsing URLs. Also, we were a little goofy at lunch the other day and discussing data structures in perl and I had to lament the lack of stacks in perl. My dog goes to work with me, so he sits under my desk while I program, and our running joke is that his favorite data structure is stacks of milkbones. But in perl he has to settle for references to milkbones, not nearly as satisfying. (Yes, we are sick, smack me now.)
― lyra (lyra), Thursday, 21 July 2005 01:39 (twenty years ago)
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Thursday, 21 July 2005 01:40 (twenty years ago)
― lyra (lyra), Thursday, 21 July 2005 01:44 (twenty years ago)
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Thursday, 21 July 2005 01:46 (twenty years ago)
― lyra (lyra), Thursday, 21 July 2005 01:49 (twenty years ago)
― lyra (lyra), Thursday, 21 July 2005 01:55 (twenty years ago)
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Thursday, 21 July 2005 02:11 (twenty years ago)
― Trayce (trayce), Thursday, 21 July 2005 02:14 (twenty years ago)
If you just look at it, it looks like it's changing the type of @array to a scalar or something, not counting its size. Perl in built-in-obfuscation shocker.
― lyra (lyra), Thursday, 21 July 2005 03:05 (twenty years ago)
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Thursday, 21 July 2005 03:07 (twenty years ago)
― lyra (lyra), Thursday, 21 July 2005 03:13 (twenty years ago)
― msp (mspa), Thursday, 21 July 2005 03:25 (twenty years ago)
― kingfish (Kingfish), Thursday, 21 July 2005 03:27 (twenty years ago)
kingfish -- the new Pirates? I loved the old one to the point where I kept around my Tandy 1000 till like 1999 so I could get better sound and gfx out of it (versus a 386 or P100 or P266).
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Thursday, 21 July 2005 03:31 (twenty years ago)
$#array gives you the index of the last element. That's one less than scalar @array. I love foreach too, but sometimes in drawing applications you need to know, say, how many search results rows you've got in your array to print out 'Found 88 items' or whatever- the scalar @array syntax is perfect for that. Or a quickie test to tell if you have anything in the errors array after an eval:
eval { $results = do_some_sketchy_function_that_might_die(); };
if (scalar $@) {print "sorry sucker i died on you";}
― lyra (lyra), Thursday, 21 July 2005 03:33 (twenty years ago)
die "sorry sucker i died on you";
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Thursday, 21 July 2005 03:34 (twenty years ago)
sure...
$#array has other strange uses like:
$#array = 20;
hey, but this is perl .... "There's more than one way to do it." i can dig your scalar usage.
seems like foreach is also pretty blahtastic for assignments ...seems like i recall there being scope issues. it's sugar sweet tho.
i can dig perl's unspoken nature... but i tend to code very explicitly. relying on all the hidden variables gets nightmarish later on.
does anybody know, is there performance bonuses to relying on fun stuff like $_ and so on? i could see a little less namespace clutter equaling less memory... less to parse = quicker... shorter, smaller, etc... but i wonder if there's any significant difference between the processing times of two different programmers essentially writing the same code... explicit vs. implicit...
?m.
― msp (mspa), Thursday, 21 July 2005 04:34 (twenty years ago)
I think.
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Thursday, 21 July 2005 04:38 (twenty years ago)
― msp (mspa), Thursday, 21 July 2005 04:40 (twenty years ago)
― Casuistry (Chris P), Thursday, 21 July 2005 04:54 (twenty years ago)
And lo, the computer expert has spoken!
Casting between arrays and non-array types is one of the most frequent operations when dealing with arrays - at least with all the code I've ever written or looked at. You might want to try learning about array-pointer equivalence sometime. And, of course, the even-more-correct answer is that you can cast any type to anything else - you're just not guaranteed to get any meaningful result.
Should I bother to learn C?
Yes. It's a good language to learn, although I don't know how useful it is for creating Mac applications. You might want to learn the basics of C and then try moving on to Objective C.
― Forest Pines (ForestPines), Thursday, 21 July 2005 05:27 (twenty years ago)
― Casuistry (Chris P), Thursday, 21 July 2005 05:31 (twenty years ago)
Oh come on fuck off, I took computer science 173 also! You can define a cast function for anything, but what MEANING does assigning an array to an int have. (YES I KNOW INT[] IS ACTUALLY INT*)
C is essentially a bunch of crap built up on top of assembly language macros. The Objective C classes for OSX are very powerful and similar to the Java class library in functionality. I have played with it, but haven't had a need to develop a real application ever.
C is used a lot of places but most people developing their own stuff now should steer clear IMHO. I mean --- there are fucking computer science programs that have stopped using it completelt (insane IMHO).
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Thursday, 21 July 2005 05:47 (twenty years ago)
Assigning an array to an int: not useful.
Assinging an array to a pointer: very useful.
(YES I KNOW INT[] IS ACTUALLY INT*)
Stop talking crap then.
― Forest Pines (ForestPines), Thursday, 21 July 2005 06:30 (twenty years ago)
I'm trying to stop using $#array for two reasons:
a) I can never remember which is less, $#array or scalar @array. Just dealing with one will make life easier.
b) I'm trying *now* to stop using syntax that's not in Perl6. $#array is going.
Well what else would it do? How can you convert an array to a scalar?
Returning the number of elements seems obvious with hindsight. It's not, though. Why should scalar @array return the length and not the highest valid index like $#array does? If you're coming from C/C++, returning an array reference would be the obvious implementation. For that matter, why shouldn't scalar @array do the same as scalar %hash?
― Forest Pines (ForestPines), Thursday, 21 July 2005 06:34 (twenty years ago)
C is good for learning more how a computer does things, like they said, it's little more than a bunch of functions on top of assembler. that said, sometimes you don't need to know how a computer does things. which is why its less fashionable these days (and why i see a lot of people brought up on java having trouble with, say, bitwise operators). C's lack of standard stuff like hashes and vectors annoys me though (although gnu libraries help)
if you know perl but want to write 'applications' then have a look at tk/tcl which basically lets you get stuff on screen (windows, file choosers etc) and has a perl binding. failing that i'd say java (which is transferable to other machines) or objective c. (is glade available on mac?)
― koogs (koogs), Thursday, 21 July 2005 07:36 (twenty years ago)
is glade available on mac?
Probably, but I wouldn't like to say so for sure. Given that GTK works and libxml (presumably) works, I don't see why not.
― Forest Pines (ForestPines), Thursday, 21 July 2005 07:43 (twenty years ago)
mono / gtk# / glade on a mac
― koogs (koogs), Thursday, 21 July 2005 09:43 (twenty years ago)
Rule #1 of good coding: don'to optimize (yet)
The compiler knows enough to turn mult and div by powers of two into bits shifts.
(Yes I know there are other reasons to use them, but I see this all the time.)
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Thursday, 21 July 2005 10:48 (twenty years ago)
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Thursday, 21 July 2005 10:49 (twenty years ago)
I'll put it this way- if you care about that infimestimal speed difference, you're on the wrong language. Even mod_perl is slow as all get out. When you need things super fast, go use C. But when you're writing web apps, you can get away with perl, because the slowness of using perl is tiny compared to the time to make the http requests. If you're using a mod_perl server on a well tuned apache web server, you'll be fast enough in comparison to the time to travel over the network.
don't you mean:die "sorry sucker i died on you";
Not really- I use eval when I suspect something might die on me, but I don't want the whole webpage/perl script to be taken down by it. So I'd throw a warning that something isn't available and then carry on. There's not too much of a point in catching dies in evals and then dying yourself right after- even if you want a custom _DIE_ handler, you can just overload that directly & save yourself the trouble of eval'ing.
― lyra (lyra), Thursday, 21 July 2005 14:38 (twenty years ago)
― lyra (lyra), Thursday, 21 July 2005 14:40 (twenty years ago)
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Thursday, 21 July 2005 14:51 (twenty years ago)
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Thursday, 21 July 2005 14:52 (twenty years ago)
― lyra (lyra), Thursday, 21 July 2005 15:04 (twenty years ago)
― OLD SPICE® CHEMTRAILS!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (ex machina), Thursday, 21 July 2005 15:11 (twenty years ago)
― k/l (Ken L), Wednesday, 10 August 2005 17:16 (twenty years ago)
Perl5 is in C, at least. Perl6 might be in C++; I'm not 100% sure on that.
― Forest Pines (ForestPines), Wednesday, 10 August 2005 17:18 (twenty years ago)
Apparently it's sparked a lot of interest in Haskell. Just thinking about it breaks my brain a little, since I thought of a number-crunching mini-task to throw together in Hugs recently, until after 20 minutes and much garbage collection and not very many iterations I decided to do it in perl, which gave me an answer in a split second. My fault for not thinking about efficiency, sure, but... well, ouch.
Oh yeah, the more official perl 6 development work is on the Parrot project, which I think is still written in C, but it's at this point that I stop even being able to pretend I know what I'm talking about, and I only wanted to mention the Haskell thing to amuse and horrify the people here who've used it.
― Rebecca (reb), Wednesday, 10 August 2005 20:23 (twenty years ago)
― Rebecca (reb), Wednesday, 10 August 2005 20:27 (twenty years ago)
What is the difference between: ($thing) = @_and $thing = @_ ?
― Gravel Puzzleworth (Gregory Henry), Saturday, 15 April 2006 19:41 (nineteen years ago)
― Fight the Real Enemy -- Tasti D-Lite (ex machina), Saturday, 15 April 2006 19:51 (nineteen years ago)
― Gravel Puzzleworth (Gregory Henry), Saturday, 15 April 2006 19:56 (nineteen years ago)
― Gravel Puzzleworth (Gregory Henry), Saturday, 15 April 2006 19:59 (nineteen years ago)
― shieldforyoureyes, Sunday, 16 April 2006 12:37 (nineteen years ago)
You have #1 right, but a clearer answer would be: it behaves the same as $thing = $_[0]
#2 is wrong; $thing isn't a list. It assigns the length of @_ to $thing, because the left-hand side puts the expression into scalar context. You're thinking of $thing = \@_
― Forest Pines (ForestPines), Sunday, 16 April 2006 13:56 (nineteen years ago)
― Forest Pines (ForestPines), Sunday, 16 April 2006 13:59 (nineteen years ago)
― the unbearable lightness of peeing (orion), Sunday, 16 April 2006 16:22 (nineteen years ago)
― Casuistry (Chris P), Sunday, 16 April 2006 16:58 (nineteen years ago)
http://www.ozonehouse.com/mark/blog/code/PeriodicTable.png
― mikef (mfleming), Sunday, 16 April 2006 17:21 (nineteen years ago)
Another question: how clever is perl about $_? Like, if I have an implicit for loop, and I call a sub from it, presumably the sub can't have anything that alters $_ in it, such as another implicit for loop?
― Gravel Puzzleworth (Gregory Henry), Sunday, 23 April 2006 18:17 (nineteen years ago)
― Gravel Puzzleworth (Gregory Henry), Sunday, 23 April 2006 18:27 (nineteen years ago)
As to the first question: yes, you can, in that case. This is because foreach loops are special (I assume you meant foreach rather than for, because for doesn't use implicit $_) in that the iterator returns to its previous value after the loop is finally exited.
― Forest Pines (ForestPines), Sunday, 23 April 2006 18:46 (nineteen years ago)
― Tracey Hand (tracerhand), Sunday, 23 April 2006 18:51 (nineteen years ago)
― Forest Pines (ForestPines), Sunday, 23 April 2006 18:51 (nineteen years ago)
-- Gravel Puzzleworth (mostlyconnec...), April 23rd, 2006 8:17 PM. (Gregory Henry) (later)
but doesn't passing parameters to a sub already alter $_? Or at least @_? -- Gravel Puzzleworth (mostlyconnec...), April 23rd, 2006 8:27 PM. (Gregory Henry) (later)
Passing parameters only alters @_, not $_ As to the first question: yes, you can, in that case. This is because foreach loops are special (I assume you meant foreach rather than for, because for doesn't use implicit $_) in that the iterator returns to its previous value after the loop is finally exited.
A
-- Forest Pines (il...), April 23rd, 2006 8:46 PM. (ForestPines) (later)
You're just playing a geekx0r version of Mornington Crescent, aren't you.
― Markelby (Mark C), Sunday, 23 April 2006 20:01 (nineteen years ago)
It could be worse - Perl really does have some bizarre hidden corners.
― Forest Pines (ForestPines), Sunday, 23 April 2006 20:06 (nineteen years ago)
― jinx hijinks (sanskrit), Sunday, 23 April 2006 20:34 (nineteen years ago)
― JW (ex machina), Monday, 24 April 2006 03:12 (nineteen years ago)
I'm guessing this should be simple for someone who actually knows perl (i.e. not me): I'm trying to search a string like this:
blah blahblahblah blahblah 1.1&1.8&2.5&3.3blah blah
― Leee, Thursday, 12 July 2007 21:37 (eighteen years ago)
end your regexp with /g for all matches
http://perl.active-venture.com/pod/perlretut-usingregexp.html
alternatively split on & then check each of the results?
― koogs, Friday, 13 July 2007 10:37 (eighteen years ago)
Smalltalk 4evah!
― anatol_merklich, Friday, 13 July 2007 11:02 (eighteen years ago)
New question. I've built a database of documents that includes past versions, e.g.:
Doc001 document description V0.1 Doc001 document description V0.2 Doc001 document description V1.0 Doc002 document description V0.1
(Tab-delimited.)
However, I sort each line in the list as a string, so when the document description changes, it can alter the order of the documents like so:
Doc001 dacument description V1.0 Doc001 document description V0.1 Doc001 document description V0.2
Do I need a hash? I'm not very good with those.
― Leee, Tuesday, 2 October 2007 23:48 (eighteen years ago)
It's not so much that you need a hash as that you need a data structure of some sort. And yes, in Perl, hashes are pretty much the the data structure, especially when dealing with string and numerical data. You'll probably need a few foreach() loops to unwind the data in preferred order, coupled with sort, and so on.
If you have a huge amount of data, then the right thing to do is probably to ASCII-encode the data with fixed-length fields so that the sort order corresponds with ASCII order.
― libcrypt, Wednesday, 3 October 2007 00:18 (eighteen years ago)
OK this one hopefully has a quick and easy answer.
I have a hash of arrays of hashes, e.g. a bunch of data of a bunch of people. The first classifying criteria is gender. Each gender is an array of entries, with each entry including multiple key/value pairs (female #124: height, weight, bust size, etc.). How do I figure out how many women and how men are in the list -- without using loops?
― Leee, Wednesday, 30 April 2008 20:35 (seventeen years ago)
Use loops. This ain't no relational data structure, dude.
― libcrypt, Wednesday, 30 April 2008 20:55 (seventeen years ago)
$count = scalar keys %hash;
― f. hazel, Wednesday, 30 April 2008 21:11 (seventeen years ago)
I kind of hate sigils in Perl. Ruby's sigil's as explicit scoping is better imo
― Catsupppppppppppppp dude 茄蕃, Wednesday, 30 April 2008 21:22 (seventeen years ago)
Hm, I forgot about the scalar function and am now wondering if it's bad form to throw in an explicit call to scalar to stop future generations scratching their heads at a particularly inscrutable (to the non-perl-grokker like the coworker most likely to need to change the script in a hurry) implicit forcing of scalar context.
(Or I could just write two lines of comments, or turn 1 line of code into 3 with needless intermediate variable)
― a passing spacecadet, Wednesday, 30 April 2008 21:46 (seventeen years ago)
Hi again. I'm parsing a text file for certain keywords (let's call them "alpha," "beta", "gamma"), and for convenience sake, I use a local hash to hold those parameters. (E.g. $hash{alpha} = some value.) I want all of these parameters to be defined before I return from the subroutine, so I have
while ( !(defined $hash{alpha}) or !(defined $hash{beta}) or !(defined $hash{gamma}))
But now, depending on certain conditions, I might want to look for additional keywords (e.g. "delta", "epsilon"). Assuming I initialize all these keys to undef before I enter the loop, is there an expression I can use for the while condition that basically sez "Keep looping until all existing keys are defined"?
― Leee, Tuesday, 25 November 2008 23:28 (seventeen years ago)
http://pastie.org/324034
― J0hn D., Tuesday, 25 November 2008 23:46 (seventeen years ago)
Actually figured it out myself; I stored the scalar of the keys in a $num_keys, then
while (scalar grep { defined $hash{$_} } @keys < $num_keys)
― Leee, Wednesday, 26 November 2008 04:04 (seventeen years ago)
New one: I'm trying to write my own Mysql module that extends DBI and DBD::mysql. My custom connect() method works fine, but when I try to write a query() method that takes care of both methods in DBD::mysql -- e.g. prepare() and execute() -- I get a compiler error saying that it can't find the prepare method. Is there something weird going on with DBD::mysql that makes it more involved to extend?
― Daleks in NYC (Leee), Tuesday, 15 June 2010 22:43 (fifteen years ago)