Re: script that passes args to subroutine works ok, after I unpack the args. But perlcritic says I'm not unpacking?

2017-01-15 Thread Rob Dixon
Hi Alan You are unpacking `@_` in a way, but perlcritic doesn't recognise doing it this way. I think you'd be better off without dereferencing the hash, and using a slice to assign your local variables. I would write your subroutine like this sub modrec { my ($args) = @_;

Re: How to get a called perl script to write output to a file with DIFFERENT user:group than the calling app?

2017-01-15 Thread Rob Dixon
the new values for user and group. Thanks. Rob Dixon On 15 January 2017 22:45:43 GMT+00:00, al...@myfastmail.com wrote: >I have an application that calls a perl script, feeding it input over >STDIN. > >The perl script takes that input, processes it, and writes is as a >change

Re: prime numbers - loop

2015-03-14 Thread Rob Dixon
On 15/03/2015 00:25, Ilan Shlossman wrote: Hi , I asked this question on linkedin but I think the best place to get answers is here ... I have a perl cod that check a range of numbers and print for each number if it's prime number or not prime number. So why its not working properly ? ... #!C:

Re: why is if (! @ARGV) skipped

2014-11-18 Thread Rob Dixon
On 18/11/2014 22:46, Harry Putnam wrote: I'll probably be battered for general poor perlmanship but still risking posting my whole script (fairly brief). The problem I'm having with it, that I don't see how to debug is that it breaks out on code inside Find.pm instead of breaking out on the if

Re: Argument isn't numeric warning in if statement

2014-09-18 Thread Rob Dixon
On 18/09/2014 00:34, SSC_perl wrote: On Sep 17, 2014, at 3:32 PM, Rob Dixon wrote: As you have presented them, those code fragments are identical in meaning. That was my understanding as well, but the inline 'if' gave an error while the block didn't. Running the code by itself

Re: Argument isn't numeric warning in if statement

2014-09-17 Thread Rob Dixon
On 17/09/2014 01:37, SSC_perl wrote: I just ran across something puzzling. Why are these two statements not equivalent when it comes to warnings? if ($item->{'optionprice'}) { $item->{'unitprice'} += $item->{'optionprice'}; } and $item->{'unitprice'} += $item->{'optionprice'}

Re: return the list content

2014-09-10 Thread Rob Dixon
On 09/09/2014 02:20, Ken Peng wrote: The second option creates the same array and populates it, but then copies it to another anonymous array, deletes the first array, and returns a reference to the copy. Since this is a shadow copy, I don't think the first array will be deleted completely. I

Re: return the list content

2014-09-08 Thread Rob Dixon
On 18/08/2014 09:17, Ken Peng wrote: sub myfunc { my @x=(1,2,3); return \@x; } # or, sub myfunc { my @x=(1,2,3); return [@x]; } which one is the better way to return the list content? And if the method is an instance method? The first version of the subroutine is the best choice

Re: How to parse XML content using lwp agent or XML Smart

2014-08-22 Thread Rob Dixon
On 22/08/2014 11:27, angus wrote: > Hi, > > Hi, > > I have some sample code that posts some XML content to an URL using > LWP agent and XML Smart. The response to this comes back as some > custom XML. I now need to try and parse the response and find the > REDIRECTURL value and redirect the

Re: Which perl for Windows?

2014-08-06 Thread Rob Dixon
On 06/08/2014 18:13, Andy Bach wrote: On Tue, Aug 5, 2014 at 9:50 PM, Rob Dixon mailto:rob.di...@gmx.com>> wrote: DWIM Perl has a version for Microsoft Windows that contains Padre, the Perl IDE and all the CPAN modules you'll ever need. So it's nice that t

Re: Suddenly.... Part 2

2014-08-05 Thread Rob Dixon
On 05/08/2014 19:13, ESChamp wrote: Here's a small portion of my script: Excuse me for my confusion as I missed "Suddenly - Part 1". Are Peter Holsberg and ESChamp one and the same, as they both seem to be driving this thread? Rob --- This email is free from viruses and malware because

Re: Which perl for Windows?

2014-08-05 Thread Rob Dixon
On 05/08/2014 22:20, ESChamp wrote: Which perl should I (an occaisonal perl user, a rare perl programmer) use? I see cygwin strawberry perl activestate perl dwim perl - Cygwin is an attempt to put a Unix-like environment on top of Windows. If you want to work with a Windows command line then

Re: Date::Parse and strange dates

2014-07-25 Thread Rob Dixon
On 25/07/2014 17:54, Chris Knipe wrote: Hi All, I have the odd (very rare) case where I am given a date in an incorrect format. I already use Date::Parse to convert the dates to a unix timestamp, and it’s working incredibly well. However, on the rare case that I get incorrect dates, Date::Pars

Re: Apologetic request for simple one-off script

2014-07-14 Thread Rob Dixon
On 14 July 2014 15:18:31 BST, John Delacour wrote: > >On 14 Jul 2014, at 14:11, Shlomi Fish wrote: > >>> perldoc -f open > >> This is irrelevant. Two-args open is dangerous - always use >three-args open: >> >> * http://perl-begin.org/tutorials/bad-elements/#open-function-style > >Who wrote that?

Re: Apologetic request for simple one-off script

2014-07-14 Thread Rob Dixon
On 14 July 2014 14:22:55 BST, John SJ Anderson wrote: >Hi. List Mom here. > >Please take this off list, it's not on-topic. > >John: Thank you for answering the OP's question. However, Shlomi is >right, the two argument form of open() is something that the general >Perl community considers to be a

Re: Planning to buy Hard Copy Book

2014-06-11 Thread Rob Dixon
On 11/06/2014 11:23, Frank Vino wrote: Could you please let me know which publisher and author name are good in Perl Book, I am planning to buy a hard copy. There are several worthy Perl 5 tutorial books available, but the definitive Perl manual is Programming Perl, now in its fourth editio

Re: How to parse C#, javascript, lisp source code for quoted literal strings

2014-05-22 Thread Rob Dixon
On 22/05/2014 10:04, siegfr...@heintze.com wrote: I need to extract some information from source code. How can I write a perl regular expression that will match a literal string in languages like C#, javascript, java and lisp? Here is my naive approach: /"[^"]*"/ This of course does not accom

Re: about open with pipe '-|', '|-'

2014-05-09 Thread Rob Dixon
On 10/05/2014 03:48, Uri Guttman wrote: On 05/09/2014 04:58 PM, Shawn H Corey wrote: On Fri, 09 May 2014 16:41:02 -0400 Harry Putnam wrote: As soon as I think I've got it right by thinking: ok, left side is into the command right side is out. If I start pondering over that ... it b

Re: about open with pipe '-|', '|-'

2014-05-09 Thread Rob Dixon
On 09/05/2014 21:41, Harry Putnam wrote: I guess I need a mnemonic device to trick myself into remembering which way the pipe with dash symbol goes. And I suppose I should apologize for the cry baby rant in advance: Even now I'm flopping around trying to remember... I've written scripts

Re: about open with pipe '-|', '|-'

2014-05-09 Thread Rob Dixon
On 09/05/2014 21:58, Shawn H Corey wrote: On Fri, 09 May 2014 16:41:02 -0400 Harry Putnam wrote: Agreed. I wished they used something like: ">|" and "<|" Hey Shawn You should raise a bug using `perlbug` on the command line. I amd sure it would be considered carefully and you would get a reas

Re: small puzzle

2014-04-25 Thread Rob Dixon
On 26/04/2014 02:16, Uri Guttman wrote: On 04/25/2014 12:55 PM, Harry Putnam wrote: Uri Guttman writes: why would you expect anything but 1 as the value? shift will return 1 value or undef. that anon array will be dereferenced to an array with 1 entry. the array is in scalar context which ret

Re: about HTML

2014-03-13 Thread Rob Dixon
On 13/03/2014 18:13, Ariel Hosid wrote: 2014-03-13 10:43 GMT-03:00 Rob Dixon On 13/03/2014 18:13, Ariel Hosid wrote: On 13/03/2014 13:33, Ariel Hosid wrote: Hi there! I am needing a module to parse a HTML page and to take action on it. Any idea? There are

Re: Build Perl keyword hash

2014-03-13 Thread Rob Dixon
On 13/03/2014 13:56, Alex Chiang wrote: Yes. Thanks for your help. How do you copy and paste from browser ? When I tried this, all I got is hyperlink and metadata. You probably need to use a decent browser. Are you using Internet Explorer? Give Firefox or Chrome a try. Rob --- This emai

Re: Build Perl keyword hash

2014-03-13 Thread Rob Dixon
On 13/03/2014 13:29, Alex Chiang wrote: I'd like to build a hash mapping from "keyword" => value. By keyword, I mean all reversed words in http://learn.perl.org/docs/keywords.html. Do you guys know any csv or text file containing all these words? I don't want to hard code all these reversed word

Re: about HTML

2014-03-13 Thread Rob Dixon
On 13/03/2014 13:33, Ariel Hosid wrote: Hi there! I am needing a module to parse a HTML page and to take action on it. Any idea? -- Ariel There are several candidates. I would look at HTML::TreeBuilder first. Rob --- This email is free from viruses and malware because avast! Antivirus

Re: regex and parse

2014-03-11 Thread Rob Dixon
On 11/03/2014 17:01, Ariel Hosid wrote: Can anyone recommend me literature that treats regular expressions and how to analyze files? The best documentation on regular expressions is Perl's own here http://perldoc.perl.org/perlre.html Analysing files is an enormous subject that is difficu

Re: return just a match from an array without changing the array

2014-03-04 Thread Rob Dixon
On 03/03/2014 23: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 When I do this: my $src = (grep {s/.*(ARIN|APNIC).*(\n)?/$1/} @ret

Re: check list if values meet criteria

2014-02-25 Thread Rob Dixon
On 25/02/2014 23:46, Bill McCormick wrote: On 2/25/2014 4:36 PM, Bill McCormick wrote: On 2/25/2014 4:30 PM, Bill McCormick wrote: What would be the perl'ish way using map or some other sugar to check if a list of values meet some criteria? Instead of doing something like my @issues = qq(123,4

Re: OO perl programming

2014-02-10 Thread Rob Dixon
On 07/02/2014 01:11, Sam wrote: The oreilly "Learning Perl" teaches one to use the ampersand when calling subroutines, which most perl'ers will disagree with. I did it for years with out even questioning it until it bit me because I had read that book. I believe that most of the recent dislike

Re: Replacing the first line of a text file

2014-02-04 Thread Rob Dixon
On 04/02/2014 01:12, SSC_perl wrote: use strict; use warnings; my $filename = 'products.csv'; open (my $fh, '+<', $filename) || die "can't open $filename: $!"; my $line = <$fh>; $line =~ s/tag_//gi; seek $fh, 0, 0; printf {$fh} $line; close $fh; If it is satisfactory to leave the original fil

Re: baby perl to get the right date

2014-01-28 Thread Rob Dixon
On 28/01/2014 07:32, Luca Ferrari wrote: Hi all, 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

Re: Identifying the current opened filehandle for writing as I'm getting undefined variable concatenation errors

2014-01-14 Thread Rob Dixon
On 15/01/2014 03:09, Matt McAdory wrote: Is there a method for determining the currently selected filehandle? should I always check for undef and open my filehandle before writing to it? use strict; use warnings; use autodie qw (:all); use My:CustomMod_with_FH_write; open (my $FH, ">", "filena

Re: Help with a RE

2014-01-09 Thread Rob Dixon
On 09/01/2014 09:55, Gary Stainburn wrote: On Thursday 09 January 2014 09:53:35 Gary Stainburn wrote: Oops, Missed a bit, try s/^[0-9]+[a-c]{0,1}[-_]//; /[a-c]{0,1}/ is normally written as /[a-c]?/ --- This email is free from viruses and malware because avast! Antivirus protection is active

Re: Gigantic file size processing error

2014-01-03 Thread Rob Dixon
On 02/01/2014 15:21, mani kandan wrote: Hi, We have file size of huge size 500MB, Need to Manipulate the file, some replacement and then write the file, I have used File::slurp and works for file size of 300MB (Thanks Uri) but for this huge size 500MB it is not processing and come out with error

Re: perlre(1) and substitution evaluations

2013-11-30 Thread Rob Dixon
"Lars Noodén" wrote: >perlre(1) seems to be missing information about substitution >evaluations >with the /e option. The functionality is present in perl: > > perl -e '$_=2; s/2/1+3/e; print' > >But it is not listed in the pod documentation for v5.16.3 or v5.18.1. >The modifier /e is descri

Re: Reading a sequence data from a file

2013-11-15 Thread Rob Dixon
On 12/11/2013 23:24, Michael Brader wrote: Hey Femi, Instructions and example code for doing all the things you want can be found in the standard Perl manual. You should be able to find it by opening a terminal window and using the perldoc command: A superb answer Michael. Well done. Rob

Re: Using a function in a variable

2013-11-09 Thread Rob Dixon
On 09/11/2013 13:33, Unknown User wrote: I have a variable that has a function in it, e.g. my $newtime = "time() + 30"; How can i use it in code so that it always returns time() + 30 when it is called? Does it *have* to be in a string like this? Where has the string come from? Rob --

Re: OT: Python

2013-10-26 Thread Rob Dixon
On 26/10/2013 23:55, David Christensen wrote: On 10/26/13 04:28, htchd...@live.com wrote: How about python? Many people consider it's better than Perl and it becomes more and more popular. There are a lot of really smart people who like Python. Maybe, but it seems that you are not one of th

Re: hello from a newbie

2013-10-26 Thread Rob Dixon
On 26/10/2013 13:59, Shawn H Corey wrote: On Sat, 26 Oct 2013 07:28:09 -0400 wrote: How about python? Many people consider it's better than Perl and it becomes more and more popular. This is why: Why what? I assume you're promoting Python, which is a bit strange on this list. > > $ pyth

Re: Need help with a programming problem

2013-10-05 Thread Rob Dixon
On 04 Oct 2013 06:33, Shlomi Fish wrote: > On 02 Oct 2013 Uri Guttman wrote: >> On 02 Oct 2013 08:56 PM, Rob Dixon wrote: >>> On 03 Oct 2013 01:39, Uri Guttman wrote: >>>> >>>> I do recommend you try to use File::Slurp to read in and write out your >

Re: I'm doing something stupid

2013-10-03 Thread Rob Dixon
shawn wilson wrote: >From position 0 to 7 should be whatever GREP_COLOR export is defined >as. There might be issues with how I'm doing that but my main issue (I >think) is how I'm looping (and/or how I'm using substr). > >#!/usr/bin/perl > >use strict; >use warnings; > >use Data::Dumper; > >my $l

Re: Need help with a programming problem

2013-10-02 Thread Rob Dixon
That should read as follows: use strict; use warnings; use Tie::File; use File::Copy 'copy'; use File::Spec; my $dir = '/path/to/my/directory'; opendir my ($dh), $dir; # Find all files in the directory that match \d{6}\.htm # Die if none or multiple files found # my @files = grep /\A\d{6}\

Re: Need help with a programming problem

2013-10-02 Thread Rob Dixon
On 02/10/2013 18:22, Peter Holsberg wrote: Hi, I have tried to do this for hours but it looks like it is just too difficult for me. I would like a script to open a file in the current directory and edit it. The file's name is \d{6}.htm The script then needs to search for a line that begins:

Re: Need help with a programming problem

2013-10-02 Thread Rob Dixon
On 03/10/2013 01:39, Uri Guttman wrote: I do recommend you try to use File::Slurp to read in and write out your files. It would help a lot if you declared your interest in File::Slurp. It is disingenuous to recommend your own modules. Rob -- To unsubscribe, e-mail: beginners-unsubscr...@pe

Re: Need help with a programming problem

2013-10-02 Thread Rob Dixon
On 03/10/2013 00:19, Shawn H Corey wrote: It would be difficult to get a file with a backslash in it. perl -e "open X, q/>\d{6}.htm/" Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Need help with a programming problem

2013-10-02 Thread Rob Dixon
On 02/10/2013 20:44, Peter Holsberg wrote: Shawn H Corey has written on 10/2/2013 2:29 PM: my @files = grep { /^\d{6}\.htm$/i } glob( '*.htm' ); Well, I'm more of a beginner than I thought I was! The /i to grep is to ignore case? Why are you globbing *.htm? Hi Peter All that Shawn has sh

Re: How Much is Too Much?

2013-10-02 Thread Rob Dixon
I'm not bucking for "net nanny" but, while full solutions and follow-on discussions can be enlightening, I wonder if they're really advantageous to the OP. Not to embarrass anyone but there was no mention of DIY attempts, no soliciting of hints or approaches, or even mention of being stuck or frus

Re: formatting a list

2013-09-28 Thread Rob Dixon
On 28/09/2013 06:59, Rajeev Prasad wrote: hello, following is obtained by concatenating 3 values using an underscore to produce a list: |abc_12_4567 xy4z_xtr4_sdf PQRSDR_xcvf_scc234| i want them to look neat, something like this: where they look in line. I do not know before hand how long each

Re: formatting a list

2013-09-28 Thread Rob Dixon
On 28/09/2013 06:59, Rajeev Prasad wrote: hello, following is obtained by concatenating 3 values using an underscore to produce a list: |abc_12_4567 xy4z_xtr4_sdf PQRSDR_xcvf_scc234| i want them to look neat, something like this: where they look in line. I do not know before hand how long each

Re: checking for file existence

2013-09-26 Thread Rob Dixon
On 25/09/2013 20:38, RENATO AUGUSTO CORREA DOS SANTOS wrote: Hi, all. I am a very begginer in PERL starting today in this mailing list! :-) I will try to work especially with Bioinformatics. I am trying to verify the existence of a file in PERL; however, is seems not to work. It always returns

Re: hash function and combining function/operator

2013-09-23 Thread Rob Dixon
On 23/09/2013 23:17, David Christensen wrote: beginners: 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) Hi David My immediate thought is that the only ha

Re: Puzzled by ouput from this script

2013-09-11 Thread Rob Dixon
On 11/09/2013 23:04, Harry Putnam wrote: Posted below is a shortened down version of a larger script that tries to show the phenomena I'm seeing and don't understand. open my $fh, '>>', $log or die "Can't open <$log>: $!"; print " $dtf START $rsync $shortargs\n $longargs\n $src/ $dst/\n

Re: Filtering Characters

2013-09-04 Thread Rob Dixon
On 04/09/2013 03:58, Michael Rasmussen wrote: On Wed, Sep 04, 2013 at 02:31:30AM +0100, Rob Dixon wrote: John's solution: next if /[^[:lower:]_\d\-. ]/; Doesn't work in this test environment: michael@bivy:~$ cat tpl && ./tpl #!/usr/bin/perl use strict;

Re: Filtering Characters

2013-09-03 Thread Rob Dixon
Matt wrote: >I have this: > >while () { >chomp; >next if /^#/; ># do stuff >} > > >It skips to the next item in the while loop of the string begins with ># and works fine. I would also like to skip to the next item in the >loop if the string contains anything other then lowercase,

Re: Recursive Validation Function

2013-09-03 Thread Rob Dixon
On 03/09/2013 06:56, Jim Gibson wrote: For readability, use the extended form and the more modern zero-width assertions \A and \z: if ( $_[0] !~ m{ \A [ric] \. (?:[1-578]) | (?:6 (\.[12])? ) \z }ix ) { Hi Jim You have incorrect parentheses. Your regex matches \A [ric] \. (?:[1-578]) o

Re: Recursive Validation Function

2013-09-03 Thread Rob Dixon
On 03/09/2013 02:23, John Aten wrote: Hello all, I am writing a script to rename files. The script prompts the user to enter tokens which will comprise part of the file name. These are made of letters and numbers separated by a dot, ie: R.3. The letters can be R, I or C, upper or lowercase. The

Re: Print to several logs

2013-08-28 Thread Rob Dixon
On 28/08/2013 19:06, John W. Krahn wrote: Rob Dixon wrote: use strict; use warnings; use autodie; my $rsync = 'rsync'; my $tmplog = 'one.log'; my $tmplog2 = 'two.log'; my %logs = map { open my $FH, '>>', $_; What if open fails?! I have `

Re: Make a sub routine return

2013-08-28 Thread Rob Dixon
On 28/08/2013 16:48, Harry Putnam wrote: The code below was a script by itself but now I need to turn it into a function inside a larger script... I've done something that sort of works but fails on a specific file name that looks like `.#somefile'. What does "fails" mean? Does it crash?, prod

Re: Print to several logs

2013-08-27 Thread Rob Dixon
On 27/08/2013 23:06, John W. Krahn wrote: Harry Putnam wrote: I happen to be scripting something that needs to have two logs written to and was sort of taken by how awkward this construction looked: (Simplified for discussion, from a longer script) my $rsync = 'rsync'; my $tmplog = 'one

Re: string match question

2013-08-21 Thread Rob Dixon
ical alarm until it finds a dot (non greedy). I agree with Rob Dixon I should be parsing the html, but unfortunately getting it was proving more complicated than this. If this check breaks with a firmware update then we will have to see wat we do then, these things do not get updates so often, f

Re: string match question

2013-08-20 Thread Rob Dixon
On 20/08/2013 15:02, Natxo Asenjo wrote: hi, for a nagios (monitoring system) check I need to scrape a web site (this is for a network device, a UPS, whatever). This particular device only offers some functionality through a web interface. I am only interested in the text '1 Critical Alarm Pres

Re: Single equals operator inside an if statement

2013-08-14 Thread Rob Dixon
On 14/08/2013 18:21, Alexey Mishustin wrote: If I make a typo and write a single "equals" operator here: if ($foo = 2) { print "yes\n"; } ...then the "warnings" pragma works OK and tells me "Found = in conditional, should be ==..." But if I make the same typo and write a single "equal

Re: parsing html

2013-08-08 Thread Rob Dixon
On 08/08/2013 18:18, David Precious wrote: On Thu, 8 Aug 2013 22:42:01 +0530 Unknown User wrote: What would be the best module available for parsing html in your opinion? My intention is to parse html that contains a table of 5 columns and any number of rows For parsing HTML tables, you want

Re: Parsing Data

2013-07-23 Thread Rob Dixon
On 23/07/2013 19:00, Shlomi Fish wrote: Why do you feel that I've been "promoting" XML::LibXML in this thread? Because you say Instead one should use [XML::LibXML] I call that promotion. Why does the fact that I'm affiliated with it, prevent me from recommending it over a different alter

Re: Parsing Data

2013-07-23 Thread Rob Dixon
On 23/07/2013 14:39, Shlomi Fish wrote: Hi Rob, I recommend against using XML::XPath because it's been undermaintained, is slower than XML::LibXML's XPath support, may be more incomplete and I believe it has poorer support for XML namespaces. Instead one should use https://metacpan.org/module/X

Re: grab pattern from start and end block

2013-07-13 Thread Rob Dixon
On 12/07/2013 12: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 following

Re: grab pattern from start and end block

2013-07-12 Thread Rob Dixon
On 12/07/2013 13:56, Shawn H Corey wrote: On Fri, 12 Jul 2013 13:51:01 +0100 Rob Dixon wrote: On 12/07/2013 13:30, Agnello George wrote: could i use local $/ instead of $INPUT_RECORD_SEPARATOR Yes, and you should do that. The extended variable names are almost never used and will

Re: grab pattern from start and end block

2013-07-12 Thread Rob Dixon
On 12/07/2013 13:30, Agnello George wrote: could i use local $/ instead of $INPUT_RECORD_SEPARATOR Yes, and you should do that. The extended variable names are almost never used and will mostly confuse people familiar with Perl. Rob -- To unsubscribe, e-mail: beginners-unsubscr...@per

Re: grab pattern from start and end block

2013-07-12 Thread Rob Dixon
On 12/07/2013 12: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 following

Re: printing content of a pipe

2013-06-28 Thread Rob Dixon
On 28/06/2013 02:32, Uri Guttman wrote: you don't need ever to set $| on stderr as it is not buffered like stdout is. and you rarely need to set it on stdout as any print with a \n will flush stdout. That isn't true. Perl will buffer STDOUT up to 8KB regardless of whether a newline has been p

Re: last

2013-06-27 Thread Rob Dixon
On 27/06/2013 16:03, Shawn H Corey wrote: On Thu, 27 Jun 2013 07:45:17 -0700 Jim Gibson 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 performed: do { … } w

Re: accessing variables in subroutines

2013-06-27 Thread Rob Dixon
On 27/06/2013 11:58, lee wrote: Shlomi Fish writes: lee wrote: 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 exp

Re: Fw: Please exempt the book Modern Perl from Web Commercials on http://perl-begin.org/

2013-06-26 Thread Rob Dixon
On 26/06/2013 10:18, Franklin Lawerence wrote: Hi, Could you please let me know how to reverse a string without using built in function. Hi Franklin Is this homework? I can think of no other reason to need what you are asking for. It is best to say if you are asking for help with homework

Re: Please exempt the book Modern Perl from Web Commercials on http://perl-begin.org/

2013-06-26 Thread Rob Dixon
On 26/06/2013 10:32, Shlomi Fish wrote: Hi, Could you please let me know how to reverse a string without using built in function. Do you want to avoid using the http://perldoc.perl.org/functions/reverse.html built-in function or any built-in function whatsoever? Assuming the latter you can

Re: Lines written to a file are not contiguous

2013-05-08 Thread Rob Dixon
On 08/05/2013 14:16, Shlomi Fish wrote: See: http://perl-begin.org/tutorials/bad-elements/ Regards, Shlomi Fish It would make me feel a lot better if you would declare your interest in your own web site when you link to it. It's hardly an endorsement if you link to something else yo

Re: Lines written to a file are not contiguous

2013-05-08 Thread Rob Dixon
On 08/05/2013 10:24, Shlomi Fish wrote: This is better: http://perl-begin.org/tutorials/bad-elements/#properly_autoflushing print `cat * >>foo.out`; # [2] qx// This is the same as «system('cat * >> foo.out')» (only more costly), and the command in this case should not emit any outp

Re: Pattern match operator

2013-05-04 Thread Rob Dixon
On 04/05/2013 14:26, Florian Huber wrote: I'm parsing a logfile and don't quite understand the behaviour of m//. From a previous regex match I have already captured $+{'GFP'}: use strict; use warnings; (...) $text =~ m/ (?FILTERS .*? WRT)/x;# I simply have my whole logfile in $text - I

Re: Email::Sender::Simple how to set priority?

2013-04-26 Thread Rob Dixon
On 27/04/2013 00:21, Rajeev Prasad wrote: following is still coming out as normal priority email. use strict; use warnings; use Email::MIME; use Email::Sender::Simple qw(sendmail); my @mesg=qw(fox jumps over the); my $subject='IMP mesg'; my $message = Email::MIME->create( header_str =>

Re: Any alternative for substr() function

2013-04-12 Thread Rob Dixon
On 12/04/2013 12:23, kavita kulkarni wrote: Thanks all, got many ideas from you.. My script took ~7 min to run with data file of ~50,000 lines with substr()/unpack() enabled and same script took ~2 min after disabling substr()/unpack(). That led me to the conclusion that substr/unpack is taking

Re: Any alternative for substr() function

2013-04-10 Thread Rob Dixon
On 10/04/2013 16:45, Bob goolsby wrote: G'Mornin' Kavita -- Before you go off on a goose chase, how do you know that substr() is going to be a problem for you? Have you bench-marked it? If your file is as large as you say, I strongly suspect that your bottleneck is going to be I/O and any diff

Re: no warnings inside a loop

2013-04-03 Thread Rob Dixon
On 04/04/2013 00:29, Angela Barone wrote: I'm just curious about this. If you put "no warnings" inside a loop, is it good only for that loop, or will it be in effect until the end of the script? Also see `perllexwarn` Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For addition

Re: no warnings inside a loop

2013-04-03 Thread Rob Dixon
On 04/04/2013 00:29, Angela Barone wrote: I'm just curious about this. If you put "no warnings" inside a loop, is it good only for that loop, or will it be in effect until the end of the script? Hi Angela The `warnings` pragma is *lexically* scoped. That means it applies to the (rest of) the

Re: large files

2013-03-05 Thread Rob Dixon
On 05/03/2013 20:41, Chris Stinemetz wrote: Hello List, 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. I have begin testing to

Re: separating code in two files

2013-03-02 Thread Rob Dixon
On 02/03/2013 14:37, Chris Stinemetz wrote: On Fri, Mar 1, 2013 at 3:37 PM, Chris Stinemetz wrote: On Fri, Mar 1, 2013 at 11:00 AM, Shlomi Fish wrote: Hi Jim, On Thu, 28 Feb 2013 11:21:59 -0800 Jim Gibson wrote: On Feb 28, 2013, at 10:31 AM, Chris Stinemetz wrote: I want to put a has

Re: obfuscating code

2013-02-13 Thread Rob Dixon
On 12/02/2013 22:50, David Crouse wrote: Seriously, I took it as just funny... get off your soapbox. I'm fairly sure that the comment was just in good fun. As a systems admin, i've had to "decipher" my share of perl, and while it "can" be written great, it "can" also be written poorly. David,

Re: other ways to parse emails from html?

2013-02-01 Thread Rob Dixon
On 31/01/2013 19:49, Jeswin wrote: Hi again, I tried to use the treebuilder modules to get emails from a webpage html but I don't know enough. It just gave me more headaches. My current method get the emails is to go to the site, put the source code in MS Word, and run a regex to get all the ema

Re: trying to understand HTML::TreeBuilder::XPath

2013-01-29 Thread Rob Dixon
On 26/01/2013 20:44, Jeswin wrote: > Hi, > I'm trying to parse out the emails addresses from a webpage and I'm > using the HTML::TreeBuilder::XPath module. I don't really understand > XML and it's been a while since I worked with perl*. So far I mashed > up a code by looking through past examples o

Re: need suggestion stat vs Devl::Size for checking size very very frequently

2013-01-25 Thread Rob Dixon
On 26/01/2013 05:58, Rajeev Prasad wrote: *From:* "rob.di...@gmx.com" Rajeev Prasad mailto:rp.ne...@yahoo.com>> wrote: i have a lot of data coming/pouring in from this: my ($rout, $pid) = $ssh-> pipe_out($cmd); while (my $line = <$rout> ) { print filehandle $line; } I want to stop writ

Re: need suggestion stat vs Devl::Size for checking size very very frequently

2013-01-25 Thread rob . dixon
Rajeev Prasad wrote: >i have a lot of data coming/pouring in from this: > >my ($rout, $pid) = $ssh->pipe_out($cmd); >while (my $line = <$rout>) { >    print filehandle $line; >} > >I want to stop writing after certain size is written (say 1gb). > >so i can try this: (it is working). But I am worr

Re: finding head and tail in data structure

2013-01-10 Thread Rob Dixon
On 10/01/2013 10:01, budi perl wrote: Hi, I have this following hash: #!/usr/bin/perl # use strict; use Data::Dumper; my %MYROUTES = ( "ROUTE-252" => { # src => dest 427 => "ABEP", "ABEP" => 441, 441 => 427, 427 => 444, 444 => "MGWQ",

Re: grouping in regex

2012-12-24 Thread Rob Dixon
On 24/12/2012 13:08, Paul Johnson wrote: On Sun, Dec 23, 2012 at 06:57:38PM +0530, punit jain wrote: Hi, I am doing grouping but seeing some weird behavior :- the strings in a file are like :- AccessModes = (18,Mail,POP,IMAP,PWD,WebMail,WebSite,Relay,Mobile,FTP,MAPI,TLS,LDAP,WebCAL); ...

Re: grouping in regex

2012-12-24 Thread Rob Dixon
On 23/12/2012 13:27, punit jain wrote: Hi, I am doing grouping but seeing some weird behavior :- the strings in a file are like :- AccessModes = (18,Mail,POP,IMAP,PWD,WebMail,WebSite,Relay,Mobile,FTP,MAPI,TLS,LDAP,WebCAL); ... . multiple lines I am seeing which lines have both POP and Web

Re: Regex help

2012-12-22 Thread Rob Dixon
On 22/12/2012 11:15, punit jain wrote: Hi, I have a file like below : - BEGIN:VCARD VERSION:2.1 EMAIL:te...@test.com FN:test1 REV:20101116T030833Z UID:644938456.1419. END:VCARD From <>(S___-0003) Tue Nov 16 03:10:15 2010 content-class: urn:content-classes:person Date: Tue, 16 Nov

Re: variable definition error not caught when using strict and warnings

2012-11-09 Thread Rob Dixon
On 09/11/2012 17:08, Nemana, Satya wrote: Hi I am a little confused with this program Program: use strict; use warnings; if ($999 == 1056) { print ("\nequal"); } else { print ("\nnot equal"); } What I expect: Perl to throw me an error as $999 variable is not defined, but perl execu

Re: perl interpreter output meaning?

2012-09-22 Thread Rob Dixon
On 22/09/2012 08:45, Anne Wainwright wrote: Hi, this is the output. Use of uninitialized value $9 in concatenation (.) or string at pg_delim2htm_01.pl line 89, <> line 1. Use of uninitialized value $9 in concatenation (.) or string at pg_delim2htm_01.pl line 89, <> line 4. Use of uninitialize

Re: My long script

2012-09-16 Thread Rob Dixon
On 16/09/2012 05:03, Robert Wohlfarth wrote: On Sat, Sep 15, 2012 at 4:46 PM, wrote: The user clicks on a button ("A" or "B"), which fires back a string that reawakens the script and shows it what answer the user chose. The script inspects the cooky-jar to determine the state of the script,

Re: File/string formatter script?

2012-09-15 Thread Rob Dixon
On 15/09/2012 02:52, newbie01 perl wrote: > Hi all, > > I have a config file that contains some text as below: > > server01:/u01/app/oracle/admin/db01/adump :*.dmp,5 > :compress :/bin/gzip > server01:/u01/app/oracle/admin/db04/adump :*.aud,5 >

Re: My script is...

2012-09-14 Thread Rob Dixon
On 14/09/2012 14:31, Rob Coops wrote: On Fri, Sep 14, 2012 at 2:52 PM, wrote: I appreciate the helpful input. It appears from my server stats that the script in question has only run a couple of times a day on average, so that's fewer than a thousand instances in the past year. I ran LOTS of

Re: My script is OUT OF CONTROL!

2012-09-13 Thread Rob Dixon
On 13/09/2012 23:42, jmrhide-p...@yahoo.com wrote: > > I installed the following script last year and it seemed to be working fine. > Yesterday, however, my hosting service took down my site because the script > was > tying up so much of their server resources that it was a threat to their > busi

Re: Using different libraries dynamically

2012-09-12 Thread Rob Dixon
On 12/09/2012 15:18, Mark Haney wrote: I've got what I hope is an easy question to answer. I've got a perl web app that I've setup with a 'live' version (more like a beta actually) and a dev version for me to make changes to that might break the other site. The way I inherited it was as a singl

  1   2   3   4   5   6   7   8   9   10   >