#perl
02 October 2007
Total 34 pages. You are browsing page 1/34.
First :: Prev :: [1] [2] [3] [4] [5] [...] :: Next :: Last
--- Log opened Tue Oct 02 00:00:43 2007
00:12 <****> uggh the BSD date sucks
00:12 <****> doesn't have that option
00:13 <****> what option?
00:13 <****> for ($i = 1; $i <= $incrementalDays; $i++) { $previousDate = `date +\%Y\%m\%d -d 'now-$i day'`;
00:14 <****> -d //
00:14 <****> i can use localtime i guess
00:16 <****> works on linux
00:18 <****> Perl has plenty of date functions/modules, no need to use external commands
00:18 <****> Just use DateTime and get it over with
00:19 <****> can someone please shed some light on how one puts a nameless has inside an array inside a hash ? I have read perlref four times. I.e. someting that should be like $h{$k1}[idx1]{$k2} = $val;
00:19 <****> s/has/hash/
00:19 <****> _abc_: That looks about right.
00:19 <****> ok, so if I want it empty I do this: $h{$k1}[idx1]{$k2} = (); ?
00:20 <****> and do I have to put in arrows ?
00:20 <****> thanks
00:20 <****> only the first arrow is necessary
00:20 <****> how does [idx1] work exactly?
00:20 <****> %{ ... thing to dereference as a hash ... } = ();
00:20 <****>{$k1}[idx1]{$k2}
00:20 <****> preaction ok
00:20 <****> So, in your case, %{$hash{$key1}[$index1]} = ();
00:20 <****> jagerman can you show a more complete example ?
00:21 <****> ok
00:21 <****> I fixed your bad variable naming, too :P
00:21 <****> yeah, thanks
00:21 <****> Lvng t vwls sn't gd wy t d thngs
00:21 <****> some things are not so obvious. imho perlref and other heavy doc sections should have more examples
00:21 <****> but why deref like that when you can just assign an empty hashref {}
00:21 <****> and less blurb about historical features
00:21 <****> preaction say again ?
00:22 <****> $hash{$key1}[$index1] = {}
00:22 <****> 1); $foo{a} = \%hash1; %$foo = (); # clears %hash1
00:22 <****> ah, it uses the reference instead of replacing it
00:23 <****> oops, that should be: %{$foo{a}} = ();
00:24 <****> _abc_: In Perl, you have scalar, arrays and hashes, and can stick a reference to any of them in a scalar. (For the pedants, I'm leaving things out on purpose)
00:25 <****> _abc_: There are two ways to reference: to get at the scalar, array, or hash as a variable, you use: ${}, @{}, or %{}
00:25 <****> _abc_: And you can leave off the {} if what is inside is a simple scalar variable, such as: %$foo
00:25 <****> so that is sort of like a cast or is it sort of like a filter that shows a certain aspect of the object _
00:25 <****> ?
00:26 <****> it's a dereference, not really a cast or a filter
00:26 <****>[$index]" to get an array element
00:27 <****> would you call a dereference an indirection ?
00:27 <****> dereference means remove a reference literally.
00:27 <****> I would call it a dereference :)
00:27 <****> silly names cause silly associations
00:27 <****> why can't you just call it a dereference?
00:28 <****> because dereferentiation is the removal of a reference.
00:28 <****> _abc_: Right, you are "removing" the reference in a sense--you're accessing the value the reference points to instead of the reference
00:28 <****> so that's indirection. ok.
00:28 <****> also correctly a reference is the address of an object and not the value
00:29 <****> did larry wall write the first manuals ?
00:29 <****> Not really--references are a lot more than just memory addresses
00:29 <****> I'm just curious where he went to school.
00:29 <****> address and type, perhaps a bless
00:30 <****> and it coincides with how perl handles garbage collection.
00:30 <****> COCKS.
00:30 <****> the literal OED definition of 'dereference' isn't applicable, as 'dereference' is a technical jargon term, which is the superset of its English denotation.
00:30 <****> jagerman a reference is a reference to an object. has nothing to do with memory or addresses. it is sort of like an opaque handle to an object.
00:31 <****> dereference is not 'technical jargon', it's in the dictionary.
00:31 <****> _abc_: In Perl, a reference is a reference to a data type, it has nothing to do with objects.
00:31 <****> that's the problem, you see, I know words like that and when they are reused (or overloaded like here) I get confused
00:31 <****> where data type is scalar, array, hash, glob, code, etc.
00:32 <****> ok, so references are correct. one can call that thing a reference. but how about dereferencing ? I'd call it indirection ?
00:33 <****> It is called dereferencing in Perl.
00:33 <****> I think I can see where he is coming from. He thought, if that's a reference and now I want its & then i dereference it. Argh.
00:33 <****> eval: +[]
00:33 <****> Caelum: []
00:33 <****> eval: []+0
00:33 <****> Caelum: 141886468
00:34 <****> _abc_: "Accessing the value referred to by a reference is called dereferencing it." # from http://en.wikipedia.org/wiki/Dereference
00:35 <****> ok. understood. http://dictionary.reference.com/search?q=dereference&r=66
00:35 <****> yes. words can ONLY have one meaning. and they MUST be applied universally to ALL uses of that word.
00:35 <****> it must be interesting in your world.
00:35 <****> now if you want to blow your mind further, look up 'dynamic'.
00:35 <****> infi please don't start this. I studied languages (<- note the plural)
00:35 <****> none of my fault
00:36 <****> _abc_: Um, "reference" also refers to a character reference, who you might put on a résumé; but that's not what I mean here when I say "reference"
00:36 <****> ok ok
00:37 <****> English is a living language, and it must be applied across multiple, ever changing disciplines.
00:37 <****> hopefully your linguistics class taught you that in the first chapter.
00:37 <****> nono, you use character _entities_ to write résumé in HTML. Not character _references_ ;)
00:37 <****> mine sure did.
00:38 <****> _abc_: So to access an entire array or hash (for example, to call functions like splice(), or keys(), or to foreach through an array) you dereference the entire array with @{ expression that evaluated to an array reference } or hash with %{ expression that evaluates to a hash reference }
00:39 <****> ok
00:39 <****> I think I get it.
00:39 <****>{$key}
00:40 <****> between them
00:40 <****> (Though I personally always put them in)
00:40 <****> ok
00:41 <****>(ARGUMENTS)
00:42 <****> s/with/which/
00:46 <****> jagerman: Socking.
00:46 <****> _abc_: There are also scalar and lvalue references, which only have a ${} style dereferencing.
00:46 <****>{$k}[0]} = ();
00:46 <****> yes ?
00:48 <****>{$k}[0] = {}
00:48 <****> but the more explicit version won't hurt, right ?
00:49 <****> yours is the less explicit version. But I think it'd work.
00:49 <****> I actually switched to a hash of hashes of hashes. now read that quickly
Total 34 pages. You are browsing page 1/34.
First :: Prev :: [1] [2] [3] [4] [5] [...] :: Next :: Last
