CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Syntax help

 



bigbacon
Novice

Aug 15, 2007, 6:38 AM

Post #1 of 10 (1585 views)
Syntax help Can't Post

I know nothing about Perl at all. I am attempting to take an old Perl script that someone at my company wrote and turn it into something else and I need help.

We are pulling web links from our homepage so I have a CVS file that includes /folder/file etc etc

I know the perl script is reading this file, spliting each line at a " " (space) then doing something with it. Here is the code I need some help with.

IF(/\/$\) {
$gci+=$Pages
if(/\/homepage\) {
$gci += $pages
elseif (/\/DotMass\//)

and it keeps going.

What I need help with is the elseif code
what does /\/Word\// mean?? I understand its looking for /folder/ but is it looking for any instance of that inthe string? Is that the beginning of the string? I don't understand.


(This post was edited by bigbacon on Aug 15, 2007, 6:50 AM)


KevinR
Veteran


Aug 15, 2007, 9:31 AM

Post #2 of 10 (1555 views)
Re: [bigbacon] Syntax help [In reply to] Can't Post

Is that supposed to be real working perl code? Obviously it can't be. Post the real perl code and maybe someone can help.
-------------------------------------------------


bigbacon
Novice

Aug 15, 2007, 9:49 AM

Post #3 of 10 (1554 views)
Re: [KevinR] Syntax help [In reply to] Can't Post

I dont think the rest of the code matters
I just need to know what its looking for in a string when it says /\/Something\//

Is it looking for any instance of that 'something' in a string or just the first one or what??


KevinR
Veteran


Aug 15, 2007, 10:18 AM

Post #4 of 10 (1553 views)
Re: [bigbacon] Syntax help [In reply to] Can't Post


In Reply To
I dont think the rest of the code matters
I just need to know what its looking for in a string when it says /\/Something\//

Is it looking for any instance of that 'something' in a string or just the first one or what??



That would find the first substring "/Something/" within a string.
-------------------------------------------------


bigbacon
Novice

Aug 15, 2007, 11:24 AM

Post #5 of 10 (1552 views)
Re: [KevinR] Syntax help [In reply to] Can't Post

how bout /\/$/??


KevinR
Veteran


Aug 15, 2007, 5:07 PM

Post #6 of 10 (1544 views)
Re: [bigbacon] Syntax help [In reply to] Can't Post


In Reply To
how bout /\/$/??


looks to be checking for a forward-slash at the end of the string.
-------------------------------------------------


bigbacon
Novice

Aug 15, 2007, 5:32 PM

Post #7 of 10 (1539 views)
Re: [KevinR] Syntax help [In reply to] Can't Post

Ahh, that make sense and I see now what the the script is doing there.



Thanks.


bigbacon
Novice

Aug 16, 2007, 4:25 AM

Post #8 of 10 (1536 views)
Re: [bigbacon] Syntax help [In reply to] Can't Post

Actually, that doesn't now that im looking at it again. The whole proccess starts by looking for that /\/$/ and in the data, nothing has a / at the end of the line. So this process would find nothing
the code is
if (/\/$/){
Add some data
if (/\/homepage/) {
add some data
}
elseif (/\/DOTMASS/) {
add some stuff
}
.....
else{
add some stuff
}
}


bigbacon
Novice

Aug 16, 2007, 7:20 AM

Post #9 of 10 (1532 views)
Re: [bigbacon] Syntax help [In reply to] Can't Post

I think I figured it out....
I was over looking some of the { } so the /\/$/ if was actually being closed. My bad, the next IF statement(s) after that were all indented in the code so I thought they were underneith it (like how Visual studio auto indents for you)

Thanks for help again!


KevinR
Veteran


Aug 16, 2007, 11:16 AM

Post #10 of 10 (1526 views)
Re: [bigbacon] Syntax help [In reply to] Can't Post

when posting perl code here, make sure it's valid code, like you have "elseif" in your code which is not a perl function at all. Right away I would think you had made a simple syntax error. Also, use the code formatting tags to post code here to retain the codes original formatting.
-------------------------------------------------


(This post was edited by KevinR on Aug 16, 2007, 11:16 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives