BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:
I've attempted t use readmore tags to reduce the length of this, but I wont see if they have worked or not until I submit it....my apologoes in advance if they don't.
I have been trying to make use of the Inline::Files module from CPAN. (Actually VERSION '0.60' from AS via PPM in conjunction with 'This is perl, v5.6.1 built for MSWin32-x86-multi-thread' ).
After an extended CB session with podmaster and dada (thanks guys!), we concluded that I may have a legitimate bug report against the module, but I am posting here to see if anyone else can see my error(s) before I raise the report and make a fool of myself. Referencing the Inline::Files pod (Files.pm:lines 360-380) the following code should? read and print the number 10..1 from the virtual file (vf) __INLINE__ and then re-write vf __INLINE__ with the numbers 1..10.
#! perl -w #use strict; use Inline::Files -backup; print <INLINE>; seek INLINE, 0, 0; print INLINE for (1..10); __INLINE__ 10 9 8 7 6 5 4 3 2 1
The results I get are:
C:\test>inline 10 9 8 7 6 5 4 3 2 1 seek() on unopened filehandle INLINE at e:/Perl/site/lib/Inline/Files/Virtual.pm line 227. print() on unopened filehandle INLINE at C:\test\inline.pl line 14. print() on unopened filehandle INLINE at C:\test\inline.pl line 14. print() on unopened filehandle INLINE at C:\test\inline.pl line 14. print() on unopened filehandle INLINE at C:\test\inline.pl line 14. print() on unopened filehandle INLINE at C:\test\inline.pl line 14. print() on unopened filehandle INLINE at C:\test\inline.pl line 14. print() on unopened filehandle INLINE at C:\test\inline.pl line 14. print() on unopened filehandle INLINE at C:\test\inline.pl line 14. print() on unopened filehandle INLINE at C:\test\inline.pl line 14. print() on unopened filehandle INLINE at C:\test\inline.pl line 14. C:\test>type inline.pl #! perl -w use strict; use Inline::Files -backup; print <INLINE>; seek INLINE, 0, 0; print INLINE for (1..10); __INLINE__ 10 9 8 7 6 5 4 3 2 1 C:\test>
dada pointed out that the pod example doesn't work as listed, and that this is because when a VF is being read and EOF is reached, it is automatically closed, which This explains the "unopened filehandle" errors above. With dada's help, I worked out the syntax for opening a VF is:
open INLINE, ">$INLINE" or die $!;
This wasn't obvious (to me) as
open CACHE or die $!; # read access (uses $CACHE to locate file)
A one param open???
Anyway these changes gave me this:
#! perl -w #use strict; use Inline::Files -backup; print <INLINE>; #seek INLINE, 0, 0; open INLINE, ">$INLINE" or die $!; print INLINE for (1..10); __INLINE__ 10 9 8 7 6 5 4 3 2 1 C:\test>inline 10 9 8 7 6 5 4 3 2 1 Use of uninitialized value in concatenation (.) or string at C:\test\i +nline.pl line 7. Use of uninitialized value in substitution (s///) at e:/Perl/site/lib/Inline/Files/Virtual.pm line 120. Use of uninitialized value in substitution (s///) at e:/Perl/site/lib/Inline/Files/Virtual.pm line 120. C:\test>type inline.pl #! perl -w #use strict; use Inline::Files -backup; print <INLINE>; #seek INLINE, 0, 0; open INLINE, ">$INLINE" or die $!; print INLINE for (1..10); __INLINE__ 10 9 8 7 6 5 4 3 2 1 __INLINE__ 12345678910 C:\test>
Which, apart from the warnings from the open line in my code which I can't explain-- apart from the fact that $INLINE is never being set--also gives the two errors from Virtual.pm?
Added to this, the open has caused a second __INLINE__ to be created, rather than the original being overwritten?
Also, the (1..10) are being written as one line (my fault) so I thought I would correct this using my usual technique in test progs ie. using local($/="\n"); (which I think is a correct way to do things) so that resulted in this:
C:\test>inline 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 Use of uninitialized value in concatenation (.) or string at C:\test\i +nline.pl line 8. Use of uninitialized value in substitution (s///) at e:/Perl/site/lib/Inline/Files/Virtual.pm line 120. Use of uninitialized value in substitution (s///) at e:/Perl/site/lib/Inline/Files/Virtual.pm line 120. C:\test>type inline.pl #! perl -w #use strict; use Inline::Files -backup; local ($,=' | ', $/="\n"); print <INLINE>; #seek INLINE, 0, 0; open INLINE, ">$INLINE" or die $!; print INLINE for (1..10); | __INLINE__ 10 9 8 7 6 5 4 3 2 1 | __INLINE__ 12345678910 C:\test>
Which as you can see, appears to have effected everything except what I wanted.
I know that setting $, was unnecessary for what I wanted to achieve (I just cut&pasted the line from another file, but it would appear that despite my use of local, my changes to these vars has effected the IO done by Inline::Files?? Is this expected behaviour?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inline::Files bug?
by Abigail-II (Bishop) on Aug 01, 2002 at 11:51 UTC | |
by BrowserUk (Patriarch) on Aug 01, 2002 at 12:18 UTC | |
by Abigail-II (Bishop) on Aug 01, 2002 at 12:41 UTC | |
by BrowserUk (Patriarch) on Aug 01, 2002 at 13:02 UTC | |
by Abigail-II (Bishop) on Aug 01, 2002 at 13:38 UTC | |
by dada (Chaplain) on Aug 01, 2002 at 12:29 UTC |