- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Matching Only Once in Perl
There is a simpler version of the match operator in Perl - the ?PATTERN? operator. This is basically identical to the m// operator except that it only matches once within the string you are searching between each call to reset.
For example, you can use this to get the first and last elements within a list −
Example
#!/usr/bin/perl @list = qw/food foosball subeo footnote terfoot canic footbrdige/; foreach (@list) { $first = $1 if /(foo.*?)/; $last = $1 if /(foo.*)/; } print "First: $first, Last: $last\n";
When the above program is executed, it produces the following result −
First: foo, Last: footbrdige
- Related Articles
- Display matching repeated date records only once in MySQL
- Grouping Matching in Perl
- Matching Boundaries & Selecting Alternatives in Perl
- Show the background image only once with CSS
- Add two array keeping duplicates only once - JavaScript
- Program to pick out duplicate only once - JavaScript
- Is it true that opportunity knocks only once?
- How to order return duplicate column values only once in MySQL?
- Get count of values that only appear once in a MySQL column?
- Filtering out the non-unique value to appear only once in JavaScript
- Find and display duplicate values only once from a column in MySQL
- Finding two missing numbers that appears only once and twice respectively in JavaScript
- Select a value from MySQL database only if it exists only once from a column with duplicate and non-duplicate values
- How to count values from a PHP array and show value only once in a foreach loop?
- How to SELECT all values from a table only once if they're duplicated?

Advertisements