On Sunday 30 April 2006 05:20 am, D. Bolliger wrote:
> tom arnall am Sonntag, 30. April 2006 01.04:
> > On Saturday 29 April 2006 10:43 am, Mr. Shawn H. Corey wrote:
> > > On Sat, 2006-29-04 at 10:28 -0700, tom arnall wrote:
> > > > i'm try to use 'Tie::StdScalar' but perl tells me it can't find it.
> > > > I've pushed '/usr/share/perl/5.8.7' onto @INC.  the error is:
> > > >
> > > >         Can't locate Tie/StdScalar.pm in @INC
> > > >
> > > > in '/usr/share/perl/5.8.7/Tie/Scalar.pm' there is 'package
> > > > Tie::StdScalar' etc.
> > > >
> > > > thanks,
> > > >
> > > > tom arnall
> > > > north spit, ca
> > >
> > > Is the module Tie::Scalar? See `perldoc Tie::Scalar` for details.
> >
> > the main module is Tie::Scalar but within that file the StdScalar package
> > is defined.
>
> No - the Tie::StdScalar package is defined therein (note the Tie:: prefix)
>
> :-)
> :
> > i dealt actually with the 'can't locate' problem by putting the
> > def' in a separate file: StdScalar.pm. but now i get a 'can't locate
> > method' error when i try to tie a variable to the package, i.e.:
>
> [...]
>
> use Tie::Scalar;
> tie my $f,'Tie::StdScalar';
>
> (The last two lines in the man page SYNOPSYS show tie'ing subclasses which
> don't have 'Tie::' in their package name).
>
> Dani

OK, the above stuff is all good. and now i have another question. the 
following code:

        #!/usr/bin/perl -w
        use strict;
        use Tie::Scalar;
        use DB_File;

        my ($f,@f,%f);

        tie %f, "DB_File", "file.txt" ;
        $f{'a'}='aaaa';
        untie %f;
        %f = ();
        tie %f, "DB_File", "file.txt" ;
        @f = %f;
        print "
        @f";

        tie $f,"Tie::StdScalar","scalar.txt","\$f";
        $f = 'a';
        untie $f;
        $f = '';
        tie $f,"Tie::StdScalar","scalar.txt","\$f";
        print "
        $f
        ";


produces:

        a aaaa
        scalar.txt

shouldn't the second line be 'a', i.e., shouldn't 'StdScalar' work  along the 
lines of the code handling the tied hash variable? if this is not true, is 
there a module that does work similarly to 'DB_File', i.e., one that enables 
tie-ing a text file to a scalar?

thanks,

tom arnall
north spit, ca



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to