Loading ...
Sorry, an error occurred while loading the content.

Writing to a file using STDOUT

Expand Messages
  • picsian1 <imoq172@hotmail.com>
    Hello all This is pretty elementary but I can t seem to get it to work. Perhaps one of you eagle eyes can spot where I m going wrong. I m appending records to
    Message 1 of 4 , Feb 2, 2003
    • 0 Attachment
      Hello all
      This is pretty elementary but I can't seem to get it to work.
      Perhaps one of you eagle eyes can spot where I'm going wrong. I'm
      appending records to a text file. I've read data from a form and I
      assemble it into a line to output and write it out. All goes well.
      Here's what the code looks like... (TEMP if file handle):

      $_= $postInputs{'First'} . "\t" ;
      $_= $_ . $postInputs{'Last'} . "\t" ;
      $_= $_ . $postInputs{'Address'} . "\t" ;
      $_= $_ . $postInputs{'Email'} . "\n" ;
      print TEMP $_;

      This works great. Now I wanted to insert an amount field in this
      record so I coded:

      my $amt='$35.00';

      Then

      $_= $postInputs{'First'} . "\t" ;
      $_= $_ . $postInputs{'Last'} . "\t" ;
      $_= $_ . $postInputs{'Address'} . "\t" ;
      $_= $_ . $amt . "\t" ;
      $_= $_ . $postInputs{'Email'} . "\n" ;
      print TEMP $_;

      When I examine the output file, there is no field with
      value '$35.00'. Just the tab char. where the $amt field should be.
      Can anyone spot where I'm going wrong or how can I get it to work.
      Your help is greatly appreciated.

      Gary
    • Charles K. Clarkson
      ... Worked for me: #!/usr/local/bin/perl my %postInputs = ( First = John , Last = Public , Address = 123 Easy Street , Email = JQ@anytown.com ,
      Message 2 of 4 , Feb 2, 2003
      • 0 Attachment
        picsian1 <imoq172@...> wrote:
        :
        : Now I wanted to insert an amount field in this
        : record so I coded:
        :
        : my $amt='$35.00';
        :
        : Then
        :
        : $_= $postInputs{'First'} . "\t" ;
        : $_= $_ . $postInputs{'Last'} . "\t" ;
        : $_= $_ . $postInputs{'Address'} . "\t" ;
        : $_= $_ . $amt . "\t" ;
        : $_= $_ . $postInputs{'Email'} . "\n" ;
        : print TEMP $_;
        :
        : When I examine the output file, there is no
        : field with value '$35.00'. Just the tab char.
        : where the $amt field should be. Can anyone
        : spot where I'm going wrong or how can I get
        : it to work.

        Worked for me:

        #!/usr/local/bin/perl

        my %postInputs = (
        First => 'John',
        Last => 'Public',
        Address => '123 Easy Street',
        Email => 'JQ@...',
        );

        my $amt = '$35.00';

        $_= $postInputs{'First'} . "\t" ;
        $_= $_ . $postInputs{'Last'} . "\t" ;
        $_= $_ . $postInputs{'Address'} . "\t" ;
        $_= $_ . $amt . "\t" ;
        $_= $_ . $postInputs{'Email'} . "\n" ;

        print $_;

        __END__

        prints:

        John Public 123 Easy Street $35.00 JQ@...


        Are you sure there are no syntax
        errors in your code? Perhaps you didn't
        Cut & Paste your exact code to the message.


        HTH,

        Charles K. Clarkson
        --
        Head Bottle Washer,
        Clarkson Energy Homes, Inc.
        Mobile Home Specialists
        254 968-8328
      • picsian1 <imoq172@hotmail.com>
        Charles, Thank you for wanting to help again. Your response did help a lot. I spent at least 4 hrs looking at that one before posting it. Then after your
        Message 3 of 4 , Feb 2, 2003
        • 0 Attachment
          Charles,

          Thank you for wanting to help again. Your response did help a lot. I
          spent at least 4 hrs looking at that one before posting it. Then
          after your response I keyed in your little rountine. It worked for
          me too. So I scrutinzed my code for the umpteeneth time. Yep. I got
          the little devil this time. The $amt field was null at the time I
          wrote the record. It was getting initalized AFTER the write
          operation. Sigh. Thanks a bunch Charles!

          Best Regards

          Gary


          --- In perl-beginner@yahoogroups.com, "Charles K. Clarkson"
          <cclarkson@h...> wrote:
          > picsian1 <imoq172@h...> wrote:
          > :
          > : Now I wanted to insert an amount field in this
          > : record so I coded:
          > :
          > : my $amt='$35.00';
          > :
          > : Then
          > :
          > : $_= $postInputs{'First'} . "\t" ;
          > : $_= $_ . $postInputs{'Last'} . "\t" ;
          > : $_= $_ . $postInputs{'Address'} . "\t" ;
          > : $_= $_ . $amt . "\t" ;
          > : $_= $_ . $postInputs{'Email'} . "\n" ;
          > : print TEMP $_;
          > :
          > : When I examine the output file, there is no
          > : field with value '$35.00'. Just the tab char.
          > : where the $amt field should be. Can anyone
          > : spot where I'm going wrong or how can I get
          > : it to work.
          >
          > Worked for me:
          >
          > #!/usr/local/bin/perl
          >
          > my %postInputs = (
          > First => 'John',
          > Last => 'Public',
          > Address => '123 Easy Street',
          > Email => 'JQ@a...',
          > );
          >
          > my $amt = '$35.00';
          >
          > $_= $postInputs{'First'} . "\t" ;
          > $_= $_ . $postInputs{'Last'} . "\t" ;
          > $_= $_ . $postInputs{'Address'} . "\t" ;
          > $_= $_ . $amt . "\t" ;
          > $_= $_ . $postInputs{'Email'} . "\n" ;
          >
          > print $_;
          >
          > __END__
          >
          > prints:
          >
          > John Public 123 Easy Street $35.00 JQ@a...
          >
          >
          > Are you sure there are no syntax
          > errors in your code? Perhaps you didn't
          > Cut & Paste your exact code to the message.
          >
          >
          > HTH,
          >
          > Charles K. Clarkson
          > --
          > Head Bottle Washer,
          > Clarkson Energy Homes, Inc.
          > Mobile Home Specialists
          > 254 968-8328
        • Krishnakant Mane
          Hello, I just wanted to remind that I need some help on creating real time reports from databases. I want to present the data in a tabular grid format with
          Message 4 of 4 , Feb 3, 2003
          • 0 Attachment
            Hello,

            I just wanted to remind that I need some help on creating real time reports from databases. I want to present the data in a tabular grid format with lines vertically drawn between columns of data. I need to change the font attribute like the bold italics etc. including size. I will also like to know if there is any technique of sending the data to the printer.

            Thanks.




            ---------------------------------
            With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs


            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.