Re: how to understand shift?

2012-02-07 Thread Jeff Peng
于 2012-2-7 15:45, lina 写道: I am sorry, still don't get. $year = shift part Try with this code: use strict; my $month = "December"; my $year = "2007" ; header($month,$year); sub header { print '@_ is: ' . "@_\n"; my $month = shift ; print '@_ is: ' . "@_\n";

Re: how to understand shift?

2012-02-07 Thread lina
On Tue, Feb 7, 2012 at 4:01 PM, Jeff Peng wrote: > 于 2012-2-7 15:45, lina 写道: > >> I am sorry, still don't get. >> >> $year = shift >> >> part > > > > Try with this code: > > use strict; > my $month = "December"; > my $year = "2007" ; > > header($month,$year); > > sub header { >        print '@_ i

Re: Foreach loop and hash of arrays

2012-02-07 Thread Rob Dixon
On 07/02/2012 01:39, sono...@fannullone.us wrote: On Feb 6, 2012, at 1:42 PM, Steve Bertrand wrote: This may be easier. It uses the hash elements directly as an array, then uses grep to see if the zip code is within the specific state. It returns true if the state owns that zip code, and false

Re: how to understand shift?

2012-02-07 Thread Shawn H Corey
On 12-02-07 03:01 AM, Jeff Peng wrote: "shift" means "shift @_" in Perl. Inside a sub, shift without an argument will shift @_. Outside, it will shift @ARGV. It is always best to explicitly state the array: sub header { my $month = shift @_; my $year = shift @_; -- Just my

Re: Foreach loop and hash of arrays

2012-02-07 Thread Shawn H Corey
On 12-02-07 06:26 AM, Rob Dixon wrote: in fact, if the objective is to reduce the code to something as brief as possible then this will do the trick my $match = (grep $_ eq $customers_zip, @{$states{$customers_state}}) ? 'yes' : 'no'; You can use first from List::Util for more efficient cod

Re: how to understand shift?

2012-02-07 Thread Paul Johnson
On Tue, Feb 07, 2012 at 08:20:06AM -0500, Shawn H Corey wrote: > On 12-02-07 03:01 AM, Jeff Peng wrote: > >"shift" means "shift @_" in Perl. > > Inside a sub, shift without an argument will shift @_. Outside, it > will shift @ARGV. It is always best to explicitly state the array: All generalisati

Re: blocking sockets?

2012-02-07 Thread Brandon McCaig
Hello, Marco: (Ewww, HTML mail..) On Mon, Feb 06, 2012 at 12:36:35PM +, Marco van Kammen wrote: > I'm having difficulties with the following: > > Say you have a server program that listens on port 1234 The > server handles requests and spawns a child process for every > connection. > > If a

Re: how to understand shift?

2012-02-07 Thread Brandon McCaig
On Tue, Feb 07, 2012 at 08:20:06AM -0500, Shawn H Corey wrote: > Inside a sub, shift without an argument will shift @_. Outside, it > will shift @ARGV. It is always best to explicitly state the array: > > sub header { > my $month = shift @_; > my $year = shift @_; Even better can

Re: how to understand shift?

2012-02-07 Thread lina
On Wed, Feb 8, 2012 at 12:24 AM, Brandon McCaig wrote: > On Tue, Feb 07, 2012 at 08:20:06AM -0500, Shawn H Corey wrote: >> Inside a sub, shift without an argument will shift @_. Outside, it >> will shift @ARGV. It is always best to explicitly state the array: >> >> sub header { >>         my $mont

Re: how to understand shift?

2012-02-07 Thread Jim Gibson
At 3:19 PM +0800 2/7/12, Jeff Peng wrote: òƒ 2012-2-7 15:07, lina é ì¼: my $month = shift ; my $year = shift ; here after shift the $year becomes null? http://perldoc.perl.org/functions/shift.html after shift the @_ becomes null. $year is 2007. To be precise, @_ be

Re: blocking sockets?

2012-02-07 Thread Jim Gibson
At 12:36 PM + 2/6/12, Marco van Kammen wrote: Dear List, I'm having difficulties with the following: Say you have a server program that listens on port 1234 The server handles requests and spawns a child process for every connection. If a client sends the text "foo" to the server, the ser

Re: How to Digest::CMAC->add($json)

2012-02-07 Thread John Refior
On Mon, Feb 6, 2012 at 11:21 PM, John Refior wrote: > I am trying to create a CMAC out of some JSON data (I have a reason for > doing this -- part of the authorization allowing my REST client to > communicate with a server that requires it). I figured I would use > Digest::CMAC to do this (but i

Re: How to Digest::CMAC->add($json)

2012-02-07 Thread Igor Dovgiy
It's not an encoding issue. It's a 'storage' issue. ) JSON::to_json returns a string, with UTF8 flag on. JSON::encode_json returns a bytecode (sequence of octets), with UTF8 flag off. -- iD 2012/2/7 John Refior > On Mon, Feb 6, 2012 at 11:21 PM, John Refior wrote: > > > I am trying to create

Editing line of text.

2012-02-07 Thread Sean Murphy
Hi All. This should be a simple task. But for the life of me, I cannot work it out. I have a chunk of text in an scaler. I want to edit this text. I look at Term::ReadLine and couldn't see a way of inserting the text into the edit area. There is addhistory which adds to the history buffer. but