A state can't punish a newspaper for publishing the name of an alleged juvenile delinquent, the Supreme ruled, 8 to 0, yesterday.

The ruling came in a West Virginia case in which a state law made it a crime for a newspaper - but not other media - to identify a youthful offender without approval in writing from a juvenile court.

In a victory for the two dailies in Charleston, Chief Justice Warren E. Burger wrote for the court that the law is inconsistent with the freedom of the press guarantee of the First Amendment to the Consitution.

"A free press cannot be made to rely solely upon the sufferance of government to supply it with information" Burger said. "If the information is lawfully obtained, as it was here, the state may not punish its publication except when necessary to further an interest more substantial than is present here."

The sole interest of the state in enacting the law was to protect a juvenile's anonymity in hopes of furthering, or at least not impairing, his rehabilitation.

That interest is insufficient to justify a criminal penalty on the Charleston papers, Burger said.

First the morning Daily Gazette and then the afternoon Daily Mail identified Stuart Perrock, 14, as the youth alleged to have shot to death classmate Arthur Smith, also, 14, in a junior high school in St. Albans, W. Va., in February 1978.

Seven eyewitnesses identified Perrock, who was arrested within three hours. The newspapers learned of the shooting through routine monitoring of the police radio. Reporters who went to the scene learned the youth's name by talking to witnesses, officers and a prosecutor.

The Daily Mail was the first to print a story, but, because of the law, didn't name Perrock. The same afternoon and the next day, however, three radio stations did name him.

The information was public knowledge by the time the Daily Gazette was to publish, and it named Perrock. In an editorial, editor Don Marsh scorned as "legalistic fiction" the use of a phrase such as "14-year-old youth" for a suspect known to "everyone in the St. Albans area."

A stage grand jury returned an indictment against the papers, but the newspapers prevented further action by obtaining an order from the West Virginia Supreme Court.

The state court said that the law operated as a prior restraint on speech, which carries a heavy presumption against its constitutionality.

Yesterday, Burger wrote that the U.S. Supreme Court "need not decide" whether the law worked as a prior restraint. Emphasizing that the dailies had "relied upon the routine newspaper reporting techniques," he said they can't be punished for publishing lawfully obtained information.