×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

What means ($_ =~ m/\ <.*\ >/g) ? (perl)

What means ($_ =~ m/\ <.*\ >/g) ? (perl)

What means ($_ =~ m/\ <.*\ >/g) ? (perl)

(OP)
I’m an English major and for some reason my professor makes us learn about perl.
It’s just really hard to grasp for me and help would be greatly appreciated.

I already know that this m/ < means that “does this line contain “<“ same goes with “>” but what is meant by “.*”??



use strict;
use warnings;

my $k = "";

print "running ...\n";

open (IN,"auste-north-1522.txt");
open (OUT,">outfile4.txt");

while (<IN>) {
$_ =~ s/(\<i\>)|(\<\/i\>)//g;
print OUT $_ unless ($_ =~ m/\<.*\>/g);
}

close (IN);
close (OUT);

print "Press the return/enter key to finish.";
$k = <STDIN>

RE: What means ($_ =~ m/\ <.*\ >/g) ? (perl)

Hi

Quote (Ave_Y)

but what is meant by “.*”?
Those are 2 different metacharacters :
  • . means any character
  • * means the previous entity 0 or more times
You can find them documented in the perlre manual's Metacharacters section.

Some examples :
'abc' =~ m/<.*>/   # not matches, presence of < and > is mandatory
'a><bc' =~ m/<.*>/ # not matches, < and > must occur in that order
'a<>bc' =~ m/<.*>/ # matches, .* quantifier allows any number of character between < and >
'a<b>c' =~ m/<.*>/ # same
'a<bc>' =~ m/<.*>/ # same
'a<<>>' =~ m/<.*>/ # matches, . accepts any character, including < and >
'<>' =~ m/<.*>/    # matches, no other character's presence is required
'<>a<>' =~ m/<.*>/ # matches, multiple < ... > subsequences may occur

Additional notes :

Feherke.
feherke.github.io

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close