Re: Compare files

2010-10-31 Thread Jim Gibson
At 9:34 PM + 10/31/10, Brian wrote: Thanks for the previous help, that triggered a few dormant grey cells :-) and leads me to another question. I would like to compare 2 (unsorted) csv files.. file 1 contains fredbloggs,0 joebloggs,3 joeblow,6 file 2 fredbloggs,1 joebloggs,4 replace the

Re: anonymous hash reference

2010-10-31 Thread Thorsten Scherf
Thanks Uri and Jepp, that was exactly the information I was looking for. - Original Message - From: "Uri Guttman" To: "Jeff Pang" Cc: beginners@perl.org Sent: Sunday, October 31, 2010 6:39:50 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna Subject: Re: anonymous ha

Compare files

2010-10-31 Thread Brian
Thanks for the previous help, that triggered a few dormant grey cells :-) and leads me to another question. I would like to compare 2 (unsorted) csv files.. file 1 contains fredbloggs,0 joebloggs,3 joeblow,6 file 2 fredbloggs,1 joebloggs,4 replace the value in file 2 with the value in file 1.

Re: Removing leading whitespace and removing alternate newlines

2010-10-31 Thread Brian
Thank you John From: John W. Krahn To: Perl Beginners Sent: Sun, October 31, 2010 8:59:43 PM Subject: Re: Removing leading whitespace and removing alternate newlines Brian wrote: > Hi guys, long time no working with PERL :-) Hello, > I have just installed 5

Re: Removing leading whitespace and removing alternate newlines

2010-10-31 Thread John W. Krahn
Brian wrote: Hi guys, long time no working with PERL :-) Hello, I have just installed 5.2.12 First, I am trying to remove leading tabs& spaces Just tabs and spaces? Your code says all whitespace. but the following leaves a few blanks at the beginning of each line, You code only remov

Re: Removing leading whitespace and removing alternate newlines

2010-10-31 Thread Brian
Thanks Shlomi, your "untested" code worked first time. :-) From: Shlomi Fish To: beginners@perl.org Cc: Brian Sent: Sun, October 31, 2010 4:23:52 PM Subject: Re: Removing leading whitespace and removing alternate newlines On Sunday 31 October 2010 17:01:24 B

Re: Removing leading whitespace and removing alternate newlines

2010-10-31 Thread Brian
Thank you Shlomi, I'll test part 2 tomorrow when I have more time. As for part one, what would be the better way of writing the code so that I can read/treat one line at a time? thanks again Brian From: Shlomi Fish To: beginners@perl.org Cc: Brian Sent: Sun,

Re: anonymous hash reference

2010-10-31 Thread Uri Guttman
> "JP" == Jeff Pang writes: JP> print check_for_exists('name','foo'); JP> sub check_for_exists { JP>my $key = shift; JP>my $value = shift; JP> for my $item (@$foo) { JP> if ($item->{$key} eq $value ) { JP>return 1; JP> } JP> }

Re: Removing leading whitespace and removing alternate newlines

2010-10-31 Thread Shlomi Fish
On Sunday 31 October 2010 17:01:24 Brian wrote: > Hi guys, long time no working with PERL :-) > See: http://perl.org.il/misc.html#pl_vs_pl > I have just installed 5.2.12 > You probably mean perl-5.12.2 . A few more comments on your code: > First, I am trying to remove leading tabs & spaces

Re: Removing leading whitespace and removing alternate newlines

2010-10-31 Thread Richard Hug
$string =~ s/^\s+//; http://oreilly.com/catalog/9781565922433/ page 43 That book is my bible!!! On Sun, Oct 31, 2010 at 11:01 AM, Brian wrote: > Hi guys, long time no working with PERL :-) > > I have just installed 5.2.12 > > First, I am trying to remove leading tabs & spaces but the following

Removing leading whitespace and removing alternate newlines

2010-10-31 Thread Brian
Hi guys, long time no working with PERL :-) I have just installed 5.2.12 First, I am trying to remove leading tabs & spaces but the following leaves a few blanks at the beginning of each line, could someone be kind enough to point out the error of my ways please? :-) #!/usr/bin/perl local $/=

Re: anonymous hash reference

2010-10-31 Thread Jeff Pang
于 2010-10-31 21:43, Thorsten Scherf 写道: Hi, I have an array with anonymous hash references like the following: $foo = [ { name = value, id = value, }, { name = value, id = value, } ]; Iterating through the hash references works with: foreach $item (@$foo) { do something with $item->name; }

anonymous hash reference

2010-10-31 Thread Thorsten Scherf
Hi, I have an array with anonymous hash references like the following: $foo = [ { name = value, id = value, }, { name = value, id = value, } ]; Iterating through the hash references works with: foreach $item (@$foo) { do something with $item->name; } What

Re: LWP::Simple::head($url) -- Return value

2010-10-31 Thread Shawn H Corey
On 10-10-31 07:52 AM, Jatin wrote: 1. From the module's documentation i can understand that the return value of the head() method in a scalar context is TRUE , but what does the value returned by the server which is HTTP::Response=HASH(0x861cd00) signify ? It is a hash reference. See `perldoc

LWP::Simple::head($url) -- Return value

2010-10-31 Thread Jatin
Hi All I had the following code to test what the head() method of the LWP::Simple module returns. #!/usr/bin/perl use warnings; use strict; use LWP::Simple; my $url = 'http://oreilly.com/store/complete.html'; #my $url = 'http://www.garimela.com/complete.html'; my $testvar = head($url); print