The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl question regarding [ ] hankooknara Shell Programming and Scripting 2 07-01-2007 05:21 PM
perl question BG_JrAdmin Shell Programming and Scripting 1 09-09-2005 08:46 PM
Perl Question Gary Dunn Shell Programming and Scripting 2 12-03-2004 12:37 PM
PERL question frank Shell Programming and Scripting 1 06-18-2002 04:13 AM
Perl question Jubba Shell Programming and Scripting 1 04-01-2002 03:24 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-07-2007
hankooknara hankooknara is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 80
another perl question

I fail to see how below answer is 1? can someone explain this for me?


DB<3> $string = "The cat sat on the mat";

DB<4> $animal = ($string =~ m/The (.*) sat/);

DB<5> print $animal;
1
  #2 (permalink)  
Old 07-07-2007
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
This behaviour is explained in the perlop manpage for m// binding in scalar context:

http://www.annocpan.org/~NWCLARK/per...perlop.pod#256

Quote:
Searches a string for a pattern match, and in scalar context returns true if it succeeds, false if it fails. If no string is specified via the =~ or !~ operator, the $_ string is searched. (The string specified with =~ need not be an lvalue--it may be the result of an expression evaluation, but remember the =~ binds rather tightly.) See also perlre. See perllocale for discussion of additional considerations that apply when use locale is in effect.
  #3 (permalink)  
Old 07-07-2007
hankooknara hankooknara is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 80
thank you...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0