Re: Schwartzian transform
On 13 August 2014 10:33, Dermot paik...@gmail.com wrote: #map { $ref-{ $_-[0] }-{position} = $count++ } You probably want = $count++, rather than =. You possibly want: map { $ref-{ $_-[0] }-{position} = $count++; $ref-{$_-[0]} } Adrian.
Re: Schwartzian transform
On 13 August 2014 11:11, Adrian Lai p...@loathe.me.uk wrote: You possibly want: map { $ref-{ $_-[0] }-{position} = $count++; $ref-{$_-[0]} } Bad copy/paste/editing, I meant: map { $ref-{ $_-[0] }-{position} = $count++; $ref-{$_-[0]} } Adrian.
Re: Using grep on undefined array
On 14 August 2013 13:12, Abigail abig...@abigail.be wrote: My guess: it's an unintentional side-effect of $_ being an alias in the first argument of grep. That does appear to be the case, given as other functions don't autovivify. e.g. perl -E '$y = scalar @$x; say $x if defined $x' Interestingly though, 'keys' does: perl -E '@y = keys %$x; say $x if defined $x' I'm guessing that perl attempts to coerce a hash (and thus autovivify) before it performs the keys action. Adrian.
Re: Using grep on undefined array
On 14 August 2013 00:09, Andrew Beverley a...@andybev.com wrote: Hi, Could someone please explain to me why the following outputs an empty string rather than *? get(); sub get($) { my $fields = shift; my @fields = grep $_ ne 'domain', @$fields; my $select_fields = $fields ? join(',', map { 'users.' . $_ } @fields) : '*'; print $select_fields\n; } I would have expected $fields to remain undefined, but it seems to be turning into an empty array during the grep. I've discovered that I can make it work by conditionally declaring @fields (with if $fields), but I'd still like to know what's going on here. Thanks, Andy The use of @$fields is sufficient to autovivify $fields as an array ref. As such, it's defined when you come to check it within your ternary. Perhaps my $select_fields = @$fields ? ... would work for you? It's not quite the same result as you'd get by conditionally declaring @fields (you'd get * returned if you passed in an empty array ref (i.e. get([])) rather than ). Alternatively I'd suggest restructuring to return early in the case of $fields being undef. Adrian.
Re: Phenona
On 14 June 2011 10:42, Dirk Koopman d...@tobit.co.uk wrote: Anyone had a go with: http://www.phenona.com/ a perl cloud? Featured on el reg today: http://www.theregister.co.uk/2011/06/14/activestate_buys_teen_programmer/
Re: Lovefilm, yes or no?
On 14 April 2010 17:47, David Alban exta...@extasia.org wrote: i would think that any factorial N! would end in zero if N 9. but i have no idea how many zeroes are at the end of 128!. Surely you mean if N 4?
Re: domain registrars
On the subject of domain names, has anyone used name.com? I was considering transferring a couple of domains over to them. Cheers, Adrian.
Re: Straight Jackets and Video Cameras
2009/7/29 Ovid publiustemp-londo...@yahoo.com: On the off chance that anyone here is interested, I thought it would be fun to produce a small parody of the I'm a PC/I'm a Mac ads. Basically, it would be a series of video shorts along the lines of I'm Java/I'm Perl, I'm Ruby/I'm Perl, etc. All in good fun, of course :) I don't think my Web cam provides *quite* the video quality I'm looking for :) I can do the the script writing (example: http://vimeo.com/1424008) and the video editing (example: http://www.youtube.com/watch?v=W3-ZUagzrjw), but if others want to chip in, that would be awesome. Would anyone be interested in working with me on this project, or perhaps make it a Sponsored by London.pm thing? I already have ideas for small sample scripts for a number of languages (one has a Java programmer in a straight jacket bragging about how he's never poked himself in the eye). Volunteer actors would be welcome, too. Cheers, Ovid Like the Java/Ruby on Rails thing of a few years ago? http://www.youtube.com/watch?v=PQbuyKUaKFo Adrian.
Re: OT: $0
2009/5/17 Andy Armstrong a...@hexten.net: So the question becomes what's the shortest one-liner that will cause what ps displays to be the same as what $0 contains? My first attempt is ( $0 .= ' ' ) =~ s/ $//; $0.=''; would appear to be sufficient to replicate. Adrian.
Re: Measuring power
2009/4/29 Andrew Beattie and...@tug.com: This is a long way off topic but I'm hoping that someone here might be able to share a clue... I need to measure the power used on dozens and dozens of servers. I need a breakdown by server, not a total for the room. (more specifically, I want to calculate the power cost per server per year). Added difficulty: I want to do this non-intrusively. I can't go round, yanking out cables and inserting in-line meters. So, I got a clamp meter. But contrary to my expectation, that only works if I can separate the individual wires in the power cable - not an option. So, I'm stuck. Is there any non-intrusive way to measure the power consumption of my servers? Andrew Do you need exact figures? And, by non-intrusively, do you mean from a software point of view as well? I'm thinking a utility like powertop could be of use, although I'm not sure how well that would compare with losses in the PSU and fans and suchlike. Presumably you could use an in-line meter for one server, and use this to work out a best guess for others. Adrian.
Re: Empty Hash Values
2009/4/14 Dave Hodgkinson daveh...@gmail.com: On 14 Apr 2009, at 18:16, Matt Lawrence wrote: Most of the time just returning does what you expect, it's false in every context and undef in scalar context. And fails PBP for exactly the confusion in previous mails. Plain return is Just Wrong. Be explicit. This isn't actually what PBP (or at least, the book of that name) says, and is subject to one or two discussions I've had at my current place of work. The book states; Use a bare return to return failure [0]. My standpoint has always quite firmly been that the calling code should be aware of the context in which to call the function in question, and that bare returns aren't the bestest of ideas. Whilst I accept the argument that if (my @list = myfunction()) { ... } could cause issues if myfunction() returns undef, this shouldn't be a real issue if myfunction() is always expected to return a scalar value. And as has been illustrated, there are other problems inherent with bare returns - I suppose it's a matter of debate as to which is the lesser evil. Right now, I'm sorta standing by my opinion that if something is supposed to return a list, it should return the empty list in case of failure, and if it's supposed to return a scalar, then undef. Adrian. [0] http://my.safaribooksonline.com/0596001738/perlbp-CHP-9-SECT-12
Re: Optimisation
2009/3/3 Jasper jaspermcc...@gmail.com: It's ironically sub-optimal to have wasted so much of your and our time on something so trivial. ;) Joss Whedon has a new tv show. It has Eliza Dushku in it. Adrian.
Re: [REVIEW] Drobo
2009/1/29 Simon Wistow si...@thegestalt.org: My alternative was either a hardware RAID controller of some kind or a small, low profile box running *nix and software RAID. The former gives me the willies - one too many stories of hardware RAID controllers dying and otherwise servicable data being unrecoverable due to not being able to get the exact make, model and rev of controller again. It looks pretty cool, but surely this is still a potential problem? Lack of ethernet port is quite disappointing, too. Adrian.
Re: My New Job (Was: Social Thurs 8 Jan 2009)
2009/1/5 David Cantrell da...@cantrell.org.uk: Get a bike. And you know the Circle line's bad when a fat bastard like *me* says that. For some reason, this reminds me of: http://www.dcs.gla.ac.uk/~craigm/challenge.shtml Although yes, that's Glasgow. Zone 50 million. Adrian.