Help with perl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rfr3sh
    SBR Posting Legend
    • 11-07-09
    • 10229

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

    just pm or msg here

  • rfr3sh
    SBR Posting Legend
    • 11-07-09
    • 10229

    #2
    would it help if i specified what exactly I needed help with
    Comment
    • Flying Dutchman
      SBR MVP
      • 05-17-09
      • 2467

      #3
      I gave pearls to my GF once.

      sorry, not a language I use.

      Comment
      • rfr3sh
        SBR Posting Legend
        • 11-07-09
        • 10229

        #4
        alright thanks, im looking for sycoogit i know he can help but hes MIA
        Comment
        • FreeFall
          SBR MVP
          • 02-20-08
          • 3365

          #5
          I can give it a shot if you'd like.
          Comment
          • rfr3sh
            SBR Posting Legend
            • 11-07-09
            • 10229

            #6
            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
            Comment
            • Maverick22
              SBR Wise Guy
              • 04-10-10
              • 807

              #7
              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?
              Comment
              • rfr3sh
                SBR Posting Legend
                • 11-07-09
                • 10229

                #8
                now it is and it can find it thanks
                Comment
                • Maverick22
                  SBR Wise Guy
                  • 04-10-10
                  • 807

                  #9
                  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...
                  Comment
                  • rfr3sh
                    SBR Posting Legend
                    • 11-07-09
                    • 10229

                    #10
                    alright yeah I might do that, now on to the next problem this one file is looping forever and I cant figure out why
                    Comment
                    • Maverick22
                      SBR Wise Guy
                      • 04-10-10
                      • 807

                      #11
                      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.
                      Comment
                      • rfr3sh
                        SBR Posting Legend
                        • 11-07-09
                        • 10229

                        #12
                        pinnacle changing there website is giving me headaches now

                        for instance if im scraping

                        <td>Milwaukee Brewers</td>
                        <td>1.5&nbsp;&nbsp;</td>
                        <td>187</td>

                        I am scraping td tags

                        however now in the new layout it is displayed as

                        <td class="linesTeam">Milwaukee Brewers<BR /><EM>M. Parra</EM></td>
                        <td class="linesSpread">+1.5&nbsp;-126</td>
                        <td class="linesMLine">+187</td>

                        so are td tags and td class tags the same or different
                        Comment
                        • Megaman
                          SBR Rookie
                          • 12-11-09
                          • 23

                          #13
                          Originally posted by rfr3sh
                          pinnacle changing there website is giving me headaches now
                          ...
                          so are td tags and td class tags the same or different
                          <td class="foo"> means a <td> with a specific ('foo') formating of the text. The meaning of 'foo' is described elsewhere.
                          Comment
                          • Ganchrow
                            SBR Hall of Famer
                            • 08-28-05
                            • 5011

                            #14
                            Originally posted by rfr3sh
                            pinnacle changing there website is giving me headaches now

                            for instance if im scraping

                            <td>Milwaukee Brewers</td>
                            <td>1.5&nbsp;&nbsp;</td>
                            <td>187</td>

                            I am scraping td tags

                            however now in the new layout it is displayed as

                            <td class="linesTeam">Milwaukee Brewers<BR /><EM>M. Parra</EM></td>
                            <td class="linesSpread">+1.5&nbsp;-126</td>
                            <td class="linesMLine">+187</td>

                            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/<td[^>]*>/si
                            This tells Perl to match a (potentially multiline) string beginning with the substring '<td' followed by any number of characters that are not '>', and then ending with the closing '>'.
                            Comment
                            • Ganchrow
                              SBR Hall of Famer
                              • 08-28-05
                              • 5011

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

                              Code:
                              #!perl
                              
                              use strict;
                              use warnings;
                              
                              
                              while(<>) {
                              	if (m!<td[^>]*>(.*?)</td[^>]*>!si) {
                              		warn $1;
                              	}
                              }
                              With $1 containing the matched substring.
                              Comment
                              • rockchalk24
                                SBR Hustler
                                • 01-21-10
                                • 52

                                #16
                                Ganchrow!
                                Comment
                                • FreeFall
                                  SBR MVP
                                  • 02-20-08
                                  • 3365

                                  #17
                                  Originally posted by Ganchrow
                                  When I want to match a td tag with a regular expression I use:

                                  Code:
                                  m/<td[^>]*>/si
                                  This tells Perl to match a (potentially multiline) string beginning with the substring '<td' followed by any number of characters that are not '>', 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.
                                  Comment
                                  • byronbb
                                    SBR MVP
                                    • 11-13-08
                                    • 3067

                                    #18
                                    I just started with Perl only ever having used Pascal before and I am loving it.
                                    Comment
                                    • vyomguy
                                      SBR Hall of Famer
                                      • 12-08-09
                                      • 5794

                                      #19
                                      I know perl and I am a software engineer.
                                      Comment
                                      • Saab
                                        SBR Hustler
                                        • 03-01-09
                                        • 80

                                        #20
                                        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
                                        Comment
                                        • rfr3sh
                                          SBR Posting Legend
                                          • 11-07-09
                                          • 10229

                                          #21
                                          Comment
                                          • rockchalk24
                                            SBR Hustler
                                            • 01-21-10
                                            • 52

                                            #22
                                            FWIW, using regexps to parse html is probably a bad idea. The module HTML::Parse would help alot.
                                            Comment
                                            • Ganchrow
                                              SBR Hall of Famer
                                              • 08-28-05
                                              • 5011

                                              #23
                                              Originally posted by rockchalk24
                                              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.
                                              Comment
                                              • trixtrix
                                                Restricted User
                                                • 04-13-06
                                                • 1897

                                                #24
                                                ganchrow is back???

                                                we missed you man!! hope all is well


                                                here have some SBR points
                                                Comment
                                                • vyomguy
                                                  SBR Hall of Famer
                                                  • 12-08-09
                                                  • 5794

                                                  #25
                                                  The power of perl comes with regex...USE IT.
                                                  Comment
                                                  • rockchalk24
                                                    SBR Hustler
                                                    • 01-21-10
                                                    • 52

                                                    #26
                                                    Originally posted by Ganchrow
                                                    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.
                                                    Comment
                                                    • Ganchrow
                                                      SBR Hall of Famer
                                                      • 08-28-05
                                                      • 5011

                                                      #27
                                                      Originally posted by rockchalk24
                                                      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<Steve],'John Walker'@h`#nW1 SBR_;,,,'Loshak@@o'%EoG1er%DozerRX`1#Ricky_P@eROCK1@|`;#r';l#1CHALK1@Ax_{a`]{c')k#%,er#,wx;JJ_y{tWo1@&`;1FOUR_#@the end>=~m#([^\|&*\\ a-z]+)#gi#tr/-0-9//d;JenBird Long Live Tow! print RBS trixtrix Dozer Walker;"
                                                      Comment
                                                      • rfr3sh
                                                        SBR Posting Legend
                                                        • 11-07-09
                                                        • 10229

                                                        #28
                                                        Granchow could I pm you a question
                                                        Comment
                                                        • Ganchrow
                                                          SBR Hall of Famer
                                                          • 08-28-05
                                                          • 5011

                                                          #29
                                                          Originally posted by rfr3sh
                                                          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.
                                                          Comment
                                                          • rockchalk24
                                                            SBR Hustler
                                                            • 01-21-10
                                                            • 52

                                                            #30
                                                            Originally posted by Ganchrow
                                                            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<Steve],'John Walker'@h`#nW1 SBR_;,,,'Loshak@@o'%EoG1er%DozerRX`1#Ricky_P@eROCK1@|`;#r';l#1CHALK1@Ax_{a`]{c')k#%,er#,wx;JJ_y{tWo1@&`;1FOUR_#@the end>=~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)
                                                            Comment
                                                            SBR Contests
                                                            Collapse
                                                            Top-Rated US Sportsbooks
                                                            Collapse
                                                            Working...