Shields come out on Frame 1. Perfect shielding happens if you shield an attack anywhere in Frames 1-3 of your shield.
If I'm not mistaken, you and the opponent incur the same amount of "stun" on a perfect shield, which is the case for any attack hitting an opponent or shield (almost any physical hit causes both the attacker and victim to freeze for a bit before knockback occurs) This hitlag freeze is dependent on the attack (stronger hits have greater hitlag freeze).
If I'm not mistaken, dropping your shield immediately after a perfect shield only takes a frame to register that you've let go of the Shield button, and then you can attack with whatever you want. This can be compared with shielding an attack normally, where you can jump out-of-shield immediately in much the same way, but you have to deal with the shield pushback, as well as limited options for a speedy attack. Grabs are 7 frames or worse, U-Smash/Up-B out-of-shield takes one frame of the jump start-up and then the attack start-up itself, while aerials out-of-shield take the full jump squat frames (5 for most of the cast, at least in past games) as well as the aerial attack start-up. You can also simply drop your shield before doing another option, which takes 7 frames as it did in Brawl.
It's something I've been experimenting a lot with as Jigglypuff, since she can shield immediately out of crouch and get easy perfect shields for attacks above her, like falling aerials and moves that would otherwise whiff on her crouching body.
As an aside, if you shield and no attack hits your shield, you have to wait 11 frames before you can simply unshield. This rule can be bypassed by doing other options immediately out of shield, such as jumping, grabbing or (and this part of why it's so good to default to) rolling. This "minimum frames of shielding" rule goes out the window once any attack hits your shield, as well.