On 2014-05-12 10:59, Satya Prasad Nemana wrote:
I have requirement to make the key of a perl hash to be read only so
that no other function can modify it.
The keys are already read-only.
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail:
On 2014-03-30 12:26, Octavian Rasnita wrote:
But I also want that module to export strict and warnings.
http://search.cpan.org/perldoc?Modern%3A%3APerl
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
On 2014-03-28 21:56, Andy Bach wrote:
On Fri, Mar 28, 2014 at 3:05 PM, Dr.Ruud rvtol+use...@isolution.nl
mailto:rvtol+use...@isolution.nl wrote:
if ($@) {
die $@;
}
Never test $@, only use the value of $@ after a failed eval.
Why not?
Because
On 2014-03-27 20:53, Natxo Asenjo wrote:
use strict;
use warnings;
use utf8;
That use utf8; is almost always wrong, see 'perldoc utf8', only use it
if your source code is utf8 encoded.
if ($@) {
die $@;
}
Never test $@, only use the value of $@ after a failed eval.
--
Ruud
--
On 2014-03-26 12:36, shawn wilson wrote:
return
sort {
return $pre-{$a} = $pre-{$b}
if $pre-{$a} $pre-{$b};
return -1 if $pre-{$a};
return +1 if $pre-{$b};
return $a cmp $b;
} @$data;
}
Benchmark-alternative:
sort {
$pre-{$a}
?
On 2014-03-04 00:35, shawn wilson wrote:
So, when I do this:
my $src = (grep {/.*(ARIN|APNIC).*(\n)?/; $1} @ret)[0];
I get a full line and not just the capture:
# ARIN WHOIS data and services are subject to the Terms of Use
First understand what you coded:
grep() is a filter: it only
On 2014-03-01 06:13, Bill McCormick wrote:
$found = $$_ =~ m|$project|;
Alternative:
$found = ( index( $project, $$_ ) = 0 );
or rather use:
$found = $project =~ /\b\Q$$_\E\b/;
Always add escaping and anchors, or you will match the unmatchable.
--
Ruud
--
To unsubscribe, e-mail:
On 2014-02-18 02:27, SSC_perl wrote:
I'm helping someone retrieve some info from a MySQL db and I'm having
trouble sending multiple select statements with Perl. Here's a portion of the
code:
use SQL::SplitStatement;
my $query_4 = CREATE TEMPORARY TABLE `temp_ip` AS
(SELECT `ip`
On 2014-02-09 17:48, Bill McCormick wrote:
Trying to map the array list into a hash, but loose the double quotes
surrounding the key's value.
Or do str-to-hash:
perl -Mstrict -MData::Dumper -wE'
my $str = q(foo1=bar1 foo2=bar2);
my $re_kv = qr/\s*(\S+)\s*=\s*([^]*)/;
my %hash = $str
On 2014-02-03 21:30, Paul Fontenot wrote:
Hi, I am attempting to write a regex but it is giving me a headache.
I have two log entries
1. Feb 3 12:54:28 cdrtva01a1005 [12: 54:27,532] ERROR
[org.apache.commons.logging.impl.Log4JLogger]
2. Feb 3 12:54:28 cdrtva01a1005 [12: 54:27,532] ERROR
On 2014-01-28 08:32, Luca Ferrari wrote:
often I find myself writing something like the following to get the
human date:
my ($day, $month, $year) = (localtime())[3..5];
$month++, $year += 1900;
print \nToday is $month / $day / $year \n;
I was wondering if there's a smarter pattern to get the
On 2014-01-07 20:28, Rajeev Prasad wrote:
so i have this series of numbers:
On 2013-11-17 10:06, loody wrote:
I try to eliminate below special character ^@ by perl in the attachment.
That is probably a representation of a zero-byte, just like ^A is a
one-byte, etc.
I have tried $.*^' regular expression for elimination in perl but fail
What do you expect $.*^'
On 2013-10-27 04:00, Mayuresh Kathe wrote:
#!/usr/bin/perl -w
use strict;
use warnings;
my $exponent = $ARGV[0];
my $number = 2;
my $result = $number;
if ( not defined $exponent ) {
die Usage: $0 exponent\n;
}
You have a die() there, so no indent needed. Alternative:
#
On 2013-10-24 01:12, Ronald F. Guilmette wrote:
In message 52684f18.2000...@stemsystems.com, you wrote:
On 10/23/2013 06:18 PM, Ronald F. Guilmette wrote:
...
print SM EOF;
To: Tristatelogic.Com Administrator admin\@tristatelogic.com
From: $sender_name $sender_addr
Subject: Your message to
On 2013-10-13 13:51, Manuel Reimer wrote:
I would like to use Perl on an embedded device, which only has 64MB of RAM.
Are there any tricks to reduce the memory usage of the perl interpreter?
That 64 MB looks like room enough. Compile a perl without threads, debug.
There is also a miniperl,
On 24/09/2013 00:17, David Christensen wrote:
I'm looking for a hash function and a related function or operator such
that:
H(string1 . string2) = f(H(string1), H(string2))
H(string1 . string2) = H(string1) op H(string2)
where:
H() is the hash function
string1
On 19/09/2013 20:09, rajesh kumar wrote:
Hi,
I am reading a set of regex, separated by comma, from database, which is
in string format and using eval to convert them in the array.
For e.g.,
String from database is'qr/^abc .* $/,qr/xxx/'
$string = 'qr/^abc .*$/,qr/xxx/'; # this $string comes
On 09/09/2013 11:00, Hans Ginzel wrote:
Is there a shorter way to write $a = ! $a, please?
perl -le '
my @a = (undef, @ARGV);
for $a (@a) {
my @r; push @r, $a:;
for (1..3) {
push @r, $a^=1; # --
}
print @r;
}
' 0 1 2 3 -1
: 1 0 1
0: 1 0 1
1: 0 1 0
2: 3 2 3
3: 2 3
On 07/09/2013 13:43, Karol Bujaček wrote:
print Dumper(@_);# just look how the @_ looks like
Consider: print Dumper( \@_ );
my($animals, $digits) = @_;
my @animals = @$animals; # dereference
my @digits = @$digits; # dereference
The comment is inaccurate.
Why would
On 05/09/2013 02:28, J M wrote:
However, I'm running into a problem: the FIRST instance of
DateTime::Format::MySQL works perfectly... but when I get to the second
one, it throws me this error:
Use of uninitialized value $input in concatenation (.) or string at
/usr/local/share/perl/5.14.2/
On 14/07/2013 22:06, Kolya Gromivchuk wrote:
I need some advice which library or module to use for multiple
connection to network devices. For example change status of ports on the
hundred switches.
Also check out 'ansible'.
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
On 12/07/2013 13:44, Agnello George wrote:
hi
i have raw data that is like this in a flat file .
start
name:agnello
dob:2 april
address:123 street
end
start
name:babit
dob:13 april
address:3 street
end
start
name:ganesh
dob:1 april
address:23 street
end
i need to get the data in the
On 12/07/2013 20:19, Nathan Hilterbrand wrote:
On 12/07/2013 13:44, Agnello George wrote:
i have raw data that is like this in a flat file .
start
name:agnello
dob:2 april
address:123 street
end
start
name:babit
dob:13 april
address:3 street
end
start
name:ganesh
dob:1 april
address:23
On 28/06/2013 09:08, Charles DeRykus wrote:
[...] I was making a case that do in limited cases could be a
shorter and/or slightly clearer idiom.
I think the context was if you would ever go as far as using double
braces to make a loop-construct out of 'do'. But even more how combining
a
On 27/06/2013 12:58, lee wrote:
Ok, so perl has a totally broken design with variables :(
No, your understanding is broken. Can you come back after you fixed it?
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
On 27/06/2013 15:44, Shawn H Corey wrote:
On Thu, 27 Jun 2013 15:07:58 +0200
Dr.Ruud rvtol+use...@isolution.nl wrote:
On 27/06/2013 12:58, lee wrote:
Ok, so perl has a totally broken design with variables :(
No, your understanding is broken. Can you come back after you fixed
On 27/06/2013 17:03, Shawn H Corey wrote:
On Thu, 27 Jun 2013 07:45:17 -0700
Jim Gibson jimsgib...@gmail.com wrote:
Note that the statement modifier syntax allows you to write a
do-while or do-until loop, where at least one pass is made through
the loop before the loop termination test is
On 27/06/2013 22:01, Shawn H Corey wrote:
On Thu, 27 Jun 2013 21:53:46 +0200
Dr.Ruud rvtol+use...@isolution.nl wrote:
See also 'Statement Modifiers' in perlsyn.
There it is shown how to make next and last work with do{}. I read
that as a rather funny way to discourage people from do-ing
On 24/06/2013 07:36, lee wrote:
It would be like:
if ( $color eq blue ) {
print test\n;
last;
}
Alternative:
print( test\n ), last
if $color eq blue;
I also see:
print( test\n ) and last
if $color eq blue;
but always question that, because: what if print() fails?
(even
On 14/06/2013 08:02, Shlomi Fish wrote:
On Thu, 13 Jun 2013 22:51:24 +0200
lee l...@yun.yagibdah.de wrote:
How likely is it that the hash is the same though the file did change?
Well, if you take SHA-256 for example, then its hash has 256 bits so you have a
chance of 1 / (2**256) that two
On 12/06/2013 11:33, lee wrote:
Jim Gibson jimsgib...@gmail.com writes:
On Jun 11, 2013, at 9:44 PM, lee wrote:
I've been googling for examples of how to create a sha-2 sum of a
file in perl without success. What I'm looking for is something
like:
$hash = create_sha2_sum( $filename);
On 12/06/2013 10:27, lee wrote:
File sizes do not reliably indicate whether a file has been modified or
not.
If the file size has changed, then your file has changed. That is 100%
reliable, and is a quick and cheap check.
But if the size hasn't changed, then you still need to check
On 26/05/2013 14:40, shawn wilson wrote:
Thank y'all, I got to where I want to be:
https://github.com/ag4ve/geocidr
...
or grep { ! m%[0-9\.\/]+% } @{$opts-{ip}}
or scalar(@{$opts-{ip}}) 1
The '+' in the regexp is superfluous as-is.
(your regexp isn't anchored)
You probably meant it
On 27/05/2013 23:55, shawn wilson wrote:
On May 27, 2013 1:02 PM, Dr.Ruud rvtol+use...@isolution.nl
mailto:rvtol%2buse...@isolution.nl wrote:
On 26/05/2013 14:40, shawn wilson wrote:
Thank y'all, I got to where I want to be:
https://github.com/ag4ve/geocidr
...
or grep { ! m%[0
On 24/05/2013 21:18, shawn wilson wrote:
How do I find the next subnet? This should print 192.168.1.0 the
second time - it errors:
#!/usr/bin/env perl
use strict;
use warnings;
use Net::IP;
my $ip = Net::IP-new('192.168.0.0/24');
print Start ip [ . $ip-ip . ]\n;
print start mask [ .
On 24/05/2013 22:25, Michael Goldsbie wrote:
[...] I installed DWIM Perl [...]
So after downloading and installing it, what's the next step?
On http://dwimperl.com/ there is a link to 'Perl Tutorial',
which has a link to 'Introduction 1. Install'.
It mentions:
Go ahead, download the exe
On 17/05/2013 14:39, *Shaji Kalidasan* wrote:
[CODE1]
keys %{$$disk_type_ref{$pool}};
[/CODE1]
Moreover, what does $$ mean here
%{$$disk_type_ref{$pool}};
can also be written as
%{ $disk_type_ref-{ $pool } };
See further perldsc.
On 15/05/2013 21:35, David Precious wrote:
On Wed, 15 May 2013 10:34:02 +0100
Gary Stainburn gary.stainb...@ringways.co.uk wrote:
Is it possible to write text cells where part of the string is
highlighted in red? If so, how can I do it?
I'm fairly sure the format of a cell applies to the
On 13/05/2013 18:08, David Precious wrote:
The usual way to catch exceptions is with an eval block or Try::Tiny
etc.
Basic example:
my $source_address = eval { $res-query(); };
if ($@) {
# an error occurred - $@ will contain the message
# do something appropriate here
}
On 07/05/2013 20:00, Sherman Willden wrote:
foreach my $file ( @docfiles ) {
my ( $write, $read );
What were they meant for?
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On 23/04/2013 13:26, kavita kulkarni wrote:
Can you help me in finding the most time effective way to retrieve the
key-values from hash in the same sequence in which data is inserted into
the hash.
But why would you want that?
You can push the keys in an array as well.
But you will often
On 2013-04-18 18:48, Uri Guttman wrote:
On 04/18/2013 03:13 AM, Dr.Ruud wrote:
If your box already is in that timezone, you can use localtime().
perl -Mstrict -we'
my @dt = reverse +(localtime)[0..5];
$dt[0] += 1900; # year
$dt[1] += 1; # month
printf qq{%s-%02d-%02d %02d:%02d
On 2013-04-18 02:00, Ricardo Pais Oliveira wrote:
I'm using DateTime::TimeZone to get my current time. Shouldn't daylight
saving time be handled by the DateTime module?
In $date I'm obtaining the time with less an hour than it should so I
believe DST is not being considered. How can I obtain
On 2013-03-07 10:21, WFB wrote:
waitpid($pid, 0);
close($trexe);
my $tr_ret = ($?8);
Never postpone the reading of a global variable,
just snapshot it as early as possible.
my $child = waitpid $pid, 0;
my $child_error = $?; # snapshot a global
$child == -1 and die No child with pid
On 2013-03-05 21:41, Chris Stinemetz wrote:
I am working on a script to parse large files, by large I mean 4 million
line+ in length and when splitting on the delimiter ( ; ) there are close
to 300 fields per record, but I am only interested in the first 44.
Try Text::CSV_XS.
--
Ruud
--
To
On 2013-03-04 17:22, Chris Stinemetz wrote:
I would like to pass a list of variables to printf.
Is there a way to multiply a set printf length instead of
righting typing printf for each variable?
what I am trying to do is below:
printf %-${longest}s x 27\n,
On 2013-03-04 20:27, Dr.Ruud wrote:
print sprintf +(| %-${wid}s x @data). |\n, @data;
Rather:
print sprintf +(| %-${wid}s x @data) . |\n, @data;
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http
On 2013-02-26 08:48, yunbin wang wrote:
Now , I want run perl script in java, but I can't install perl on the
machine, only I can copy the perl files(those installed on other
machine) to that machine.
so how can I initial perl INC in java that I can run perl in my java program?
Can you run
On 2013-02-23 00:50, Jim Gibson wrote:
my $content = do { local $/; $fh };
Leaner written as:
my $content; { local $/; $content= $fh }
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On 2013-02-23 01:51, *Shaji Kalidasan* wrote:
my $cr = $content =~ tr/\r/\r/;
my $lf = $content =~ tr/\n/\n/;
my $crlf = $content =~ s/\r\n/\r\n/g;
See also 'perldoc -q count'.
Alternatives:
my $cr = $content =~ tr/\r//;
my $lf = $content =~ tr/\n//;
my $crlf =()= $content =~ /\r\n/g;
On 2013-02-18 08:13, chenlin rao wrote:
Or how can I know whether one module like YAML is such a core module?
I need to write some perl scripts used for hadoop map/reduce streaming, so
I donot want to use extra modules exists in my own computer.
Nothing ever stops me from adding code to a
On 2013-01-26 04:52, Rajeev Prasad wrote:
i have a lot of data coming/pouring in [...]
I want to stop writing after certain size is written (say 1gb).
[...] I am worried I am doing too many stat [...]
For a close approximation, you can just sum the length of the input data.
$written +=
On 2013-01-20 04:43, Jim Gibson wrote:
On Jan 19, 2013, at 7:09 PM, Jun Meng mengju...@gmail.com wrote:
I need to extract items that happened once from an array. Here is an example
@my_array=qw (one, one, two, three, three, four);
The expected result: @new_array=(two, four).
Could you give
On 2013-01-08 13:28, punit jain wrote:
{
test = (test123);
test = (test123,abc);
test = (test123,abc,xyz);
}
{
test1 = (passfile);
test1 = (passfile,pasfile1);
test1 = (passfile,pasfile1,user);
}
and so on
The requirement is to have the file parsing so that final output is :-
test =
On 2013-01-02 15:34, Hamann, T.D. wrote:
[...] given a string:
i99o
where I want to replace the 'i' by a '1' and the 'o' by a '0' (zero), the
following regex fails:
s/(i)(\d\d)(o)/1$20/;
Since you are capturing 3 groups:
s/(i)([0-9]{2})(o)/$1$2$3/;
for the obvious reason that perl
On 2013-01-03 17:42, Andy Bach wrote:
s/(i)([0-9]{2})(o)/1${2}0/;
But why capture and don't use?
s/i([0-9]{2})o/1${1}0/;
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On 2012-12-28 21:32, twle...@reagan.com wrote:
I hope this is a simple fix. I want to check the beginning characters of items in a
hash, and compare that to a scalar variable. I do not need for the entire value to
match; just the first couple of characters. Here is a simple example of what
On 2012-12-22 10:46, Feng He wrote:
You probably had $string double quoted instead of
single quoted which later results in the \ being eaten.
Thank you. The people who said the problem of double quoted string are correct,
I didn't know this item before.
This is what I really want:
use
On 2012-12-15 06:13, timothy adigun wrote:
Using Dr., Ruud's data. This is another way of doing it:
[solution using a hash]
Realize that with keys(), the input order is not preserved.
Another difference is that when a key comes back later,
the hash solution will collide those, which is
On 2012-12-14 14:54, samuel desseaux wrote:
=995 \\$xPR$wLivre
=995 \\$bECAM$cECAM
=995 \\$n
=995 \\$oDisponible
=995 \\$kG1 42171
and i want in one line
=995 \\$bECAM$cECAM$kG1 42171$n$oDisponible$xPR$wLivre
echo -n '1 a
1 b
1 c
2 x
=995 \\$xPR$wLivre
=995 \\$bECAM$cECAM
=995
On 2012-11-15 03:07, Uri Guttman wrote:
my %hash = read_file( 'file.txt' ) =~ /^(.+)\s*=\s*(.+)$/mg ;
Trailing whitespace in the keys? Skipping empty values?
my %kv= read_file( 'file.txt' ) =~ /^(.+?)\s*=\s*(.*)/mg;
and without File::Slurp:
my %kv= map m/(.+?)\s*=\s*(.*)/, $fh;
On 2012-11-15 11:46, jet speed wrote:
22:5a = 10.00.00.00.aa.56.9b.7a
22:5a = 10.00.00.00.aa.57.99.8a
32:9c = 10.00.00.00.aa.46.9b.33
a2:cc = 10.00.00.00.aa.5a.9b.63
a5:cc = 10.00.00.00.aa.5a.9b.63
b2:cc = 10.00.00.00.aa.5a.9b.63
How do i build all the entries into hash
On 2012-11-13 13:12, Shlomi Fish wrote:
while (my $line = )
{
chomp($line);
if (my ($dev_num) = $line =~ /\AdisplayDevNum=(.*)\z/)
In Perl5, '\z' is not needed here, because '.' matches non-newlines.
(also the chomp is not needed here, looks like cargo cult to me)
--
Ruud
--
To
On 2012-09-27 17:16, Chris Stinemetz wrote:
I have the following millisecond value: 54599684
This represents a timestamp reported as milliseconds past midnight local time.
Is there a module to convert this into a hh::mm format? Or a Perlish
example to handle this?
Variants:
perl -we '
my
On 2012-09-20 09:08, Octavian Rasnita wrote:
my ( $file_name ) = $data =~ /([^\\]+)$/g;
No need for that g-modifier.
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On 2012-09-05 12:47, jet speed wrote:
output
---
abc-12 20/1
def-22 30/22
ghi-33 40/3
def-22 20/1
@array1 =abc-12, def-22, ghi-33,abc-12,def-22;
@array2 =20/1, 30/22, 40/3, 20/1;
i did try to map array1 to array2 elements, did'nt work.
%hash = map {$array1[$_] = $array2[$_] }
On 2012-08-31 15:17, Torsten wrote:
I found a strange behaviour for printf: If you do for example
printf %d,29/100*100
you get 28. But with
printf %d,29*100/100
it's 29. Seems to be related to rounding.
The perl version is 5.10.1 on debian.
There is nothing strange about it.
I think you
On 2012-08-20 22:39, Rajeev Prasad wrote:
just want to find out in how many records string was found:
my $count=0;
seek $tmp_FH,0,0;
while ($tmp_FH)
{
my $line=$_;chomp($line);
if ($line=~m/\$str\/)
On 2012-08-08 12:17, Sandip Karale wrote:
use File::Spec::Functions;
my $f=foo.txt;
my $d=machdir;
Try:
my $d = '//mach/dir';
print $f \n;
print $d \n;
print catfile($d,$f);
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands,
On 2012-08-24 13:28, Sasikanth Eda wrote:
1. Script has to run on client machine.
2. Using the Perl script on client machine, we need to login to remote
machine-1 using ssh protocol.
3. From remote machine-1, the script should login to other remote machine-2
using ssh protocol.
4. From
On 2012-08-20 00:18, John W. Krahn wrote:
print map exists $stud{ $_ } ? $_ = $stud{ $_ }\n : (), @names;
A map using a ternary with (), is like a grep:
print $_ = $stud{ $_ }\n for grep exists $stud{ $_ }, @names;
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For
On 2012-08-29 18:46, Ashwin Rao T wrote:
3)Check if email address is valid using only return functions and regular
expressions in Perl.
It has been tried:
http://www.regular-expressions.info/email.html
http://ex-parrot.com/~pdw/Mail-RFC822-Address.html
On 2012-07-30 15:47, punit jain wrote:
my $pm = new Parallel::ForkManager(10);
my $count=0;
foreach my $user (@users) {
$pm-start($user) and next;
my $result;
--- do some processing ---
$pm-finish(0, \$result);
}
On 2012-07-27 17:43, Andy Bach wrote:
On Fri, Jul 27, 2012 at 10:22 AM, Dr.Ruud rvtol+use...@isolution.nl wrote:
On 2012-07-27 16:58, Andy Bach wrote:
if ($model=~/(\S+)\s+(.*)\s*$/) {
The \s* in the end does nothing.
Well, I was thinking if it's a multi-word second match:
v6 Austin
On 2012-07-27 16:58, Andy Bach wrote:
if ($model=~/(\S+)\s+(.*)\s*$/) {
The \s* in the end does nothing.
Closer:
/(\S+)\s+(.*\S)/
Then play with this:
perl -Mstrict -we'
my $data= $ARGV[0] ? q{Ford} : qq{ \t Fiat Ulysse 2.1 TD};
printf qq{%s %s\n}, split( q{ }, $data, 2 ),
On 2012-07-18 01:18, Tessio F. wrote:
Hello,
I have an database with a two column primary key:
create database contacts(
username char(20) not null,
contact char(20) not null,
primary key (username, contact)
);
I'm trying to delete a row with the command:
(connect to db..)
my $sth =
On 2012-07-19 12:37, punit jain wrote:
if( @folders ) {
map {$query .= not in:$_ and; } @folders;
print \n $query \n;
}
'if' is not a function, so put a white space after it.
But in this case you don't need the 'if' at all.
Don't use map in void context.
Alternative code:
On 2012-07-20 13:05, punit jain wrote:
I have a multiple processes which are modifying hash of hash of array. For
multiprocessing I am using Parallel::ForkManager
The requirement is I set Max processes to say 5. Each process is fired by
the script and max 5 parallel process runs and it
On 2012-07-21 14:50, punit jain wrote:
I have a requirement where I need to run my perl script for x hours
You can let the ALRM-sub simply set a global variable, like $STOP.
Your process should check this before starting a next iteration.
Beware that each child needs its own alarm. The
On 2012-07-21 14:50, punit jain wrote:
*(B) How do I stop the script graceful without killing the processes and
stop from other sunbprocesses being spanned ?*
Just let $SIG{INT} and $SIG{TRM} also set $STOP.
Per child you can update $0, to be able to watch the status of the
process in ps.
On 2012-07-21 15:30, Dr.Ruud wrote:
On 2012-07-21 14:50, punit jain wrote:
*(B) How do I stop the script graceful without killing the processes and
stop from other sunbprocesses being spanned ?*
Just let $SIG{INT} and $SIG{TRM} also set $STOP.
s/TRM/TERM/
See `kill -l` for the names
On 2012-07-21 15:41, punit jain wrote:
You can let the ALRM-sub simply set a global variable, like $STOP.
Your process should check this before starting a next iteration.
I suppose this needs to be set in parent process which means Signal needs
to be invoked in parent. Is my understanding
On 2012-07-21 16:20, Dr.Ruud wrote:
On 2012-07-21 15:41, punit jain wrote:
You can let the ALRM-sub simply set a global variable, like $STOP.
Your process should check this before starting a next iteration.
I suppose this needs to be set in parent process which means Signal needs
On 2012-07-21 19:16, punit jain wrote:
for my $step ( @steps ) {
last if $STOP;
I would think the issue here is if the list is 30K long and we are still
at 2K why would be really like to process whole list ?
We can die or handle exit of the script gracefully in my understanding.
Is my
On 2012-06-08 12:49, Dmitry Korzhevin wrote:
perl check2.pl
DBI::db=HASH(0x1e40ae0)-disconnect invalidates 1 active statement
handle (either destroy statement handles or call finish on them before
disconnecting) at check2.pl line 17.
You didn't fetch all the rows.
#!/usr/bin/perl -l
use
On 2012-05-26 14:51, pa...@fsmail.net wrote:
split is slower than the correct regex matching.
troll alert
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On 2012-05-25 22:51, Christopher Gray wrote:
I have a text file containing records. While I can extract single
sub-strings, I cannot extract multiple sub-strings.
Try split, see perldoc -f split.
while ( my $line= $fh_in ) {
my @data= split ' ', $line;
;
}
--
On 2012-04-25 21:53, Shawn H Corey wrote:
On 12-04-25 03:18 PM, Mark Haney wrote:
FWIW, I've never seen an entire website built completely in perl.
Doesn't mean there aren't any, but they must be very few and far
between. (No offense to the perl crowd, just an observation.)
Here's a few:
On 2012-04-16 07:58, Shekar wrote:
next if (/^\s$/);
You probably meant:
next if /^\s*$/; # skip blank lines
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On 2012-04-14 09:26, Somu wrote:
I was trying to strip off all html tags and the special characters from a
html file using regex.
Alternative:
lynx -stdin -dump in.html out.txt
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail:
On 2012-04-10 06:05, Rob Dixon wrote:
while (FILEHANDLE) {
:
}
is identical to
while (readline FILEHANDLE) {
:
}
which compiles as
while (defined($_ = readline FILEHANDLE)) {
:
}
Not accurate, you can check with -MO=Deparse.
--
Ruud
--
To unsubscribe, e-mail:
On 2012-04-09 03:12, Tiago Hori wrote:
Is there any way that I could parse a row at a time
while ( $fh ) {
$_ eq 'foo' and print $.:$_\n
for split /\t/;
}
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail:
On 2012-04-08 07:08, Bryan Harris wrote:
I love perl's ability to stack processing without intermediate variables,
e.g. to read in a pipe, strip off commented lines, pull out column 5, and
join, I can just do this:
$txt = join , map { (split)[4] } grep { !/^#/ };
What I haven't figured out
On 2012-04-08 17:10, Vyacheslav wrote:
using eval helped me.
You should not use exceptions for normal code flow.
Read the DBI docs (perldoc DBI).
If a failed connection must be an exception, set RaiseError to true.
But if it isn't an exception, leave it false, and test $dbh-err (or the
On 2012-04-04 16:33, lina wrote:
my ($keys, $value) = split /[ ]+/, $line;
That is better written as
split , $line;
See perldoc -f split, about this special (and default) split mode.
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail:
On 2012-04-02 16:13, Samir Arishy wrote:
eval { $sender-send($email) };
die Error sending email: $@ if $@;
Don't test $@, it is a global.
Make use of the return value of the eval:
eval {
$sender-send( $email );
1; # success
}
or do { # failure
my
On 2012-03-30 12:33, Eko Budiharto wrote:
I would like to ask about 2 dimensional array
Each element of a Perl array is a scalar.
my @colors = ( red, white, blue );
which can also be written as:
my @colors = qw( red white blue );
and can be used as:
print ok if $colors[ 2 ] eq
On 2012-03-30 11:14, punit jain wrote:
my $file = /tmp/test;
die \n Killed as filed doesnot exist \n if(-e $file);
It looks like you have to reverse your test.
-e $file
or die [$$] exit early because '$file' doesn't exist\n;
But why even start a child, if its data
On 2012-03-25 15:11, Chris Stinemetz wrote:
What is the best approach for only printing the hashes that have the
value 'ND' or hashes that have different values such as '149' does
below.
Code it, in Perl.
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional
1 - 100 of 1196 matches
Mail list logo