Line 15: Input date is converted into time in seconds from epoch (epoch on most unix systems is 01-Jan-1970 00:00:00).
Line 16: Localtime returns an array and the 7th element specifies the count of current day starting from sunday. So, if localtime were to see 12/22/2011, 7th element returned would contain 4, i.e. 4th day from Sunday starting from 0. According to your specification, week starts from Monday, so I subtracted 1 from the result. This multiplied by 86400 seconds subtracted from $sec would give prev monday's stamp in seconds from epoch.
Line 17: Similarly, the next sunday is determined.
Line 19: The time in seconds from epoch is converted to human readable format.
Line 20: Ditto.
---------- Post updated at 18:39 ---------- Previous update was at 18:28 ----------
@vivek_d_r: What would your revised program print if the input date is 02/29/2012 in mm/dd/yyyy?