show run Building configuration... ! encryption key 1 size 40bit 7 621AA6093A25 transmit-key encryption key 2 size 40bit 7 7260637E4720 encryption key 3 size 40bit 7 0F733F116035 encryption key 4 size 40bit 7 03B71F3D601D encryption mode wep mandatory ! #### key : 1 size: 40 value: 621AA6093A25 (the length could be different) TransmitKey: true # The number 7 in the encryption key information should be ignored. #### for ($Count=1; $Count<=4; $Count++) { if ($showrunOutput=~/encryption\skey\s$Count\s(.+)\s\n/){ print $1; } }