Pattern Recognition - perl


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Pattern Recognition - perl
# 1  
Old 09-22-2006
Pattern Recognition - perl

can someone help me with this..
cant for the life of me figure it out..
=~ m!^(/.*)/bin/xx!

specific query > What does m!^ do
> What does the ! at the end do..
# 2  
Old 09-22-2006
Hi Scorreg,

In perl we most often we use directl pattern matching. This 'm' is nothin but the match operator, often used in conjunction with the bind operator(~).
'^' just signifies the start of the pattern and '!' is delimiter.

You can write the same as ......

=~ {^(/.*)/bin/xx}

Now the 'm' is absent and '{' and '}' are delimiters!!
# 3  
Old 09-22-2006
thanks.. man
# 4  
Old 09-23-2006
Quote:
Originally Posted by apoorvasharma80
You can write the same as ......

=~ {^(/.*)/bin/xx}

Now the 'm' is absent and '{' and '}' are delimiters!!
Actually the 'm' is necessary unless '/' is used as delimiter. So, m{} but not {}, as {} means something else in Perl (reference to hash literal).
 
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Conditional pattern recognition with awk

Hi, I would need some help extracting the desired data from the following text: # Time_result: 1.056179 next_value: 0.000077 OTHER VALUE 445552341; SELECT row with values # IP = 192.168.1.15 # Time: 45 # Time_result: 100.15 next_value: 0.000077 OTHER VALUE 445552341; SELECT row with... (2 Replies)
Discussion started by: alex2005
2 Replies

2. Shell Programming and Scripting

Perl pattern use

Hi , I have a file. I would like to split each line into 3 value. Ex: i/p line: 09.11.12 04:40: 561 users on GCSS_gcsspr3a. Expect output: $a=09.11.12 04:40 $b=561 $c=GCSS_gcsspr3a. Any idea plz Thanks, Mani (1 Reply)
Discussion started by: Mani_apr08
1 Replies

3. Shell Programming and Scripting

perl:: search for tow pattern and replace the third pattern

Hi i want to search two pattern on same line and replace onther pattern.. INPut file aaaa bbbbb nnnnnn ttttt cccc bbbbb nnnnnn ppppp dddd ccccc nnnnnn ttttt ffff bbbbb oooooo ttttt now i want replace this matrix like.. i want search for "bbbbb","nnnnnn" and search and replace for... (4 Replies)
Discussion started by: nitindreamz
4 Replies

4. OS X (Apple)

Automatic device recognition in OSX

Can anyone point me to a resource (or answer my question) that will show me how to automatically run a script in OSX when a device is plugged in. The OS recognizes that the device is plugged in but how do I direct it to do something I want it to do. it seems that linux has udev but what would... (2 Replies)
Discussion started by: djkuzenko
2 Replies
Login or Register to Ask a Question