#perl
19 October 2007
Total 39 pages. You are browsing page 5/39.
First :: Prev :: [...] [3] [4] [5] [6] [7] [...] :: Next :: Last
02:43 <****> there's nothing special about "foo() or die" that requires the latter part be die
02:43 <****> j2daosh: you can put any expr you like on the right side of or, but calling a sub with & is a shooting offense.
02:43 <****> but please don't call subroutines with &
02:44 * Khisanth shoots j2daosh with a rocket launcher
02:44 <****> .... i thought that was how it was supposed to be done?
02:44 * j2daosh goes to grab his "Learning Perl" book
02:45 <****> j2daosh: do you have the edition of Learning Perl that was published in 1993? ;)
02:45 <****> Khisanth: man, now we have blood and guts everywhere
02:45 <****> july 2005 (4th edition
02:46 <****> hobbs: learning perl uses & at least initially
02:46 <****> uhh, all the examples im seeing are using the & sign...
02:46 <****> is there some reason I shouldn't?
02:46 <****> thats how I aqquired that habit too
02:47 <****> j2daosh: & has meaning you didn't intend, read perldoc perlsub if you want details
02:47 <****> apparently thats "old-school" shit j2daeosh
02:47 <****> otherwise just call subs as sub_routine()
02:47 <****> it also does stuff like reuse your current @_
02:47 <****> downloadPr0n("all") if ($noone_is_looking);
02:48 <****> Khisanth: hrm... that I did not know
02:49 * j2daosh now must go read some perlsub to figure out what the big deal is
02:49 <****> GumbyBRAIN: Damn, this is some gourmet shit, Jimmy!
02:49 <****> i think i see this as a prophet or some shit.
02:49 <****> i shall return;
02:49 <****> i shall goto;
02:49 <****> i don't need you to tell how fucking good my coffee is julie, I'm the one who buys it!
02:50 <****> when bonnie goes shopping, she buys shit!
02:50 <****> Khisanth: I guess the idea is to drive home the "hey look at this, it's a sub and it has a sigil like everyone else" thing but... meh. I don't like it at all :)
02:50 <****> wait... what if i want @_ to be visible to the sub-routine?
02:50 <****> j2daosh: then you're a very strange person.
02:50 <****> j2daosh: it's usually a monumentally bad idea
02:50 <****> lol well i have been accused of that before
02:50 <****> j2daosh: but in that case go ahead and do that.
02:51 <****> oy, any of y'all using urxvt -pe tabbed?
02:51 <****> j2daosh: foo(@_)
02:52 <****> idiotben: no. I keep meaning to play with it. but xterm WFM
02:52 <****> ya know, for having "more then one way to do it", i sure do get shunned alot... maybe the new motto should be "more then one way to do it, but really only one proper way to do it :P"
02:52 <****> j2daosh: hardly
02:52 <****> i am an avid xterm user as well
02:52 <****> but the built in perl bit intruiges me
02:52 <****> turns out it makes URLs clickable!
02:52 <****> which gives me geek wood
02:52 <****> hobbs: merlyn actually gave a reason for that before, it's to problems if a person ends up writing a sub using the same name as a builtin
02:53 <****> j2daosh: mastering perl means making sure every behaviour has the semantics you want.
02:53 <****> j2daosh: it's more "more than one way to do it but quite a few that are usually wrong"
02:53 <****> lol mst
02:53 <****> since they are "learning perl" it would be assumed they don't know what builtins are and what to avoid when naming their subs
02:53 <****> and I have always liked tabbed term windows
02:53 <****> j2daosh: &sub -does- have its uses, but I'd almost never use it without it being "goto &sub"
02:53 <****> If you're after "things that work" , your code will be confusing to people trying to work with you.
02:53 <****> that makes sense bpalmer
02:53 <****> that is, if you're just after "things that work"
02:53 <****> idiotben: the built in perl bit is what intrigued me
02:54 <****> for some reason when I use the tabbed extention seems to hose up stuff
02:54 <****> j2daosh: your a friend of puting everything into global variables, aren't you?
02:54 <****> like it interferes with window manager functionality for that window
02:54 <****> idiotben: I don't get it, why would you want tabbing done by the terminal? wouldn't that be better done with your window manager?
02:55 <****> mst: I'm not clever enough with perl to really exploit all that functionality =P
02:55 <****> idiotben: I use konsole, I really like my tabs ;)
02:55 <****> s/your/you're/
02:55 <****> yeah Somni, if your wm supports that, most don't
02:55 <****> globals? (i have heard this terminology before and i remember reading about it monthes ago but i dont quite recall what that is). if you mean by predeclaring all my variables at the beginning of my script with my ($, $, $, etc); then yes.
02:55 <****> just fluxbox and like ion
02:56 <****> if i still had a laptop with a decent sized display I'd still be using ion3
02:56 <****> j2daosh: yea, a lump of variables declared at the top of your script, for no other reason than to declare them, is usually a bad sign
02:56 <****> j2daosh: sure, there is more than one way to do it but that doesn't mean using a shotgun to peel an apple would as effective as using a knife
02:56 <****> j2daosh: variables should be declared and used in the narrowest scope possible
02:57 <****> I go back and forth on that one.
02:57 * CPAN upload: WWW-WorldLingo-0.02 by ASHLEY
02:57 <****> Somni: well i do intend to use them...and typically do fairly early in my scripts
02:57 <****> sometimes a bunch of my ($opt1, $opt2, %opt3, ...); at the top is clearer than my $opt1 = ... ; foo() ; bar(); my $opt2 = ...
02:57 <****> j2daosh: yes, but you use them somewhere deep in your code, some of which are temporaries
02:58 <****> j2daosh: they don't belong at file scope
02:58 <****> bpalmer: sure it is, but you didn't change scope
02:58 <****> ok, let me rephrase, i only put all my variables at the top if (a) they will be used in various parts of my script, and (b) change frequently
02:58 <****> bpalmer: so the effect is the same
02:58 <****> j2daosh: it's the "various parts" that are of concern
02:58 <****> j2daosh: Still not good enough!
02:59 <****> i dont declare my sub-routine variables at the top, or variables i only use in my conditionals once
02:59 <****> not quite ; a spurious reference to $opt2 before it's assigned to is caught in the my $opt2 = ... case, and not in the chunk-at-the-top case.
02:59 <****> j2daosh: Basically you should never declare a variable without an equal sign on the other side.
02:59 <****> bpalmer: I was referring to scope
02:59 <****> but what if it equals nothing yet?
02:59 <****> but I stand by chunk-at-the-top
02:59 <****> buu: well that's just not true
03:00 <****> my @stack; while (...) { modify @stack } process @stack;
03:00 <****> say i need to initiate a $count.... but i dont know what that count is until i run thru my first conditional() to find out what that count will be
03:00 <****> j2daosh: then you do what I did, with the variable close to the code
03:00 <****> Somni: Not 100%, no.
03:01 <****> But as a rule of thumb it's not terrible.
03:01 <****> Somni: Er, my @stack = map ...;
03:01 <****> your thumb is too small! and the wrong shape!
03:01 * Khisanth throws buu off a roof
03:01 <****> buu: if the process were simple, maybe
03:01 * buu shrugs.
03:02 <****> I stand by my rule.
03:02 <****>, yea, not so much
03:03 <****> What's your point?
03:03 <****>; # is silly
03:03 <****> Heh.
03:04 <****> Moving the code in to a subroutine might make it cleaner.
Total 39 pages. You are browsing page 5/39.
First :: Prev :: [...] [3] [4] [5] [6] [7] [...] :: Next :: Last
