Re: escape character in regex

2022-10-10 Thread John W. Krahn
On 2022-10-10 18:12, Henrik Park wrote: I know "/" is a special character for regex, which should be escaped. But if I put "/" in a variable and use the variable in regex, then it doesn't need the explicit escape. Like this one: $ perl -le '$delimiter="/"; $str="hello/world/buddy";

Re: Benchmark for Scala, Ruby and Perl

2022-01-15 Thread John W. Krahn
On 2022-01-15 00:04, Jon Smart wrote: Hello Paul Do you mean by undef $/ and with <$fh> we can read the file into memory at one time? $/ is the input record separator, newline by default. If undefined that means that the whole file is treated as one single record. Yes that would be faster

Re: memory mapped file example

2020-10-03 Thread John W. Krahn
On 2020-10-03 5:41 a.m., stefano cerbioni wrote: hi guys i try to read a memory mapped file created with c++ , this is a c++ code that i have [code] [snip code] [/code] how can read a memory mapped created ? thankz at all A memory mapped file should be just like any other file. Just

Re: question about perl script

2019-10-30 Thread John W. Krahn
On 2019-10-29 7:48 p.m., 刘东 wrote: Dear every one: Hello. I try to write a perl script to delet the content of file carp01_1_both.txt as same as from another file carp-carp01_TKD181002053-1_1_sg.txt, so to get a new file from file carp-carp01_TKD181002053-1_1_sg.txt but excluding file

Re: Help me with a regex problem

2019-10-25 Thread John W. Krahn
On 2019-10-25 3:23 a.m., Maggie Q Roth wrote: Hello Hello. There are two primary types of lines in the log: What are those two types? How do you define them? 60.191.38.xx/ 42.120.161.xx /archives/1005 From my point of view those two lines have two fields, the first

Re: perl script question

2019-10-10 Thread John W. Krahn
On 2019-10-09 7:21 p.m., 刘东 wrote: hellow: I have written a script, but it does not work, can you tell me what wrong with me? #! /usr/bin/perl use strict; use warnings; use Getopt::Long; my ($dir, $files, $file_name, $file_format, $file_dir, $file_main); GetOptions ('dr=s' =>\$dir); open

Re: perl script question

2019-10-10 Thread John W. Krahn
On 2019-10-09 7:21 p.m., 刘东 wrote: hellow: I have written a script, but it does not work, can you tell me what wrong with me? #! /usr/bin/perl use strict; use warnings; use Getopt::Long; my ($dir, $files, $file_name, $file_format, $file_dir, $file_main); GetOptions ('dr=s' =>\$dir); open

Re: symlink to "pack"

2019-09-09 Thread John W. Krahn
On 2019-09-08 12:20 p.m., Jorge Almeida wrote: On Sun, Sep 8, 2019 at 8:08 PM John W. Krahn wrote: On 2019-09-07 1:25 p.m., Jorge Almeida wrote: On Unix/Linux a character in a file name can be any character except a slash '/' character because that is used to separate path elements

Re: symlink to "pack"

2019-09-08 Thread John W. Krahn
On 2019-09-07 1:25 p.m., Jorge Almeida wrote: Sorry about the title, it's the best I can do... #!/usr/bin/perl use strict; use warnings; my $num=12; my $target=pack('n', $num); symlink($target, "foo") || die $!; It dies with "No such file or directory" No symlink is created. What I want is a

Re: Syntax "||" before sub

2018-11-22 Thread John W. Krahn
On 2018-11-22 8:08 a.m., David Precious wrote: You'll often see these operators used to provide default values. e.g. sub hello { my $name = shift; $name ||= 'Anonymous Person'; Which is usually written as: sub hello { my $name = shift || 'Anonymous Person'; I

Re: Code Assistance Pls

2018-11-21 Thread John W. Krahn
On 2018-11-21 3:08 a.m., Amanda Paziuk wrote: I'm hoping someone can assist as I'm having difficulty with parsing a section of the following configuration: This is the code I have: push @list, $datum; # should only contain '1', and '3' > > ... > foreach my $i (@list){ # loops

Re: help with a stat script

2018-07-12 Thread John W. Krahn
On Thu, 2018-07-12 at 19:35 +0800, Lauren C. wrote: > > My web is powered by Apache and PHP,its access log seems as blow, > > xx.xx.xx.xx - - [12/Jul/2018:19:29:43 +0800] "GET  > /2018/07/06/antique-internet/ HTTP/1.1" 200 5489 "https://miscnote.ne > t/"  > "Mozilla/5.0 (Macintosh; Intel Mac OS

Re: Removing a Pattern using a Regular Expression

2018-06-14 Thread John W. Krahn
On Wed, 2018-06-13 at 21:21 -0500, Martin McCormick wrote: > I wrote a small perl program to more quickly read all the > subjects in an email list.  One of the things the script does is > to remove the mailing list name which repeats for every message > and consists of a [, some English text and

Re: project euler #8

2018-06-06 Thread John W. Krahn
On Tue, 2017-05-16 at 14:01 +0800, derr...@thecopes.me wrote: I am working on problem #8 of the euler project. see below. > > > > The four adjacent digits in the 1000-digit number that have the > greatest product are 9 × 9 × 8 × 9 = 5832. > >

Re: regex with HEX ascii chars

2018-04-13 Thread John W. Krahn
On Thu, 2018-04-12 at 17:26 +0100, Gary Stainburn wrote: > I have a text file (created by  pdftotext) that I've imported into my > script. > > It contains ASCII characters 251 for crosses and 252 for ticks. ASCII defines 128 characters so those characters are not ASCII. John -- To

Re: compute depth of word in line

2018-03-10 Thread John W. Krahn
On Sat, 2018-03-10 at 00:14 +0100, hw wrote: > > Not really, the words I get from the ReadLine functions are not > organized in an array. > > I´ve come up with this function to compute the "depth" of a word: > > > sub get_depth { >   my $string = shift; > >   $string =~ s/\s/ /g; >   $string

Re: Find::Perl find not returning

2017-12-13 Thread John W. Krahn
On Wed, 2017-12-13 at 11:28 +, Mike Martin wrote: > Hi > I have the following code > > use strict; > use File::Find; > my @vsbe; > my $top='P:\PT-6\PT-60\PT-603\Shared\Data Store\Files Dump Folder'; > my $max_depth=9; > my $cnt1=0; > > find({wanted=>\,preprocess=>\},$top) ; > > sub wanted1

Re: Using Pack and Unpack

2017-12-06 Thread John W. Krahn
On Wed, 2017-12-06 at 21:53 -0600, Martin McCormick wrote: > A perl program needs to send binary data to an external device > such that 0xff looks like $ perl -le'my $x = sprintf q/%b/, 0xff; print $x' > I have a line in the program as follows: > > my $txstart =

Re: Use of uninitialized value for perl

2017-11-05 Thread John W. Krahn
On Sun, 2017-11-05 at 00:43 +, Dong Liu wrote: > I try used perl script to get characters from data: > > #!/usr/bin/perl -w > use v5.14; > while (){ > chomp; > my $line = ''; > $line = (split //,@_)[5]; At no point in your script do you or perl assign a value to the array @_ so

Re: Perl invocations

2017-10-29 Thread John W. Krahn
On Sun, 2017-07-02 at 11:16 -0400, Shawn H Corey wrote: > On Sun, 2 Jul 2017 14:29:25 +0200 > Eric de Hont wrote: > > > What it boils down to: use warnings as well as -w works, but -w is  > > considered old fashioned. > > The problem with -w is that it can't be turned

Re: [ANN] SurfShop 1.6.1 Shopping Cart Released

2014-09-21 Thread John W. Krahn
SSC_perl wrote: Again, let us know what you think! Your feedback, as always, is appreciated. Regards, Frank Jance Hello Frank, It looks like you still have some of the same problems I pointed out last year in November. To begin, these files do not have a terminating newline, so

Re: Suddenly.... Part 2

2014-07-31 Thread John W. Krahn
Peter Holsberg wrote: I think I've isolated the section that is not doing what I want. open (FHIN, $recapfile) or die $!; That would be better as: open my $FHIN, '', $recapfile or die Cannot open '$recapfile' because: $!; my $indexb; ## for the recapfile array my $ofile; You never use

Re: Where's this documented?

2014-03-20 Thread John W. Krahn
shawn wilson wrote: Oh, I guess I was thinking that using the file name repeats the stat (which it does). Since I was complaining about the ugliness of '_'. However, you're right - that works as well as (-f _)-- that doesn't look weird as shit? I've got issues moving my fingers into typing

Re: Where's this documented?

2014-03-18 Thread John W. Krahn
Shaji Kalidasan wrote: You can use more than one file test on the same file to create a complex logical condition. Suppose you only want to operate on files that are both readable and writable; you check each attribute and combine them with and: if (-r $file and -w $file) { ... } Each

Re: Turn part of a string into a single newline

2014-02-14 Thread John W. Krahn
Parysatis Sachs wrote: Hi everyone! Hello, I'm new to this mailing list as well as to programming and Perl in general. So there is a chance I might ask relatively stupid questions with very obvious answers... Please bear with me! So, here it goes: I have a very long string with lots of Ns

Re: [OT] SurfShopPRO Perl shopping cart system is now open source

2013-11-19 Thread John W. Krahn
SSC_perl wrote: Hi John, Hello, Thanks for getting back to me with your findings. I really appreciate it. I've gone through everything, made the changes that I could, and I have some questions to some of your remarks. You are using the value from readdir() without prepending the

Re: Need explanation of expression

2013-11-18 Thread John W. Krahn
Angela Barone wrote: Hello, Hello, Could someone explain the format of the following line and how to read it? $name = $fieldname =~ /\[(.*?)\]/ ? $main::global-{'form'}-{$1} : $out; Do the contents of $fieldname match the pattern /\[(.*?)\]/? If they do then assign

Re: [OT] SurfShopPRO Perl shopping cart system is now open source

2013-11-14 Thread John W. Krahn
SSC_perl wrote: Hello, Hello, This is a one-time post to announce that the SurfShopPRO Perl shopping cart system is going open source. Our site hasn't been fully updated yet, but you can download the cart and check it our for yourself. We are looking for developers, designers,

Re: Problem rewinding the __DATA__ filehandle

2013-10-25 Thread John W. Krahn
Jim Gibson wrote: On Oct 25, 2013, at 4:46 PM, Shaji Kalidasan wrote: Dear Perlers, I am trying to print the matching lines using __DATA__ filehandle and for the very first time it prints the desired lines, but as soon as I rewind it using seek, it is printing lines from the very beginning

Re: Help needed with here documents (security?)

2013-10-24 Thread John W. Krahn
Ronald F. Guilmette wrote: In message5268663c.4040...@stemsystems.com, Uri Guttmanu...@stemsystems.comwrote: i think a blank line with . will end input to smtp servers. try that too in the line after the from field. DING DING DING!!! Give that man a cupie doll, because he's the winner of

Re: Not following the action here.

2013-10-03 Thread John W. Krahn
Harry Putnam wrote: John W. Krahnjwkr...@shaw.ca writes: First, thanks for the input. [...] my $exe = 33261; Or: my $exe = 0100755; Where does that come from? And it appears some kind of conversion must take place. If you print $exe right after assigning it 0100755, it still shows

Re: Quizzing students with Perl

2013-10-03 Thread John W. Krahn
Rick T wrote: The code below (server addresses Xed out for security) has been used on my website for years, but it does seem to misbehave on rare occasions, so I have a few questions on how I might improve it. I apologize in advance for my amateurish coding; I’m a high school teacher who cannot

Re: Need help with a programming problem

2013-10-02 Thread John W. Krahn
Peter Holsberg wrote: sigh Let me start over. The file I want to modify has a 6-digit filename and an extension htm. For example, 131002.htm I'm working in Windows, with Strawberry perl, with Randall L. Schwartz's Randal L. Schwartz John -- Any intelligent fool can make things bigger and

Re: Need help with a programming problem

2013-10-02 Thread John W. Krahn
Shawn H Corey wrote: On Wed, 02 Oct 2013 13:57:36 -0400 Peter Holsbergpjh42atpobox@gmail.com wrote: blushing I was so upset that I deleted it all! It seems to me that it should be fairly straightforward, but at 79, the old synapses aren't firing quite as well as they used to. Can you

Re: Not following the action here.

2013-10-02 Thread John W. Krahn
Harry Putnam wrote: Why is this script showing uninitialized variable warnings? - -----=----- - #!/usr/local/bin/perl use strict; use warnings; use File::Find; my $exe = 33261; Or: my $exe = 0100755; my $eperm; You don't really need this variable at

Re: Sleep

2013-09-15 Thread John W. Krahn
Shawn H Corey wrote: On Sun, 15 Sep 2013 13:00:36 -0700 Unknown Userknowsuperunkn...@gmail.com wrote: If my perl script has a sleep for say 300 seconds, when the sleep is being run is there any way i can find the time remaining in the sleep say by sending a signal? Thanks, Not directly.

Re: negate, !!$a, $a!!, flip-flop

2013-09-12 Thread John W. Krahn
Hans Ginzel wrote: Hello! Hello, Is there a shorter way to write $a = ! $a, please? Something analogous to ++ and -- operators like $a !! or !! $a would negate the variable $a and return its previous or new value respectively. You can do that if you use a reference to a scalar like this:

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread John W. Krahn
Hans Ginzel wrote: Hello! Hello, Is there a shorter way to write $a = ! $a, please? No. John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To

Re: negate, !!$a, $a!!, flip-flop

2013-09-10 Thread John W. Krahn
David Christensen wrote: September 10, 2013 06:15 Hans Ginzel wrote: Is there a shorter way to write $a = ! $a, please? Something analogous to ++ and -- operators like $a !! or !! $a would negate the variable $a and return its previous or new value respectively. I don't believe Perl has

Re: Filtering Characters

2013-09-03 Thread John W. Krahn
Matt wrote: I have this: while (IN) { 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: Print to several logs

2013-08-28 Thread John W. Krahn
Rob Dixon wrote: On 27/08/2013 23:06, John W. Krahn wrote: my %logs = ( 'one.log' = undef, 'two.log' = undef, ); for my $name ( keys %logs ) { open my $FH, '', $name or die Cannot open '$name' because: $!; $logs{ $name } = $FH; } for my $log_FH ( values %logs ) { print $log_FH kdkdkdkd

Re: Print to several logs

2013-08-27 Thread John W. Krahn
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.log'; my $tmplog2 = 'two.log';

Re: grab pattern from start and end block

2013-07-12 Thread John W. Krahn
Agnello George wrote: hi Hello, 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 format

Re: grab pattern from start and end block

2013-07-12 Thread John W. Krahn
Dr.Ruud wrote: 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

Re: Perl file and STDERR

2013-07-09 Thread John W. Krahn
jitendra B wrote: Hi All, Hello, Can you please let me know the following snippset? why it is used for? select( STDERR ); Select STDERR as the default filehandle. $| = 1; Turn on autoflush for the current default filehandle. (Redundant because STDERR autoflushes by default.)

Re: last

2013-06-24 Thread John W. Krahn
Dr.Ruud wrote: 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

Re: last

2013-06-24 Thread John W. Krahn
Brandon McCaig wrote: On Sun, Jun 23, 2013 at 12:02:38PM +0300, Shlomi Fish wrote: last is not a function (a.k.a subroutine) - it cannot be. It is a special statement which is handled in a special way by the Perl interpreter. redo and next are not functions either for a similar reason. I

Re: Tips or Tricks to print out tab-separated data?

2013-06-24 Thread John W. Krahn
Brandon McCaig wrote: On Fri, Jun 21, 2013 at 02:15:39PM +0100, Gary Stainburn wrote: What your code did was to tag the \n onto the end of the array then pass the whole thing to join. Gary is basically correct, but he worded it wrongly. When Perl calls subroutines it basically flattens

Re: Tips or Tricks to print out tab-separated data?

2013-06-21 Thread John W. Krahn
Marc Perry wrote: Hi, Hello, I routinely generate rows of tab-separated data like this; my @array = ( boris, natasha, rocky, bullwinkle); print join \t, @array, \n; However this code inserts an extra tab between bullwinkle and the newline character. So when it is important I do this

Re: sha-2 sum of files?

2013-06-13 Thread John W. Krahn
Jim Gibson wrote: On Jun 13, 2013, at 10:51 AM, lee wrote: + Is print and printf pretty much the same thing implementation wise? I'm wondering if printf might involve more overhead so it might be less efficient, depending on what you're doing. They are pretty much the same. print will

Re: Return values more than 256?

2013-03-07 Thread John W. Krahn
Brandon McCaig wrote: On Thu, Mar 07, 2013 at 10:21:40AM +0100, WFB wrote: Hi, List, Hello, To test our software I use perl to start it several times. My perl script gather some information and start then the program with different parameters. It works very well, but I have a problem with

Re: nested subroutines

2013-03-02 Thread John W. Krahn
Chris Stinemetz wrote: Thanks in advance. I have a subroutine inside another subroutine in a module I am tyring to put together. I would like to pass the value assigned to $srt in the while loop as the parameter for the session_attempts subroutine called withing the processPegs subroutine.

Re: obfuscating code

2013-02-13 Thread John W. Krahn
Kevin Walzer wrote: I'm an experienced developer in several other languages (Python, Tcl, AppleScript, JavaScript, C/Objective C), so I'm quite familiar with structuring a program--but as I work on learning Perl, I find it somewhat obscure, if not downright obfuscated. None of the other

Re: Fwd: Question regarding while loops for reading files

2013-02-13 Thread John W. Krahn
Tiago Hori wrote: Hey Guys, Hello, I am still at the same place. I am writing these little pieces of code to try to learn the language better, so any advice would be useful. I am again parsing through tab delimited files and now trying to find fish from on id (in these case families AS5 and

Re: matching certain lines

2013-02-09 Thread John W. Krahn
Chris Stinemetz wrote: I would like to only work with the data that has a line with |68| in it print that line and then print each subsequent lines in that match /\|7\|\d+\|\d+/ until #END is reached and then repeat for the rest of the input data. Below is what I have attempted. Thanks in

Re: converting dates to epoch seconds and back

2013-01-18 Thread John W. Krahn
Bill Stephenson wrote: When converting DMYHMS to Epoch Seconds and back I get cheated out of a day. Why? Bill -- #!/usr/bin/perl use strict; use warnings; use Time::Local; my ($time, $month, $day, $year, $seconds, $minutes, $hours, $wday, $yday, $isdst); my $start_date = '11/30/2012';

Re: File:: Find help

2013-01-10 Thread John W. Krahn
punit jain wrote: Hi, Hello, I have a requirement where I have directory structure like : - test -- test/user1/files/, test/user2/files/, test/user3/files/ etc. under sub-directories with usernames I have file with name usersettings. So the final structure as : - test / user1 /

Re: Substituting letters for numbers

2013-01-03 Thread John W. Krahn
Hamann, T.D. wrote: Hello, Hello, Given a string: i994 where I want to replace the 'i' by a '1' the following regex succesfully replaces the letter by a number: s/(i)(\d\d\d)/1$2/; tr/i/1/; However, given a string: i99o where I want to replace the 'i' by a '1' and the 'o' by a '0'

Re: Array vs List output

2013-01-02 Thread John W. Krahn
Neeraj wrote: Hi, I am new to Perl and perplexed with output of printing entire Array vs printing each element +4 ## check Array vis-a-vis List +5 +6 @arr = qwhello happy new year 2013; +7 print my array is : @arr \n; +8 +9 ## lets print in a loop +10 my

Re: Array vs List output

2013-01-02 Thread John W. Krahn
*Shaji Kalidasan* wrote: Neeraj, If you print an array inside double quotes, each item of the array is separated by the value specified in Perl special variable $ which is the Output list separator. (interpolated lists) It is just the _List Separator_ , it has nothing to do with output.

Re: grouping in regex

2012-12-23 Thread John W. Krahn
Danny Gratzer wrote: Shouldn't that *.** be *.*? *to avoid having it consume everything? It is not clear exactly which *.** you are referring to however a non-greedy match does not necessarily consume less than a greedy match. John -- Any intelligent fool can make things bigger and more

Re: data extract - Help !

2012-11-13 Thread John W. Krahn
jet speed wrote: I have a file with similar data, around 10,000 entries with similar format. i need to extract the output in below format. I can match the WWN and push into an arrray, however i am not sure how to reference the WWN to its corresponding device displayDevNum as in the below

Re: Is comp.lang.perl dead?

2012-10-22 Thread John W. Krahn
Danny Gratzer wrote: I'm looking at comp.lang.perl and it doesn't seem like it's had new posts in well, years. Is it dead? It died in 1995. If so are there any other good perl groups you'd recommend? comp.lang.perl.misc John -- Any intelligent fool can make things bigger and more

Re: My script is OUT OF CONTROL!

2012-09-14 Thread John W. Krahn
jmrhide-p...@yahoo.com wrote: Hi, and thanks for volunteering to help! 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

Re: regx substitution question

2012-09-05 Thread John W. Krahn
Shlomi Fish wrote: On Wed, 5 Sep 2012 14:33:13 +0100 jet speedspeedj...@googlemail.com wrote: i have an regx question. i have the array contents, now i want to remove the first 2 characters (fc) of each element in the array and store it in a second array ex: @array2 @array =fc20/1, fc30/22,

Re: regx substitution question

2012-09-05 Thread John W. Krahn
Shlomi Fish wrote: Replying to myself, I have a correction which Shawn inspired. On Wed, 5 Sep 2012 16:49:42 +0300 Shlomi Fishshlo...@shlomifish.org wrote: On Wed, 5 Sep 2012 14:33:13 +0100 jet speedspeedj...@googlemail.com wrote: i have an regx question. i have the array contents, now i

Re: regx substitution question

2012-09-05 Thread John W. Krahn
Shlomi Fish wrote: thanks for your answer. See below for my response. On Wed, 5 Sep 2012 09:54:11 -0400 Shawn H Coreyshawnhco...@gmail.com wrote: On Wed, 5 Sep 2012 14:33:13 +0100 jet speedspeedj...@googlemail.com wrote: i have an regx question. i have the array contents, now i want to

Re: how to handle two input files

2012-08-29 Thread John W. Krahn
timothy adigun wrote: Hi, Hello, On 8/29/12, timothy adigun2teezp...@gmail.com wrote: for(my $i=0; $i= length(@startSite)-1; $i++) { The above could be: for(my $i=0; $i= scalar (@startSite); $i++) { ... for(my $i=0; $i= scalar (@startSite); $i++) { ## Oops for(my

Re: how to handle two input files

2012-08-29 Thread John W. Krahn
timothy adigun wrote: On 8/29/12, John W. Krahnjwkr...@shaw.ca wrote: timothy adigun wrote: On 8/29/12, timothy adigun2teezp...@gmail.com wrote: for(my $i=0; $i= length(@startSite)-1; $i++) { The above could be: for(my $i=0; $i= scalar (@startSite); $i++) { ...

Re: close file if it's open

2012-08-28 Thread John W. Krahn
lina wrote: Thanks Jim and John. btw, what does the fileno mean? mean file-not-open? It means file number. For example, STDIN is file number 0, STDOUT is file number 1, STDERR is file number 2 and the next file opened is file number 3, etc. John -- Any intelligent fool can make things

Re: close file if it's open

2012-08-27 Thread John W. Krahn
lina wrote: Hi, Hello, I don't know which is the best way to check whether this file is open or not, Here it what I came out so far, #!/usr/bin/env perl use strict; use warnings; use autodie qw(open close); use 5.012; my $fn = new_30.pdb; open my $fh, '', $fn; my $ofh; while(my $line

Re: a condition

2012-08-26 Thread John W. Krahn
Wang, Li wrote: Dear All Hello, Thanks very much for your help! I tried the script with my real data and found out that the situation gets more complicate. The following is part of my data: scaffold_1_13528T/T C/T T/T C/T T/T C/T T/T T/T N/N T/T

Re: a condition

2012-08-25 Thread John W. Krahn
Wang, Li wrote: Dear All Hello, I have an array of a series of strinngs. I want to set up a condition in which all the scalers in the array are not the same. For example AB AB AB AB AB (delete the array) AB AC AB AB AB (Keep the array) AB AC AD AB AB (keep) $ perl -le' for ( [ AB, AB,

Re: grep array of arrays

2012-08-23 Thread John W. Krahn
Chris Stinemetz wrote: Hello List, Hello, I'm trying to grep an array of arrays, but I am getting the following error: Can't use string (1) as an ARRAY ref while strict refs in use at form.pl line 121,$COORDS line 1281. Press any key to continue . . . Below is the grep statement: print

Re: matching array elements from hash ?

2012-08-19 Thread John W. Krahn
jet speed wrote: Hi All, Hello, Is there a way to find matching array elements from hash. ex: @names = ( abc. def. ghi, jky; ); %stud = ( abc = 34, nba =99, def =24, ghi= 33); How can i go throught each elements of has %stud and print the matching array value in this case abc =34

Re: Unable to change pos in regex match

2012-08-15 Thread John W. Krahn
Paul Anderson wrote: [ snip ] #!/usr/bin/myperl -w # euler8.pl --- Euler Problem 8 # Author: Paul Andersonwackyvorlon@paul-andersons-macbook-pro-3.local # Created: 14 Aug 2012 # Version: 0.01 use warnings; use diagnostics; use 5.16.0; #use strict; no strict; # The number.

Re: case statement in perl

2012-08-01 Thread John W. Krahn
Paul.G wrote: Below is an extract from the perl script, the switch/case statement seemed like a simple solution. # Mail Program # operation_CHECKFREEPVS(); print $numPV \n; # print $FreePV[1] $FreePV[0] $numPV\n; if ($numPV ne 0 ) {

Re: case statement in perl

2012-08-01 Thread John W. Krahn
Paul.G wrote: The example below is just a test, I need to be able to insert multiple values into a command, those values can be either 1, 2 or upto 5. Below is closer to the working example, but I will read that document and to help make a final decision. # Check Free PV's

Re: updating variable in Parent using Parallel::ForkManager

2012-07-30 Thread John W. Krahn
punit jain wrote: Hi, Hello, I am facing an issue. Below is code snippet : - my $pm = new Parallel::ForkManager(10); my $count=0; foreach my $user (@users) { $pm-start($user) and next; my $result; --- do some processing ---

Re: How to zip all files which are value from awk command ?

2012-07-26 Thread John W. Krahn
Jack Vo wrote: Hi all, Hello, I need to compress many files in a directory on server. I use awk and zip command to compress these files. By awk command, I filter theses file : *# ls -latr | grep iMAP.med0 | awk '{print $9}'* You are doing way too much just to get the correct file names.

Re: How to set as record separator in a Perl one liner?

2012-07-16 Thread John W. Krahn
Michael Brader wrote: On 07/16/2012 04:05 PM, De-Jian Zhao wrote: I want to change the record separator in a Perl one liner with as the separator. However, I tried without success. The perlrun document (http://perldoc.perl.org/perlrun.html#Command-Switches) says that*

Re: printing anonymous array

2012-07-08 Thread John W. Krahn
timothy adigun wrote: [snip] my %new_hash = (); foreach my $data1 ( keys %$hash1 ) { while ( my ( $key, $value ) = each %$hash2 ) { my ($new_value) = keys %$value; $new_hash{$key} = $new_value if $data1 == $key; } } No need for the nested llops: my %new_hash; for

Re: how to transform xyz into matrix

2012-06-29 Thread John W. Krahn
lina wrote: On Thu, Jun 28, 2012 at 4:44 PM, John W. Krahnjwkr...@shaw.ca wrote: lina wrote: I have some data like: 0.35 3.41 1 0.35 4.24 1 0.35 4.35 2 0.36 0.36 1 0.36 1.32 1 0.36 1.45 1 0.36 1.46 1 wish the output look like 0.36 1.32 1.45 1.46 3.41 4.24 4.35 0.35 0 0

Re: how to transform xyz into matrix

2012-06-28 Thread John W. Krahn
lina wrote: Hi, Hello, I have some data like: 0.35 3.41 1 0.35 4.24 1 0.35 4.35 2 0.36 0.36 1 0.36 1.32 1 0.36 1.45 1 0.36 1.46 1 wish the output look like 0.36 1.32 1.45 1.46 3.41 4.24 4.35 0.35 0 0 0 0 11 2 0.36 1 1 1 1 0

Re: search scalers of an array in another file

2012-06-21 Thread John W. Krahn
Wang, Li wrote: Dear list members Hello, I am a very beginner of perl programming. Welcome to the Perl beginners mailing list. I am trying to write a script to search all scalers of one array (geneIDFile) in another file (annotationFile). If it is found and matched, output the whole

Re: Save contents of double-quotes to a variable?

2012-06-16 Thread John W. Krahn
Grant wrote: Can anyone show me how to save to a variable the contents of a set of double-quotes in a string? The string could look like any of these: phrase1 phrase2 phrase3 phrase2 phrase3 phrase1 phrase3 phrase4 In all of these examples, phrase2 would be saved to the variable. Many thanks

Re: Sluggish code

2012-06-11 Thread John W. Krahn
venkates wrote: Hi all, Hello, I am trying to filter files from a directory (code provided below) by comparing the contents of each file with a hash ref (a parsed id map file provided as an argument). The code is working however, is extremely slow. The .csv files (81 files) that I am reading

Re: Argument isn't numeric

2012-06-10 Thread John W. Krahn
jmrhide-p...@yahoo.com wrote: Hello and thanks for volunteering your time! Hello. (And it's Perl, not PERL. :-) I'm returning to PERL after about a year and am struggling to remaster some syntax: #!/usr/local/bin/perl use warnings; use strict; use diagnostics; # Converts current

Re: subroutine returning data

2012-06-05 Thread John W. Krahn
Shlomi Fish wrote: On Mon, 04 Jun 2012 14:19:27 -0700 John W. Krahnjwkr...@shaw.ca wrote: Chris Stinemetz wrote: I have a subroutine that I want to return 1 only if the value of %{$href-{$_[0]}} is equal to 'ND' for the whole 24 occurences. One way to do it: sub site_offAir {

Re: subroutine returning data

2012-06-05 Thread John W. Krahn
[ Please do not top-post your replies. Please remove non-relevant text from your reply before posting. TIA ] Jack Maney wrote: ProTip: The top two results from Google state: PROTIP | Know Your Meme About PROTIP is a term often used in forums and comments to preface snarky, obvious,

Re: lexical scope

2012-06-05 Thread John W. Krahn
Chris Stinemetz wrote: Why does this short program only seem to capture the last line of input in the @array, but when I put the for loop inside the while loop all lines of input are available in @array. I thought by declaring the @array outside the while loop would make all of its contents

Re: subroutine returning data

2012-06-04 Thread John W. Krahn
Chris Stinemetz wrote: I have a subroutine that I want to return 1 only if the value of %{$href-{$_[0]}} is equal to 'ND' for the whole 24 occurences. One way to do it: sub site_offAir { return values %{ $href-{ $_[ 0 ] } } == grep( $_ eq 'ND', values %{ $href-{ $_[ 0 ] } } ) ? 1 : '';

Re: parsing script help please

2012-05-31 Thread John W. Krahn
nathalie wrote: Hi Hello, I have this format of file: (see attached example) 1 3206102-3207048 3411782-3411981 3660632-3661428 2 4481796-4482748 4483180-4483486 and I would like to change it to this 1 3206102-3207048 1 3411782-3411981 1 3660632-3661428 2 4481796-4482748 2 4483180-4483486

Re: Perl HTTP Get

2012-05-30 Thread John W. Krahn
Chris Nehren wrote: On Wed, May 30, 2012 at 16:22:29 -0500 , Matt wrote: I did this. Snippet from larger code: eval { $rststr = ; local $SIG{ALRM} = sub { die get timeout }; alarm(30); $rststr = get(http://; . $dst . /request.htm ); # try to get my data

Re: Help required to extract multiple text fields from a text string

2012-05-27 Thread John W. Krahn
Michael Rasmussen wrote: On Sat, May 26, 2012 at 05:52:19PM +0100, Rob Dixon wrote: On 26/05/2012 14:07, pa...@fsmail.net wrote: From: Rob Dixonrob.di...@gmx.com On 26/05/2012 13:51, pa...@fsmail.net wrote: split is slower than the correct regex matching. That is complete nonsense. Can

Re: To quote variables or not

2012-05-23 Thread John W. Krahn
sono...@fannullone.us wrote: Subject: To quote variables or not Your question is not about quoting variables, which is bad, but about quoting hash keys. See: perldoc -q quoting A script that I'm refactoring has global variables in two different styles, e.g.:

Re: Why not match?

2012-05-19 Thread John W. Krahn
Shlomi Fish wrote: On Sat, 19 May 2012 12:04:16 -0500 Xi Chencxde...@gmail.com wrote: I have a simple code, but it doesn't work and don't know why. Please see it below: Input file: 1.txt which including number and letter o in one line. 10o10o10 Wanted output file: 2.txt in

Re: Use of uninitialized value in length

2012-05-17 Thread John W. Krahn
Chris Stinemetz wrote: Hello List, Hello, I'm stumped on this one. I'm getting this error: Use of uninitialized value in length at ./DBSR.pl line 21, line 6. Use of uninitialized value in length at ./DBSR.pl line 21, line 8. Use of uninitialized value in length at ./DBSR.pl line 21,

Re: insert

2012-05-07 Thread John W. Krahn
timothy adigun wrote: On Mon, May 7, 2012 at 8:36 AM, linalina.lastn...@gmail.com wrote: I have two files, one with 3 2 1 another is: 3 1 3 2 6 3 How can I insert the first file into the middle of the second file, This is one way to do it: #!/usr/bin/perl use warnings; use strict;

Re: sort and count match in file

2012-04-15 Thread John W. Krahn
Вячеслав Агапов wrote: Hello all. Hello, I have a file with logs 2012-04-13 17:06:10,881 test:dom1 CRIT home 2012-04-13 17:06:10,882 work:dom1 CRIT home 2012-04-13 17:06:10,882 my:dom1 CRIT home 2012-04-13 17:06:10,881 test:dom2 CRIT home 2012-04-13 17:06:10,882 work:dom2 CRIT home

  1   2   3   4   5   6   7   8   9   10   >