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

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;

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. > >

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 arbitrarily named filehandles. I know, it could get rended with >gobblewort

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 'em! exit() does just fine. Something lik

Re: Filehandles named with a variable

2002-04-02 Thread Mr Hash
like: > > 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] >

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 > could get rended with gobbleworts if the data gets out of hand..

Re: Filehandles and variables

2001-11-02 Thread Jeff 'japhy' Pinyan
On Nov 2, Mike Gargiullo said: >OK I know Perl is the language that lets you do things several different >ways. So with that having been said, how can I convert the while >statement into a subroutine and pas the filehandles to it ? I'd make a function that takes two filenames, and does the work.

Re: Filehandles and variables

2001-11-02 Thread register
something like this # # Nothing special .. just opening the file handles # open(ONE,"one.dat") or die $!,"\n"; open(TWO,"two.dat") or die $!,"\n"; open(THREE,"three.dat") or die $!,"\n"; # # sending the file handle into a reference as a glob # you could also do thi

Re: Filehandles

2001-06-23 Thread Jeff 'japhy' Pinyan
On Jun 23, Me said: >> I want STDOUT to be sent to a FILESHANDLE. I have a script writing >output >> DISPLAY..But I wanna this to be going into a file through FILEHANDLES >.. >> >> Ur Help is Highly APPRECIATED > >open(STDOUT, ">foo") or die "can't redirect STDOUT: $!"; It's probably easier

Re: Filehandles

2001-06-23 Thread Jos I. Boumans
if you want an explicit file handle, you'll have to do something like the following: open O, ">out.txt"; print O "whatever it is you need to print\n"; however, you can just reopen STDOUT and point it to a log file or something rather then the default (display) So i'm not sure i see the problem in

Re: Filehandles

2001-06-23 Thread Me
> I want STDOUT to be sent to a FILESHANDLE. I have a script writing output > DISPLAY..But I wanna this to be going into a file through FILEHANDLES .. > > Ur Help is Highly APPRECIATED Well I'll SEE if I can HELP YOU. open(STDOUT, ">foo") or die "can't redirect STDOUT: $!"; HOPE THIS HELPS.

Re: Filehandles

2001-06-23 Thread David Monarres
If you are using print then just include the FILEHANDLE before the message (make sure that you open the file first) ie: print FILE "hello"; mainly this means that most things that spit out messages toward STDOUT as a default. print "hello"; is the same as: print STDOUT "hello"; I hope that