Hewlett-Packard (HPQ) posted a lighter-than-feared 32% contraction in fiscal second-quarter profits on Wednesday as the aging tech giant’s cost cutting helped offset shrinking revenue.

Shares of H-P, already up almost 50% on the year, spiked another 10% in after-hours trading as Wall Street focused on the earnings beat and upbeat guidance instead of weaker-than-expected sales.

H-P said it earned $1.1 billion, or 55 cents a share, last quarter, compared with a profit of $1.6 billion, or 80 cents a share, a year earlier.

Excluding one-time items, it earned 87 cents a share, down 11% from the year before but above the  Street’s view of 81 cents.

Revenue declined 10% to $27.6 billion, trailing consensus calls from analysts for $28.01 billion.

In a sign of progress, H-P said its quarterly cash flow from operations soared 44% year-over-year to $3.6 billion.

Meg Whitman, H-P’s CEO, said in a statement that the earnings beat was “driven by better than expected performance in Enterprise Services and Printing, coupled with the accelerated capture of restructuring savings and improvement in our operation.”

Looking ahead, H-P forecasted fiscal third-quarter non-GAAP EPS of 84 cents to 87 cents, compared with the Street’s view of 83 cents.

For the full year, management sees non-GAAP EPS of $3.50 to $3.60, which would also exceed consensus calls from analysts for $3.48. 

“I am encouraged by our performance in the second quarter, and I feel good about the rest of the year," Whitman said. "As I have said many times before, this is a multi-year journey. We have a long way to go.”

H-P’s results underscore the difficult PC market as its personal systems revenue tumbled 20%. This division’s commercial revenue slid 14%, while consumer sales dropped 29%. Desktop units decreased 18% and notebook units fell 24%.

While H-P suffered across-the-board revenue decreases, other parts of its business managed lighter declines.

The company’s printing revenue dipped just 1%, while enterprise revenue fell 10% and enterprise services sales dropped 8%. H-P said its software revenue was off 3%.

H-P continued to improve its balance sheet during the quarter, slashing its operating net debt position by $1.8 billion -- the fifth consecutive quarterly cut of more than $1 billion.

Whitman said by the end of fiscal 2013, H-P expects its net debt to fall below the levels before the disastrous $11.1 billion buyout of software company Autonomy in August 2011. 

Shares of Palo Alto, Calif.-based H-P rallied 10.2% to $23.40 in extended trading on Wednesday.

Follow Matt Egan on Twitter @MattMEgan5