RE: Is this possible? (file handles)

2004-04-01 Thread Venugopal P
Once you close the file, memory for the file handle will be deallocated.
You can unlink file using the original file name.
unlink ("abc");

-Original Message-
From: Jeff Westman [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 2:02 AM
To: perl_help
Subject: Is this possible? (file handles)


Hi,

I want to remove an empty file using the file handle and not a
variable name or literal name referencing it.  Something like this:

 1  #!/bin/perl 
 2  use warnings;
 3  use strict;
 4  no strict 'subs';
 5
 6  open(F, "> abc") or die "cant create file: $!";
 7  close(F) or die "cant close file: $!";
 8
 9  unlink(\*F) if -z (F);

But, in this case, I get an error:

$ runme.pl
-z on closed filehandle F at ./x line 9.


TIA,

Jeff

__
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Missing sequence finder for logfiles

2004-04-15 Thread Venugopal P
Will it work?

open (TEST, "C:\\sample.log");
my $valcount=0;
my $missvalue = 1;
while ()
{
if(/value : (\d+)/)
{
$val = $1;
$val = $val - 1 if($val> 0);

if ($valcount != $val)
{
$valc = $valcount + 1 ;
print "\nMissing $valc to ". $val;
}
$valcount=$1;
}
$valcount=0 if($valcount==255);
}
Let me know if it does not suit
Thankyou
VENU

-Original Message-
From: Sten Berg [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 7:01 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Missing sequence finder for logfiles


Sorry!
This is what I´ve come up with so far:

my $nr=0;
my @missing;
open (FILE, ") {
  ($firstbit, $value)=split /:/,$_;
  $value=trim ($value);
  if ($firstbit eq "- value ") {
 if ($nr==256) {
 $nr=0;
 print "New Sequence Started\n";
 }
if ("$value" ne "$nr") {
 print"read $value expected $nr\n";
  push (@missing,"$nr-$value\n");
  $nr = $value;
 }
 $nr++;
  }
}
print "missing ranges\n\n";
print for (@missing);
close FILE;
sub trim {
my @out= @_;
for (@out) {
s/^\s+//;
s/\s+$//;
}
return wantarray ? @out : $out[0];
}

It would be nice though, to be able to give the log filename as a parameter
to the perlscript. If the filename differs from time to time, it would be
nice if I could avoid having the filename within the script.

eplabi



>From: James Edward Gray II <[EMAIL PROTECTED]>
>To: "Sten Berg" <[EMAIL PROTECTED]>
>CC: [EMAIL PROTECTED]
>Subject: Re: Missing sequence finder for logfiles
>Date: Thu, 15 Apr 2004 07:54:29 -0500
>
>On Apr 15, 2004, at 7:08 AM, Sten Berg wrote:
>
>>Hi gurus!
>>
>>I´m looking for a way of analysing a log file and pinpoint missing
>>sequences (foreach loop?). The logfiles looks something like this:
>>
>>LOGFILE
>>- value : 0
>>some data...
>>- value : 1
>>some data...
>>- value : 2
>>some data...
>>...
>>...
>>- value : 255
>>some data...
>>- value : 0
>>some data...
>>- value : 1
>>some data...
>>...
>>
>>In other words; one loop stretches from 0-255 and then the next loop
>>starts off att 0 again. I just want to know which values that are missing
>>between 0-255 AND in which loop they were missing.
>>
>>I´m greatful if anyone can solve this :-)
>
>What have you tried?  Where are you stuck?  Show us some code.  Help us
>help you.
>
>James
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
> 
>
>

_
Lättare att hitta drömresan med MSN Resor http://www.msn.se/resor/


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]