~and s in perl

HI I am new to perl .

can you lease give me explanation of these commands .

 
$Program = $0 ; $Program =~ s/.*\/// ;
$MyDir = $0 ; $MyDir =~ s/[^\/]*$// ;
 
what does these lines mean "~ s/.*\/// " ,"~ s/[^\/]*$// " ?
 
use DBI;
use DBD::Oracle qw(:ora_types);
use File::Copy;

what does above lines refer to ?

 
if ( defined ( $opt_v ) ) 

what does this mean?

s/.\/// - replaces everything in front of / with nothing
s/[^\/]
$// - replaces the characters in between the last / and the end of the string with nothing

[FONT=Courier New]

if ( defined ( $opt_v ) ) 

if variable $opt_v is defined

This is a substitute command similar to sed on the unix shell.
s/.*\/// --> delete all the characters in $Program variable from the beginning till the last occurrence of '/' (rather it substitutes the characters from the beginning till the last occurrence of '/' with nothing)

s/[^\/]*$// --> delete all the characters in $Mydir from the last occurrence of '/' till the end (substitute the characters from the last occurrence of '/' till the end with nothing).

To give a better picture these two 's' commands work similar to "basename" and "dirname" utilities in unix.

You're asking the perl compiler to use these modules (load these modules) so that the sub-routines in these modules can be used in your current program. You may want to read more about modules in perl.

This is plain English: If $opt_v is defined, then do this...

Sometimes $opt_v may not be defined or defined with "undef", in that case, this condition will fail.