Re: Problem with my code

2007-08-08 Thread Dr.Ruud
"Mumia W." schreef: > Jeff Pang wrote: >> [...] >> while(my $obj = readdir DIR) { >> next if $obj =~ /^\.+$/; #or [...] > > More, precisely, you might use this: > > next if $obj =~ /\A\.\.?\z/; Please see `perldoc -f -f`. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mai

Re: Problem with my code

2007-08-06 Thread Mr. Shawn H. Corey
perl pra wrote: hi jhon, If I use use opendir/readdir I am getting the default directories . and .. into the directoy handle. Is there any way tha i could eliminate this. For example if i want to copy all contentents of the directory(including sub directories) I open a directory Handle using

Re: Problem with my code

2007-08-05 Thread perl pra
Thanks a lot Regards, Siva On 8/6/07, Mumia W. <[EMAIL PROTECTED]> wrote: > > On 08/06/2007 12:32 AM, Jeff Pang wrote: > > [...] > > while(my $obj = readdir DIR) { > > next if $obj =~ /^\.+$/; #or [...] > > More, precisely, you might use this: > >next if $obj =~ /\A\.\.?\z/; > > > >

Re: Problem with my code

2007-08-05 Thread Mumia W.
On 08/06/2007 12:32 AM, Jeff Pang wrote: [...] while(my $obj = readdir DIR) { next if $obj =~ /^\.+$/; #or [...] More, precisely, you might use this: next if $obj =~ /\A\.\.?\z/; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] htt

Re: Problem with my code

2007-08-05 Thread Jeff Pang
-Original Message- >From: Jeff Pang <[EMAIL PROTECTED]> > >while() { >next if /^\.+$/; #or >next if $_ eq '.' or $_ eq '..'; >} > Sorry for the mistake,it's, while(my $obj = readdir DIR) { next if $obj =~ /^\.+$/; #or next if $obj eq '.' or $obj eq '..'; } -- Jeff Pang

Re: Problem with my code

2007-08-05 Thread Jeff Pang
-Original Message- >From: perl pra <[EMAIL PROTECTED]> >Sent: Aug 6, 2007 12:29 PM >To: "John W. Krahn" <[EMAIL PROTECTED]> >Cc: Perl beginners >Subject: Re: Problem with my code > >hi jhon, > >If I use use opendir/readdir I am getting th

Re: Problem with my code

2007-08-05 Thread perl pra
hi jhon, If I use use opendir/readdir I am getting the default directories . and .. into the directoy handle. Is there any way tha i could eliminate this. For example if i want to copy all contentents of the directory(including sub directories) I open a directory Handle using opendir and read

Re: Problem with my code

2007-08-04 Thread John W. Krahn
perl pra wrote: hi Mihir Kamdar, Please the following highlighted. I have tested it. this excatly does what you need. configure the parent_path,child_path and out_path to your corresponding paths. _ BEGIN use strict; use File::Path; use File::Copy; use warnings; m

Re: Problem with my code

2007-08-04 Thread perl pra
hi Mihir Kamdar, Please the following highlighted. I have tested it. this excatly does what you need. configure the parent_path,child_path and out_path to your corresponding paths. _ BEGIN use strict; use File::Path; use File::Copy; use warnings; my $parent_path="C:

Re: Problem with my code

2007-08-04 Thread perl pra
hi Mihir Kamdar, Please the following highlighted. I have tested it. this excatly does what you need. configure the parent_path,child_path and out_path to your corresponding paths. _ BEGIN use strict; use File::Path; use File::Copy; use warnings; my $parent_path="C:/

Re: Problem with my code

2007-08-03 Thread [EMAIL PROTECTED]
On Aug 3, 6:54 am, [EMAIL PROTECTED] (Mihir Kamdar) wrote: > I appreciate your comments and have tried to make changes as per your > suggestions. Plz have a look at the below and comment if any further changes > are required. This is turning out to be a good learning for me. Most of the things I

Re: Problem with my code

2007-08-03 Thread Chas Owens
On 8/3/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: > Chas Owens wrote: > > Okay, I will concede that, but there is generally a character that is > > safe (usually the character the line was split on). In this case > > $hash{join ',', @cdr[2,3,6,7]} = $line; > > is safe due to the fact th

Re: Problem with my code

2007-08-03 Thread Mr. Shawn H. Corey
Chas Owens wrote: Okay, I will concede that, but there is generally a character that is safe (usually the character the line was split on). In this case $hash{join ',', @cdr[2,3,6,7]} = $line; is safe due to the fact that @cdr was created using split /,/, so I would recommend that over a mul

Re: Problem with my code

2007-08-03 Thread Chas Owens
On 8/3/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: snip > Whnever you use a composite key, you have the possibility of a collision. snip Okay, I will concede that, but there is generally a character that is safe (usually the character the line was split on). In this case $hash{join ',',

Re: Problem with my code

2007-08-03 Thread Mr. Shawn H. Corey
Chas Owens wrote: Note that my advice is to use $hash3{"@key"} Which does not suffer from that problem and that I specifically said "you don't want the spaces that using an array slice will add". Whnever you use a composite key, you have the possibility of a collision. #!/usr/bin/perl use

Re: Problem with my code

2007-08-03 Thread Chas Owens
On 8/3/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: > Chas Owens wrote: > > The use of the special variable $; is not why > > $foo{$a[1],$a[2],$a[3],$a[4]} is a bad choice; it is a bad choice > > because it is hard to tell if they meant to use > > @foo{$a[1],$a[2],$a[3],$a[4]} but screwed up t

Re: Problem with my code

2007-08-03 Thread Xavier Noria
El Aug 3, 2007, a las 1:45 PM, Mr. Shawn H. Corey escribió: But the expression $hash{"@cdr[2,3,6,7]"} is the same as $hash{join ($",@cdr[2,3,6,7])} You have just replaced one special variable with another and $" is a bad choice since it's default is a space character, which may easily appea

Re: Problem with my code

2007-08-03 Thread Mr. Shawn H. Corey
Chas Owens wrote: The use of the special variable $; is not why $foo{$a[1],$a[2],$a[3],$a[4]} is a bad choice; it is a bad choice because it is hard to tell if they meant to use @foo{$a[1],$a[2],$a[3],$a[4]} but screwed up the sigil. The spaces are only important if you want to recover the indiv

Re: Problem with my code

2007-08-03 Thread Chas Owens
On 8/3/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: snip > But the expression $hash{"@cdr[2,3,6,7]"} is the same as > $hash{join($",@cdr[2,3,6,7])} You have just replaced one special variable > with another and $" is a bad choice since it's default is a space character, > which may easily

Re: Problem with my code

2007-08-03 Thread Mr. Shawn H. Corey
Chas Owens wrote: On 8/3/07, Jeff Pang <[EMAIL PROTECTED]> wrote: -Original Message- From: Mihir Kamdar <[EMAIL PROTECTED]> $hash{$cdr[2],$cdr[3],$cdr[6],$cdr[7]}=$line; #Add some more cdr key fields if u want. There are (maybe) two problems above. 1. when using hash slice,the form

Re: Problem with my code

2007-08-03 Thread Jeff Pang
-Original Message- >From: Chas Owens <[EMAIL PROTECTED]> >Sent: Aug 3, 2007 3:21 AM >To: Jeff Pang <[EMAIL PROTECTED]> >Cc: beginners@perl.org >Subject: Re: Problem with my code > >On 8/3/07, Jeff Pang <[EMAIL PROTECTED]> wrote: >> >> &

Re: Problem with my code

2007-08-03 Thread Chas Owens
On 8/3/07, Jeff Pang <[EMAIL PROTECTED]> wrote: > > > -Original Message- > >From: Mihir Kamdar <[EMAIL PROTECTED]> > > >$hash{$cdr[2],$cdr[3],$cdr[6],$cdr[7]}=$line; #Add some more cdr key fields > >if u want. > > There are (maybe) two problems above. > 1. when using hash slice,the form i

Re: Problem with my code

2007-08-02 Thread Jeff Pang
-Original Message- >From: Mihir Kamdar <[EMAIL PROTECTED]> >$hash{$cdr[2],$cdr[3],$cdr[6],$cdr[7]}=$line; #Add some more cdr key fields >if u want. There are (maybe) two problems above. 1. when using hash slice,the form is @hash{'key1','key2'...},not $hash{'key1','key2'...} 2. when y

Re: Problem with my code

2007-08-02 Thread Mihir Kamdar
On 8/2/07, Chas Owens <[EMAIL PROTECTED]> wrote: > > On 8/2/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote: > > > #!/usr/bin/perl > > > > my $child_path = > > > '/home/user71/RangerDatasource/Customization/TelekomMalaysia/Scripts/Tests/cprogs/files/child' > > ; > > my $parent_path = > > > '/home/user71

Re: Problem with my code

2007-08-02 Thread Chas Owens
On 8/2/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote: > #!/usr/bin/perl > > my $child_path = > '/home/user71/RangerDatasource/Customization/TelekomMalaysia/Scripts/Tests/cprogs/files/child' > ; > my $parent_path = > '/home/user71/RangerDatasource/Customization/TelekomMalaysia/Scripts/Tests/cprogs/fil

Re: Problem with my code

2007-08-02 Thread Mihir Kamdar
On 8/2/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > On Aug 2, 10:48 am, [EMAIL PROTECTED] (Mihir Kamdar) wrote: > > > my $line; > > my %hash; > > my @file; > > my $key ; > > my $value ; > > my %times ; > > You appear to be suffering from a nasty case of premature declaration. > > Looking at

Re: Problem with my code

2007-08-02 Thread [EMAIL PROTECTED]
On Aug 2, 10:48 am, [EMAIL PROTECTED] (Mihir Kamdar) wrote: > my $line; > my %hash; > my @file; > my $key ; > my $value ; > my %times ; You appear to be suffering from a nasty case of premature declaration. Looking at your code it appears that three of those are harmlessly being declared in the

Re: Problem with my code

2007-08-02 Thread Mr. Shawn H. Corey
Mihir Kamdar wrote: As soon as the data file is updated completely, the tag file is touched with the same name in the child directory. This process is automatic. No manual touching of tag files. As per my requirement, in my code, I am trying to open the child directory, read the tag name, open

Re: Problem with my code

2007-08-02 Thread Mihir Kamdar
On 8/2/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: > > Ken Foskey wrote: > > I find this style more 'normal'. > > > > foreach my $key (keys %hash) { > > print $OUT_FILE $hash{$key}; > > } > > > > Or even this to make code predictable: >

Re: Problem with my code

2007-08-02 Thread Mr. Shawn H. Corey
Ken Foskey wrote: I find this style more 'normal'. foreach my $key (keys %hash) { print $OUT_FILE $hash{$key}; } Or even this to make code predictable: foreach my $key (sort keys %hash) { print $OUT

Re: Problem with my code

2007-08-02 Thread Ken Foskey
On Thu, 2007-08-02 at 17:44 +0530, Mihir Kamdar wrote: ... Have you run it in a debugger and seen what happens? perl -d script The snippet does not actually assign to %hash, I assume it is in the missing code but you should show a sample line from it. > while (($key, $value) =

RE: Problem with my code

2007-08-02 Thread Bob McConnell
> -Original Message- > From: Mihir Kamdar > Sent: Thursday, August 02, 2007 8:15 AM > To: beginners > Subject: Re: Problem with my code > > On 8/2/07, Mihir Kamdar wrote: > > > > > > > > On 8/2/07, Mihir Kamdar wrote: > > > > >

Re: Problem with my code

2007-08-02 Thread Mihir Kamdar
On 8/2/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote: > > > > On 8/2/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > I have a requirement. There are files in the parent directory and they > > are touched in the child directory. So in child directory there are 0 byte > > files having th

Re: Problem with my code

2007-08-02 Thread Mihir Kamdar
On 8/2/07, Mihir Kamdar <[EMAIL PROTECTED]> wrote: > > Hi, > > I have a requirement. There are files in the parent directory and they are > touched in the child directory. So in child directory there are 0 byte files > having the same name as the ones in the parent directory. I need to read > files

Problem with my code

2007-08-02 Thread Mihir Kamdar
Hi, I have a requirement. There are files in the parent directory and they are touched in the child directory. So in child directory there are 0 byte files having the same name as the ones in the parent directory. I need to read files in the child directory, and for each file present in the child