Re: how to understand shift?

2012-02-06 Thread lina
On Tue, Feb 7, 2012 at 3:19 PM, 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.

Re: how to understand shift?

2012-02-06 Thread Jeff Peng
于 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 unsubscribe, e-mail: beginners-unsubscr...@perl.org For addit

how to understand shift?

2012-02-06 Thread lina
#!/usr/bin/perl $month = "December"; $year = "2007" ; header($month,$year); sub header { my $month = shift ; my $year = shift ; here after shift the $year becomes null? http://perldoc.perl.org/functions/shift.html print "-" x 79, "\n" ; print "$month

Re: syntax error near unexpected token `;'

2012-02-06 Thread lina
On Tue, Feb 7, 2012 at 12:49 PM, Parag Kalra wrote: > > > On Mon, Feb 6, 2012 at 8:35 PM, lina wrote: >> >> until ($name eq ""); >> do { >>        print "Enter another name, or Enter to stop:\n" ; >>        $name = ; >>        chomp ($name); >>        push @namelist,$name; >> >> } >> >> print @na

Re: syntax error near unexpected token `;'

2012-02-06 Thread Parag Kalra
On Mon, Feb 6, 2012 at 8:35 PM, lina wrote: > until ($name eq ""); > do { >print "Enter another name, or Enter to stop:\n" ; >$name = ; >chomp ($name); >push @namelist,$name; > > } > > print @namelist > This should work. Also start using strict and warnings pragma

syntax error near unexpected token `;'

2012-02-06 Thread lina
#/usr/bin/perl until ($name eq ""); do { print "Enter another name, or Enter to stop:\n" ; $name = ; chomp ($name); push @namelist,$name; } print @namelist $ ./generate_namelist.pl ./generate_namelist.pl: line 6: syntax error near unexpected token `;' ./gener

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

2012-02-06 Thread John Refior
Hello, 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 if someone knows a better way, please let me know). Ho

Re: extracting exif information from images

2012-02-06 Thread John W. Krahn
Harry Putnam wrote: I've been looking around, googling for a way to extract exif info from images. There are many tools out there. But I wanted to fiddle with the information in very specific ways. I hit on the perl module: Image-ExifTool (Phil Harvey) on cpan. However I am apparently badly mi

Re: Foreach loop and hash of arrays

2012-02-06 Thread sono-io
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 if it doesn't. > > if ( grep( /^$customers_z

Re: Foreach loop and hash of arrays

2012-02-06 Thread Robert Wohlfarth
On Mon, Feb 6, 2012 at 3:14 PM, wrote: >So I'm creating a hash of arrays that contains a list of Zip Codes > for the United States. I've also written a foreach loop to access this > hash but I'd like to see if it could be written better. For example, do I > really need three foreach loo

Re: Foreach loop and hash of arrays

2012-02-06 Thread Uri Guttman
On 02/06/2012 04:58 PM, Parag Kalra wrote: On Mon, Feb 6, 2012 at 1:14 PM, wrote: For example, do I really need three foreach loops? You can get rid of third ForLoop for sure. you don't actually lose the third loop. grep is an implied loop. STATE: foreach my $state (keys %states

Re: Foreach loop and hash of arrays

2012-02-06 Thread Rob Dixon
On 06/02/2012 21:14, sono...@fannullone.us wrote: use strict; use warnings; my %states = ( AL => [ '350','351', ], AK => [ '995','996', ], AZ => [ '850','851', ], AR => [ '716','717', ], ); my $customers_state = 'AZ'; my $customers_zip = '850'; my $match = 'n

Re: Foreach loop and hash of arrays

2012-02-06 Thread Parag Kalra
On Mon, Feb 6, 2012 at 1:14 PM, wrote: >For example, do I really need three foreach loops? > > > You can get rid of third ForLoop for sure. use strict; use warnings; my %states = ( AL => [ '350','351', ], AK => [ '995','996', ], AZ => [ '850','851', ], AR => [ '

Re: Foreach loop and hash of arrays

2012-02-06 Thread Steve Bertrand
On 2012.02.06 16:14, sono...@fannullone.us wrote: I have a web form where people enter their address info and I want to make sure that the first three digits of their Zip Code correspond to their State. So I'm creating a hash of arrays that contains a list of Zip Codes for the

Foreach loop and hash of arrays

2012-02-06 Thread sono-io
I have a web form where people enter their address info and I want to make sure that the first three digits of their Zip Code correspond to their State. So I'm creating a hash of arrays that contains a list of Zip Codes for the United States. I've also written a foreach loop to

Re: extracting exif information from images

2012-02-06 Thread Ken Slater
On Mon, Feb 6, 2012 at 6:59 AM, Harry Putnam wrote: > I've been looking around, googling for a way to extract exif info from > images. There are many tools out there.  But I wanted to fiddle with > the information in very specific ways. > > I hit on the perl module: Image-ExifTool (Phil Harvey) on

blocking sockets?

2012-02-06 Thread Marco van Kammen
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 server itself should try to make a connection with anot

extracting exif information from images

2012-02-06 Thread Harry Putnam
I've been looking around, googling for a way to extract exif info from images. There are many tools out there. But I wanted to fiddle with the information in very specific ways. I hit on the perl module: Image-ExifTool (Phil Harvey) on cpan. However I am apparently badly misunderstanding the usa

Re: need guidance on encode JSON and sorting

2012-02-06 Thread Igor Dovgiy
That's what the documentation says: ... $json = $json->canonical([$enable]) "If $enable is true (or missing), then the encode method will output JSON objects by sorting their keys. This is adding a comparatively high overhead". ... So I guess you'd have to use something like that: my $ret_json =