in reply to Re: format and IO::String
in thread format and IO::String

Hmm, It works, I'll give you that. I'm still confused as to why it locks up on my version though. Take a look at this code (I was experementing and benchmarking at the same time):

#!/usr/bin/perl -w use strict; use IO::File; use GMS; require "GMSConstant.pl"; use Benchmark qw(cmpthese); my $t1 = '1'; my $t2 = '2'; my $t3 = '3'; my $GMS = new GMS; my $sitename = $GMS->getsetting('GUILD','SITENAMET'); my($name,$email,$icq) = ('Iron','flame@berkshire.rr.com','16307443'); my @stats = (100,100,25); my $skills = [ {'SKILL' => 'Anatomy','VALUE' => 100}, {'SKILL' => 'Swordsmanship','VALUE' => 100}, {'SKILL' => 'Tactics','VALUE' => 100} ]; my $onotes = "This is a long test string.\n\n" x 30; my $notes; sub otherway{ $notes = $onotes; #Re-Initialize variable since it was wiped out by + the write() my $fh = IO::File->new_tmpfile() or die $!; $fh->format_name('GMMAIL'); #This one works regardless of which format it's attached to. select($fh); write(); seek($fh, 0, 0); # Rewind the file my $str = do {local $/; <$fh>}; select(STDOUT); print $str; } sub myway{ $notes = $onotes; #Re-Initialize variable since it was wiped out by + the write() pipe(TESTOUT,TEST) or die($!); select(TEST); $~='GMMAIL'; #Note THIS Line: When set to 'TEST' everything's fine... #however, when set to GMMAIL like this, it locks up. #What's the difference that causes it to work for one but #not the other? $|=1; write(); close(TEST); select(STDOUT); my @temp = <TESTOUT>; print join('',@temp); close(TESTOUT); } cmpthese(10000,{ 'Suggestion' => \&otherway, 'MyTest' => \&myway} ); format TEST= @||| @||| @||| $t1,$t2,$t3 @||| @||| @||| $t3,$t2,$t1 . format GMMAIL= @||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +||||||||| "$sitename - Application" Name: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | Notes: ^<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $name, $notes E-Mail: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $email, $notes ICQ: @<<<<<<<<<< | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $icq, $notes ---------------------------------------| ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $notes /------\ | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $notes | Stats | | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $notes |--------| | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $notes |@<<: @>>| | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $GMS::Constant::STATS[0],$stats[0], $notes |@<<: @>>| | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $GMS::Constant::STATS[1],$stats[1], $notes |@<<: @>>| | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $GMS::Constant::STATS[2],$stats[2], $notes \------/ | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $notes ---------------------------------------| ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $notes | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $notes Skills | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $notes ------ | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $notes @<<<<<<<<<<<<<: @###.# | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $skills->[0]->{'SKILL'},$skills->[0]->{'VALUE'}, $notes @<<<<<<<<<<<<<: @###.# | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $skills->[1]->{'SKILL'},$skills->[1]->{'VALUE'}, $notes @<<<<<<<<<<<<<: @###.# | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $skills->[2]->{'SKILL'},$skills->[2]->{'VALUE'}, $notes ~~ | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<< $notes @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>> $GMS->getsetting('FILE','CGIBINS').'/join.c +gi?admin' .


The comments inside the tested subs should explain my current question well enough.

FYI: It appears that when it actually works, my way is faster by about 3%. But I suppose regardless of what's faster, I have to use what works... heh.

Thanks for the suggestion.



"Weird things happen, get used to it."

Flame ~ Lead Programmer: GMS