Re: How to split 6 digits into 3 lots of 2

2003-01-29 Thread Mark Fowler
On Tue, 28 Jan 2003, Phil Pereira wrote: Is there an easy way to split 123456 into 12-34-56? I've been splitting with a basic // into an array, and then printing 2 array elements at a time, sorta like: $array[0] . $array[1] Golf solutions aside (where people try and solve it in the fewest

Re: How to split 6 digits into 3 lots of 2

2003-01-29 Thread Dave Cross
From: Mark Fowler [EMAIL PROTECTED] Date: 1/29/03 10:21:18 AM Another way is to use a loop with a regular expression to match two chars with the funky 'g' option to tell it to match each loop starting from where it left off at the end of the previous loop (so it moves slowly along the

Re: How to split 6 digits into 3 lots of 2

2003-01-29 Thread Robin Berjon
Mark Fowler wrote: The last one I can think of (though there will be many more) is to use the unpack operator. This is somewhat like a regular expression where you define a template that the string will be broken up into. my @array = unpack (A2)*, $input; This uses a simple template. 'A'

Slides: Core Perl Modules You Might Not Know About

2003-01-29 Thread Leon Brocard
Oops, I forgot to post this to the list, but I see it has made it to the website anyway ;-) http://www.astray.com/coremodules/ Leon -- Leon Brocard.http://www.astray.com/ scribot.http://www.scribot.com/ ... The worst thing about

Re: How to split 6 digits into 3 lots of 2

2003-01-29 Thread Mark Fowler
On Wed, 29 Jan 2003, Dave Cross wrote: And that can be simplified to my @array = $input =~ /(..)/g; And that can be simplified in turn to my $output = join '-', $input =~ /(..)/g; As operators can give each other list context, which is a whole other conversation (one that's in Chapter 3.8

Re: How to split 6 digits into 3 lots of 2

2003-01-29 Thread Paul Johnson
Mark Fowler said: On Wed, 29 Jan 2003, Dave Cross wrote: And that can be simplified to my @array = $input =~ /(..)/g; And that can be simplified in turn to my $output = join '-', $input =~ /(..)/g; And that can be simplified in turn to my $output = join '-', $input =~ /../g; Which is

Re: SQL switcheroo

2003-01-29 Thread the hatter
On Wed, 29 Jan 2003, Paul Makepeace wrote: So there are a bunch of things order by rank. I'd like to implement a move up/down in SQL. So say the target was id=20 moving up, I'd like its rank to become 1, and id=10's rank to become 2. $query = UPDATE fw SET

Re: How to split 6 digits into 3 lots of 2

2003-01-29 Thread David Cantrell
On Wed, Jan 29, 2003 at 12:49:40AM +0100, Paul Johnson wrote: On Tue, Jan 28, 2003 at 11:35:29PM +, Paul Makepeace wrote: On Tue, Jan 28, 2003 at 11:22:48PM +, Phil Pereira wrote: Is there an easy way to split 123456 into 12-34-56? $ perl -lne 'print $1-$2-$3 if

Re: How to split 6 digits into 3 lots of 2

2003-01-29 Thread Joel Bernstein
On Wed, Jan 29, 2003 at 01:31:32PM +, David Cantrell wrote: On Wed, Jan 29, 2003 at 12:49:40AM +0100, Paul Johnson wrote: On Tue, Jan 28, 2003 at 11:35:29PM +, Paul Makepeace wrote: On Tue, Jan 28, 2003 at 11:22:48PM +, Phil Pereira wrote: Is there an easy way to split 123456

Re: SQL switcheroo

2003-01-29 Thread David Cantrell
On Wed, Jan 29, 2003 at 02:16:58AM +, Paul Makepeace wrote: I'd like to switch the values of a field in two rows. 1-2 while 2-1, say. I have a table containing: = select * from pageplans order by rank; id | parent | child | rank | loopable | required

Re: how do I identify a reference to an array?

2003-01-29 Thread Joel Bernstein
On Wed, Jan 29, 2003 at 02:12:43PM +, Martin Bower wrote: Hi, I'm using the Image::Info module to return Exif information located inside images. image_info() returns a reference to a hash, so the code below returns all keys and dumps their values. This works fine, except some keys

how do I identify a reference to an array?

2003-01-29 Thread Martin Bower
Hi, I'm using the Image::Info module to return Exif information located inside images. image_info() returns a reference to a hash, so the code below returns all keys and dumps their values. This works fine, except some keys return a reference to an array. Any ideas on how I can indentify a

Re: how do I identify a reference to an array?

2003-01-29 Thread Leo Lapworth
On Wed, Jan 29, 2003 at 02:12:43PM +, Martin Bower wrote: This works fine, except some keys return a reference to an array. Any ideas on how I can indentify a reference to an array so I can deal with it accordingly ? You want the ref() function. e.g foreach my $key (keys

Re: how do I identify a reference to an array?

2003-01-29 Thread Martin Bower
Thanks Joel/Leo Martin _ Express yourself with cool emoticons http://messenger.msn.co.uk

Fwd: London Sci-Fi film festival

2003-01-29 Thread David Cantrell
http://www.sci-fi-london.com/programme.htm Some interesting stuff here: * 'Solaris' on the big screen on Saturday * A PKD documentary * Westworld/Soylent Green double bill on Sunday -- David Cantrell|Reprobate|http://www.cantrell.org.uk/david There is no sigmonster

Baby Jesus is crying...

2003-01-29 Thread Ben
Just read it and weap. http://www.datapower.com/products/xa35.html Ben

Re: SQL switcheroo

2003-01-29 Thread Paul Makepeace
On Wed, Jan 29, 2003 at 01:48:04PM +, David Cantrell wrote: On Wed, Jan 29, 2003 at 02:16:58AM +, Paul Makepeace wrote: I'd like to switch the values of a field in two rows. 1-2 while 2-1, say. I have a table containing: = select * from pageplans order by rank; id |

$host-ip_address

2003-01-29 Thread Paul Makepeace
Anyone think it would be nice is Sys::Hostname did this itself? $ perl -MSys::Hostname -le 'print join ., unpack C*, (gethostbyname hostname)[4]' 195.82.114.220 $ perlfaq9, consulted belatedly, (requires Socket) $ perl -MSocket -MSys::Hostname -le 'print inet_ntoa(scalar gethostbyname

Re: SQL switcheroo

2003-01-29 Thread Paul Makepeace
On Wed, Jan 29, 2003 at 12:10:38PM +, the hatter wrote: On Wed, 29 Jan 2003, Paul Makepeace wrote: So there are a bunch of things order by rank. I'd like to implement a move up/down in SQL. So say the target was id=20 moving up, I'd like its rank to become 1, and id=10's rank to

Re: SQL switcheroo

2003-01-29 Thread Tim Sweetman
Not wanting to be awkward or anything, but ... Paul Makepeace wrote: On Wed, Jan 29, 2003 at 12:10:38PM +, the hatter wrote: On Wed, 29 Jan 2003, Paul Makepeace wrote: So there are a bunch of things order by rank. I'd like to implement a move up/down in SQL. So say the target was

Re: SQL switcheroo

2003-01-29 Thread Paul Makepeace
On Thu, Jan 30, 2003 at 12:13:04AM +, Paul Makepeace wrote: On Wed, Jan 29, 2003 at 12:10:38PM +, the hatter wrote: On Wed, 29 Jan 2003, Paul Makepeace wrote: So there are a bunch of things order by rank. I'd like to implement a move up/down in SQL. So say the target was id=20