formats and write()

From: Dani Pardo (dani_at_enplater.com)
Date: 04/29/04


Date: Thu, 29 Apr 2004 12:17:48 +0200 (CEST)
To: beginners@perl.org


  Hi, I've a question involving formats.
  I have a text file that has lines like this:

 __LINE1__
 __LINE2__

 I use s/__LINE(\d+)__/$line{$1}/ to change each of these lines by an
scalar that is stored in a hash, i.e:

 line{1}="CUSTOMER_NAME | PHONE | EMAIL | COUNTRY";

 But, as you may have guessed, I need to format $line{1} with Perl
formats. But write() writes to a filehandle, and I need to store the
result into the scalar variable,

 How can I do it? TIA,

---
Dani Pardo, dani@enplater.com
Enplater S.A


Relevant Pages

  • Re: formats and write()
    ... I've a question involving formats. ... > scalar that is stored in a hash, ... > But, as you may have guessed, I need to format $linewith Perl ... You can find the answer in the perlform document under the section ...
    (perl.beginners)
  • Re: [opensuse] test of sending to list using TEXT not HTML
    ... Hash: SHA1 ... automatically save the doc to a file and pdf is one of the formats ...
    (SuSE)
  • Re: Using hashes in a format
    ... Adam> $phone_numbers#needs to print the keys of the hash for the ... and Adam> values for the phone number so it will be like this "Some ... formats couldn't access lexical variables. ...
    (perl.beginners)
  • Re: Using hashes in a format
    ... Adam> $phone_numbers#needs to print the keys of the hash for the name, ... formats couldn't access lexical variables. ... Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. ...
    (perl.beginners)