From echo_dev at hotmail.com Sat Feb 22 11:41:44 2003 From: echo_dev at hotmail.com (echo dev) Date: Thu Aug 5 00:19:43 2004 Subject: [roch-pm] Help with File handle. Message-ID: Hello, I just subscribed to your mailing list in need of a little help. I have a program that backs up a give file system or just a set of dir's. Well here is my problem I have a config sub that reads all the dir's in that give file system or set of dirs and matches there corresponding names with there paths and puts them in a config file. I need this file for later reference so I can thus rebuild the file system if the crash or some other OOPPS. Well back to the problem at had when I print something (something more like 500+ lines of paths) to stdio it prints everyone\ but when I print to a file it does'nt print anything. I open the file with open (CONFIG_FILE, ">/home/hde/file.conf") or die "Can't open file file.conf : $!\n"; then I select the output like select CONFIG_FILE; I don't have the complete source right now because I am at work but at you request I will be more then happy to post the sub when I arrive at my house thanks in advance. If you are in need of any more info plz let me know so I can post it thanks a lot. Happy Hacking hde _________________________________________________________________ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail -- For information on unsubscribing from this list, please visit http://rochester.pm.org From jkeen at concentric.net Sat Feb 22 16:29:31 2003 From: jkeen at concentric.net (James E Keenan) Date: Thu Aug 5 00:19:43 2004 Subject: [roch-pm] Help with File handle. References: Message-ID: <006101c2dac1$df9dcfc0$22b80340@concentric.net> ----- Original Message ----- From: "echo dev" To: Sent: Saturday, February 22, 2003 12:41 PM Subject: [roch-pm] Help with File handle. > when I print something (something more like 500+ > lines of paths) to stdio it prints everyone\ but when I print to a file it > does'nt print anything. I open the file with open > (CONFIG_FILE, ">/home/hde/file.conf") or > die "Can't open file file.conf : $!\n"; > > then I select the output like > > select CONFIG_FILE; > In the simplest case, there's no need to 'select CONFIG_FILE'. Why couldn't you just say: print CONFIG_FILE "$_\n" foreach (@paths); Jim Keenan -- For information on unsubscribing from this list, please visit http://rochester.pm.org From echo_dev at hotmail.com Sat Feb 22 19:31:26 2003 From: echo_dev at hotmail.com (echo dev) Date: Thu Aug 5 00:19:43 2004 Subject: [roch-pm] Help with File handle. Message-ID: >From: "James E Keenan" >Reply-To: rochester-pm-list@happyfunball.pm.org >To: >Subject: Re: [roch-pm] Help with File handle. >Date: Sat, 22 Feb 2003 17:29:31 -0500 > > >----- Original Message ----- >From: "echo dev" >To: >Sent: Saturday, February 22, 2003 12:41 PM >Subject: [roch-pm] Help with File handle. > > > > when I print something (something more like 500+ > > lines of paths) to stdio it prints everyone\ but when I print to a file >it > > does'nt print anything. I open the file with open > > (CONFIG_FILE, ">/home/hde/file.conf") or > > die "Can't open file file.conf : $!\n"; > > > > then I select the output like > > > > select CONFIG_FILE; > > >In the simplest case, there's no need to 'select CONFIG_FILE'. Why >couldn't >you just say: > print CONFIG_FILE "$_\n" foreach (@paths); > >Jim Keenan > >-- >For information on unsubscribing from this list, please visit >http://rochester.pm.org I have tried both and nothing will work except when I print to stdio. hde _________________________________________________________________ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 -- For information on unsubscribing from this list, please visit http://rochester.pm.org From jkeen at concentric.net Sat Feb 22 22:09:07 2003 From: jkeen at concentric.net (James E Keenan) Date: Thu Aug 5 00:19:43 2004 Subject: [roch-pm] Help with File handle. References: Message-ID: <00f601c2daf1$f13bd940$22b80340@concentric.net> ----- Original Message ----- From: "echo dev" To: Sent: Saturday, February 22, 2003 8:31 PM Subject: Re: [roch-pm] Help with File handle. > > > when I print something (something more like 500+ > > > lines of paths) to stdio it prints everyone\ but when I print to a file > >it > > > does'nt print anything. I open the file with open > > > (CONFIG_FILE, ">/home/hde/file.conf") or > > > die "Can't open file file.conf : $!\n"; > > > > > > then I select the output like > > > > > > select CONFIG_FILE; > > > > >In the simplest case, there's no need to 'select CONFIG_FILE'. Why > >couldn't > >you just say: > > print CONFIG_FILE "$_\n" foreach (@paths); > > > >Jim Keenan > > > >-- > >For information on unsubscribing from this list, please visit > >http://rochester.pm.org > I have tried both and nothing will work except when I print to stdio. > > hde > Then you should probably post the "config sub" you referred to in the OP. -- For information on unsubscribing from this list, please visit http://rochester.pm.org From bwalton at rochester.rr.com Sat Feb 22 22:39:13 2003 From: bwalton at rochester.rr.com (Bob Walton) Date: Thu Aug 5 00:19:43 2004 Subject: [roch-pm] Help with File handle. References: Message-ID: <3E585071.9060806@rochester.rr.com> echo dev wrote: >> From: "James E Keenan" ... > I have tried both and nothing will work except when I print to stdio. ... Hmmmm...can you tell us if the following test program copied verbatim generates file /home/hde/file.conf with one line of output in it: open CONFIG_FILE,">/home/hde/file.conf" or die "Oops, $!"; print CONFIG_FILE "This is a line of output\n"; Note that the select function has nothing to do with where output gets written by the print function. And note there is no comma following the filehandle specification in the print function call (that being a common error). -- Bob Walton -- For information on unsubscribing from this list, please visit http://rochester.pm.org From bwalton at rochester.rr.com Sat Feb 22 22:47:22 2003 From: bwalton at rochester.rr.com (Bob Walton) Date: Thu Aug 5 00:19:43 2004 Subject: [roch-pm] Oops References: <3E585071.9060806@rochester.rr.com> Message-ID: <3E58525A.5030204@rochester.rr.com> Bob Walton wrote: ... > Note that the select function has nothing to do with where output gets > written by the print function. ... ... Oops, I see that the select function does indeed specify the default filehandle for the print function -- sorry about the misinformation. I've never seen it used that way before -- probably because it is so much clearer to specify the filehandle when printing to anything other than STDOUT. -- Bob Walton -- For information on unsubscribing from this list, please visit http://rochester.pm.org From echo_dev at hotmail.com Sun Feb 23 00:05:17 2003 From: echo_dev at hotmail.com (echo dev) Date: Thu Aug 5 00:19:43 2004 Subject: [roch-pm] Help with File handle. Message-ID: Here is the sub with errors. Thanks hde sub code_base_conf { my @file_contents; my $start_dir = shift; my @dir_contents; my $cwd = $start_dir; my $old_cwd; open (CONFIG_FILE, ">/home/hde/code_serv.conf") or die "Can't create config file : $!\n"; chdir ($start_dir) or die "Can't cd to $start_dir : $!\n"; opendir (DIR, $start_dir) or die "Can't open $start_dir : $!\n"; @dir_contents = readdir (DIR) or die "Can't read dir $start_dir : $!\n"; closedir (DIR) or die "Can't close dir $start_dir : $!\n"; select CONFIG_FILE; for my $file_or_dir (@dir_contents) { next if ($file_or_dir eq qq{.}); next if ($file_or_dir eq qq{..}); if (-d $file_or_dir) # If the file is a directory. { next if (-l $file_or_dir); $cwd = &cwd; $old_cwd = $cwd; $cwd =~ s{(/.*/)+}{}g; printf ("%s %s %s\n", $cwd, "=>", $old_cwd); $cwd = &cwd; chdir (qq{$cwd/$file_or_dir}) or die "Can't cd to $cwd/$file_or_dir : $!\n"; opendir (DIR, qq{$cwd/$file_or_dir}) or die "Can't open dir $file_or_dir : $!\n"; code_base_conf ((readdir (DIR))); closedir (DIR); chdir ($cwd) or die "Can't cd to $cwd : $!\n"; next; } } chdir ("/home/hde/code_base/perl/code_base_Backup"); #clean_conf ("./code_serv.conf"); } _________________________________________________________________ Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail -- For information on unsubscribing from this list, please visit http://rochester.pm.org From echo_dev at hotmail.com Sun Feb 23 02:14:54 2003 From: echo_dev at hotmail.com (echo dev) Date: Thu Aug 5 00:19:43 2004 Subject: [roch-pm] Help with File handle. Message-ID: Hey, Never mind I fixed the bug see I had the open in the sub and everytime I recurivly called the sub it made a new file. So I moved the open out of the sub and BOOM it works great thanks everyone. Happy Hacking hde >From: "echo dev" >Reply-To: rochester-pm-list@happyfunball.pm.org >To: rochester-pm-list@happyfunball.pm.org >Subject: Re: [roch-pm] Help with File handle. >Date: Sun, 23 Feb 2003 06:05:17 +0000 > >Here is the sub with errors. > >Thanks >hde > >sub code_base_conf >{ > my @file_contents; > my $start_dir = shift; > my @dir_contents; > my $cwd = $start_dir; > my $old_cwd; > > open (CONFIG_FILE, ">/home/hde/code_serv.conf") > or die "Can't create config file : $!\n"; > > chdir ($start_dir) or > die "Can't cd to $start_dir : $!\n"; > > opendir (DIR, $start_dir) > or die "Can't open $start_dir : $!\n"; > > @dir_contents = readdir (DIR) > or die "Can't read dir $start_dir : $!\n"; > > closedir (DIR) or > die "Can't close dir $start_dir : $!\n"; > > select CONFIG_FILE; > > for my $file_or_dir (@dir_contents) > { > next if ($file_or_dir eq qq{.}); > next if ($file_or_dir eq qq{..}); > > if (-d $file_or_dir) # If the file is a directory. > { > next if (-l $file_or_dir); > > $cwd = &cwd; > $old_cwd = $cwd; > $cwd =~ s{(/.*/)+}{}g; > > printf ("%s %s %s\n", $cwd, "=>", $old_cwd); > $cwd = &cwd; > > chdir (qq{$cwd/$file_or_dir}) or > die "Can't cd to $cwd/$file_or_dir : $!\n"; > > opendir (DIR, qq{$cwd/$file_or_dir}) or > die "Can't open dir $file_or_dir : $!\n"; > > code_base_conf ((readdir (DIR))); > > closedir (DIR); > > chdir ($cwd) or > die "Can't cd to $cwd : $!\n"; > > next; > } > > } > chdir ("/home/hde/code_base/perl/code_base_Backup"); > #clean_conf ("./code_serv.conf"); >} > >_________________________________________________________________ >Add photos to your e-mail with MSN 8. Get 2 months FREE*. >http://join.msn.com/?page=features/featuredemail > >-- >For information on unsubscribing from this list, please visit >http://rochester.pm.org _________________________________________________________________ MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus -- For information on unsubscribing from this list, please visit http://rochester.pm.org