Pete Flaherty was standing around the new shopping mall here the other evening, not looking or acting much like a candidate for the U.S. Senate, when an odd thing happened.

Spotting Flaherty, a burly man in a porkpie hat rushed up, shook his hand with gusto, and laid a pep talk on the former Democratic mayor of Pittsburgh. w

"Knock his a-- off, Pete," the fellow loudly counseled. Shoppers were taken a little aback, but Flaherty liked the line and laughed.

It also happened to be a kind of high point of enthusiasm in another day of an otherwise lackluster race for the Senate seat being vacated by Richard S. Schweiker.

They may recognize Pete Flaherty, 55, in Reading (and quite a few did), but not many people believe his casual campaign style will be enough to overcome energetic Arlen Specter, the GOP candidate and former district attorney of Philadelphia.

In every sense, Specter, 50, would seem to be in the driver's seat. He has most of the newspaper endorsements, several big unions are behind him, he has flooded radio and TV with ads, he's outspending Flaherty by about 4 to 1, the polls show him slightly ahead.

But wait a minute. This is Pennsylvania, where Democrats have a 726,000-vote edge in registration, and nothing is to be taken for granted. Ticketsplitting is endemic. But candidates and their staffs agree it's a horse race for the Senate seat.

Past lessons carry weight here and both Specter and Flaherty know it. In 1978, Flaherty was ahead handily in the polls and ended up losing the governorship to Richard Thornburgh. Most agree Thornburgh did it by outhustling Flaherty.

As in the presidential race, which most consider too close to call, a key next Tuesday will be the Democratic turnout. If it's slim, the wisdom holds, Specter and Ronald Reagan should be in roses on Wednesday.

In this Senate Race, however, it is not as though Pennsylvanians are dealing with two unknown quantities. Both have extremely high name recognition, as much for their occasional wins as for their more frequent electoral defeats.

Flaherty was a popular two-term mayor of Pittsburgh from 1970 until 1977, when he became President Carter's deputy attorney general for a while. But in 1974 he lost a Senate race to Schweicker and in 1978 was defeated by Thornburgh for the governorship.

Specter, once a Democrat, has a record of even more setbacks, although his eight years as Philadelphia district attorney made his a household name. He ran for mayor and lost; ran for reelection as prosecutor and lost; ran for the Senate nomination and lost; ran for the gubernatorial nomination and lost. t

Although separated by wide gulfs of philosophy and style, both men have made revitalization of Pennsylvania's economy -- help for the coal and steel and the cities -- centerpieces of their campaigns. Both talk of stronger defense and a better shake for Pennsylvania in getting money from Washington.

Flaherty would do it through traditional Democratic means of public spending; Specter would do it with the GOP warhorses of tax incentives and less regulation.

Specter is a highly organized, glib and bright campaigner, backed by a $1.5 million campaign exchequer highlighted by a $525,000 contribution from the Republican Senatorial Campaign Committee, headed by Sen. John H. Heinz III (R-Pa.). Political consultant David Garth, who handles John Anderson, is behind Specter's big advertising campaign.

Flaherty is more easygoing, less programmed and less formal as a campaigner.

He and his wife, Nancy, run his low-budget effort ($330,000 for the general election) and Mrs. Flaherty does his ads, which even the Specter camp acknowledges as being effective.

Specter has traveled extensively in the west, hoping to cut into Flaherty's strongholds around Pittsburgh. Flaherty spends a good deal of time in the east, around heavily Democratic Philadelhia, where he must win to offset the GOP suburbs.

Flaherty is making an issue of his opponent's contributions from powerful business groups and charging that Heinz, a multimillionaire, is the puppeteer who pulls Specter's strings.

"Pennsylvania is not for sale," he told reporters at Allentown the other afternoon. "Heinz bought his seat in the Senate . . . and now he's trying to help Specter buy this election. We don't need politicians who are beholden to the special interests."

Will it fly in Pennsylvania? Not even Flaherty is certain. "It's hard to get that message across to the public about out-of-state money," he said.

Come Tuesday, it may not matter. Said a Democratic strategist in Harrisburg: "Specter is a strong campaigner and he is perceived as an honest man from his days as prosecutor. Many see him as brilliant . . . but he's bombarding the airways with ads and Pete isn't. How do you beat that?"