Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
What the hell does this mean in perl?
Old 02-16-2010, 09:57 AM What the hell does this mean in perl?
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Hi guys,

Im trying to fix an aging system created by someone many moons ago.

What is this matching?

More importantly, what does the =~ mean? and the (.*) in the IF?



foreach my $line (@registars) {
chomp $line;
if($line =~ /<tr><td>(.*)<\/td><td>(.*)<\/td><\/tr>/) {
$isps{$1} = "$1 ($2)";
$tag[$i++] = $1;
}
}
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
 
Register now for full access!
Old 02-16-2010, 10:23 AM Re: What the hell does this mean in perl?
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
As per, Once ive posted ive figured it out and fixed it! typical.

Looks like
if($line =~ /<tr><td>(.*)<\/td><td>(.*)<\/td><\/tr>/) {

Means ( or along the lines of )

if ($line islike STRING ignoring (.*) bits inbetween.

Anywho.
This can be closed / removed.

Grrrrrr

I need a dummy forum i can post in and if i still cant figure it out after 30 mins, it will post to here lol
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 02-16-2010, 11:15 AM Re: What the hell does this mean in perl?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,371
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
just to clarify the (.*) actually means:

"match any number of any characters"

(includes spaces but excludes line breaks.)
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-16-2010, 12:08 PM Re: What the hell does this mean in perl?
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Ahh ok,

So it will match <tr><td>(.*)<\/td><td>(.*)<\/td><\/tr>

But wont care about whats inbetween the bold?

While i didnt realise that, i still manage to get some 1998 code working again. Yeahhhhhh hehe

Ty chris.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 02-16-2010, 12:26 PM Re: What the hell does this mean in perl?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,371
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You could reduce that to

<tr(.*)\/tr>

That would match everything between the first <tr and the last /tr> in the line , because your expression would match the middle bolded section anyway.

Regular expressions using (.*) are "greedy" and will match as much as possible.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-16-2010, 12:39 PM Re: What the hell does this mean in perl?
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Ah yeah true, I didnt see that.
Ill keep that in mind for when it break again ( Im sure it will )

It like being told to sit on an old rotten fence and asked not to break it.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Reply     « Reply to What the hell does this mean in perl?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.34597 seconds with 12 queries