Re: write to a file

2004-03-12 Thread $Bill Luebkert
Anderson, Mark (Service Delivery) wrote:

> Works perfectly for me... ActiveState 5.6.1 on NT4
> 
> #!C:/Activeperl/bin/perl.exe
> use strict;
> use warnings;
> my ($name, $address, $city, $state, $zip);
> format ADDRESSLABEL =
> ===
> | @<< |
> $name
> | @<< |
> $address
> | @, @< @ |
> $city,  $state, $zip
> ===
> .
> 
> open(ADDRESSLABEL,">addresses.txt") or die("ack: $!");
> 
> while () {
>chomp;
>($name, $address, $city, $state, $zip) = split(/;/);
>select (ADDRESSLABEL);

There's no need to select a FH when you specify the FH on the write/print.
I would drop the parens below though just to be clear it's not an expression.

>write (ADDRESSLABEL);
> }
> 
> __DATA__
> David R. Wagner;4485 Long Green Dr;San Francisco;CA;994058
> 
> 
> F:\>formtest.pl
> F:\>cat addresses.txt
> ===
> | David R. Wagner |
> | 4485 Long Green Dr  |
> | San Francisco, CA 99405 |
> ===


-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: write to a file

2004-03-12 Thread Anderson, Mark (Service Delivery)
Works perfectly for me... ActiveState 5.6.1 on NT4

#!C:/Activeperl/bin/perl.exe
use strict;
use warnings;
my ($name, $address, $city, $state, $zip);
format ADDRESSLABEL =
===
| @<<<<<<<<<<<<<<<<<<<<<<<<<< |
$name
| @<<<<<<<<<<<<<<<<<<<<<<<<<< |
$address
| @<<<<<<<<<<<<<<<<, @< @<<<< |
$city,  $state, $zip
===
.

open(ADDRESSLABEL,">addresses.txt") or die("ack: $!");

while () {
   chomp;
   ($name, $address, $city, $state, $zip) = split(/;/);
   select (ADDRESSLABEL);
   write (ADDRESSLABEL);
}

__DATA__
David R. Wagner;4485 Long Green Dr;San Francisco;CA;994058


F:\>formtest.pl
F:\>cat addresses.txt
===
| David R. Wagner |
| 4485 Long Green Dr  |
| San Francisco, CA 99405 |
===

Kind regards,

Mark Anderson
SMS Deployment
The Royal Bank of Scotland
113 Dundas Street, Edinburgh, EH3 5DE
http://www.manufacturing.rbs.co.uk/GTrswi/


> -Original Message-
> From: Eric Edwards [SMTP:[EMAIL PROTECTED]
> Sent: Friday, March 12, 2004 7:52 AM
> To:   Anderson, Mark (Service Delivery);
> [EMAIL PROTECTED]
> Subject:  Re: write to a file
> 
> *** WARNING : This message originates from the Internet ***
> 
> From: "Anderson, Mark
> 
> > Hi,
> >
> > you need to
> > select(ADDRESSLABEL);
> > before you
> > write(ADDRESSLABEL);
> >
> > Tested!
> Mark,
> It doesn't like that.
> Eric
> >
> > Kind regards,
> >
> > Mark Anderson
> > SMS Deployment
> > The Royal Bank of Scotland
> > 113 Dundas Street, Edinburgh, EH3 5DE
> > http://www.manufacturing.rbs.co.uk/GTrswi/
> >
> >
> > > -Original Message-
> > > From: Eric Edwards [SMTP:[EMAIL PROTECTED]
> > > Sent: Thursday, March 11, 2004 11:55 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: re:write to a file
> > >
> > > *** WARNING : This message originates from the Internet ***
> > >
> > > Hey list,
> > > This program will print the input but will not write the format to the
> > > output file.  Any ideas as to the error of my ways?  Its
> > > probably real obvious.
> > > Thanks in advance.
> > > Eric
> > > #!/usr/bin/perl
> > > use strict;
> > > use warnings;
> > > my ($name, $address, $city, $state, $zip);
> > > format ADDRESSLABEL =
> > > ===
> > > | @<<<<<<<<<<<<<<<<<<<<<<<<<< |
> > > $name
> > > | @<<<<<<<<<<<<<<<<<<<<<<<<<< |
> > > $address
> > > | @<<<<<<<<<<<<<<<<, @< @<<<< |
> > > $city,  $state, $zip
> > > ===
> > > .
> > > open(ADDRESSLABEL, ">c:\\perl_prgm\\labels-to-print") or
> > >die "can't create";
> > > open(ADDRESSES, "c:\\perl_prgm\\addresses.txt") or
> > >die "cannot open addresses";
> > > while () {
> > >chomp;
> > >($name, $address, $city, $state, $zip) = split(/:/);
> > > write (ADDRESSLABEL);
> > > }
> > >
> > > ___
> > > Perl-Win32-Users mailing list
> > > [EMAIL PROTECTED]
> > > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> >
> >
> > The Royal Bank of Scotland plc, Registered in Scotland No. 90312.
> Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB
> >
> > The Royal Bank of Scotland plc is authorised and regulated by the
> Financial Services Authority and represents The Royal Bank of Scotland
> Marketing Group. The Bank sells life policies, collective investment
> schemes
> and pension products and advises only on the Marketing Group's range of
> these products and on a With-Profit Bond produced by Norwich Union Life
> (RBS) Limited.
> >
> > This e-mail message is confidential and for use by the addressee only.
> If
> the message is received by anyone other than the addressee, please return
> the message to the sender by replying to it and then delete the message
> from
> your computer. Internet e-mails are not necessarily sec

RE: Write to a file issue

2002-04-05 Thread Morse, Richard E.

Based on the program that you sent, and what I understand of what you're asking,
you need to read in the entire file, parse it, internally represent it, and then
write it back out...

HTH,
Ricky

> -Original Message-
> From: Jorge Goncalvez [mailto:[EMAIL PROTECTED]]
> Sent: Friday 05 April 2002 11:08 AM
> To: Morse, Richard E.
> Subject: RE: Write to a file issue
> 
> 
> I tried but it didn't work
> In fact I wanted to write only one time for exemple "test" 
> but with my code it 
> adds "test" always i run my program.
> Thanks if you could help me.
> I would be very grateful.
> 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs