User Profile
Collapse
-
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. -
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:... -
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);
Leave a comment:
-
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...Leave a comment:
-
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?Leave a comment:
-
If you pass an anonymous hash it will be treated as a reference.
eg:
$hash = { name => 'Jim', age => '29'};Leave a comment:
-
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...Leave a comment:
-
Nice, I had never heard of the Fibonacci search myself.
Very interesting...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.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,...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]Leave a comment:
-
The main thing to notice in my suggestion was this line:
Code:my $file = <LOGFILE>;
Code:while(match){ push $message, $1; }
Using the s modifier allows perl's dot character to match all characters...Leave a comment:
-
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!!Leave a comment:
-
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
Code:http://www.domain.com/someword/somenumber
-
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...Leave a comment:
-
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.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....Leave a comment:
-
Very interesting.
Here is the results from your code KevinADC.
Code:index 0 = <> index 1 = <2009> index 2 = <01> index 3 = <12>
Thanks!
PS- I almost didn't notice your new avatar. Nice.Leave a comment:
-
-
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...
No activity results to display
Show More
Leave a comment: