[Israel.pm] converting string to file name

Tal Kelrich tal at musicgenome.com
Mon Jun 7 03:07:58 PDT 2004


On Mon, 7 Jun 2004 12:28:46 +0300
"Itamar Elem" <elem at compugen.co.il> wrote:

> hi
> 
> ibe got pel string in var (say $buffer) and function which reuire 
> file name as one of its arguments(the function belong to external
> module. cant change) the file name content should be $buffer. here
> there away which i can convert $buffer sow i can send it to the
> function instead of the file name
> 
> itamar
> 
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://www.perl.org.il/mailman/listinfo/perl
> 
open a temporary file, then destroy it, doing something in the interim:

my $buffer="foo";
my $tmpfname=join "","/tmp/",('A'..'Z','a'..'z',0..9,'.','_')[rand 64,rand 64, rand 64, rand 64, rand 64];#temp filename generation
print "$tmpfname\n";
open TMP, ">", $tmpfname;
print TMP $buffer;
close TMP;
#do whatever you want with $tmpfname

unlink $tmpfname;#then remove it

-- 
Tal Kelrich
PGP fingerprint: 3EDF FCC5 60BB 4729 AB2F  CAE6 FEC1 9AAC 12B9 AA69
Key Available at: http://www.hasturkun.com/pub.txt
----
Ogden's Law: The sooner you fall behind, the more time you have to catch
up.
----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://perl.org.il/pipermail/perl/attachments/20040607/e07fd1df/attachment.pgp 


More information about the Perl mailing list