The former Friends star talked about the primary school incident on a Wednesday-night television appearance.
Mr Perry was born in the US state of Massachusetts but raised in Ottawa, Canada and attended the same school as Mr Trudeau.
He said a friend recently reminded him of the long-ago altercation.
The actor and comedian said he was a couple of years ahead of Mr Trudeau in school.
"I have a story about him that I'm not proud of," he recounted on the Jimmy Kimmel Live talk show.
"I think he was excelling in a sport that we weren't. So it was pure jealousy."
The current prime minister lived in Ottawa and attended school there as a youth while his father, Pierre Elliott Trudeau, served as prime minister.
Perry, who came to fame playing the awkward, sarcastic and funny character Chandler Bing on Friends, also lived in the Canadian capital with his mother, who was a journalist and served as a former press secretary to the elder Trudeau.
"I'm not bragging about this, it was terrible, I was a stupid kid," he told Mr Kimmel.
But he jokingly said the incident might have helped spur Mr Trudeau's future ambition.
"I think it was rather instrumental in him becoming, you know, going to such great heights and becoming the prime minister. I think he said 'I'm going to rise above this.'"
He said he still feels bad about the incident.
"I feel shame, I don't want to think about it," he told Mr Kimmel.

It comes after 17 schools in Edinburgh were closed earlier this year due to safety concerns.
The BBC sent Freedom of Information requests to councils across the country asking what, if any, structural faults had been found at schools in their areas in the last five years.
So what schools have been affected and when?
In 2010, defects were discovered at St Ninian's in East Renfrewshire.
Engineers found wall ties were not properly embedded because the joints in the walls were not aligned. Photographs obtained using Freedom of Information legislation showed metal ties dangling mid-air rather than linking the exterior and interior walls.
East Renfrewshire Council paid more than £870,000 to carry out the necessary repairs.
The local authority said it did not inform parents of the issue because "at no time was there a health and safety risk to pupils, staff or visitors".
It said the matter was discussed "openly" at a full council meeting in May 2013.
In January 2012, problems were identified at two schools in South Lanarkshire.
In stormy weather, during the Christmas holidays, walls collapsed at both Trinity High School in Rutherglen and Duncanrig High School in East Kilbride.
Repair work was overseen by Morgan Sindall, the company which runs the schools.
It then looked at all 16 schools it has responsibility for in South Lanarkshire and found a small number of wall and header ties needed replaced at an additional eight schools:
After the problems with schools in Edinburgh were identified earlier this year it emerged that a similar structural fault had been found at Lourdes Primary in Glasgow in November 2012.
Engineers found header ties missing.
The building firm involved, Miller Construction, was also involved in the Edinburgh school crisis.
Lourdes Primary was temporarily closed with pupils moved to other schools.
Glasgow City Council said the issue was handled quickly and effectively, with Miller Construction accepting all responsibility and covering the cost of the repair work.
Structural surveys were subsequently carried out on all Glasgow schools built by Miller Construction and came back clear.
In May this year, Balfron High School in Stirlingshire was partially closed after structural problems were identified.
A wall at the school had been damaged during winter storms and after checks were carried out by engineers issues with walls in the stairwell, gym and atrium were discovered.
Again, the problems centred on wall and header tie defects.
Initial repair work was carried out before the holidays with further work due to be completed ahead of pupils returning after the summer break.
The problems with schools in Edinburgh came to light earlier this year during inspections carried out following a wall collapse at Oxgangs Primary School.
Other schools affected included:
Repairs have now been completed at all the Edinburgh schools, with pupils due to return to their classrooms this week.
The council has assured parents all the buildings affected by the closures are now safe.
BBC Scotland Investigates: How Safe is My School? On BBC1 Scotland at 19:00 on Monday 22 August.
Actor Matthew Perry is claiming that he once "beat up" Canadian Prime Minister Justin Trudeau.
[NEXT_CONCEPT]
A BBC Scotland investigation has revealed that a total of 30 schools in Scotland have had to make repairs due to structural defects in the last five years.