Hewlett-Packard will trim 27,000 employees as part of its long-term restructuring plan, the company said Wednesday when it announced quarterly financial results.

The company will shed about 8% of its workforce through a combination of layoffs and retirement offers that started last Oct. 31 and will continue through the end of its 2014 fiscal year, HP said. Employee reduction plans vary by country.

In a statement, HP said it expects the restructuring program will save $3 billion to $3.5 billion through fiscal year 2014. A majority of those savings will be reinvested in the company, HP said.

The job cuts are "difficult" but they also are "necessary to improve execution and to fund long-term health" of HP, CEO Meg Whitman said in a statement.

HP also announced that its net income for the second quarter, which ended April 30, was $1.6 billion, a drop of 31% over the same quarter a year ago. It reported revenue of $30.7 billion, down 3%.

Excluding one-time charges, the company's earnings per share was 98 cents, which topped the consensus estimate of 91 cents from analysts polled by Thomson Reuters.

The company also forecast third quarter earnings of 94 cents to 97 cents, below previous expectations of $1.02 per share, but it expects that its full-year earnings will be $4.05 to $4.10, rather than $4.03 that analysts had forecast.