Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PRINT

Status
Not open for further replies.

Nova980

Technical User
Joined
May 20, 2009
Messages
40
Location
US
Thanks in advance,

I'd like to print only the first 25 characters of a 40 character line from error.log/@lines.

Code:
 if (@lines) {
   open FILE_LOG, ">", "error.log" or die $!;
   print FILE_LOG @lines;
}

How can I output only the first 25 characters (redundant).

Happy 4th of June
 
Use substr.

Code:
if (@lines) {
   open FILE_LOG, ">", "error.log" or die $!;
   for (@lines) {
      print FILE_LOG substr($_,0,25), "\n";
   }
}


Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top