RE: Info from flat file

2008-03-16 Thread Manoj
Thanks Chas. Working on this now...digging as much I can and updating some thing new. -Original Message- From: Chas. Owens [mailto:[EMAIL PROTECTED] Sent: Sunday, March 16, 2008 4:06 AM To: Manoj Cc: Perl Beginners Subject: Re: Info from flat file On Fri, Mar 14, 2008 at 3:33 PM, Manoj

Re: whats wrong with this error msg "Illegal division by zero"

2008-03-16 Thread Dr.Ruud
"John W. Krahn" schreef: > Also the format "%2.0f" says to print the argument as a floating point > number but not print the "floating point" part which is effectively > the same as printing the argument as an integer using "%2d". No, %d truncates, %f evens: perl -wle' printf("%1\$4.1f: %1\

List of hashes

2008-03-16 Thread Krzysztof . Chodak
Hi, as it is only my second week of perl I would be grateful for some help with hashes. I need to build a list of multidimensional hashes one by one, sort it by one of fields and iterate through it later. 1. building a hashes sub t { return { a => 1, b => 2, } } sub r { return (

reg:file handling

2008-03-16 Thread Gowri Chandra Sekhar Barla, TLS, Chennai
Hi I am unable to modify the input file , If I am redirecting output to with different file name it working fine In want to replace name in a file Script: problem print " Enter the file Name \n"; $filename = ; open(INPUT,"<$filename"); open(OUTPUT,">filename"); while()

Re: reg:file handling

2008-03-16 Thread Süleyman Gülsüner
Hi, > I am unable to modify the input file , > If I am redirecting output to with different file name it working fine > In want to replace name in a file > $filename = ; > open(OUTPUT,">filename"); As I understand, you want to modify $filename. so second line is actually : open(OUTPUT,">$filenam

Re: List of hashes

2008-03-16 Thread yitzle
Always start your code with: use warnings; use strict; > my %record = r(); This line won't work. r() returns a reference (think pointer if you used C) to a hash. You need a scalar to store it. $record = r(); > $record{fieldA}{fieldB} = value... This requires a hash, unlike the above line that use

while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread Richard Lee
While reading 'mastering perl', I run into @- and @+ for the first time. Trying to understand what's going on, I ran the code from the book, but $-[1] and $+[1] shoudln't match only the first match? (in this case, shoudln't it be, 7 to 8 ?, instead of 7 to 9 ?) --code-- #!/usr/bin/perl $alphabet

Re: reg:file handling

2008-03-16 Thread John W. Krahn
Gowri Chandra Sekhar Barla, TLS, Chennai wrote: Hi Hello, I am unable to modify the input file , If I am redirecting output to with different file name it working fine In want to replace name in a file Perl provides a way to do that. It is called the "in-place edit" switch(-i)/variable

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread John W. Krahn
Richard Lee wrote: While reading 'mastering perl', I run into @- and @+ for the first time. perldoc perlvar Trying to understand what's going on, I ran the code from the book, but $-[1] and $+[1] shoudln't match only the first match? (in this case, shoudln't it be, 7 to 8 ?, instead of 7 to

Re: List of hashes

2008-03-16 Thread John W. Krahn
yitzle wrote: Always start your code with: use warnings; use strict; my %record = r(); This line won't work. r() returns a reference (think pointer if you used C) to a hash. You need a scalar to store it. $record = r(); Or dereference the reference returned from the sub: my %record = %{ r()

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread Richard Lee
John W. Krahn wrote: Richard Lee wrote: While reading 'mastering perl', I run into @- and @+ for the first time. perldoc perlvar Trying to understand what's going on, I ran the code from the book, but $-[1] and $+[1] shoudln't match only the first match? (in this case, shoudln't it be, 7 t

Re: List of hashes

2008-03-16 Thread yitzle
On Sun, Mar 16, 2008 at 12:54 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: > >> push @records, %record > > I think you want an array of references, not of hashed themselves. > > Actually, the hash is converted to a list and that list is pushed onto > the array. > > > John Darn! I tested it us

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread Rob Dixon
Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: While reading 'mastering perl', I run into @- and @+ for the first time. perldoc perlvar Trying to understand what's going on, I ran the code from the book, but $-[1] and $+[1] shoudln't match only the first match? (in this case,

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread Richard Lee
Rob Dixon wrote: Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: While reading 'mastering perl', I run into @- and @+ for the first time. perldoc perlvar Trying to understand what's going on, I ran the code from the book, but $-[1] and $+[1] shoudln't match only the first mat

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread John W. Krahn
Richard Lee wrote: John W. Krahn wrote: Richard Lee wrote: While reading 'mastering perl', I run into @- and @+ for the first time. perldoc perlvar Trying to understand what's going on, I ran the code from the book, but $-[1] and $+[1] shoudln't match only the first match? (in this case,

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread Rob Dixon
Richard Lee wrote: Rob Dixon wrote: Perhaps it would help to think of the offset as being the index of the points between the characters, so the start of the string is at offset zero, after 'a' (and before 'b') is at offset one and so on. Then can you see how offset 7 is before 'hi' and offset

Re: while reading 'mastering perl' @+ and @-, not too clear on this

2008-03-16 Thread Richard Lee
Rob Dixon wrote: Richard Lee wrote: Rob Dixon wrote: Perhaps it would help to think of the offset as being the index of the points between the characters, so the start of the string is at offset zero, after 'a' (and before 'b') is at offset one and so on. Then can you see how offset 7 is befor

Re: reg:file handling

2008-03-16 Thread Gunnar Hjalmarsson
Gowri Chandra Sekhar Barla, TLS, Chennai wrote: I am unable to modify the input file , In addition to other posted solutions, I thought I'd mention the possibility to open the file in read/write mode. open my $FH, '+<', $filename or die $!; my @lines = <$FH>; truncate $FH, 0 or d

Re: reg:file handling

2008-03-16 Thread John W. Krahn
Gunnar Hjalmarsson wrote: Gowri Chandra Sekhar Barla, TLS, Chennai wrote: I am unable to modify the input file , In addition to other posted solutions, I thought I'd mention the possibility to open the file in read/write mode. open my $FH, '+<', $filename or die $!; my @lines = <$FH

Re: comparing some but not all fields in lists

2008-03-16 Thread David Newman
Jay Savage wrote: On Mon, Mar 3, 2008 at 5:32 PM, David Newman <[EMAIL PROTECTED]> wrote: Greetings. I'm looking to compare two contact lists in csv format, and then print out "here are the records in in Llist only, in Rlist only, and what's in common." I should compare only 3 of the 82 fiel