ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> activeperl
activeperl
Re: Help with $_
by Michael Ellery other posts by this author
Oct 27 2009 4:33PM messages near this date
Re: Help with $_ | Re: Help with $_
I would recommend either (1) don't chomp in the first place or (2) just
do print "$_\n".

-Mike

Barry Brevik wrote:
>  I am aware that there are a number of Perl "operations" that will use
>  the system variable $_ as the default variable if one is not supplied.
>  
>  Consider the following snippet (where XMLIN is a previously opened file
>  handle):
>   
>  
>    foreach (<XMLIN>)
>    {
>      chomp;
>  
>      # Do some stuff to the contents of the line.
>  
>      print;
>    }
>  
>  OK, what I really want to do here is print the (possibly changed) line,
>  AND a CR/LF, but to do that, I have to add a separate print statement
>  like this: print "\n";
>  
>  So after all these years, I'm wondering, is there a PERLish way to add a
>  "\n" in the same line of code that prints the default $_ variable?
>  
>  Barry Brevik
>  _______________________________________________
>  ActivePerl mailing list
>  ActivePerl@[...].com
>  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>  

_______________________________________________
ActivePerl mailing list
ActivePerl@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Barry Brevik
Olivier Mengue
Michael Ellery
Gabor Szabo

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved