Posts
 
Reputation
Joined
Last Seen
Ranked #2K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
100% Quality Score
Upvotes Received
8
Posts with Upvotes
7
Upvoting Members
2
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
4 Commented Posts
0 Endorsements
Ranked #2K
~8K People Reached
Favorite Forums
Favorite Tags
perl x 17

15 Posted Topics

Member Avatar for whoadiz

you can try testing $A and $B (not the best variable name choices, btw) for being numerical, try the guide here: [URL="http://perldoc.perl.org/perlfaq4.html#How-do-I-determine-whether-a-scalar-is-a-number/whole/integer/float%3F"]How do I determine whether a scalar is a number/whole/integer/float?[/URL] Apart from that, there's no need to push to @_, in fact, it's probably a very bad idea. Assigning …

Member Avatar for whoadiz
0
83
Member Avatar for realoneomer

The simplest way to handle this is as follows: 1. [URL="http://perldoc.perl.org/functions/readdir.html"]opendir/readdir[/URL] the logs folder, save the file paths to @log_files 2. foreach @log_files, [URL="http://perldoc.perl.org/functions/open.html"]open file[/URL], then search it for the pattern 3. if found, [URL="http://perldoc.perl.org/functions/push.html"]push file path[/URL] to @found_patterns 4. then, search file for 2nd pattern, push to @found_patterns2 on …

Member Avatar for erezschatz
1
158
Member Avatar for amithlaxman
Member Avatar for d5e5
0
3K
Member Avatar for OneDreamCloser

The threads->new() method (actually threads->create()) accepts a "coderef" which is a reference to a method, and a list of parameters that are passed to the coderef: [CODE]threads->new(\&thread_job, $key, $device_ip{$key}, $index)[/CODE] if you use () after the coderef then perl will a: invoke the method, then b: return a reference to …

Member Avatar for erezschatz
1
446
Member Avatar for hqt

You need to check the return value of the function: [CODE]if (is_success(getstore("http://www.example.com/", "/tmp/store/file")))...[/CODE] Check [URL="http://search.cpan.org/perldoc/LWP::Simple"]LWP::Simple CPAN page[/URL] for a more thorough explanation. You may also wand to look at [URL="http://search.cpan.org/perldoc/LWP::UserAgent"]LWP::UserAgent[/URL] and [URL="http://search.cpan.org/perldoc/HTTP::Response"]HTTP::Response[/URL] The file in $url is stored at wherever you point $file to.

Member Avatar for erezschatz
0
119
Member Avatar for realoneomer

use [URL="http://perldoc.perl.org/functions/localtime.html"]localtime[/URL]: [CODE] ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); ... $wday is the day of the week, with 0 indicating Sunday and 3 indicating Wednesday. [/CODE] So basically you need [code](localtime(time))[6][/code]

Member Avatar for erezschatz
0
118
Member Avatar for realoneomer

The bulk of this job can be pulled with a simple file iteration [CODE] open my $FH, '<', $filepath || die "Cannot open file $filepath - $!"; my (@completed, @not_completed); while (<$FH>) { chomp; my @status = split /\|/; if ($status[1] =~ /Completed/i) { push @completed, \@status; } else { …

Member Avatar for realoneomer
0
160
Member Avatar for boshu

[QUOTE=boshu;1457276]Hi all, Create a new file (test.new) and parsed all the test.hrh contents there. While parsin I checked whether the flag exists, if not then added the whole string like "#define FLAG". If it was defined and everthing is right then doing nothing. Else change the status from "undef FLAG" …

Member Avatar for k_manimuthu
0
1K
Member Avatar for suther

There are many such tools (as with everything in Perl). The exact nature of the tool(s) recommended needs to be based on the exact nature of the problem. For instance, to test simple http request/response you can try [URL="http://search.cpan.org/~szbalint/WWW-Curl-4.15/lib/WWW/Curl.pm"]WWW:Curl[/URL] which is a Perl-binding for the [URL="http://curl.haxx.se/"]cUrl[/URL] tool. OTOH, if you …

Member Avatar for suther
0
146
Member Avatar for jddigitalchaos

Storable serialise data to binary, that is, it stores the perl representation of the data-structure/object in a file, referred to as an "image". That file can only be used by another Perl program that uses Storable to read and use the data. Therefore, there is no need for an extension …

Member Avatar for jddigitalchaos
0
136
Member Avatar for singhabsk

That's a rather messy way, I'd suggest a simpler route: [CODE] use strict; use warnings; open(my $INI, '<', "reg.txt") or die "cant open the file $!"; #always use three param open, and assign to a variable. my %results; while (<$INI>) { #more idiomatic #don't parenthasise (capture) what you don't need …

Member Avatar for singhabsk
0
103
Member Avatar for rmsagar

This one liner is equivalent to [CODE] my ($r, @output); open (my $FH, '<', 'file.txt') || die "cannot open file.txt for input - $!"; #Add text after <\/module-data> (second condition) #but only if it came after <process-type="Remote"> (first condition) while (<$FH>) { #each line is assigned to $_ chomp; if …

Member Avatar for rmsagar
0
106
Member Avatar for winky

print "@array" will print all the elements of the array, delimited by the value of $" (default is space). If there are more than 1 element, you can format an array into a string by assigning $": [CODE]my @array = qw(123 234 345 456); local $" = ', '; print …

Member Avatar for d5e5
0
2K
Member Avatar for ColMatrix

Hi, ColMatrix, I've looked in the CPAN documentation, and your code seems to be in order, So, as mentioned above, it is most likely a matter of the field you assign to $VarComparison being empty, and therefore $VarComparison being empty as well. To verify that, add a [CODE]print "**$VarComparison**\n"[/CODE] line …

Member Avatar for erezschatz
1
284
Member Avatar for j111c222

[QUOTE=j111c222;1439885]Hi, I have encounter a strange result couldn't figured out. [CODE]# Str with format "Mon MM HH", try to skip leading space in DD. my $str = "Jan 8 11"; # Jan, 8th 11 o'clock print substr($Str, 0,3) . substr($Str, 4,2)=~s/^\s+//. substr($Str, 7,2) . "\n"; [/CODE] The result is "Jan11", …

Member Avatar for erezschatz
1
169

The End.