Subroutine return value

2025-05-14 Thread Daryl Lee
In “Learning Perl”, Pg. 116, is found this sentence: Whatever calculation is last performed in a subroutine is automatically also the return value. I have a subroutine that (almost) ends with this loop: foreach my $line (@lines) { $sum += evaluate($line); } What I want to return i

Re: project euler #8

2017-05-26 Thread lee
Shlomi Fish writes: > Hi lee, > > I decided to try to give you another chance to be educated, despite Uri's > conclusion in the other thread. Hopefully you won't let me down. He has made a lot of conclusions and decided not to say anything further. I know it can be diffi

Re: Fwd: Re: dangerous perl (Re: is this reasonably save?)

2017-05-26 Thread lee
Kent Fredric writes: > On 26 May 2017 at 05:33, lee wrote: >> Perl doesn't have data structures, so variables in perl are not data >> structures. That is unfortunate. > > > So when I write: > > my $var = { > memory => { >

Re: project euler #8

2017-05-25 Thread lee
Shlomi Fish writes: > [...] >> >> while ( my $numbline = ) { >> >> chomp $numbline; >> >> my @numbline = split //, $numbline; >> > >> > You're processing the input number line-by-line, but it's one whole number >> > and the products may span across more than one line. You need to slurp

Re: Fwd: Re: dangerous perl (Re: is this reasonably save?)

2017-05-25 Thread lee
Uri Guttman writes: > this private IMO> > > > On 05/24/2017 08:20 PM, lee wrote: >> Uri Guttman writes: >> >> >> you can get an array of hashes, where each hash is one row. >> >> learning dereferencing will do you much more good than us

Re: project euler #8

2017-05-24 Thread lee
Ok, here's one more: [...] unless($ad) { print " * $ad = 0\n"; $start = $digit; next DIGITS; } [...] You can skip right away to behind the 0 which has already been found within the current range of adjacency. lee writes: > Sorry, I

Re: Time::HiRes output

2017-05-24 Thread lee
"Chas. Owens" writes: > You can use printf or sprintf to control the format, but what you are doing > is called profiling and it is better to use an actual profiler. Take a look > at Devel::NYTProf > > http://search.cpan.org/~timb/Devel-NYTProf-6.04/lib/Devel/NYTProf.pm > > https://www.perl.org/a

Re: project euler #8

2017-05-24 Thread lee
\n"; exit 0; What is more expensive: Using if() statements or letting it go trough on zeroes? Using an array or substr()? lee writes: > Shlomi Fish writes: > >> Hi all! >> >> Resending because the original message does not appear to have arrived

Re: project euler #8

2017-05-24 Thread lee
Shlomi Fish writes: > Hi all! > > Resending because the original message does not appear to have arrived at the > list. > > = > > Hi Derrick, > > On Tue, 16 May 2017 14:01:34 +0800 > derr...@thecopes.me wrote: > >> Hi All, >> >> I am working on problem #8 of the euler project. see below. >>

Re: is this reasonably save?

2017-05-24 Thread lee
Shawn H Corey writes: > On Sun, 14 May 2017 18:16:50 +0100 > lee wrote: > >> Ok, do you see a way to do what I'm doing here by evaluating a block? >> > > Simply remove it. > > $sth_cmds->bind_columns(@params); But then the program doesn't wo

Re: is this reasonably save?

2017-05-14 Thread lee
Shawn H Corey writes: > On Sun, 14 May 2017 02:08:11 +0100 > lee wrote: > >> I haven't used 'eval' before, and this seems inherently dangerous. > > eval EXPR; > eval; > > These are dangerous. > > eval BLOCK > > This is not

Re: is this reasonably save?

2017-05-14 Thread lee
Uri Guttman writes: > On 05/13/2017 09:08 PM, lee wrote: >> Hi, >> >> would you say this acceptable or something that should be forbidden? >> >> >> my $sth_cmds = $dbh->prepare_cached($sql); >> my @params; >> push(@params, undef)

Re: keyboard input without pressing return?

2017-05-14 Thread lee
Shlomi Fish writes: > On Sun, 14 May 2017 12:08:59 +0300 > Shlomi Fish wrote: > >> Hi lee, >> >> On Sat, 06 May 2017 02:06:19 +0100 >> lee wrote: >> >> > Hi, >> > >> > how can a sleeping program react to a key that was presse

is this reasonably save?

2017-05-13 Thread lee
Hi, would you say this acceptable or something that should be forbidden? my $sth_cmds = $dbh->prepare_cached($sql); my @params; push(@params, undef) foreach(0..12); $sth_cmds->execute(); $sth_cmds->bind_columns(eval join(', ', map('\$params[' . $_ . ']', 0..$#params))); I haven't used 'eval'

keyboard input without pressing return?

2017-05-13 Thread lee
Hi, how can a sleeping program react to a key that was pressed without return being pressed? perl -e 'use Term::ReadKey; my $ke = ReadKey(10); print "k: $ke\n";' ... shows that: + ReadKey() returns undef after the timeout + ReadKey() returns undef after the timeout even when you pressed ke

Re: are state objects ok?

2017-04-25 Thread lee
r has disconnected the program due to inactivity but not when it's disconnected due to an error in the program. And I need to figure that out for SNMP sessions, too. Can they even get disconnected? > On Mon, Apr 24, 2017, 20:02 lee wrote: > >> Hi, >> >> is it ok to

are state objects ok?

2017-04-24 Thread lee
Hi, is it ok to assign an object to a state variable? Or does doing so involve a chance of causing problems because objects are not supposed or designed to be used with the state-feature? Example: use feature qw(state); use DBI; sub foo { my ($dbh, $q, $finish) = @_; state $sth = $dbh->

Re: Net::SNMP

2017-04-23 Thread lee
Илья Рассадин writes: > Hi! > > It looks like the password issue, maybe password is incorrect or not > set properly? Why would I need a password with perl when I don't need one with snmpget? It turned out to be an acl on the switch having assumed unexpected values: , | #H3C-acl-basic-2000

Re: Perl reserved words

2017-04-23 Thread lee
Shlomi Fish writes: > Hi Frank, > > On Sun, 23 Apr 2017 10:07:56 -0700 > SSC_perl wrote: > >> Is ‘vendor’ a reserved word of some type in either Perl, MySQL, or >> DBM? > > It is not a reserved word of Perl. No idea about MySQL. , | mysql> create database vendor; | Query OK, 1 row a

Net::SNMP

2017-04-22 Thread lee
Hi, Net::SNMP only gives a useless error message "ERROR: Received usmStatsWrongDigests.0 Report-PDU with value 16 during synchronization." with the number (16) increasing by 1 every time I run the program? What is this supposed to tell me? How is it possible for the number to be increased by 1

Re: how to repeatedly execute a command on a remote machine via a shh login from within a perl program capturing the output?

2017-04-20 Thread lee
Shekar writes: > Depending upon how vendor implemented SNMP part for their device, other > than standard OID's such as sysUptime , will have custom MIB files. > You should try visiting their website for downloading required MIB file for > your switch. > Then import them with -m or put it under sn

Re: how to repeatedly execute a command on a remote machine via a shh login from within a perl program capturing the output?

2017-04-20 Thread lee
mailing lists writes: > are you sure? > > # emerge -s expect >     > [ Results for search key : expect ] > Searching... > > [...] > *  dev-perl/Expect >   Latest version available:

Re: how to repeatedly execute a command on a remote machine via a shh login from within a perl program capturing the output?

2017-04-19 Thread lee
lee writes: > Shekar writes: > >> +1 for SNMP, or if Net::SSH::Perl didn't help, can you try expect module? > > Thanks! 'Expect' isn't available as Gentoo package, so I skipped it. > > SNMP is probably better, so I need to learn about that first a

Re: how to repeatedly execute a command on a remote machine via a shh login from within a perl program capturing the output?

2017-04-19 Thread lee
e to learn about SNMP anyway :) (BTW, I seem to be subscribed again :) ) > > Cheers, > Shekar > > On Wed, Apr 19, 2017 at 1:38 PM, lee wrote: > >> Duncan Ferguson writes: >> >> > If the temperature is available on your switch, can you not enable SNMP >&

Re: how to repeatedly execute a command on a remote machine via a shh login from within a perl program capturing the output?

2017-04-19 Thread lee
Duncan Ferguson writes: > If the temperature is available on your switch, can you not enable SNMP on it > and read the specific OID to get the info? Far far easier than trying to > keep an ssh connection open, I think. > > I guess this does depend on the switch type and whether the info is ava

Re: how to repeatedly execute a command on a remote machine via a shh login from within a perl program capturing the output?

2017-04-19 Thread lee
SSC_perl writes: >> On Apr 18, 2017, at 6:19 PM, lee wrote: >> >> The purpose is to get room temperature readings > > Hey Lee, > > I don’t have a solution for you, but I have an idea that might > help. Have you tried the Misterhouse mailing list?

how to repeatedly execute a command on a remote machine via a shh login from within a perl program capturing the output?

2017-04-18 Thread lee
Hi, I'm trying to repeatedly execute a command on a remote machine and to capture the output with a perl program. I have tried Net::OpenSSH and Net::SSH::Perl. Both log in, execute the command, capture the output --- and then log out. According to the log file of the remote machine, Net::OpenS

Re: configure a switch via ssh with a perl program

2016-07-12 Thread lee
Shekar writes: > Hi Lee, > > If you can login to your switch via ssh, run required commands on the > switch and exit out, you should be able to simulate the same via > Net::OpenSSH or Net::SSH::Perl Yes, that's what I was thinking. Only it takes time to program, that&

Re: configure a switch via ssh with a perl program

2016-07-04 Thread lee
Shlomi Fish writes: > Hi lee, > > On Mon, 04 Jul 2016 04:18:22 +0200 > lee wrote: > >> Hi, >> >> would it be possible to use something like Net::SSH::Perl to >> automatically alter the configuration of a switch into which I can log >> in manuall

configure a switch via ssh with a perl program

2016-07-03 Thread lee
Hi, would it be possible to use something like Net::SSH::Perl to automatically alter the configuration of a switch into which I can log in manually via ssh? I'm looking for a way to automatically switch a network connection between two others. Since there don't seem to be any switches for this p

Re: This is one of the things ...

2016-05-14 Thread lee
Uri Guttman writes: > On 05/14/2016 07:11 PM, chace wrote: >> Can you miss something you weren't aiming at? Thanks for the fun >> fact, Uri :) > > well, he asked about other langs with map like features which was the > target you aimed at. so missing lisp is worth noting! :) Somehow I thought li

Re: This is one of the things ...

2016-05-14 Thread lee
"Walker, Michael E" writes: > Hi, > > What framework are you all using for database development? When tracking this > thread back to the original message, I thought, "Nice syntax." I am overall > new to Perl, but am learning it for ETL at work. http://dbi.perl.org/ -- To unsubscribe, e-mail:

Re: This is one of the things ...

2016-05-14 Thread lee
Uri Guttman writes: > On 05/12/2016 08:04 PM, lee wrote: >> ... I appreciate perl for: >> >> >> $dbh->do("INSERT INTO $T_ENTRIES (" . >> join(', ', map($dbh->quote_identifier($_), $cgi->param)) . ') VALUES >> (

Re: Script to fork, send data to parent via a tcp conn

2016-05-14 Thread lee
Unknown User writes: > I wrote this scrpt to fork off a few child processes, then the child > processes process some data, and send the data back to the parent > through a tcp socket. > This is not working as i expected it would. Why not? How can it be corrected? > > > #!/usr/bin/perl -w > use st

This is one of the things ...

2016-05-12 Thread lee
... I appreciate perl for: $dbh->do("INSERT INTO $T_ENTRIES (" . join(', ', map($dbh->quote_identifier($_), $cgi->param)) . ') VALUES (' . join(', ', map($dbh->quote($_), map($cgi->param($_), $cgi->param))) . ')') if(scalar($cgi->param) == 111); -- To unsubscribe, e-mail:

Re: returning arrays

2016-02-21 Thread lee
Nathan Hilterbrand writes: > On 01/25/2016 05:13 PM, lee wrote: >> Paul Johnson writes: >> >>> On Mon, Jan 25, 2016 at 12:24:04AM +0100, lee wrote: >>>> Paul Johnson writes: >>> [...] >>>> Consider with these examples that an expressi

Re: returning arrays

2016-02-21 Thread lee
Kent Fredric writes: > On 26 January 2016 at 12:02, Nathan Hilterbrand wrote: >> return wantarray() ? ($a, $b) : [$a, $b]; >> >> In a list context, you get back a list.. otherwise you get back a reference >> to a list. Might not be what you want, though. >> >> Works with arrays, too.. >> >> my

Re: carp and cgi warnings

2016-02-20 Thread lee
Uri Guttman writes: > On 02/14/2016 01:09 AM, Uri Guttman wrote: >> On 02/13/2016 02:07 PM, lee wrote: >>> Brock Wilcox writes: >>> >>>> Greetings! >>>> >>>> Could you give an example of these warnings, and even better some >

Re: Cache::*

2016-02-20 Thread lee
Chris Knipe writes: > Hi, > > Are there any Cache::* modules that are thread safe and can be used with > Threading? > > Using Cache::Memory (even specifying the same NameSpace), two or more > threads can't access the same keys in the cache, > > Using Cache::File, there are issues with the indexes

Re: display information on a web page and offer a file for download with the same page

2016-02-16 Thread lee
"Octavian Rasnita" writes: > From: "lee" > >> "Octavian Rasnita" writes: >> >>> From: "lee" >>> >>>> Hi, >>>> >>>> how can I make it so that my cgi program displays information on

Re: display information on a web page and offer a file for download with the same page

2016-02-13 Thread lee
Shlomi Fish writes: > Hi lee, > > On Sat, 13 Feb 2016 14:17:54 +0100 > lee wrote: > >> Hi, >> >> how can I make it so that my cgi program displays information on a web >> page it sends to a user's web browser /and/ then makes the browser'

Re: carp and cgi warnings

2016-02-13 Thread lee
Nathan Hilterbrand writes: > On 02/13/2016 07:33 AM, lee wrote: >> Hi, >> >> is there a way to disable the annoying warnings about carp and cgi which >> cgi programs write to the web-server's log file in a general way rather >> than per program? Same goes

Re: display information on a web page and offer a file for download with the same page

2016-02-13 Thread lee
"Octavian Rasnita" writes: > From: "lee" > >> Hi, >> >> how can I make it so that my cgi program displays information on a web >> page it sends to a user's web browser /and/ then makes the browser's >> download dialog-box come

Re: carp and cgi warnings

2016-02-13 Thread lee
Brock Wilcox writes: > Greetings! > > Could you give an example of these warnings, and even better some minimal > code that generates them? Something like this gives you warnings in apaches error.log: #!/usr/bin/perl # use strict; use warnings; use autodie; use CGI;# q

carp and cgi warnings

2016-02-13 Thread lee
Hi, is there a way to disable the annoying warnings about carp and cgi which cgi programs write to the web-server's log file in a general way rather than per program? Same goes for smartmatch warnings. The log file is overloaded with these useless messages, which makes it difficult to find actua

display information on a web page and offer a file for download with the same page

2016-02-13 Thread lee
Hi, how can I make it so that my cgi program displays information on a web page it sends to a user's web browser /and/ then makes the browser's download dialog-box come up to let the user download a file? It seems that making the web browser wanting to download a file is only possible by sending

Re: Regex to match "bad" characters in a parameter

2016-01-27 Thread lee
"Chris Charley" writes: > You could do that in 1 line - See the following small program. > (The line using a 'grep' solution is commented out. It would work as well). > > > #!/usr/bin/perl > use strict; > use warnings; > > while (my $id = ) { >chomp $id; >#if (grep /itemid=.*?[^\w-]/, spl

Re: returning arrays

2016-01-25 Thread lee
Shlomi Fish writes: > Hi lee, > > I should note that it is my impression that you are far too needy in your > enquiring, and I'm starting to lose patience. > > On Mon, 25 Jan 2016 00:11:43 +0100 > lee wrote: > >> Shlomi Fish writes: >> >> &g

Re: returning arrays

2016-01-25 Thread lee
Paul Johnson writes: > On Mon, Jan 25, 2016 at 12:24:04AM +0100, lee wrote: >> Paul Johnson writes: > [...] >> Consider with these examples that an expression like (1, 3) might >> unexpectedly evaluate to 3, and you start to think that you don't like >> thing

Re: returning arrays

2016-01-24 Thread lee
Paul Johnson writes: > On Sun, Jan 24, 2016 at 05:44:14PM +0200, Shlomi Fish wrote: >> Hi lee, >> >> On Sun, 24 Jan 2016 13:11:37 +0100 >> lee wrote: >> >> > Paul Johnson writes: >> > > >> > > In scalar context the comm

Re: returning arrays

2016-01-24 Thread lee
Shlomi Fish writes: >> > >> > In scalar context the comma operator evaluates its left-hand side, >> > throws it away and returns the right-hand side. >> >> What is the useful use for this operator? >> > > Well, I believe its use was originally inherited from > https://en.wikipedia.org/wiki/C_

Re: returning arrays

2016-01-24 Thread lee
Paul Johnson writes: > On Tue, Sep 09, 2014 at 03:12:00PM -0700, Jim Gibson wrote: >> >> On Sep 9, 2014, at 2:57 PM, Shawn H Corey wrote: >> >> > On Tue, 09 Sep 2014 23:09:52 +0200 >> > lee wrote: >> > >> >> my $i = 1; >>

CGI::formbuilder

2016-01-22 Thread lee
Hi, how do I arrange two (text) input fields side by side rather than one underneath the other? How do I automatically set the cursor into a particular field when the form is loaded so that keyboard input is entered into that field without the user having to select the field manually first? --

extracting images and cells from spreadsheet

2015-12-02 Thread lee
Hi, how can I extract images and information from another cell in the same row from a spreadsheet? The spreadsheet is in xls and can be converted to ods (or other formats Libreoffice supports). The sheet has over 1000 rows that look like this: | [image] | irrelevant cell | irrelevant cell | ex

Re: how to create a LO spreadsheet

2015-04-29 Thread lee
Vincent Lequertier writes: > Le 2015-04-26 14:27, lee a écrit : >> Hi, >> >> how can I create a libreoffice spreadsheet with perl? There seem to be >> two modules for it, yet none of them seems to let you do it --- if they >> do, the documentation doesn&#

how to create a LO spreadsheet

2015-04-27 Thread lee
Hi, how can I create a libreoffice spreadsheet with perl? There seem to be two modules for it, yet none of them seems to let you do it --- if they do, the documentation doesn't have any example of how to do it. The alternative seems to be to write MS excel files, and I don't really want to resor

Re: returning arrays

2014-09-09 Thread lee
Jim Gibson writes: > On Sep 8, 2014, at 3:13 PM, lee wrote: > >> Shawn H Corey writes: >> >>> On Mon, 18 Aug 2014 16:17:53 +0800 >>> # or >>> >>> sub myfunc { >>> return [ 1, 2, 3 ]; >>> } >> >> Is there a

returning arrays (was: Re: return the list content)

2014-09-08 Thread lee
Shawn H Corey writes: > On Mon, 18 Aug 2014 16:17:53 +0800 > Ken Peng wrote: > >> sub myfunc { >> my @x=(1,2,3); >> return \@x; >> } >> >> # or, >> >> sub myfunc { >> my @x=(1,2,3); >> return [@x]; >> } > > # or > > sub myfunc { > return [ 1, 2, 3 ]; > } Is there a difference to su

Re: async, non blocking tcp server

2014-09-08 Thread lee
Chris Knipe writes: > This is an actual example of a communication stream between a client > and the perl server, the socket is already established, and > communication is flowing between the two parties. [C] indicates what > the client is sending to the server, and [S] indicates the responses >

Re: which module to read configuration file?

2014-09-07 Thread lee
"Richard Bailey" writes: > There is code available from my wizard at > http://www.rtbaileyphd.com/perlwizard that is doing something fairly similar > to what you described. Use PerlWizard to generate a simple test program, > run it once, and then examine the contents of the pwiz subirectory, whi

Re: Read email

2014-08-31 Thread lee
"Danny Wong (dannwong)" writes: > Hi Perl Gurus, > What is the best module to use to read incoming emails from a particular > user? Any examples would be great to! Thanks! It depends on what you consider "read". There's an example that uses Net::IMAP

Re: which module to read configuration file?

2014-08-30 Thread lee
lee writes: > Hi, > > is there a module available to read configuration files which are like > this: > > > arbitrary_denominator-00 | alternate-denominator-00 | > alternate-denominator-01 [| ...] > { > itemA = > itemB = > itemC = > itemD = >

which module to read configuration file?

2014-08-30 Thread lee
Hi, is there a module available to read configuration files which are like this: arbitrary_denominator-00 | alternate-denominator-00 | alternate-denominator-01 [| ...] { itemA = itemB = itemC = itemD = } as in: postmas...@example.com | u...@example.com { itemB = 5 itemC = 3.

module for emacs org-mode tables?

2014-03-06 Thread lee
Hi, is there some perl module to handle emacs org-mode tables? -- Debugger entered--Lisp error: (error "No error here") signal(error ("No error here")) error("No %s here" "error") -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@per

Re: accessing variables in subroutines

2013-06-28 Thread lee
timothy adigun <2teezp...@gmail.com> writes: use strict; use warnings; sub test { print $counter . "\n"; } my $counter = 0; while($counter < 5) { test(); $counter++; } It says "Global symbol "$counter"

Re: accessing variables in subroutines

2013-06-27 Thread lee
Shlomi Fish writes: > Hi Lee, > > On Wed, 26 Jun 2013 10:18:44 +0200 > lee wrote: > >> Hi, >> >> the following example doesn't compile: >> >> >> use strict; >> use warnings; >> >> >> sub test { >

Re: last

2013-06-27 Thread lee
shawn wilson writes: > On Jun 25, 2013 3:11 AM, "lee" wrote: >> >> shawn wilson writes: >> >> > Lee, can you provide an example of another programming language that >> > implements this or a thesis that describes this problem in more

Re: last

2013-06-27 Thread lee
John SJ Anderson writes: > Lee, have you read the 'statement modifiers' and 'compound statement' > portions of 'perldoc perlsyn'? You may find that this clarifies this > issue for you. Well yes, I understand that there are two different kinds of

accessing variables in subroutines

2013-06-26 Thread lee
Hi, the following example doesn't compile: use strict; use warnings; sub test { print $counter . "\n"; } my $counter = 0; while($counter < 5) { test(); $counter++; } It says "Global symbol "$counter" requires explicit package name ...". When I put the subroutine after the 'whil

Re: last

2013-06-25 Thread lee
Uri Guttman writes: > On 06/24/2013 08:46 AM, lee wrote: >> John Delacour writes: >>> >>> “Stop if it’s raining, open your umbrella.” >>> >>> Nobody would know what you intend to say. No condition is actually >>> attached to “stop”. >>

Re: last

2013-06-25 Thread lee
shawn wilson writes: > Lee, can you provide an example of another programming language that > implements this or a thesis that describes this problem in more depth? I'm not sure what you mean --- other programming languages I know don't have two different kinds of 'if

Re: last

2013-06-24 Thread lee
Shlomi Fish writes: >> An 'if' is an 'if', and when putting 'last' in front of it changes it to >> something else, why isn't there a keyword for it like 'lastif'? >> > > How so? > > last MYLABEL if $x == 5; > > does exactly the same as: > > if ($x == 5) { > last MYLABEL; > } > > Similarly:

Re: last

2013-06-24 Thread lee
"Dr.Ruud" writes: > 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 >

Re: last

2013-06-24 Thread lee
John Delacour writes: > What you are saying is rather like expecting meaning from a sentence It tells you to stop when it's raining and to open your umbrella. > like: > > “Stop if it’s raining, open your umbrella.” > > Nobody would know what you intend to say. No condition is actually > attach

Re: last

2013-06-24 Thread lee
timothy adigun <2teezp...@gmail.com> writes: > Hi lee, > Please, check my comment below: > > On Sun, Jun 23, 2013 at 3:43 AM, lee wrote: > >> James Alton writes: >> >> > lee, >> > >> > You have a post statement if and then a code block

Re: last

2013-06-23 Thread lee
Shlomi Fish writes: > Hi Lee, > > On Sun, 23 Jun 2013 04:43:58 +0200 > lee wrote: > >> James Alton writes: >> >> > lee, >> > >> > You have a post statement if and then a code block. You can only use one of >> > two forms: >&

Re: last

2013-06-22 Thread lee
James Alton writes: > lee, > > You have a post statement if and then a code block. You can only use one of > two forms: > > print "test" if $color eq "blue"; #no parenthesis required > if($color eq "blue"){print "test";} And I can&#

last

2013-06-17 Thread lee
Hi, trying to figure out what `last' actually does, I wrote this test script: use strict; use warnings; use autodie; my $counter = 0; while($counter < 8) { last if($counter > 2) { print "if: " . $counter . "\n"; } else { print "else: " . $counter . "\n"; } $

Re: sha-2 sum of files?

2013-06-14 Thread lee
Shlomi Fish writes: >> > But if the size hasn't changed, then you still need to check something >> > else. You can do another light check, or decide to do the heavy one. >> > >> > This is also important because a hash-value is only a fingerprint, so >> > different files have (a small chance on ha

Re: the perl script (SOLVED: sha-2 sum of files?)

2013-06-14 Thread lee
Jim Gibson writes: > Some comments on your code: > > 1. Rather than doing this: > > while ( <$curridx>) { chomp $_; my $current_file = $_; > > you should do this: > > while ( my $current_file = <$curridx> ) { chomp($current_file); Ah cool :) I really didn't like the way I did that, this is

Re: sha-2 sum of files?

2013-06-14 Thread lee
Jim Gibson writes: > On Jun 13, 2013, at 1:30 PM, lee wrote: > >> In my application, my estimate is that there will be a set of around >> 100--150 files. Once a file is closed and reported one last time, it >> doesn't need to be considered anymore, so the number of

the perl script (SOLVED: sha-2 sum of files?)

2013-06-13 Thread lee
Hi, so I've done this script now --- my fourth perl script ever --- and since I'm getting so much help here, I thought I'd post it here. I'm sure it could be done much better, it's just plain and simple. It has one problem: The list of closed files can grow indefinitely, and since the script che

Re: sha-2 sum of files?

2013-06-13 Thread lee
"Dr.Ruud" writes: > On 12/06/2013 11:33, lee wrote: >> Jim Gibson 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. Wha

Re: sha-2 sum of files?

2013-06-13 Thread lee
"Dr.Ruud" writes: > 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.

split() (Re: sha-2 sum of files?)

2013-06-13 Thread lee
Jim Gibson writes: > On Jun 13, 2013, at 10:51 AM, lee wrote: >> + When I create files with lines like "filename:size:mtime" or >> "filename:hash", is there something built in to read a syntax like >> this into, let's say, an array like "my @f

Re: SOLVED: sha-2 sum of files?

2013-06-13 Thread lee
Jim Gibson writes: > On Jun 13, 2013, at 11:33 AM, lee wrote: > >> Shlomi Fish writes: >> >> >>>>>> our $fh; >>>>> >>>>> Why the our? >>>> >>>> I've been reading that you need to declare v

Re: SOLVED: sha-2 sum of files?

2013-06-13 Thread lee
Shlomi Fish writes: > Hi Lee, > > thanks for replying to the list and for not top posting. Yvw :) I hate top posting --- only in rare cases, I find it useful/reasonable. And posting the solution here might help others. >> >> #!/bin/perl >> > >> > Is you

Re: sha-2 sum of files?

2013-06-13 Thread lee
Jim Gibson writes: > On Jun 12, 2013, at 2:33 AM, lee wrote: > >> Jim Gibson writes: >> >>> >>> The first thing to do would be to check the file size. If the file >>> size has changed, then the file has been modified. So you will want to >

Re: sha-2 sum of files?

2013-06-12 Thread lee
Shlomi Fish writes: >> 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: > > In general, you should not Google for Perl information, because Google tends > to > find outdated results. Instead, use MetaCPAN

SOLVED: sha-2 sum of files?

2013-06-12 Thread lee
Shlomi Fish writes: > Hi Lee, > > some comments on your code: > > On Wed, 12 Jun 2013 11:28:34 +0200 > lee wrote: > >> David Christensen writes: >> >> > On 06/11/13 21:44, lee wrote: >> >> ... what I don't understand is what >&g

Re: sha-2 sum of files?

2013-06-12 Thread lee
James Alton writes: > What is the reason for checking file hashes once a month? Are you just > trying to do a basic sys admin task like ensuring system file integrity? No > sense in reinventing the wheel. Look into tripwire. > http://www.linuxjournal.com/article/8758 The purpose is to generate m

Re: sha-2 sum of files?

2013-06-12 Thread lee
Pritish Pattanaik writes: > Hello Lee, > > use Digest::MD5 module I believe solve your problem, But you can > incorporate other Perl modules to achieve your task. > > Things I would consider for this task : > > 1. Scripts checks on file/directory on every ? seconds onc

Re: sha-2 sum of files?

2013-06-12 Thread lee
David Christensen writes: > On 06/11/13 21:44, lee wrote: >> ... what I don't understand is what >> the most efficient way would be to create a sha-2 sum for a file. > > Have you considered Digest? > > http://perldoc.perl.org/Digest.html Yes, I've been

Re: sha-2 sum of files?

2013-06-12 Thread lee
Jim Gibson 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);

sha-2 sum of files?

2013-06-11 Thread lee
Hi, what I'm trying to do is create a list of sha-2 sums of files the names of which are stored in a file. The purpose is to verify from time to time whether any of the listed files have been modified or not in the meantime. So I can read the list of file names; what I don't understand is what t

for rss 2.0?

2013-01-22 Thread Sam Lee
Hey, I am trying to add an with : item title> http://example.com/1 * sam* Here is perl code: =8<= use strict; use warnings; use XML::RSS; my $rss = XML::RSS->new(version => '*2.0*'); $rss->add_module(prefix => 'dc', uri => 'http://purl.org/dc/elements/1.1/'); $rss->channel(title =

Re: Just why?

2011-08-12 Thread Olga Lee
Oh, thank you!! Now I understand, the point is that if don't suppose to give an argument to function, i should declare it as function() with brackets. Thanks again! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.pe

help: segmentation fault in threads program that use binmode

2011-06-14 Thread anders lee
when i use binmode in threaded program, i got a segmentation fault; i comment the binmode line, the program works well use threads; use threads::shared; use utf8; binmode(STDOUT, ':encoding(utf8)'; ---thread create and join- -- 使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/m

help: segmentation fault in threads program that use binmode

2011-06-08 Thread anders lee
when i use binmode in threaded program, i got a segmentation fault; i comment the binmode line, the program works well use threads; use threads::shared; use utf8; binmode(STDOUT, ':encoding(utf8)'; ---thread create and join- -- 使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/m

Re: perl setuid/suid and "use MODULE"

2010-04-29 Thread David Lee
so it needs to be untainted it before being fed into "use lib" (or other adjustment to '@INC'). -- : David Lee : ECMWF (Data Handling System) : Shinfield Park : Reading RG2 9AX : Berkshire : : tel:+44-118-9499 362 : email: david@ecmwf.int -- To unsubscribe, e-mail: begi

  1   2   3   4   >