1. #1
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604

    Help with perl

    anyone good with perl scripting and is willing to help me with something easy

    just pm or msg here


  2. #2
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604

    would it help if i specified what exactly I needed help with

  3. #3
    Flying Dutchman
    Floggings continue until morale improves
    Flying Dutchman's Avatar Become A Pro!
    Join Date: 05-17-09
    Posts: 2,467
    Betpoints: 759

    I gave pearls to my GF once.

    sorry, not a language I use.

  4. #4
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604

    alright thanks, im looking for sycoogit i know he can help but hes MIA

  5. #5
    FreeFall
    FreeFall's Avatar Become A Pro!
    Join Date: 02-20-08
    Posts: 3,365
    Betpoints: 2391

    I can give it a shot if you'd like.

  6. #6
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604

    well I have figured out the original problem. now when i try to access my web server i get this message

    "
    Can't locate ../cfg.pl in @INC (@INC contains: C:/strawberry/perl/site/lib C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib .) at C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin/line_movements/index.cgi line 7.
    For help, please send mail to the webmaster (admin@phub.net.cable.rogers.com), giving this error message and the time and date of the error."


    but i placed the cfg.pl in C:/strawberry/perl/site/lib

  7. #7
    Maverick22
    Maverick22's Avatar Become A Pro!
    Join Date: 04-10-10
    Posts: 807
    Betpoints: 58

    What folder is the "executable" in? Its looking up a directory ("../cfg.pl"). Is cfg.pl in the parent folder of whatever file is looking for it?

  8. #8
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604

    now it is and it can find it thanks

  9. #9
    Maverick22
    Maverick22's Avatar Become A Pro!
    Join Date: 04-10-10
    Posts: 807
    Betpoints: 58

    You may want to edit the code to have the configuration file in the same directory as the main program. If you ever have to move code, it could get confusing...

    Not sure what the "best practice" is... But I know this is commonly done...

    Or make a sub folder called "config" and put all the configuration items there. And have the code look for this folder.

    Just thoughts though...

  10. #10
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604

    alright yeah I might do that, now on to the next problem this one file is looping forever and I cant figure out why

  11. #11
    Maverick22
    Maverick22's Avatar Become A Pro!
    Join Date: 04-10-10
    Posts: 807
    Betpoints: 58

    Programming And its headaches...

    I just had to farm out some programming work, that i simply dont want to do myself... One of my old minions from college. LOL.

    I dont know perl...but i can try to give it a shot (It cant be very worldly different from most other languages)... paste the code segment here or in the PM. I'll see if i can help any.... I'll look at anything but C++/Java... else my head will explode.

  12. #12
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604

    pinnacle changing there website is giving me headaches now

    for instance if im scraping

    Milwaukee Brewers
    1.5  
    187

    I am scraping td tags

    however now in the new layout it is displayed as

    Milwaukee Brewers
    M. Parra
    +1.5 -126
    +187

    so are td tags and td class tags the same or different

  13. #13
    Megaman
    Megaman's Avatar Become A Pro!
    Join Date: 12-11-09
    Posts: 23
    Betpoints: 384

    Quote Originally Posted by rfr3sh View Post
    pinnacle changing there website is giving me headaches now
    ...
    so are td tags and td class tags the same or different
    means a with a specific ('foo') formating of the text. The meaning of 'foo' is described elsewhere.

  14. #14
    Ganchrow
    Nolite te bastardes carborundorum.
    Ganchrow's Avatar Become A Pro!
    Join Date: 08-28-05
    Posts: 5,011
    Betpoints: 1088

    Quote Originally Posted by rfr3sh View Post
    pinnacle changing there website is giving me headaches now

    for instance if im scraping

    Milwaukee Brewers
    1.5  
    187

    I am scraping td tags

    however now in the new layout it is displayed as

    Milwaukee Brewers
    M. Parra
    +1.5 -126
    +187

    so are td tags and td class tags the same or different
    When I want to match a td tag with a regular expression I use:

    Code:
    m/]*>/si
    This tells Perl to match a (potentially multiline) string beginning with the substring '', and then ending with the closing '>'.

  15. #15
    Ganchrow
    Nolite te bastardes carborundorum.
    Ganchrow's Avatar Become A Pro!
    Join Date: 08-28-05
    Posts: 5,011
    Betpoints: 1088

    And of course if you wanted to get the contents within the tag pair then (assuming you were reading from STDIN) you could use:

    Code:
    #!perl
    
    use strict;
    use warnings;
    
    
    while(<>) {
    	if (m!]*>(.*?)]*>!si) {
    		warn $1;
    	}
    }
    With $1 containing the matched substring.

  16. #16
    rockchalk24
    rockchalk24's Avatar Become A Pro!
    Join Date: 01-21-10
    Posts: 52

    Ganchrow!

  17. #17
    FreeFall
    FreeFall's Avatar Become A Pro!
    Join Date: 02-20-08
    Posts: 3,365
    Betpoints: 2391

    Quote Originally Posted by Ganchrow View Post
    When I want to match a td tag with a regular expression I use:

    Code:
    m/]*>/si
    This tells Perl to match a (potentially multiline) string beginning with the substring '', and then ending with the closing '>'.
    Man I don't think anyone understands the power of regular expressions. I get so frustrated when I'm unable to use them. I <3 Perl.

  18. #18
    byronbb
    byronbb's Avatar Become A Pro!
    Join Date: 11-13-08
    Posts: 3,067
    Betpoints: 2284

    I just started with Perl only ever having used Pascal before and I am loving it.

  19. #19
    vyomguy
    vyomguy's Avatar Become A Pro!
    Join Date: 12-08-09
    Posts: 5,794
    Betpoints: 234

    I know perl and I am a software engineer.

  20. #20
    Saab
    Saab's Avatar Become A Pro!
    Join Date: 03-01-09
    Posts: 80
    Betpoints: 91

    for pinny's lines you might be better in the long run using an actual xml library, not simply matching regular expressions... just my 2 cents though

  21. #21
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604


  22. #22
    rockchalk24
    rockchalk24's Avatar Become A Pro!
    Join Date: 01-21-10
    Posts: 52

    FWIW, using regexps to parse html is probably a bad idea. The module HTML::Parse would help alot.

  23. #23
    Ganchrow
    Nolite te bastardes carborundorum.
    Ganchrow's Avatar Become A Pro!
    Join Date: 08-28-05
    Posts: 5,011
    Betpoints: 1088

    Quote Originally Posted by rockchalk24 View Post
    FWIW, using regexps to parse html is probably a bad idea. The module HTML::Parse would help alot.
    And what, pray tell, do you think that the now deprecated HTML::Parse module and its more robust offspring use internally?

    1. magic
    2. regular expressions

    It's not magic.
    Points Awarded:

    djiddish98 gave Ganchrow 5 SBR Point(s) for this post.

    trixtrix gave Ganchrow 465 SBR Point(s) for this post.


  24. #24
    trixtrix
    trixtrix's Avatar Become A Pro!
    Join Date: 04-13-06
    Posts: 1,897

    ganchrow is back???

    we missed you man!! hope all is well


    here have some SBR points

  25. #25
    vyomguy
    vyomguy's Avatar Become A Pro!
    Join Date: 12-08-09
    Posts: 5,794
    Betpoints: 234

    The power of perl comes with regex...USE IT.

  26. #26
    rockchalk24
    rockchalk24's Avatar Become A Pro!
    Join Date: 01-21-10
    Posts: 52

    Quote Originally Posted by Ganchrow View Post
    And what, pray tell, do you think that the now deprecated HTML::Parse module and its more robust offspring use internally?

    1. magic
    2. regular expressions

    It's not magic.
    Yeah, I know it uses regular expressions. That doesn't mean you should use them manually. Your work is a lot easier when most of it is done by a module.

  27. #27
    Ganchrow
    Nolite te bastardes carborundorum.
    Ganchrow's Avatar Become A Pro!
    Join Date: 08-28-05
    Posts: 5,011
    Betpoints: 1088

    Quote Originally Posted by rockchalk24 View Post
    Yeah, I know it uses regular expressions. That doesn't mean you should use them manually. Your work is a lot easier when most of it is done by a module.
    I'm sorry, my earlier response was overly sarcastic. That was rude of me.

    Personally, I'm more of a do-it-yourself type guy and find that packaging my own regex parsing routines works infinitely better than calling prebuilt one-size-fits-all methods. But you're right ... a neophyte Perl programmer (referring to the OP) would likely have an easier go starting off with preexisting modules.

    That said, regular expressions are certainly one of Perl's most powerful features and I think it behooves anyone seeking to learn the language to spend time honing his or her regex skillz.

    I mean how else could one endeavor creates gems like this:
    Code:
    perl -e "print grep ord $_,map{y/)!#@'%{];/0-8/;y/,0-9/--/c;s/[^0-9-]//g;$x.=qq~+$_~;chr eval $x;}q=~m#([^\|&*\\ a-z]+)#gi#tr/-0-9//d;JenBird Long Live Tow! print RBS trixtrix Dozer Walker;"

  28. #28
    rfr3sh
    Blind Knucklehead
    rfr3sh's Avatar Become A Pro!
    Join Date: 11-07-09
    Posts: 10,229
    Betpoints: 604

    Granchow could I pm you a question

  29. #29
    Ganchrow
    Nolite te bastardes carborundorum.
    Ganchrow's Avatar Become A Pro!
    Join Date: 08-28-05
    Posts: 5,011
    Betpoints: 1088

    Quote Originally Posted by rfr3sh View Post
    Granchow could I pm you a question
    You can post it here and if I have the time and find it sufficiently interesting I'll give it a shot.

  30. #30
    rockchalk24
    rockchalk24's Avatar Become A Pro!
    Join Date: 01-21-10
    Posts: 52

    Quote Originally Posted by Ganchrow View Post
    I'm sorry, my earlier response was overly sarcastic. That was rude of me.

    Personally, I'm more of a do-it-yourself type guy and find that packaging my own regex parsing routines works infinitely better than calling prebuilt one-size-fits-all methods. But you're right ... a neophyte Perl programmer (referring to the OP) would likely have an easier go starting off with preexisting modules.

    That said, regular expressions are certainly one of Perl's most powerful features and I think it behooves anyone seeking to learn the language to spend time honing his or her regex skillz.

    I mean how else could one endeavor creates gems like this:
    Code:
    perl -e "print grep ord $_,map{y/)!#@'%{];/0-8/;y/,0-9/--/c;s/[^0-9-]//g;$x.=qq~+$_~;chr eval $x;}q=~m#([^\|&*\\ a-z]+)#gi#tr/-0-9//d;JenBird Long Live Tow! print RBS trixtrix Dozer Walker;"
    That kind of complexity reminds me of my favorite use of regular expressions:

    Code:
    sub is_prime { 
        my ($number) = @_; 
        return (1 x $number) !~ m/\A (?: 1? | (11+?) (?> \1+ ) ) \Z/xms; 
    }
    (take from Perl Best Practices)

Top