Unless you are doing some formatting just use print $_
 
    When you are doing printf $_ and printf is trying to use $_ for for formatting. If you had had strict and warnings, you would have seen that occurring.
 
      if you do printf "%s", $_ then will print.
 
    But you should always use strict and warnings. Saves you a lot of time and energy ( believe me - l know from my past )
 

          If you have any problems or questions, please let me know.

     Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449           FAX
http://fedex.com/us

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Wednesday, September 27, 2006 14:39
To: [email protected]
Subject: <> Operator and String Expansion

Does anyone know why the following is happening? A solution/workaround would be greatly appreciated!


I have a simple perl program which loops through a file, line by line -- eg:


open FOO,"..."
while (<FOO>)
{
printf $_;
}

my file looks like this:


abc
%abc
abc

etc.


When I run the program, it seems as though Perl attempts to replace '%' with a a variable reference -- for example, the output often looks like this:


abc
0bc
abc

or

abc
0.000000000bc
abc



I've tried replacing '%''s before the printf, but this doesn't work -- the variable expansion seems to occur when the line is assigned to $_


Any thoughts?


Thanks!



Jeff.

- The integrity of the transmitted information in this email is not guaranteed by Desjardins Securities, which accepts no liability for any damage caused by its fraudulent alteration. This email is confidential and is intended for the sole use of the recipient or authorized representative of the recipient. Any person who receives this email by mistake shall immediately notify the sender and destroy it. Any other use of the information therein is strictly prohibited. Desjardins Securities reserves the right to monitor all communications sent by e-mail through its networks. Instructions related to operations sent by e-mail will not be accepted. In no way does this notice limit other more restrictive warnings that may have been sent to you by Desjardins Securities.

**********************************************************************

This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited.

**********************************************************************

 

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to