Perl q/STRING/ Function

These sites are FOR SALE: miscperlinfo.com, mpihowto.com!
If you are interested, please use my Contact page.




q/STRING/ is rather an operator than a function.

You can use it instead of single quotes.

Because it returns a single quoted string, the interpolation is not allowed.

Instead of slashes you can use any set of delimiters you want.

If you use parentheses as delimiters, its syntax looks like a function, where string is the argument:

q(string)

Single quotes are used to enclose data you want taken literally.


Click Below to See the Best

Perl How-to Snippet Collection

and Save Hours of Surfing on Internet!


See the following example:

my $str = 'The pencil is mine.';
print "$str\n";

# the same thing:
$str = q/The pencil is mine./;
print "$str\n";

The output:

The pencil is mine.
The pencil is mine.


A-N-Y-O-N-E Can Learn and Master Perl!
And That Includes YOU!


Check these how-to tutorial eBooks (PDF format):


Table of Contents:

A Perl Script
Install Perl
Running Perl
Perl Data Types
Perl Variables
Perl Operators
Perl Lists
Perl Arrays
    Array Size
    Array Length
Perl Hashes
Perl Statements
    Perl if
    Perl unless
    Perl switch
    Perl while
    Perl do-while
    Perl until
    Perl do-until
    Perl for
    Perl foreach
Built-in Perl Functions
    Functions by Category
        String Functions
        List Functions
        Array Functions
        Hash Functions
        Miscellaneous Functions
    Functions in alphabetical order
        chomp
        chop
        chr
        crypt
        defined
        delete
        each
        grep
        hex
        index
        join
        lc
        lcfirst
        length
        map
        oct
        ord
        pack
        pop
        push
        q (more)
        qq
        qw
        reverse
        rindex
        scalar
        shift
        sort
        splice
        split
        sprintf
        substr
        tr
        uc
        ucfirst
        undef
        unshift

return from Perl q/STRING/ function to Perl Basics



Would you like to create your own website like this one?
Hit the Alarm Clock!

Site Build It!