<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
toiletpaper wrote:<br>
<blockquote type="cite" cite="mid408CD656.50100@thecookies.org">
  <meta content="text/html;" http-equiv="Content-Type">
  <title></title>
Rich wrote:<br>
  <blockquote cite="mid200404251412.44584.scriptyrich@yahoo.co.uk"
 type="cite">
    <pre wrap="">On Sunday 25 Apr 2004 2:50 am, Edward wrote:
  </pre>
    <blockquote type="cite">
      <pre wrap="">ok well. heres something really odd. when using the listView in perlqt i
can no longer close or write to filehandles. they supposedly open fine
but when i print to them nothing prints and when i close them using
close FHA or die "cant close $pathname: $!";
i get cant close /tmp/Adema.Adema: Bad file descriptor at
/root/ui/form1.pl line 234

    #    $pathname = "/tmp/Adema.Adema";
    #    print "Opening file and printing to it\n";
    #    open(FHA, "&gt; $pathname")    or die "can't open $pathname: $!";
    #    #flock(FH, LOCK_EX)        or die "can't flock $pathname: $!";
    #    print FHA "hello there\n"     or die "cant print $pathname: $!";
    #    close(FHA)            or die "cant close $pathname: $!";
    </pre>
    </blockquote>
    <pre wrap=""><!---->
This isn't going to answer your question, but a couple of suggestions:

1) Use a lexical scalar for filehandles.

On modern(ish) perls you can do the following:

open my $fh, "&gt;", $pathname  or die "can't open $pathname: $!";   #&lt;&lt;&lt;&lt;
print $fh "hello there\n"     or die "cant print $pathname: $!";
close $fh                        or die "cant close $pathname: $!";

This is generally a good thing, as it both limits filehandle scope, and closes 
files when the handle goes out of scope, ie:

{
  open my $fh, "&gt;", $pathname  or die "can't open $pathname: $!";   #&lt;&lt;&lt;&lt;
  print $fh "hello there\n"     or die "cant print $pathname: $!";

}  ## File closes here as $fh goes out of scope.

Its still a good idea to explicitly close files as soon as they're not needed 
however. You never know, that might solve your problem (but probably not).

Also note the three argument form of open is safer than the two argument form. 
perldoc -f open for lots of details (BTW the perlopentut docs for my version 
(5.8.0) seem pretty out of date as the examples dont use lexical scalars for 
filehandles).

2) $pathname = "/tmp/Adema.Adema";

Do you want a temporary file here? If so, you *must* use File::Temp - read the 
docs for the reasons why.

If you actually want to store data between runs, don't put the file in /tmp - 
this is for temporary files, and there's no guarantee when data in /tmp will 
be deleted. 

Instead you could use File::HomeDir to find a suitable directory, then create 
a hidden subdirectory and store data there - this will work on Unix style 
systems, for windows there would be better alternatives but I'm not in a 
position to comment.

3) If you're going to add file locking, make sure you read the docs in detail 
- there are some subtleties that make it easy to get wrong.

Sorry this doesn't answer your question, but it will make the code slightly 
more robust!
  </pre>
  </blockquote>
well, i changed it to the lexical scalars as you suggested. <br>
i had it put the file in the /tmp folder because it was just to see if
it was working. so i changed it to the /home directory. same results.
nothing prints and cant close it saying:<br>
cant close /home/Adema.Adema: Bad file descriptor at ./form1.pl line
225.<br>
  <br>
i decided file locking was pretty much a waste as only one program is
going to write this file at a time, no need to prevent others from
writing to it as well.<br>
i dont really think its something to do with the
opening/printing/closing code in the end because when it is placed
before the listview line it works fine. i am going to try using the kde
listview control tommorow instead of the generic listview. with some
luck it will work the way its supposed to.<br>
  <br>
the new subroutine looks like this:<br>
  <br>
sub puttrackinfo_tofile {<br>
&nbsp;&nbsp;&nbsp; my $pathname = "/home/Adema.Adema";<br>
&nbsp;&nbsp;&nbsp; my $line;<br>
&nbsp;&nbsp;&nbsp; my $dontadd = FALSE;<br>
&nbsp;&nbsp;&nbsp; my $lookforme;<br>
&nbsp;&nbsp;&nbsp; my $counter;<br>
&nbsp;&nbsp;&nbsp; $lookforme = join($combochars, $artist, $album, $tracknumber,
$trackname, $tracklength, $genre);<br>
&nbsp;&nbsp;&nbsp; #open(my $ALBUMINFO,"&lt;", $pathname);<br>
&nbsp;&nbsp;&nbsp; #my @rawdata = &lt;$ALBUMINFO&gt;;<br>
&nbsp;&nbsp;&nbsp; #close $ALBUMINFO;<br>
&nbsp;&nbsp;&nbsp; print "filepath=$pathname\n";<br>
&nbsp;&nbsp;&nbsp; print "filelinecount=$#rawdata\n";<br>
&nbsp;&nbsp;&nbsp; if (!$#rawdata == -1) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; foreach $line (@rawdata) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ("$line" eq "$lookforme") {&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $dontadd=TRUE; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print $line,"\n";<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; #if ($dontadd == FALSE) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print "Opening file and printing to it\n";<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; open my $FHA, "&gt;&gt;", $pathname&nbsp;&nbsp;&nbsp; or die "can't open
$pathname: $!";<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; print $FHA "$lookforme\n" &nbsp;&nbsp;&nbsp; or die "cant print $pathname:
$!"; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; close $FHA&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; or die "cant close $pathname: $!"; <br>
&nbsp;&nbsp;&nbsp; #}<br>
}<br>
&nbsp;
  <br>
</blockquote>
ok well. i decided to spend a little time and try that klistview, its
the same control, i wonder why the qt-designer says they are different,
i looked at the code and they were the same thing just missing the
trUtf8 in the title part of the code. but same results :( any help
would be greatly appreciated<br>
</body>
</html>