Catfish, you still have a typo: you dropped the closing parenthesis for the if() block.

use v5.12; use warnings; my $Namelist = 'Wilma Fred Barney Betty Dino'; if ( $Namelist =~ m/(\w+a)/ ) { print "Matched|$<$&$>|\n"; say "The name that matched was $1 \n"; } else { print "No match: \n"; }

This code results in:

Matched|0Wilma0| The name that matched was Wilma

Note the strange "0" before and after "Wilma". I am in Windows, so I don't get a $< UID or a $> EUID. As I pointed out, those varibles make no sense in the context of trying to print matched output. When I asked what you "what were you trying to do with those", I was trying to get clarification of what you wanted your output to look like. Were you trying to have angle brackets literally used in your output? like:

Matched|<Wilma>| The name that matched was Wilma
That would be accomplished with print "Matched|<$&>|\n";

Or were you trying to have literal dollar signs and literal angle brackets? like:

Matched|$<Wilma>$| The name that matched was Wilma
That would be accomplished with print "Matched|\$<$&\$>|\n";

Or did you just really want Wilma to be printed between the vertical bars? like:

Matched|Wilma| The name that matched was Wilma
That would be accomplished with print "Matched|$&|\n";

Or did you really want the linux user-id number ($<) and effective user-id number ($>) to surround Wilma? like:

Matched|###Wilma###| The name that matched was Wilma
(where ### are actual numbers, not the number-signs I have shown): That would be accomplished with print "Matched|$<$&$>|\n";


In reply to Re^4: Simple prog isnt cooperating by pryrt
in thread Simple prog isnt cooperating by catfish1116

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.