Perl | qw Operator Last Updated : 17 Mar, 2023 Comments Improve Suggest changes Like Article Like Report The qw operator in Perl is used to extract each element of the given string as it is in an array of elements in single-quote ( ' ' ). This function stands for quote word because it considers each word of the given string as it is quoted like qw(Geeks for Geeks) is equivalent to ('Geeks', 'for', 'Geeks'). This qw() uses parentheses so it seems like it is a function but it is not. It uses different types of delimiters which are shown below: @String = qw/Ram is a boy/; @String = qw{Geeks for Geeks}; @String = qw[Geeks for Geeks]; @String = qw'Geeks for Geeks'; @String = qw"Geeks for Geeks"; @String = qw!Geeks for Geeks!; @String = qw@Geeks for Geeks@; Syntax: qw(String) Parameters: String : It is the input string whose each element is extracted. Returns: each element of the given string as it is an array of elements in single-quote (''). Example 1: Perl #!/usr/bin/perl # Initialising a String as the parameter of qw # operator whose each element is extracted. @String = qw(GfG is a computer science portal); foreach $key (@String) { print"Element is: $key\n"; } Output: Element is: GfG Element is: is Element is: a Element is: computer Element is: science Element is: portal Example 2: Perl #!/usr/bin/perl # Initialising a String as the parameter of qw # operator whose each element is extracted. @String = qw(Delhi Mumbai Kolkata Patna); foreach $key (@String) { print"City name is: $key\n"; } Output : City name is: Delhi City name is: Mumbai City name is: Kolkata City name is: Patna Note: The qw operator reads a white-space and extract elements before and after the white-space. Example - 3: We can also use the qw operator with numbers. The syntax will alter in that case. Syntax of qw operator while using it with numbers - qw/<space separated numbers>/; Perl #!/usr/bin/perl # your code here @array = qw/12 15 46 98 42 35/; foreach $key (@array){ print($key,"\n"); } Output12 15 46 98 42 35 Comment More infoAdvertise with us Next Article Perl | qw Operator K Kanchan_Ray Follow Improve Article Tags : Perl perl-operators Perl-String-Operators Similar Reads Perl | y Operator The y operator in Perl translates all characters of SearchList into the corresponding characters of ReplacementList. Here the SearchList is the given input characters which are to be converted into the corresponding characters given in the ReplacementList. Syntax: y/SearchList/ReplacementList/ Retur 2 min read Perl | gt operator 'gt' operator in Perl is one of the string comparison operators used to check for the equality of the two strings. It is used to check if the string to its left is stringwise greater than the string to its right. Syntax: String1 lt String2 Returns: 1 if left argument is greater than the right argume 1 min read Perl | eq operator 'eq' operator in Perl is one of the string comparison operators used to check for the equality of the two strings. It is used to check if the string to its left is stringwise equal to the string to its right. Syntax: String1 eq String2 Returns: 1 if left argument is equal to the right argument Examp 1 min read Perl | lt operator 'lt' operator in Perl is one of the string comparison operators used to check for the equality of the two strings. It is used to check if the string to its left is stringwise less than the string to its right. Syntax: String1 lt String2 Returns: 1 if left argument is less than the right argument Exa 1 min read Perl | ge operator 'ge' operator in Perl is one of the string comparison operators used to check for the equality of the two strings. It is used to check if the string to its left is stringwise greater than or equal to the string to its right. Syntax: String1 ge String2 Returns: 1 if left argument is greater than or e 2 min read Like