User Profile

Collapse

Profile Sidebar

Collapse
Kelicula
Kelicula
Last Activity: Oct 26 '15, 12:59 PM
Joined: Jul 1 '07
Location: Wilmington, NC
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Kelicula
    replied to Regex challange...kinda :-)
    in Perl
    OK, no replies, well just for the record I found out what it was I was choosing the same delimiter for my regular expression as is used in the repetitive quantifier therefore on the closing bracket of the 1 repetitive qualifier it was closing the regular expression I changed my delimiter to a single quote and it worked perfectly.
    See more | Go to post

    Leave a comment:


  • Kelicula
    started a topic Regex challange...kinda :-)
    in Perl

    Regex challange...kinda :-)

    I have a strange case, that has just stumped me.
    I am trying to make sure that if someone's name starts with just one character (between "space" and "tilde") OR it starts with one letter followed by a "dot" it's no good BUT if it is one letter followed by a dot and another character it's OK.

    Meaning these names are ok, J.D. or TJ.

    But these are BAD J or T.

    Here's what I have:...
    See more | Go to post

  • Kelicula
    replied to Does Perl Always Pass Argument By Reference?
    in Perl
    When passing to subroutines, the convention is; if there are more than 3-4 things you are passing you should probably be using an anonymous hash, otherwise you can just pass the value directly.
    eg:
    Code:
    sub passing_things {
        my $thing = shift;
        do stuff with thing passed...
    }
    # Then later...
    passing_things($variable);
    The value in $variable will be passed to the subroutine....
    See more | Go to post

    Leave a comment:


  • Kelicula
    replied to Hash of Arrays
    in Perl
    No problem Akino877!
    The way perl overcomes this is through "references ", you can use a reference to an array or hash, or even an array of hashes or hash of arrays as a value for a hash, here's an example:
    To make a reference you simply use the slash like so:
    my @array = ('Jon', 'James', "jimmy', 'Julie');
    my $array_ref = \@array;

    Now $array_ref is a scalar value that points to the memory allocation...
    See more | Go to post
    Last edited by Kelicula; Jan 26 '15, 06:41 PM. Reason: Adding URL to perlref

    Leave a comment:


  • Kelicula
    replied to Hash of Arrays
    in Perl
    What is the benefit? Why are you trying to make each key be associated with an array as opposed to a reference to an anonymous array?
    See more | Go to post

    Leave a comment:


  • Kelicula
    replied to Does Perl Always Pass Argument By Reference?
    in Perl
    If you pass an anonymous hash it will be treated as a reference.
    eg:
    $hash = { name => 'Jim', age => '29'};
    See more | Go to post

    Leave a comment:


  • Kelicula
    replied to Does Perl Always Pass Argument By Reference?
    in Perl
    You need to be clearer as to where you are talking about perl passing things to. Do you mean mean passing arguments to a subroutine? A hash in perl is really an array, (not really but when it comes to passing things) if you pass a named hash to a subroutine (in certain context) it will be "flattened" into an array where the first element is the "key" and the second is the "value" and so on... as in:
    %hash = ( name...
    See more | Go to post

    Leave a comment:


  • Kelicula
    replied to Binary Search Algorithm
    Nice, I had never heard of the Fibonacci search myself.

    Very interesting...
    See more | Go to post

    Leave a comment:


  • Hummm....
    How are you calling on genreport?
    What exactly do you pass to it?
    Is it in the current package, or a separate file?

    Very strange.

    Have you tried KevinADC's code?
    It looks like it works too. (using too objectively..:)

    I swear my code worked in Komodo with Perl 5.10 on Windows.

    Of course I didn't have the exact same logfile to scan.
    See more | Go to post

    Leave a comment:


  • That didn't work. :(

    But this did.

    [code=perl]
    while($file =~ /^(\[ERROR\](?-s:.*)infrastruc ture:ID_UNHANDL ED.*?infrastruc ture:RUN_ID_RUN TIME.*?)\n\n/mgs) {
    push(@message, $1);
    }
    [/code]

    Assuming you want only lines that start with [ERROR] followed by any character EXCEPT a newline, followed by "infrastructure :ID_UNHANDLED", followed by any character INCLUDING a newline,...
    See more | Go to post

    Leave a comment:


  • I noticed some lines say [ERROR] but you don't want them.
    Just add the "infrastructure :RUN_ID_RUNTIME " back into the regexe.

    This should do it:
    [code=perl]
    while($file =~ /^(\[ERROR\].*?infrastructu re:RUN_ID_RUNTI ME.*?)\n\n/mgs) {
    push(@message, $1);
    }
    [/code]
    See more | Go to post

    Leave a comment:


  • The main thing to notice in my suggestion was this line:
    Code:
    my $file = <LOGFILE>;
    Slurping the whole file into a single var, and then saying...

    Code:
    while(match){
    push $message, $1;
    }
    In your genreport sub you are still testing for a match "one line at a time".

    Using the s modifier allows perl's dot character to match all characters...
    See more | Go to post
    Last edited by Kelicula; Apr 14 '09, 09:31 PM. Reason: Adding File::Slurp link.

    Leave a comment:


  • Kelicula
    replied to Mod rewrite question
    Alright man, thanks!!

    I just had to remove the "R". For some reason I had the R=301 modifier.
    So it would re route you to correct script, but it would change the url in browser too. Without the R, it leaves the url entered untouched.

    Works great now!!
    See more | Go to post

    Leave a comment:


  • Kelicula
    started a topic Mod rewrite question

    Mod rewrite question

    I am trying to make the url change, and STAY that way.

    I would like to change url's of this type:

    [code]http://www.domain.com/someword/somenumber[/codel]

    into...

    Code:
    http://www.domain.com/cgi-bin/someword.cgi?id=somenumber
    I have that working, but what if I want the url in the address bar to change to:
    Code:
    http://www.domain.com/someword/somenumber
    AND STAY THAT WAY, while...
    See more | Go to post
    Last edited by Kelicula; Apr 11 '09, 01:39 PM. Reason: spelling, code tags

  • Kelicula
    replied to url rewriting
    You are searching the URI for the same match on each rewrite rule. So Apache doesn't know which one you wish to match.

    This match is true if the url matches "any" character. One or more times from beginning to end of url.
    RewriteRule ^(.*)$ index.php?do=$1 [L,QSA]

    This one also matches the same criteria.
    RewriteRule ^(.*)$ link.php?get=$1 [L,QSA]

    How are you going to specify when...
    See more | Go to post

    Leave a comment:


  • Kelicula
    replied to Populate array with split problem.
    in Perl
    Ah ha! That's it.
    That works just as I expect it to.

    In fact that is exactly what I was trying to do, I had seen it before in a book and remembered it incorrectly.

    Thanks.
    See more | Go to post

    Leave a comment:


  • Please use the code tags, so others can see it better and possibly use it to help you reach a solution. (copy&paste). Just an FYI.

    I think one problem may be that "$line" is always filtered in "one line at a time" but you are attempting to capture more than one line at a time, but using push to append an array one line at a time. In other words...

    No "single" line matches the criteria....
    See more | Go to post

    Leave a comment:


  • Kelicula
    replied to Populate array with split problem.
    in Perl
    Very interesting.
    Here is the results from your code KevinADC.
    Code:
    index 0 = <>
    index 1 = <2009>
    index 2 = <01>
    index 3 = <12>
    My only guess is the capturing vars, $1, $2, etc..were used as indices?

    Thanks!

    PS- I almost didn't notice your new avatar. Nice.
    See more | Go to post

    Leave a comment:


  • Hum....

    I think your answer lies here?
    See more | Go to post

    Leave a comment:


  • Kelicula
    started a topic Populate array with split problem.
    in Perl

    Populate array with split problem.

    Hello all. I have a problem which seems to make no sense to me.
    Therefore I must be doing something wrong.

    I am trying to populate an array using split with a regexe.
    Here is the code (snippet only).
    [code=perl]
    my $date = $q->param('date' ); # 20090112 format
    @dateArray = split(/(\d{4})(\d{2})( \d{2})/, $date);
    [/code]

    After this I loop through the array using print and all...
    See more | Go to post
No activity results to display
Show More
Working...