Perl Pie (aka perl -p -i -e)

Few days ago a co-worker came to me for an advice and he said the following “I have a huge file that has 2 million records and I would like to change a date in it from 04/29/2012 to 04/15/2012.” He emphasized that there was only one column that has that date.

In order to solve the problem I went ahead and executed this statement on unix command line:

$ perl -p -i -e 's|04/29/2012|04/15/2012|g' file

The run time was few seconds and all records got updated properly.

How to extract the domain name from an email address

Method 1:

SELECT SUBSTR(
'EXAMPLE@YAHOO.COM' ,
INSTR('EXAMPLE@YAHOO.COM' , '@' ) + 1 )
AS EMAIL_DOMAIN
FROM DUAL;

Method 2:

SELECT
REPLACE(
REGEXP_SUBSTR( 'EXAMPLE@YAHOO.COM' , '@.*' ) , '@' )
AS EMAIL_DOMAIN
FROM DUAL;

All you need to do now is to replace ‘EXAMPLE@YAHOO.COM’ with your email address column name or value.