Hi, Thanks alot for the detailed explanation. Regards Anand Kumar
Prabu <[EMAIL PROTECTED]> wrote: anand kumar wrote: > hi all, > > I could not understand clearly the functions > qw(),qq(),qr(),qx(),q(),quotemeta(). I > have read the explanation for these functions in the perl documentation but i > could not get idea of where exactly we can use these functions. So please > send some other links or examples for these functions. > > Thanks in advance for the help > > Regards > Anand Kumar Hello Anand, q/STRING/ STRING A single-quoted, literal string.A generalized single-quote operation. A backslash represents a backslash unless followed by the delimiter or another backslash, in which case the delimiter or backslash is interpolated. for example $foo = q!Hello World!; This is equivalent to $foo='hello world'; _________________________________________________________________________________ qq/STRING/ "STRING" A double-quoted, interpolated string. for example $foo = qq!Hello World!; This is equivalent to $foo='hello world'; _________________________________________________________________________________ qr/STRING/imosx This operator quotes (and possibly compiles) its STRING as a regular expression. STRING is interpolated the same way as PATTERN in "m/PATTERN/" Options are: i Do case-insensitive pattern matching. m Treat string as multiple lines. o Compile pattern only once. s Treat string as single line. x Use extended regular expressions. For example $rex = qr/my.STRING/is; s/$rex/foo/; This is equivalent too s/my.STRING/foo/is; _________________________________________________________________________________ qx/STRING/ STRING A string which is (possibly) interpolated and then executed as a system command with "/bin/sh" or its equivalent. Shell wildcards, pipes, and redirections will be honored. The collected standard output of the command is returned; standard error is unaffected. qx(ls); This is equivalent to `ls` (backtics) qw/STRING/ Evaluates to a list of the words extracted out of STRING, using embedded whitespace as the word delimiters. @a=qw(foo bar baz); This is equivalent too @a=("foo", "bar", "baz"); _________________________________________________________________________________ quotemeta EXPR Returns the value of EXPR with all non-"word" characters backslashed. _________________________________________________________________________________ A Small Example PROGRAM $ cat func.pl #!/usr/bin/perl $foo = q!Hello World\n!; print "single-quote operation\n\t",$foo."\n"; $foo = qq!Hello World\n!; print "double-quote operation\n\t",$foo; $foo = "Hello world"; $pattern = qr!Hello!is; $foo=~s/$pattern/HELL0/; print "Regex operation\n\t",$foo; @a=qw(hello perl world); print "\nTurn a space-delimited string of words into a list\n\t"; foreach(@a){ print "$_\n\t"; } $foo="Hello*world"; $non_word_char = quotemeta($foo); print "\nBackslashed non-word characters\n\t",$non_word_char."\n"; print qx/ps/; OUTPUT $ perl func.pl single-quote operation Hello World\n double-quote operation Hello World Regex operation HELL0 world Turn a space-delimited string of words into a list hello perl world Backslashed non-word characters Hello\*world PID TTY TIME CMD 20453 pts/5 00:00:00 bash 20737 pts/5 00:00:00 perl 20738 pts/5 00:00:00 ps -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------- Heres a new way to find what you're looking for - Yahoo! Answers