Re: regexp pattern matching

2006-06-30 Thread M. Kristall
Mr. Shawn H. Corey wrote: m/The satchel contains the following items? \((\d+)\): (.*)/ my $count_of_items = $1; my $item_list = $2; And don't forget to check if it matched (otherwise you have the old $1 and $2): if (m/The satchel contains the following items? \((\d+)\): (.*)/) {

Re: uninitialized value error

2006-06-21 Thread M. Kristall
> open (PS, "ps -ef|grep /usr/sbin/[n]amed |") or die "not spawn ps $!"; ps -ef works, so does grep... but if named isn't running (or /usr/sbin/[n]amed doesn't match it), you won't be able to read much from PS. > for (;;) { > push @arry, (split)[1]; > } (Why not 'while ()' instead? It's the sam

Re: using (sharing) variables between perl files

2006-06-19 Thread M. Kristall
Varga Pavol wrote: Hi, Hello may be very simple, but I don't understand well how to simple use (share) varables between perl files? I have (very) big perl script and I would like to divide it into more small scripts to make it all more transparent. perldoc is your friend. If you have separate '

Re: A loop to parse a large text file--output is empty!

2006-06-17 Thread M. Kristall
[snip] probe:HG_U95Av2:1138_at:395:301; Interrogation_Position=2631; ... probe:HG_U95Av2:107_at:543:519; Interrogation_Position=258; Antisense; ... probe:HG_U95Av2:1156_at:528:483; Interrogation_Position=2054; ... probe:HG_U95Av2:1102_s_at:541:589; Interrogation_Position=4316; [snip]

Re: reading a line at a time inefficient?

2006-05-17 Thread M. Kristall
Bryan R Harris wrote: I figured the OS would load the file in blocks, but I thought the blocks might only be 12k or something like that. Block sizes are often chosen based on average files sizes. Where there will be lots of small files, smaller block sizes - perhaps 12KB - are used, and the lon

Re: using "our" across blocks

2006-05-16 Thread M. Kristall
Oops, ignore the contradictions in my first message. The code shows what I meant where the words are misleading (or just plain wrong). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: using "our" across blocks

2006-05-16 Thread M. Kristall
Anthony Ettinger wrote: I want to double-check that it is correct to use "our" to import globals. #!/usr/bin/perl -w use strict; BEGIN { our $foo = 'foo'; } sub something { our $foo; our $bar; ...at this point I can see 'foo' and 'bar' values. } END { our $bar = 'bar'; } [snip

Re: array question

2006-05-10 Thread M. Kristall
for (my $i = 0; $i < @arry; $i++) { splice (@arry, $i, 1, split (' ', $arry[$i], 2)); } If one of the elements of @arry contains "one two three" then using "2" will add the two elements "one" and "two three" instead of the three elements "one", "two" and "three" so you may still be left with

Re: array question

2006-05-10 Thread M. Kristall
John W. Krahn wrote: for (my $i = 0; $i < @arry; $i++) { splice (@arry, $i, 1, split (' ', $arry[$i], 1)); } How does that populate the @new_array variable? Mine doesn't populate @new_array. It takes the original array and replaces it with the equivalent of everyone else's @new_array :-)

Re: array question

2006-05-09 Thread M. Kristall
chen li wrote: I have an arry like this: @arry=('AA bb','BB','CC AG') How do I turn it into new array like this: TMTOWTDI @new_array=('AA','bb','BB','CC','AG') my @new_array = split ' ', "@arry"; Both line codes work perfectly: my @new_array = map { split } @arry; or my @new_array = spl

Re: golf

2006-04-23 Thread M. Kristall
With while(), the $_ is already local. Wouldn't using that 'local' explicitly, add another local-layer? my $i = 5; $_ = 'Hi there!!!'; while ($_ = $i--) { print } print 543210 my $i = 5; $_ = 'Hi there!!!'; while (local $_ = $i--) { print } print 54321Hi there!!! for (<>) is the same as for (r

Re: Coding Styles

2006-04-23 Thread M. Kristall
Brent Clark wrote: Hi all Hi there I seem to be having a few run ins with the "Project Leader", in terms of my coding style. Im very much for modularizing my work - hence the OO concept. That is creating packages using return in my subroutine etc (Oh and using strict) But the ex Cobol Projec

Re: golf

2006-04-23 Thread M. Kristall
John W. Krahn wrote: Chad Perrin wrote: On Fri, Apr 21, 2006 at 12:48:51PM -0700, John W. Krahn wrote: print/.*/g,$"while<> Yeah, that's it. Woah, that's pretty short. You can make it even shorter: print/.*/g,$"for<> They aren't quite the same though. 'while' loops if the condition is sti

Re: golf

2006-04-21 Thread M. Kristall
Chad Perrin wrote: This is kind of a frivolous question, but . . . is there some way to golf this? while (<>) { s/\n/ /; print; } Oops, I misread that as s/\n//; Sorry :'( -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: golf

2006-04-21 Thread M. Kristall
Chad Perrin wrote: This is kind of a frivolous question, but . . . is there some way to golf this? while (<>) { s/\n/ /; print; } How about print/(.*)\n/while<> ? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: sorting an array of arrays by arr_el[$idx][2] (or something like that)

2006-04-18 Thread M. Kristall
Ed wrote: I want to sort the lines in the file by the 3rd column (Field, Internal, CM, DocAdmin) Since Perl doesn't really support multidimensional arrays but instead uses references, something like this should work: sort { $$a[2] cmp $$b[2] } @array; This is more or less like the typical sort

Re: combine 2 "open for reading" filehandles

2006-04-17 Thread M. Kristall
JupiterHost.Net wrote: Howdy list :) I'm having a bit of a time with combining 2 read filehandles. [snip] What I'd like to do is process $read_fh and $error_fh in the order they actually happen ( which is what open3($write_fh, $read_fh, $read_fh, ... does ) but still have the error handle a

Re: Question about File Uploads

2006-04-17 Thread M. Kristall
Mike Martin wrote: Hi I have a CGI script that uses filefields to get filenames before passing to the shell and I want to disable the creation of a tempfile. After googling for a while I cant find out where to turn this behaviour off. I have found references to $use_tempfiles variable, but am hav

Re: encoding of source file

2006-04-17 Thread M. Kristall
Brano Gerzo wrote: Hi all, I have bunch of TXT files. I'd like to know theirs encoding, for Try Encode::Guess -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: And a CGI question.

2006-04-11 Thread M. Kristall
Closing STDOUT should be good enough for the server. Alternatively, if you know how big the content you are sending is, you can send a Content-Length header, and assuming the client doesn't ignore that (it shouldn't), the client will say the page is done when it is. It might make more sense to

Re: Use Perl to extract keywords

2005-04-27 Thread M. Kristall
Robert Kerry wrote: I want to use Perl to extract keywords from plaintext, don't know whether there are some exsiting package / algorithm for doing that? Thank you. Regards, Robert. If you are attempting to "extract" keywords as a search engine might (i.e. find all words of substance), you might s

Re: Script that spans multiple files

2005-04-22 Thread M. Kristall
Charles K. Clarkson wrote: Daniel Kasak wrote: : : I have a large script ( 6000 lines ) that I'd like to break into : logical units. Is there a way I can tell perl to 'append' a list : of files into 1 script so that I can call subs from any of the : files and have them t

Re: sub declarations

2005-04-19 Thread M. Kristall
Manish Sapariya wrote: Thanks fxn, This certainly should help. List, Is there a search tool which can give me perldoc pages given a string. --- perldoc-q Search the text of questions (not answers) in perlfaq[1-9] --- does not seems to be powerful enough. Thanks and Regards, Manish On 04/08/2

Re: RE : Capturing the integer return value of a "C" program, called inside perl script

2005-04-19 Thread M. Kristall
Jose Nyimi wrote: -Message d'origine- De : Ambikesh Chaurasia [mailto:[EMAIL PROTECTED] Envoyé : dimanche 10 avril 2005 18:30 À : perl Objet : Capturing the integer return value of a "C" program, called inside perl script Hi Guys, I want to capture the return value of a "C" program call

Re: Encrpt a file

2005-04-18 Thread M. Kristall
Zentara wrote: On Mon, 18 Apr 2005 14:37:49 +0530, [EMAIL PROTECTED] (Anish Kumar K) wrote: Can any one suggest a good algorithm for encrpt and decrypt the files ..I donot want to use any perl module for that... I don't know if I would call it "good" encryption, but.. I wouldn't call it encr

Re: import() functions from another module

2005-04-14 Thread M. Kristall
Jay Savage wrote: [snip] But think a little bit about the convoluted namespace you created to get that function in there. Think also about this: why have you put this code into a module? So you can reuse it, presumably. Or at least that's the assumption I'm working with. Maybe you're even goin

Re: Uniq from array ?

2005-04-13 Thread M. Kristall
Chris Devers wrote: On Wed, 30 Mar 2005, Peter Rabbitson wrote: Anyway my 2c - I myself use the [$elided] archives quite a bit, which does not prevent me from owning hard prints of the Cookbook, the Pocket Ref and recently Object Oriented Perl. It however prevents from owning 2 pcs of each of t

Re: very new - need help with regular expressions

2005-04-12 Thread M. Kristall
John W. Krahn wrote: M. Kristall wrote: John W. Krahn wrote: As long as you realise that putting a space between the operator name and the left parenthesis may trigger a warning when warnings are enabled. (And you DO have warnings enabled, don't you?) $ perl -le'use warnings; print(

Re: very new - need help with regular expressions

2005-04-11 Thread M. Kristall
John W. Krahn wrote: M. Kristall wrote: John W. Krahn wrote: open INPUT, '<', 'record.txt' or die "Error, can't open 'record.txt' $!"; while ( ) { next unless /^\?/; print "$1\n" if /<([^>]+)>/; } close INPUT; We

Re: very new - need help with regular expressions

2005-04-11 Thread M. Kristall
John W. Krahn wrote: Brett Williams wrote: Hi :) Hello, I am still very new to perl (and programming) and am getting stuck with regular expressions. I have a text file in which I want to find, then print to screen all lines beginning with "?" and then print the text between the "<" and ">" char

Re: Regex against a scalar

2005-04-11 Thread M. Kristall
Offer Kaye wrote: On Wed, 23 Mar 2005 17:41:31 -0800, Perl wrote: Hi. I would like to search a scalar variable and have the output to another scalar. For example: $test = "This is some test data"; I want another scalar, $regex to hold the output of a regular expression lookup against $test. So some