Re: writing to output using filehandles

2011-04-12 Thread Rob Dixon
On 12/04/2011 01:47, mark baumeister wrote: Hi I am having trouble with my search and replace code in the program below. I can sucessfully copy the input file to the output file but my search and replace is not working. Any hints on what I am doing wrong? Hello Mark. You must tell us what i

RE: writing to output using filehandles

2011-04-12 Thread Sunita Rani Pradhan
AM To: beginners@perl.org Subject: writing to output using filehandles Hi I am having trouble with my search and replace code in the program below. I can sucessfully copy the input file to the output file but my search and replace is not working. Any hints on what I am doing wrong? Thanks, M #!/

writing to output using filehandles

2011-04-12 Thread mark baumeister
Hi I am having trouble with my search and replace code in the program below. I can sucessfully copy the input file to the output file but my search and replace is not working. Any hints on what I am doing wrong? Thanks, M #!/usr/bin/perl -w use strict; my $input; my $output; my $search; my $rep

Re: Closing all filehandles associated with a filedescriptor...

2009-12-12 Thread James Olin Oden
ec...they could tell me but that would feel like a really clumsy daemon library. I did find this out though. There is a "table" of filehandles (or really PerlIO structures) in perlio.c. This is what is iterated across when you exit perl. What I need to do is write some C code that wil

Re: Closing all filehandles associated with a filedescriptor...

2009-12-12 Thread C.DeRykus
;> expect to have.   The code to close the fd was using POSIX::close(), > >> and this was a bad idea because, though it closes the fd, it leaves > >> any perl filehandles associated with the fd hanging around.  This > >> makes for really twisty and perplexing bugs. > >

Re: Closing all filehandles associated with a filedescriptor...

2009-12-11 Thread James Olin Oden
ons and at some >> point code was added to handle closing all fd's so the daemonized >> process would not have fd's hanging around it shouldn't have or didn't >> expect to have.   The code to close the fd was using POSIX::close(), >> and this was a bad idea becau

Re: Closing all filehandles associated with a filedescriptor...

2009-12-11 Thread Shawn H Corey
onized > process would not have fd's hanging around it shouldn't have or didn't > expect to have. The code to close the fd was using POSIX::close(), > and this was a bad idea because, though it closes the fd, it leaves > any perl filehandles associated with the fd hang

Closing all filehandles associated with a filedescriptor...

2009-12-11 Thread James Olin Oden
ldn't have or didn't expect to have. The code to close the fd was using POSIX::close(), and this was a bad idea because, though it closes the fd, it leaves any perl filehandles associated with the fd hanging around. This makes for really twisty and perplexing bugs. So I don't want

Re: A question on filehandles

2009-10-28 Thread Shawn H Corey
ANJAN PURKAYASTHA wrote: > A filehandle to run a program ?!! And what is that pipe symbol doing there? > Would appreciate any pointers to how this works or where I can read up > about this. Yes Perl can use pipes in open. See: perldoc -f open http://perldoc.perl.org/functions/open.html perld

Re: A question on filehandles

2009-10-28 Thread Jim Gibson
On 10/28/09 Wed Oct 28, 2009 3:00 PM, "ANJAN PURKAYASTHA" scribbled: > Trying to learn how to run Gnuplot via a Perl script I came across the > following helpful example: > > #!/usr/bin/perl > # Generate postscript and png plot with GNUplot from Perl > # Author: Ioan Vancea > # Usage: Give "da

A question on filehandles

2009-10-28 Thread ANJAN PURKAYASTHA
Trying to learn how to run Gnuplot via a Perl script I came across the following helpful example: #!/usr/bin/perl # Generate postscript and png plot with GNUplot from Perl # Author: Ioan Vancea # Usage: Give "data file" as an argument for script use strict; use warnings; my $file = ARGV[0]; # P

Re: Running an interactive program with filehandles

2008-03-25 Thread Chas. Owens
On Tue, Mar 25, 2008 at 8:30 PM, ANJAN PURKAYASTHA <[EMAIL PROTECTED]> wrote: snip > HP->autoflush(1); snip > Unfortunately this gives me a list of errors: > > perl handle_test.pl > Can't locate object method "autoflush" via package "IO::Handle" at > handle_test.pl line 7. snip In order to u

Running an interactive program with filehandles

2008-03-25 Thread ANJAN PURKAYASTHA
Consider the following program- HydrophobicityProfiler.pl Here is a sample run of the program: perl HydrophobicityProfiler.pl Enter the name of the sequence file (try protein.txt) and then press Enter: ../data/protein.txt Enter the desired window size as an odd number and then press Enter: 5 Which

Re: Filehandles in a socket server

2008-03-10 Thread Tom Phoenix
On Mon, Mar 10, 2008 at 7:43 AM, Jonathan Mast <[EMAIL PROTECTED]> wrote: > What benefit does flushing have? Would it help prevent memory > leaks as per the above scenario or what? Flushing gets the data out right away, in case there's anybody waiting for it. In the case of log files, it means

Re: Filehandles in a socket server

2008-03-10 Thread Jonathan Mast
Yeah I'm leaving it alone for now. The socket server receives input episodically and could be invoked thousands of times per minute. But typically it 2 or 3 times per hour. It just seems to be a design flaw to do the repeated open/closing stuff inside the while loop. But something that just cam

Re: Filehandles in a socket server

2008-03-10 Thread Rob Dixon
Jonathan Mast wrote: > We have a socket server that, in addition to serving data, also writes logging statements to a file. My question concerns the correctness of how it accesses the log file. The script is running continuously and all the log file IO stuff is inside the main 'while' loop. The

Re: Filehandles in a socket server

2008-03-10 Thread Chas. Owens
On Mon, Mar 10, 2008 at 10:08 AM, Jonathan Mast <[EMAIL PROTECTED]> wrote: > We have a socket server that, in addition to serving data, also writes > logging statements to a file. > > My question concerns the correctness of how it accesses the log file. The > script is running continuously and

Re: Filehandles in a socket server

2008-03-10 Thread John W. Krahn
Jonathan Mast wrote: We have a socket server that, in addition to serving data, also writes logging statements to a file. My question concerns the correctness of how it accesses the log file. The script is running continuously and all the log file IO stuff is inside the main 'while' loop. The f

Filehandles in a socket server

2008-03-10 Thread Jonathan Mast
We have a socket server that, in addition to serving data, also writes logging statements to a file. My question concerns the correctness of how it accesses the log file. The script is running continuously and all the log file IO stuff is inside the main 'while' loop. The file is opened, written

Re: Storing filehandles(for writing) in hashes doesn't work (Re: whilereach my $variable () )

2007-01-16 Thread Mumia W.
On 01/16/2007 04:02 AM, Michael Alipio wrote: - Original Message From: Mumia W. <[EMAIL PROTECTED]> To: Beginners List Sent: Tuesday, January 16, 2007 3:13:38 PM Subject: Re: Storing filehandles(for writing) in hashes doesn't work (Re: whilereach my $variable () ) On 01/15

Re: Storing filehandles(for writing) in hashes doesn't work (Re: whilereach my $variable () )

2007-01-16 Thread Michael Alipio
e of uninitialized value in ref-to-glob cast at extractdevice.pl line 20. Can't use string ("") as a symbol ref while "strict refs" in use at extractdevice.pl line 20. Any idea what does the above means? - Original Message From: Mumia W. <[EMAIL PROTECTE

Re: Storing filehandles(for writing) in hashes doesn't work (Re: whilereach my $variable () )

2007-01-16 Thread Mumia W.
chomp $device; ($device) = $device =~ /(\S+)$/; open( my $fh, '>', "$device.log") or die "Can't open $device.log: $!"; $log{$device} = $fh; } close DEVICES; # So far I can understand that in the first part, the code will read the deviceid.conf and c

RE: Storing filehandles(for writing) in hashes doesn't work (Re: whilereach my $variable () )

2007-01-15 Thread Thomas Bätzler
DEVICES, '<', $devices or die "Can't open $devices $!"; my %log; my %client; while ( my $line = ){ my($clientid, $devid) = ( $line =~ m/^(\S+)\s+-\s+(\S+)/ ); # store device-id <=> client-id relationship $client{$devid} = $clientid; # store dev

Storing filehandles(for writing) in hashes doesn't work (Re: whilereach my $variable () )

2007-01-15 Thread Michael Alipio
ot;; $log{$device} = $fh; } close DEVICES; # So far I can understand that in the first part, the code will read the deviceid.conf and create a file handle for writing for each device id, and store these filehandles inside %log. But that is what I wanted to do, I want to, as I wante

Re: 'use strict' and filehandles

2006-08-31 Thread Ted Fines
--- Original Message --- > Ted Fines wrote: > > Hi, > > Hello, > > > I'm running into a Cach-22 with 'use strict', and filehandles. > > > > I have a program which opens two log files at the beginning: > > open(INFLOG,">>$info

Re: 'use strict' and filehandles

2006-08-31 Thread John W. Krahn
Ted Fines wrote: > Hi, Hello, > I'm running into a Cach-22 with 'use strict', and filehandles. > > I have a program which opens two log files at the beginning: > open(INFLOG,">>$info_log") || die "Could not append to $info_log_file. > Qui

RE: 'use strict' and filehandles

2006-08-31 Thread Timothy Johnson
lto:[EMAIL PROTECTED] Sent: Thursday, August 31, 2006 12:17 PM To: beginners@perl.org Subject: 'use strict' and filehandles Hi, I'm running into a Cach-22 with 'use strict', and filehandles. I have a program which opens two log files at the beginning: open(INFLOG,"&

'use strict' and filehandles

2006-08-31 Thread Ted Fines
Hi, I'm running into a Cach-22 with 'use strict', and filehandles. I have a program which opens two log files at the beginning: open(INFLOG,">>$info_log") || die "Could not append to $info_log_file. Quitting.\n"; open(ERRLOG,">>$err

Re: combine 2 "open for reading" filehandles

2006-04-19 Thread JupiterHost.Net
I didn't test this so don't assume it will work, but I think it should ;-) eof should return true if there is nothing left to read. So, instead of using <> which will block until there's something to read (or the fh is closed), you could periodically test eof on your file handles. Perhaps some

Re: combine 2 "open for reading" filehandles

2006-04-19 Thread JupiterHost.Net
John W. Krahn wrote: JupiterHost.Net wrote: Howdy list :) Hello, I'm having a bit of a time with combining 2 read filehandles. The FAQ has a good explanation about that: perldoc -q stderr That was informative, thanks! I ended up using IO::Select to process the open3 rea

Re: combine 2 "open for reading" filehandles

2006-04-17 Thread John W. Krahn
JupiterHost.Net wrote: > Howdy list :) Hello, > I'm having a bit of a time with combining 2 read filehandles. The FAQ has a good explanation about that: perldoc -q stderr John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comma

Re: combine 2 "open for reading" filehandles

2006-04-17 Thread M. Kristall
JupiterHost.Net wrote: Howdy list :) I'm having a bit of a time with combining 2 read filehandles. [snip] What I'd like to do is process $read_fh and $error_fh in the order they actually happen ( which is what open3($write_fh, $read_fh, $read_fh, ... does ) but still have the er

combine 2 "open for reading" filehandles

2006-04-17 Thread JupiterHost.Net
Howdy list :) I'm having a bit of a time with combining 2 read filehandles. Let me explain, use strict; use warnings; use IPC::Open3; my ($write_fh, $read_fh, $error_fh); open3($write_fh, $read_fh, $error_fh, ... while(<$read_fh>) { ... } while(<$error_fh>) { ... }

Re: Type-globbing filehandles

2005-03-17 Thread Offer Kaye
On Thu, 17 Mar 2005 12:54:23 -0600, Dave Kettmann wrote: > Here is the whole first part. Snipped part is just declaration of variables. > Okay, here is the problem: > > use File::Remote qw(:replace); > The problem is, when you use the ":replace" tag, File::Remote imports new "open" and "close"

RE: Type-globbing filehandles

2005-03-17 Thread Dave Kettmann
nal Message- > From: Offer Kaye [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 17, 2005 9:14 AM > To: Perl Beginners > Subject: Re: Type-globbing filehandles > > > On Thu, 17 Mar 2005 08:46:55 -0600, Dave Kettmann wrote: > > > > > > > > ope

Re: Type-globbing filehandles

2005-03-17 Thread Offer Kaye
On Thu, 17 Mar 2005 08:46:55 -0600, Dave Kettmann wrote: > > > > open (CFG, "/etc/backup.conf") or die "Can't open config file: $!\n"; > while () { > } > close CFG; > > > > Ok so when I run my program like this .. it complains on the the open() line > and the close() line. > It

Type-globbing filehandles

2005-03-17 Thread Dave Kettmann
Hi all, I think I am using the term (Type-globbing) correctly but we will see... I have a program I am making that needs to read lines from a file. Here is a snip of code to show what I'm doing... #/usr/bin/perl use strict; use warnings; my (%User_Preferences, $var, $value); open (CFG,

Re: Can't use global FILEHANDLEs?

2004-01-31 Thread TeamSolCO
This matter has already been resolved. Thank you for following up. : TeamSolCO wrote: : : > To start, let me say this: : > 1) I have both "Learning Perl 3rd Ed" and "Programming Perl 3rd Ed" : > 2) I have read "Learning Perl 3rd Ed", and I use "Programming Perl 3rd Ed" as reference. : > 3) I ha

Re: Can't use global FILEHANDLEs?

2004-01-31 Thread Rob Dixon
Teamsolco wrote: > > To start, let me say this: > 1) I have both "Learning Perl 3rd Ed" and "Programming Perl 3rd Ed" > 2) I have read "Learning Perl 3rd Ed", and I use "Programming Perl 3rd Ed" as > reference. > 3) I have searched with Google for several key words related to my problem, but the

Re: Can't use global FILEHANDLEs?

2004-01-31 Thread R. Joseph Newton
TeamSolCO wrote: > To start, let me say this: > 1) I have both "Learning Perl 3rd Ed" and "Programming Perl 3rd Ed" > 2) I have read "Learning Perl 3rd Ed", and I use "Programming Perl 3rd Ed" as > reference. > 3) I have searched with Google for several key words related to my problem, but the >

Re: Can't use global FILEHANDLEs?

2004-01-31 Thread TeamSolCO
to use : > the traditional, 'HNDFIFO' and 'HNDLOG' variable names in "our (HNDFIFO, : > HNDLOG);" fashion. What I have now is working. Do you have a better : > recommendation? : : Perl's filehandles are "global". Unless you are using packages, :

Re: Can't use global FILEHANDLEs?

2004-01-31 Thread John McKown
On Sat, 31 Jan 2004, John W. Krahn wrote: > use POSIX 'mkfifo'; > > die "Cannot initialize $path_fifo: $!" > unless unlink $path_fifo and mkfifo $path_fifo and chmod 0600, > $path_fifo; > Just one, very minor "improvement", of the above might be: die "Cannot initialize $path_fifl: $!"

Re: Can't use global FILEHANDLEs?

2004-01-31 Thread John W. Krahn
o'; die "Cannot initialize $path_fifo: $!" unless unlink $path_fifo and mkfifo $path_fifo and chmod 0600, $path_fifo; > : > our ($hndLOG, $hndFIFO); > : > : Why use 'our' and not 'my'? Why use scalars and not filehandles? > > I'm using 'o

Re: Can't use global FILEHANDLEs?

2004-01-31 Thread TeamSolCO
f code to be more sensitive to failure (useless $! values will just come with the territory): unless ((unlink($path_fifo)) && ((system("mkfifo $path_fifo")) || (chmod(0600, $path_fifo { die("Cannot initialize $path_fifo: $!"); } : > our ($hndLOG, $hnd

Re: Can't use global FILEHANDLEs?

2004-01-30 Thread TeamSolCO
January 30, 2004 3:26 PM Subject: Re: Can't use global FILEHANDLEs? : TeamSolCO wrote: : > Now then, I've opened a can of worms by adding "use strict" and : > "use warnings" to the source. Keep in mind that this application : > was running JUST FINE before doing

Re: Can't use global FILEHANDLEs?

2004-01-30 Thread Rob Dixon
Sorry - bad click. /R -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Can't use global FILEHANDLEs?

2004-01-30 Thread Rob Dixon
"Teamsolco" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > To start, let me say this: > 1) I have both "Learning Perl 3rd Ed" and "Programming Perl 3rd Ed" > 2) I have read "Learning Perl 3rd Ed", and I use "Programming Perl 3rd Ed" as > reference. > 3) I have searched with Google

Re: Can't use global FILEHANDLEs?

2004-01-30 Thread John W. Krahn
r die "Can't mkfifo $path_fifo: $!"; > chmod(0600, $path_fifo); You should check the return from chmod. chmod 0600, $path_fifo or die "Cannot chmod $path_fifo: $!"; > } > > # Open the $hndFIFO stream. > open($hndFIFO, "< $path_fifo&qu

Re: Can't use global FILEHANDLEs?

2004-01-30 Thread Steve Grazzini
fifo(); When you call this the first time, you'll end up doing close($hndFIFO = undef); And strict won't let you dereference "undef" as a filehandle -- for historical reasons, filehandles and glob/symbol references are more equivalent than they should be, and that's why you

Can't use global FILEHANDLEs?

2004-01-30 Thread TeamSolCO
To start, let me say this: 1) I have both "Learning Perl 3rd Ed" and "Programming Perl 3rd Ed" 2) I have read "Learning Perl 3rd Ed", and I use "Programming Perl 3rd Ed" as reference. 3) I have searched with Google for several key words related to my problem, but the mass of junk I get back is no

Re: use strict and filehandles

2004-01-22 Thread Peter Scott
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (B McKee) writes: >On Tuesday, January 20, 2004, at 10:34 AM, B McKee wrote: > >> Hi All, >> I'm having trouble understanding what use strict is trying to tell me. >> If I have run this program >...snipped >> open(MESSAGE, "$datafile") or die "Can

Re: use strict and filehandles

2004-01-21 Thread B McKee
On Tuesday, January 20, 2004, at 10:34 AM, B McKee wrote: Hi All, I'm having trouble understanding what use strict is trying to tell me. If I have run this program ...snipped open(MESSAGE, "$datafile") or die "Cannot open datafile: $!"; while (!eof(MESSAGE)) { $page = new CGI(MESSAGE); ...mor

Re: Filehandles stored in hashes

2004-01-20 Thread Robin Sheat
On Wed, Jan 21, 2004 at 12:40:39AM -0500, Steve Grazzini wrote: > But you have a syntax error as well, because the hash-dereference > <$self->{filehandle}> > ^..^ Ahh, I didn't notice that at all, I was wondering why it was complaining about it...shoulda twigged :) > You've already fo

Re: Filehandles stored in hashes

2004-01-20 Thread Steve Grazzini
On Tuesday, January 20, 2004, at 11:34 PM, Robin Sheat wrote: Hey there, I'm not a total beginner to Perl, but am far enough into it to have a lot of questions, so I hope this is a suitable place for them :) Fire away! sub getResponse { my $self = shift; my $incoming = <$self->{filehandle}

Re: Filehandles stored in hashes

2004-01-20 Thread Roberto Álamos Moreno
Hi, Robin. 1st Situation. I think the problem with " my $incoming = <$self->{filehandle}>; " it's that Perl thinks that the expresion inside the < > is $self- and then expects a semicolon but that semicolon isn't there. 2nd Situation. Do you like this option ? sub mySub { $foo = shift;

Filehandles stored in hashes

2004-01-20 Thread Robin Sheat
Hey there, I'm not a total beginner to Perl, but am far enough into it to have a lot of questions, so I hope this is a suitable place for them :) My current one is this. I have a method: sub getResponse { my $self = shift; my $fh = $self->{filehandle}; my $incoming = <$fh>; ...

Re: use strict and filehandles

2004-01-20 Thread Jan Eden
I had a similar problem passing a filehandle to a sub and learned that I had to use the typeglob instead. HTH, Jan B McKee wrote: >Hi All, >I'm having trouble understanding what use strict is trying to tell me. > >If I have run this program > >-CODE--- >#!/u

use strict and filehandles

2004-01-20 Thread B McKee
Hi All, I'm having trouble understanding what use strict is trying to tell me. If I have run this program -CODE--- #!/usr/bin/perl -wT # use warnings and turn on data tainting use CGI qw(:standard); $CGI::POST_MAX=1024 * 100; $CGI::DISABLE_UPLOADS = 1; use stric

RE: Persistant Filehandles.

2003-10-17 Thread Daniel Staal
--On Friday, October 17, 2003 13:46 -0500 "Charles K. Clarkson" <[EMAIL PROTECTED]> wrote: : (I've tried re-creating the : HTML::Stream too, or just using the 'global' version.) : This actually was my first try at it. Again, slide() : works fine, but slide_() doesn't, even though it gets : call

RE: Persistant Filehandles.

2003-10-17 Thread Charles K. Clarkson
Daniel Staal <[EMAIL PROTECTED]> : : : I actually tried that, using the following code: [code sample snipped] : : But that doesn't seem to work either. What do you mean by "doesn't seem to work"? : (I've tried re-creating the : HTML::Stream too, or just using the 'global' version.) : This

Re: Persistant Filehandles.

2003-10-17 Thread Daniel Staal
--On Friday, October 17, 2003 13:54 -0400 Steve Grazzini <[EMAIL PROTECTED]> wrote: You could use a lexically-scoped filehandle. { my $fh; sub do_open { open $fh } sub do_append { print $fh } sub do_close { close $fh } } I actually tried that, using t

Re: Persistant Filehandles.

2003-10-17 Thread Steve Grazzini
On Fri, Oct 17, 2003 at 12:38:33PM -0500, Daniel Staal wrote: > I need to open a filehandle in one sub, use it in several > others, and then close it in a different sub yet. I'd pass it as a > parameter, but all the subs are actually called by XML::Parser, so I > don't get to choose the paramet

Persistant Filehandles.

2003-10-17 Thread Daniel Staal
Ok, I'm writing an apxl to html converter and I have one little problem: I need to open a filehandle in one sub, use it in several others, and then close it in a different sub yet. I'd pass it as a parameter, but all the subs are actually called by XML::Parser, so I don't get to choose the par

Re: Question about filehandles

2003-07-02 Thread Jenda Krynicky
From: "Azubi CAI" <[EMAIL PROTECTED]> > Hi there, > > I need to substitute a string in a .rtf file with a string from an > HTML form. I thought about using placeholders in the .rtf document and > then searching and overwriting them with the data from the HTML form. > I tried it out with that code:

RE: Question about filehandles

2003-07-01 Thread Dan Muey
> Hi there, Howdy > > I need to substitute a string in a .rtf file with a string > from an HTML form. I thought about using placeholders in the > .rtf document and then searching and overwriting them with > the data from the HTML form. I tried it out with that code: > > #!/usr/bin/perl -w >

Re: Question about filehandles

2003-07-01 Thread Janek Schleicher
Azubi Cai wrote at Tue, 01 Jul 2003 16:40:23 +0200: > I need to substitute a string in a .rtf file with a string from an HTML > form. > I thought about using placeholders in the .rtf document and then > searching and overwriting them with the data from the HTML form. > I tried it out with that cod

Question about filehandles

2003-07-01 Thread Azubi CAI
Hi there, I need to substitute a string in a .rtf file with a string from an HTML form. I thought about using placeholders in the .rtf document and then searching and overwriting them with the data from the HTML form. I tried it out with that code: #!/usr/bin/perl -w open PASSWD, "test.rtf" or

Re: Two filehandles

2003-01-27 Thread Jenda Krynicky
From: "Brian Ling" <[EMAIL PROTECTED]> > > I need to output both STDOUT and STDERR to the same log file, what http://search.cpan.org/author/KENSHAN/IO-Tee-0.64/Tee.pm Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards

Two filehandles

2003-01-27 Thread Brian Ling
> > Hi All, > > I need to output both STDOUT and STDERR to the same log file, what is > the best way to achieve this, I'm currently using; > > open STDOUT, "> $logfile" or die "message"; > open STDERR, ">> $logfile" or die "message; > > Which I'm sure is not right, but sort of works. > >

RE: File munging: from $old to $new, using filehandles andarrays ....

2002-07-30 Thread McCormick, Rob E
John, thanks for the succinct suggestion on the set in place edit extension.I'll humbly accept additional "yo here's how to simplify this deal" examples. ;^) I could still be doing a number of things wrong, I can launch the script , but it 'hangs', & my prompt doesn't return. I'm not getting

Re: File munging: from $old to $new, using filehandles andarrays ....

2002-07-29 Thread John W. Krahn
Rob E McCormick wrote: > > > How are the new file names defined? Are they based on the old file > > names or something else? > > > > open IN, $old_filename > > or die "cannot open $old_filename for reading: $!"; > > open OUT,">$newdir/$with_new_filename" > > or die "cannot create $newdir

RE: File munging: from $old to $new, using filehandles andarrays ....

2002-07-29 Thread McCormick, Rob E
John, ... Thanks for your suggestionsI would like to take each old filename ('ex020525.log' or exyymmdd.log...) and output 'exyymmdd.new' or even 'exyymmdd.log.new' > How are the new file names defined? Are they based on the old file > names or something else? > > open IN, $old_filename

Re: filehandles and while loops

2002-07-27 Thread Connie Chan
Sorry, still can't get your logic... But there's a better approach here : open COUNT,"count.dat"; # ./ mean current dir, so, it's not nessary open TEMP, "temp.dat" ; Then , for the entire loop, you can read from COUNT, and write to TEMP. At last, unlink the COUNT file, then rename the temp.dat

RE: filehandles and while loops

2002-07-27 Thread David Gerler
print COUNT "$image\=$count\n"; } flock(COUNT, 8); close (COUNT) or die "cannot close countfile: $!"; return 1; } -Original Message- From: Connie Chan [mailto:[EMAIL PROTECTED]] Sent: Saturday, July 27, 2002 4:57 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject

Re: filehandles and while loops

2002-07-27 Thread Connie Chan
> > sub count { > > open (COUNT, "+>./count.dat") or die "cannot open countfile: $!"; > > flock(COUNT, 2); > > > > while (){ > > if (m/BC0012/i){ > > ($key, $count) = split('=',$_); > > $found = 1; > > $count++; > > } else { > >

Re: filehandles and while loops

2002-07-27 Thread Yupapa
open(COUNT,") { chomp; if($_ =~ /BC0012/) { my($key,$count) = split('=',$_); $count++; print "$count\n"; } } close(COUNT); "David Gerler" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > okay... see

Re: filehandles and while loops

2002-07-26 Thread John W. Krahn
David Gerler wrote: > > okay... seems tonight is the night for regex... I have been looking at the > emails that have been flying all evening.. I have tried to implement what I > see. > > For some reason, mine don't work. Others say what they got in the email > works. I try it and it don't. > >

filehandles and while loops

2002-07-26 Thread David Gerler
okay... seems tonight is the night for regex... I have been looking at the emails that have been flying all evening.. I have tried to implement what I see. For some reason, mine don't work. Others say what they got in the email works. I try it and it don't. The plan for the code is to read a cou

Re: File munging: from $old to $new, using filehandles andarrays....

2002-07-26 Thread John W. Krahn
logs into a 'processed' directory. > I'm struggling with arrays, FILEHANDLES, opendir, readdir, variables, ... > despite patient advice from some list members. > > Below is a crude regex, but this part seems to be working from the command > line (accept filenames input

Re: Filehandles named with a variable

2002-04-03 Thread Peter Scott
At 03:48 PM 4/2/02 -0600, Mr Hash wrote: >So, I'm trying to 'open ($1,">>$file")', where $1 is a string like >"cbQosCMPrePolicyPktOverflow". > >Obviously, with use strict this does not work. How can I make it work? I >need arbitra

Re: Filehandles named with a variable

2002-04-02 Thread Jenda Krynicky
From: Mr Hash <[EMAIL PROTECTED]> > $1 is the resultant of a regex match. It don't need to be around very > long, because I build a hash of open filehandles (key = filehandle > string, value = file) at the time I open the file. > > And no, I don't close 'e

Re: Filehandles named with a variable

2002-04-02 Thread Mr Hash
$1 is the resultant of a regex match. It don't need to be around very long, because I build a hash of open filehandles (key = filehandle string, value = file) at the time I open the file. And no, I don't close 'em! exit() does just fine. On 04/02, Timothy Johnson said something

RE: Filehandles named with a variable

2002-04-02 Thread Timothy Johnson
You REALLY shouldn't use $1 for a variable name, though, since it has a special meaning. -Original Message- From: David Gray [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 02, 2002 2:33 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: Filehandles named with a variable

RE: Filehandles named with a variable

2002-04-02 Thread David Gray
> So, I'm trying to 'open ($1,">>$file")', where $1 is a string > like "cbQosCMPrePolicyPktOverflow". > > Obviously, with use strict this does not work. How can I make > it work? I need arbitrarily named filehandles. I know, it > cou

Filehandles named with a variable

2002-04-02 Thread Mr Hash
So, I'm trying to 'open ($1,">>$file")', where $1 is a string like "cbQosCMPrePolicyPktOverflow". Obviously, with use strict this does not work. How can I make it work? I need arbitrarily named filehandles. I know, it could get rended with gobbleworts if

RE: Testing for filehandles

2002-03-28 Thread eric-perl
On Thu, 28 Mar 2002, Bob Showalter wrote: > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > > Thanks, Bob! After reading the IO::Handle man page, I decided > > to distill this approach a bit further: > > > > print F if fileno(F); > > Of course, that's even simpler! Just to be nitpicky,

RE: Testing for filehandles

2002-03-28 Thread Bob Showalter
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, March 27, 2002 6:16 PM > To: Beginners Perl Mailing List > Subject: RE: Testing for filehandles > > > On Wed, 27 Mar 2002, Bob Showalter wrote: > > You can pass a

RE: Testing for filehandles

2002-03-27 Thread eric-perl
On Wed, 27 Mar 2002, Bob Showalter wrote: > You can pass a filehandle glob to IO::Handle::opened(): Thanks, Bob! After reading the IO::Handle man page, I decided to distill this approach a bit further: print F if fileno(F); -- Eric P. Los Gatos, CA -- To unsubscribe, e-mail: [EMAIL PROTE

Re: Testing for filehandles

2002-03-27 Thread eric-perl
On Wed, 27 Mar 2002, Agustin Rivera wrote: > Ok, I've tried it both ways and it returns 1 (true) as the value. What am I > doing wrong? Agustin: 1. What *exactly* do you mean "both" ways? 2. References... >From the Getopt::Std man page: getopt('oDI'); # -o, -D & -I take arg. Sets o

Re: Testing for filehandles

2002-03-27 Thread Agustin Rivera
Message - From: "Chas Owens" <[EMAIL PROTECTED]> To: "Agustin Rivera" <[EMAIL PROTECTED]> Cc: "Beginners Perl Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, March 27, 2002 1:51 PM Subject: Re: Testing for filehandles > Getopt::Std creates t

RE: Testing for filehandles

2002-03-27 Thread Bob Showalter
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, March 27, 2002 3:18 PM > To: Beginners Perl Mailing List > Subject: Testing for filehandles > > > Hello, All: > > I've looked around for an answer to th

Re: Testing for filehandles

2002-03-27 Thread eric-perl
On 27 Mar 2002, Chas Owens wrote: > Getopt::Std creates the $opt_n variables. To use it with use strict; in > place you must use the use vars ($opt_n); pragma as well. or just use > the getopts('n', \%opts); call. Then you can say $opts{n}. Agustin: Also from the Getopt::Std man page:

Re: Testing for filehandles

2002-03-27 Thread Chas Owens
TED]> > To: <[EMAIL PROTECTED]>; "Beginners Perl Mailing List" > <[EMAIL PROTECTED]> > Sent: Wednesday, March 27, 2002 1:32 PM > Subject: RE: Testing for filehandles > > > > > > You'd probably have better luck testing for the open()

Re: Testing for filehandles

2002-03-27 Thread eric-perl
On Wed, 27 Mar 2002, Agustin Rivera wrote: > How would that work with use strict;? I tried it once and when I declared my > $opt_n before using getopts, it wouldn't work. Agustin: >From the Getopt::Std man page: Note that, if your code is running under the recommended `use strict

RE: Testing for filehandles

2002-03-27 Thread Timothy Johnson
ch 27, 2002 1:46 PM To: Timothy Johnson; Beginners Perl Mailing List Subject: Re: Testing for filehandles How would that work with use strict;? I tried it once and when I declared my $opt_n before using getopts, it wouldn't work. Agustin Rivera Webmaster, Pollstar.com http://www.po

Re: Testing for filehandles

2002-03-27 Thread Agustin Rivera
To: <[EMAIL PROTECTED]>; "Beginners Perl Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, March 27, 2002 1:32 PM Subject: RE: Testing for filehandles > > You'd probably have better luck testing for the open() command's success > > use Getopts::Std; > getopts(

RE: Testing for filehandles

2002-03-27 Thread eric-perl
Tim: I know, I know: I excluded the "or die" portion for readability/simplicity. On Wed, 27 Mar 2002, Timothy Johnson wrote: > You'd probably have better luck testing for the open() command's success I wrote: >> use Getopts::Std; >> getopts("n"); >> open(OPT_LOG,">/tmp/foo.txt") if ($opt_n); >

Re: Testing for filehandles

2002-03-27 Thread Chas Owens
On Wed, 2002-03-27 at 15:18, [EMAIL PROTECTED] wrote: > Hello, All: > > I've looked around for an answer to this (The Camel Book, The Ram Book, > perldoc, google.com, etc.) but can't find a thing: Is it possible to test > for the existence of a filehandle? > > I've got a small script that ope

RE: Testing for filehandles

2002-03-27 Thread Timothy Johnson
EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002 12:18 PM To: Beginners Perl Mailing List Subject: Testing for filehandles Hello, All: I've looked around for an answer to this (The Camel Book, The Ram Book, perldoc, google.com, etc.) but can't find a thing: Is it possible to test for th

Testing for filehandles

2002-03-27 Thread eric-perl
Hello, All: I've looked around for an answer to this (The Camel Book, The Ram Book, perldoc, google.com, etc.) but can't find a thing: Is it possible to test for the existence of a filehandle? I've got a small script that opens a filehandle. If that filehandle exists, I'd like to print to it

  1   2   >