Re: sleep exactly after n seconds (sleep finishing longer than specified)

2009-04-22 Thread John W. Krahn
Michael Alipio wrote: Hi, Hello, I have a script that forks a child. at the parent, i have a line that tells it to sleep for n seconds. Once the 3 seconds have passed, it will kill the child process. I noticed that most of the time, sleep doesn't count exact seconds.. most of the time it's l

Re: Aliasing functions

2009-04-21 Thread John W. Krahn
Kelly Jones wrote: I want foo() and bar() to do the same thing. One way to do this: sub foo {return bar(@_);} Is there a more clever way using \&bar and things like that? $ perl -le' use warnings; use strict; sub bar { print "in sub bar: @_" } bar 1, 2, 3; sub foo { goto &bar } foo 4, 5,

Re: Bareword "Google::Adwords::Campaign" not allowed while "strict subs" in use

2009-04-19 Thread John W. Krahn
Grant wrote: I'm trying to use the Google::Adwords perl modules but I'm getting: Bareword "Google::Adwords::Campaign" not allowed while "strict subs" in use Here is the beginning of my script: use Google::Adwords::Campaign; use Google::Adwords::CampaignService; sub { my $campaign = Google::Adw

Re: Data Comparison

2009-04-18 Thread John W. Krahn
Nabeel wrote: Greetings, I need to be able to re-read a file every 60 seconds until the two changing values are the same in my data file. Once the values become the same the script simply exits. Not exactly sure if my filehandle will reread itself every 60 seconds either but I keep getting

Re: help needed to get over endless loop

2009-04-17 Thread John W. Krahn
Brian wrote: John W. Krahn wrote: Brian wrote: This is what I'm using upto the code that is giving me a headache. I know it's messy, but I have no training in PERL, I am trying to forward-engineer this cgi by back-engineering from html templates I created and which were chosen usi

Re: help needed to get over endless loop

2009-04-17 Thread John W. Krahn
Brian wrote: This is what I'm using upto the code that is giving me a headache. I know it's messy, but I have no training in PERL, I am trying to forward-engineer this cgi by back-engineering from html templates I created and which were chosen using $t->src [ *SNIP* ] whe

Re: help needed to get over endless loop

2009-04-17 Thread John W. Krahn
Brian wrote: This is what I'm using upto the code that is giving me a headache. I know it's messy, but I have no training in PERL, I am trying to forward-engineer this cgi by back-engineering from html templates I created and which were chosen using $t->src thanks for any help Brian #! c:

Re: Cannot resolve the read/write issue...

2009-04-17 Thread John W. Krahn
Joseph Mwesigwa Bbaale wrote: Please help... *This is the original line in outFile* *This goes into inFile* I was expecting to find the two lines above in the file "*outFile*" after running the code below: #!/usr/bin/env perl use warnings; use strict; use 5.010; `touch inFile`; `touch o

Re: reading files c vs perl

2009-04-15 Thread John W. Krahn
Emen Zhao wrote: This is off topic. But I'm just curious about why "4096" is picked here. Is there any particular reason behind it? I guess you can even calc the lines like this - perl -0777 -wne 'print scalar ($_=~s/\n//g)' filename Except that it's slower than using tr///: $ time perl -ln077

Re: Syntax query

2009-04-15 Thread John W. Krahn
Chas. Owens wrote: On Wed, Apr 15, 2009 at 09:20, Rajini Naidu wrote: I am trying to execute the below line in the perl program and returns a value 0. my $test2 = ""; my $include = "file"; $test2 = system("/usr/atria/bin/cleartool desc \$include | grep created | awk -F\" \" \'{print \$2}\'

Re: if statement being ignored

2009-04-15 Thread John W. Krahn
Robert Citek wrote: On Wed, Apr 15, 2009 at 12:08 AM, Brian wrote: could someone please help me with this little problem? I am trying to include an if statement part way through printing. When the program reaches the line if ($Lang = fr ) { print " that line gets ignored and the cgi keeps g

Re: reading files c vs perl

2009-04-15 Thread John W. Krahn
Dermot wrote: 2009/4/14 Chas. Owens : On Tue, Apr 14, 2009 at 11:49, Rick wrote: is it true that perl will be just as fast as c for reading files ? for example cow...@amans:~$ time cat /usr/share/dict/words | perl wc.pl my $count = 0; $/ = \4096; while (<>) { $count += tr/\n//;

Re: Match and split on array help with output

2009-04-14 Thread John W. Krahn
John W. Krahn wrote: p...@highdeck.com wrote: Hi john, Hello, thanks for the prompt reply. Ok, here's what I'd like it to do. #!/usr/bin/perl # # Build Initial list and put into array. @serverlist = `/usr/bin/wget -q -O - http://www.amazon.co.uk`; for ($index =

Re: Match and split on array help with output

2009-04-14 Thread John W. Krahn
p...@highdeck.com wrote: Hi john, Hello, thanks for the prompt reply. Ok, here's what I'd like it to do. #!/usr/bin/perl # # Build Initial list and put into array. @serverlist = `/usr/bin/wget -q -O - http://www.amazon.co.uk`; for ($index = 0; $index <= $#serverlist; $inde

Re: Match and split on array help with output

2009-04-14 Thread John W. Krahn
p...@highdeck.com wrote: Hi all, Hello, I have some basic code that I want to pull out the web addresses from web pages. Would like to keep it as basic as possible for easy reading. The line to replace http with newline seems to work ok. however the "match" line doesnt seem to pull out the r

Re: Turn off $ anchor greedy behavior

2009-04-14 Thread John W. Krahn
Michael Alipio wrote: Hi, Hello, Subject: Turn off $ anchor greedy behavior Anchors are not greedy. Anchors don't even match characters. I have a $string that is separated by , and space; boy, pig, 123, 123:412adbd, d0g, lajdlf134><<_ lkadsf !234, Now I want to capture the string(s)

Re: output record separator in one liner

2009-04-13 Thread John W. Krahn
Rick wrote: perl -lane' print "$F[0] ", "$F[4]" , " $F[5]";' Is there anyway to incoporate $\ <- output record separtor to do this instead of printing out w/ manual spaces beteween the variables? The Output Record Separator is what comes at the end of the record (or line in this case), in

Re: Looking for a quick, easy way to time system process to the sub-second

2009-04-10 Thread John W. Krahn
Dan Huston wrote: Greetings All: Hello, I have a script that I am using to run a series of sql statements against two different Oracle databases to compare performance based on a request from our DBAs. I am currently using code like this: $time1 = time(); $result = `$this_comm`; $time

Re: LWP

2009-04-08 Thread John W. Krahn
ANJAN PURKAYASTHA wrote: I have a file stored at a location: http://parent_dir/file Which among gazillion LWP options can I use to download and store the file on my machine? Have you read the LWP cookbook? perldoc lwpcook John -- Those people who think they know everything are a great anno

Re: Using array from subroutine

2009-04-05 Thread John W. Krahn
Thomas H. George wrote: In order to call them from menubuttons I moved my code into subroutines. sub open_file { if ( ! open NEWFILE, "<$file") { die "Could Not Open $file: $!" } else { my @lines = ; my() *creates* a new variable that is only vis

Re: Database row sets: working with ref to array-of-refs to array

2009-04-01 Thread John W. Krahn
Chap Harrison wrote: On Apr 1, 2009, at 2:04 PM, Chas. Owens wrote: If I understand you correctly, you want a map[1] that feeds a join[2]: #!/usr/bin/perl use strict; use warnings; my @aref = ( [qw/a1 b1 c1/], [qw/a2 b2 c2/], [qw/a3 b3 c3/], ); print join(", ", map { "($_->[0]=

Re: Pattern matching question

2009-03-31 Thread John W. Krahn
Richard Hobson wrote: Hi, Hello, Please be patient with this beginner. I have a subrouting as follows, that prints out an ASCII representation of chess board sub display_board { foreach (0..7) { my $ref = @_[$_]; That should be: my $ref = $_[$_]; Or better: f

Re: Array question

2009-03-30 Thread John W. Krahn
Dave Tang wrote: On Tue, 31 Mar 2009 04:49:17 +1000, John W. Krahn wrote: Or instead of using arrays you could store the 1s and 0s in strings: $ perl -le' my $string = "10110111001"; print $-[0] while $string =~ /0/g; ' 1 4 8 9 Could you explain how the above code w

Re: Array question

2009-03-30 Thread John W. Krahn
ANJAN PURKAYASTHA wrote: Hi, Hello, Here is my problem; I have a series of arrays with 0s and 1s. here is an example: (1, 0, 1, 1). I need to parse through this series of arrays and extract the index of the 0s in the array. Is there any quick way of doing this? $ perl -le' my @array = ( 1,

Re: Input from bash shell to perl -e

2009-03-30 Thread John W. Krahn
D. Crouse wrote: I have a perl -e function in my .bashrc file. This sources in the perl -e function so I can run it by just the command name. I'm having trouble with the substitution of my $1 bash variable into the perl -e function. Here is what I have so far. grepi () { perl -ne 'BEGIN {$/ = "

Re: Use of my on left side breaks STDIN on right side?

2009-03-29 Thread John W. Krahn
Kelly Jones wrote: perl -le '$x=; print $x' hello <- I TYPED THIS IN AND HIT RETURN hello perl -le 'my($x)=; print $x' hello <- I TYPED THIS IN AND HIT RETURN [no answer, hangs forever] $x= is in scalar context so only one line is read. ($x)= is in list context so readline keeps reading ut

Re: bit patterns and bitwise operations

2009-03-27 Thread John W. Krahn
Dermot wrote: Hi All, Hello, I have been trying to write this email for a day or two but the content keeps shifting as my understanding of the problem develops. I have encountered a bit of code that I am struggling to understand completely. The code is for dealing with database fields that a

Re: query in searching

2009-03-24 Thread John W. Krahn
Rajini Naidu wrote: Hi, Hello, I am trying to search for a pattern in a file in my perl script. Syntax used is : system("grep \"$res\" ${data_dir}/${node}.load > /tmp/${day[0]}.${day[1]}.${day[2]}.${node}.log"); But the grep command is'nt successful in getting the desired string. Am I miss

Re: whatz wrong here ?

2009-03-23 Thread John W. Krahn
igotux igotux wrote: Hi Team, Hello, Can someone explain what is wrong happeneing here ? $ perl -e 'use Business::ISBN; $isbn_object = new Business::ISBN('0-59610-206-2');print $isbn->as_string;' Can't call method "as_string" on an undefined value at -e line 1. Change: print $isbn->as_str

Re: Editing file

2009-03-20 Thread John W. Krahn
Martin Spinassi wrote: Hi list! Hello, I've just started with perl, but I'm really excited about its power. I'm excited that you're excited! ;-) I'm trying to edit a file, but couldn't find out how to do it without making a temp file. I've been searching for the solution, but all I find

Re: Perl: grep in if clause

2009-03-18 Thread John W. Krahn
Feng Yue wrote: Hi, Hello, I have a problem about grep in Perl. I'd like to use grep in a if clause like this if( *grep /^\$/, @array* ){ ... } This works well. However, when I add some more tests in this if, like this: if( *0 || grep /^\$/, @array || 0* ){ ... } this if will nev

Re: Matching Over Multiple Lines

2009-03-17 Thread John W. Krahn
Jeff Westman wrote: All, Hello, I know this has been asked many times, and I have read the documentation ("perldoc -q "matching over more than one line") and still can't make head or tails out of this. I have a problem where my pattern can be in one line, or span multiple lines. This is wha

Re: how variables definition works?

2009-03-16 Thread John W. Krahn
josanabr wrote: Hi, Hello, I having problems with a perl module implemented in Sun Grid Engine. This perl module (script) continuously watches the state of jobs submitted to my cluster. Every job can reach some of these states: r - run t - transfer q - queued s - suspended w - waiting In ord

Re: I am considering changing my footnote style.

2009-03-15 Thread John W. Krahn
Chas. Owens wrote: As many of you have probably noticed, I am addicted* to footnotes in my answers. I am considering changing their format to [1], [2], [3] instead of *, **, ***. If you have any opinions you can vote for your favorite style If you *have* to have footnotes then I vote for numb

Re: undefined subroutine

2009-03-15 Thread John W. Krahn
practicalp...@gmail.com wrote: Hello, Hello, How to find there're one or more undefined subroutines in a perl scritp? perldoc -f defined John -- Those people who think they know everything are a great annoyance to those of us who do.-- Isaac Asimov -- To unsubscribe, e-mail: begi

Re: I'm sure this is a common question, but I can't find the solution.

2009-03-14 Thread John W. Krahn
Ron Smith wrote: Hello all, Hello, How do you print elements of an array, each on its own line, in a Windows' console? I'm doing the following: E:\My Documents>perl -e "use ExtUtils::Installed; my $inst = ExtUtils::Installed->new(); my @modules = $inst->modules(); print @modules" it retu

Re: "Late" interpolation of a scalar variable inside a string

2009-03-14 Thread John W. Krahn
Chap Harrison wrote: I want to compute a file pathname based on a "template" at runtime, when I know the value of a variable that the template uses. In other words, the template for the path name looks like this... /foo/bar/$project/here ...and I want to evaluate this expression once I have s

Re: one liner need help

2009-03-12 Thread John W. Krahn
John W. Krahn wrote: John W. Krahn wrote: Toby Stuart wrote: Hello All Hello, It's been almost 13 years since I last posted on this board and my Perl skills are extremely rusty. Could someone help me to convert this to a one liner:- use strict; use warnings; while (<>)

Re: one liner need help

2009-03-12 Thread John W. Krahn
John W. Krahn wrote: Toby Stuart wrote: Hello All Hello, It's been almost 13 years since I last posted on this board and my Perl skills are extremely rusty. Could someone help me to convert this to a one liner:- use strict; use warnings; while (<>) { /^##\s*(.*)$/ &&

Re: one liner need help

2009-03-12 Thread John W. Krahn
Toby Stuart wrote: Hello All Hello, It's been almost 13 years since I last posted on this board and my Perl skills are extremely rusty. Could someone help me to convert this to a one liner:- use strict; use warnings; while (<>) { /^##\s*(.*)$/ && print $1; print " && " unless eof; } I

Re: problem with random arrays

2009-03-12 Thread John W. Krahn
Kammen van, Marco, Springer SBM NL wrote: Hi All, Hello, I'm trying to generate random sentences using a few words, but can't get the thing to work.. I know I'm doing something wrong but what? :-D Any help is appreciated! #!/usr/bin/perl -w #!/usr/bin/perl use warnings; use strict;

Re: Assigning an array to a dereferenced hash slice - syntax!

2009-03-11 Thread John W. Krahn
Chap Harrison wrote: On Mar 11, 2009, at 11:51 PM, Chas. Owens wrote: Dereference the hashref as an arrayref then ask for the keys: #!/usr/bin/perl use strict; use warnings; my %hash = ( adams => {} ); my @keys = qw/a ar af aw/; my @values = (1, 19, 13, 11); @{$hash{adams...@keys} = @val

Re: Assigning an array to a dereferenced hash slice - syntax!

2009-03-11 Thread John W. Krahn
Chap Harrison wrote: Hello, Hello, I have a hash of hashes, and I'm trying to bulk-assign some key/value pairs to the referenced hash, using a technique I read on the perlmonks list (hash slices, see link below). I've never been good at working out syntax where complex data structures are

Re: Stupid newb question

2009-03-11 Thread John W. Krahn
neckha...@penntraffic.com wrote: Hi guys, Hello, I am starting to learn Perl as the ksh scripting language (which I don't know either) looks less than powerful. I have used C many years ago, and write my stuff in REXX on a mainframe, so Perl looks like the best of both worlds. My environmen

Re: Network Printing using a Perl Script

2009-03-11 Thread John W. Krahn
Aglipay, Recelyn wrote: Hello everyone, Hello, I'm a beginner and having some issues with a Perl Script I had written for work. I am trying to print to a network label printer. I've verified that the printer is working on its own. But when I try to print to it using Perl nothing happens. He

Re: Regex problem, #.*# on new line

2009-03-11 Thread John W. Krahn
Brent Clark wrote: Hiya Hello, I got a string like so, and for the likes of me I can get regex to have it that each line is starts with #abc#. my $a = "#aaa#message:details;extra:info;variable:times;#bbb#message:details;extra:info;variable:times;#ccc#not:always;the:same;ts:14:00.00;"; $

Re: My confusion about if ( /grep $desc/ )

2009-03-11 Thread John W. Krahn
kevin liu wrote: Hello everyone: Hello, When I am using a pattern match to find my wanted process, things like this: * ps -ef | grep hald-runner root 5006 5005 0 Mar04 ?00:00:00 hald-ru

Re: I need scoping help

2009-03-04 Thread John W. Krahn
sf wrote: this is my problem: variable theParent never updates - it always stays "1" if ($ARGV[0] eq ""){ if ( @ARGV != 1 ) { print STDOUT "Enter the filename and path you wish to use:"; $nameoffile=; chomp $nameoffile; } } You have a } there without

Re: Printing directory sizes

2009-03-03 Thread John W. Krahn
Lauri Nikkinen wrote: It says that *** no packages installed matching 'File::Find *** I tried this also on my Mac and it goes like this ~ > perl -File::Find -le 'print "ok"' ok perldoc perlrun [ snip ] -Fpattern specifies the pattern to split on if -a is also in effect. The

Re: Strange problem with substr() function and right aligned fields

2009-03-03 Thread John W. Krahn
Bill Harpley wrote: I must process the output of an SQL query using Perl. I know the column position of the data in the output file, which means that I am able to calculate the width of each field. All of the data in the file is left-aligned to the field, except for one column. Basically, in t

Re: word similarity measure

2009-03-01 Thread John W. Krahn
Susan wrote: If my data looks like this: word 1: 100101 101102102 102106106 word 2: 101104 106110113 129131148 word 3: 101153 175180381 word 4: 106110 113122131 137142148 word 5: 120165 16

Re: Is there any function like perlinfo()

2009-03-01 Thread John W. Krahn
prasath_linux wrote: Hi, Hello, I need to find the location of perl.ini configuration file, is there any function like perlinfo() to find. Eg. phpinfo() is the function which can used to display all the configuration settings in php. Likewise any function to display the configuration funct

Re: DBI fetchall_arrayref

2009-02-27 Thread John W. Krahn
Chas. Owens wrote: On Fri, Feb 27, 2009 at 08:43, David Shere wrote: The following sub uses "fetchall_arrayref" in the DBI module to put the results of an SQL command into an array, where each element of the array is a hash of that records name/value pairs. The documentation says to pass it a

Re: Use join on multi-dimensional array

2009-02-27 Thread John W. Krahn
Jenda Krynicky wrote: From: "Bill Harpley" Suppose I have a multidimensional array of the form: @array[names][values] For example, I have a list of database field names and the value associated with each one. If this was a single dimensional array called @list, I could create an output line

Re: regarding regular expression

2009-02-26 Thread John W. Krahn
Irfan Sayed wrote: Still i am not getting proper result. Here is my code. please help. $string = "pqp-un_1.0G_2009-02-23_17-38-09_5678903.txt"; $string = ( split /\D+/ )[ -1 ]; $string = ( split /\D+/, $string )[ -1 ]; print "$string\n"; John -- Those people who think they know everyt

Re: picking largest key by value..

2009-02-26 Thread John W. Krahn
Rick wrote: trying out getting lasrgest key(by value) but below is not working... help please. my %files=%{{"one" =>"1", "thiry" =>"30", "four" =>"4", "never" =>"997", "forever" =>"11", "five" =>"5"}}; my $max; print join(" ",keys %files),"\n"; =pod grep($max=($files{$_} > $max )? $_ : $

Re: regarding regular expression

2009-02-26 Thread John W. Krahn
Irfan Sayed wrote: Hi All, Hello, I have a string like this "pqp-un_1.0G_2009-02-23_17-38-09_5678903.txt " now what i need is only all digits before .txt till first underscore. which means i need only output as 5678903 $ perl -le' $_ = "pqp-un_1.0G_2009-02-23_17-38-09_5678903.txt "; p

Re: RegExp Problem using Substitutions.

2009-02-24 Thread John W. Krahn
John W. Krahn wrote: Deviloper wrote: Hi there! Hello, I have a string "bbbababbaaassass". I want to get a string without any double a 'aa' or and without the 'b's. but if I do: my $s = "bbbababbaaassass"; $s=~ s/aa|b//g; as a result I will

Re: RegExp Problem using Substitutions.

2009-02-24 Thread John W. Krahn
Deviloper wrote: Hi there! Hello, I have a string "bbbababbaaassass". I want to get a string without any double a 'aa' or and without the 'b's. but if I do: my $s = "bbbababbaaassass"; $s=~ s/aa|b//g; as a result I will get a string "aaassass". (I understand WHY I get this result.

Re: local and my in subroutines

2009-02-23 Thread John W. Krahn
Karyn Stump wrote: I am trying to learn subroutines. I have seen refernces to using my and local for passing variables so I am playing with them to try to understand better how this all works. http://perl.plover.com/FAQs/Namespaces.html There is also some information in: perldoc perlsub I

Re: Unmatched '

2009-02-23 Thread John W. Krahn
John W. Krahn wrote: Karyn wrote: Can someone else see why I am getting the following error, cause as far as I can tell I have escaped all the ' single quotes. ganymede# perl -i.bak1 -p -e 's/include(\'http:\/\/calarts.edu\/redcat\/nav.php\')\;/include(\'nav.php\&

Re: Unmatched '

2009-02-23 Thread John W. Krahn
Karyn wrote: Can someone else see why I am getting the following error, cause as far as I can tell I have escaped all the ' single quotes. ganymede# perl -i.bak1 -p -e 's/include(\'http:\/\/calarts.edu\/redcat\/nav.php\')\;/include(\'nav.php\')\;/ig' *.php Unmatched '. ganymede# perl -v Th

Re: why while loop 6 times when @data have only 3 elements

2009-02-20 Thread John W. Krahn
itshardtogetone wrote: Hi, Hello, Looking at the script below, why does the while function loop 6 times instead of 3 times when @data have only 3 elements and I thought the output should be:- 1 $_ = aaa1 2 $_ = bbb2 3 $_ = ccc3 Thanks # #!/usr/bi

Re: Invalid conversion in sprintf "%\"

2009-02-19 Thread John W. Krahn
Rob Dixon wrote: John W. Krahn wrote: Strings like '%1\$s16->' are not valid sprintf/printf formats. What does your data look like and what do you expect it to look like after using sprintf? From perldoc -f sprintf: format parameter index An explicit format parameter inde

Re: how to do this in one line (with map?)

2009-02-18 Thread John W. Krahn
Rob Dixon wrote: John W. Krahn wrote: pa...@compugenic.com wrote: I want to extract a list of postfix's queue id's. The 'mailq' command returns output as follows: right now I'm doing the following: my @ids; foreach (`mailq`) { next unless /^\w+/; chomp;

Re: how to do this in one line (with map?)

2009-02-18 Thread John W. Krahn
pa...@compugenic.com wrote: I want to extract a list of postfix's queue id's. The 'mailq' command returns output as follows: -- 8C0597408D 2503 Tue Feb 17 16:15:34 ka...@domain.org (connect to bar-plate.com[209.62.20.192]:25: Connection refused) staffo...@ba

Re: Invalid conversion in sprintf "%\"

2009-02-18 Thread John W. Krahn
Rob Canning wrote: hi i have a sprintf which uses a scalar as its format: my $Bformat = "%1\$s16-> %2\$s16 %3\$s16 %4\$s16 %5\$s16 %6\$s16-> %7\$s16 %8\$s16" what i would like to do is generate a new format for the sprintf by doing permutations of 5 arrays like this: my @phraseA = qw( %1\$s

Re: strange string match

2009-02-15 Thread John W. Krahn
org chen wrote: Hi, Hello, I am coding a script to read a pure txt fiel and show it. I can't understand why any lines in the file match the word of "[DIED]". Thanks Org the txt file is like this: Fri Feb 13 14:31:26 2009 [PROCESS]: Welcom

Re: perl deprecated functions and alike

2009-02-15 Thread John W. Krahn
Octavian Râsnita wrote: From: "John W. Krahn" Kevin wrote: Could someone please direct me to some web pages where I can go through all deprecated perl functions and/or ways of writing perl script? It is not easy for me to figure out whether an on-line example is deprecated or no

Re: perl deprecated functions and alike

2009-02-14 Thread John W. Krahn
Kevin wrote: Could someone please direct me to some web pages where I can go through all deprecated perl functions and/or ways of writing perl script? It is not easy for me to figure out whether an on-line example is deprecated or not. I once saw: @files = <$path_to_directory> on the web a

Re: solution critique?

2009-02-13 Thread John W. Krahn
John W. Krahn wrote: David Shere wrote: I'm seeking critique of the following work-in-progress: My task is to read in a binary data file and prepare it for use. The "use" involves answering a query on whether some data is in the file, and if it is, return the rest of the data

Re: solution critique?

2009-02-12 Thread John W. Krahn
David Shere wrote: I'm seeking critique of the following work-in-progress: My task is to read in a binary data file and prepare it for use. The "use" involves answering a query on whether some data is in the file, and if it is, return the rest of the data associated with it. Each line/record i

Re: what does this match for?

2009-02-11 Thread John W. Krahn
practicalp...@gmail.com wrote: I saw a Regex: (?i:(j?sessionid|(php)?sessid|(asp|jserv|jw)?session[-_]?(id)?|cf(id|token)|sid)) I especially didn't know what the leading "?i:" means. Please help, thanks! The /i option means that everything inside the parentheses is a case insensitive patter

Re: How to speed up two arrays compare.

2009-02-11 Thread John W. Krahn
kevin liu wrote: On Wed, Feb 11, 2009 at 11:22 PM, John W. Krahn wrote: The best you can do with two arrays is exit as soon as an element of @nwarray0 is not found in @nwarray1: my $found = 1; SEARCH: foreach my $srctemp ( @nwarray0 ) { foreach my $tgttemp ( @nwarray1 ) { if

Re: How to speed up two arrays compare.

2009-02-11 Thread John W. Krahn
kevin liu wrote: Hi everybody: Hello, I have two arrays(@nwarray0 and @nwarray1) in my program and i want to make sure that all the elements in @nwarray0 could be found in @nwarray1. Here is my implementation: --- for

Re: Making regex's

2009-02-10 Thread John W. Krahn
Dermot wrote: Hi, Hello, I just hit something that I hadn't noticed before and I am not sure it's it's a syntax issue or I have not been doing my reading. I am trying to create a regex to match a directory name in path string my $dir = dirname(shift); (my $code) = ($dir =~ m|track.(\w{3

Re: question on 2 sub modules on the same scope

2009-02-09 Thread John W. Krahn
itshardtogetone wrote: Hi, Hello, Looking at the script below, can someone explain why the final output is "Final = 1" instead of "Final = 5". I thought at the end of the while loop, $a_ctr is 5, this value is then read by the sub module &data() and this value of 5 is then passed on to sub pu

Re: How hard is it to learn this langauge?

2009-02-09 Thread John W. Krahn
Damien Learns Perl wrote: I have experience in C and I find that Perl would have been a much easier language to start with. You can write powerful code right away. I started to learn Perl last month and I am blogging about it at: http://damienlearnsperl.blogspot.com/ This is certainly not acade

Re: RegEx to extract last character of a line

2009-02-07 Thread John W. Krahn
Rob Dixon wrote: Greg wrote: I have an input file that I have to evaluate whether to include lines based upon their last character. Is there a simple regex that would allow me to assign the very last character to a variable? ^^^ ^^^

Re: RegEx to extract last character of a line

2009-02-07 Thread John W. Krahn
Greg wrote: I have an input file that I have to evaluate whether to include lines based upon their last character. Is there a simple regex that would allow me to assign the very last character to a variable? In my case it will either be A or I (capital i) if that helps? /([AI])\z/ and my $vari

Re: ending a character to each line

2009-02-05 Thread John W. Krahn
stuforman wrote: i want to use perl to end each line with a '~'. i would really appreciate any syntax that would help me do this... $line =~ s/$/~/; John -- Those people who think they know everything are a great annoyance to those of us who do.-- Isaac Asimov -- To unsubscribe, e-ma

Re: hash baby steps

2009-02-02 Thread John W. Krahn
John W. Krahn wrote: John W. Krahn wrote: Johnson, Reginald (GTS) wrote: I am wondering if I am doing this in an efficient manor. I am taking my first input file and putting it in a hash with server name as a the key. The second input file has two fields exp_server and exp_date. I put this

Re: hash baby steps

2009-02-02 Thread John W. Krahn
John W. Krahn wrote: Johnson, Reginald (GTS) wrote: I am wondering if I am doing this in an efficient manor. I am taking my first input file and putting it in a hash with server name as a the key. The second input file has two fields exp_server and exp_date. I put this file in hash using

Re: hash baby steps

2009-02-02 Thread John W. Krahn
Johnson, Reginald (GTS) wrote: I am wondering if I am doing this in an efficient manor. I am taking my first input file and putting it in a hash with server name as a the key. The second input file has two fields exp_server and exp_date. I put this file in hash using exp_server as the key. I th

Re: working with CPAN

2009-01-31 Thread John W. Krahn
Fisher, John wrote: I have luck sometimes with CPAN and sometimes I don't. It like spinning a wheel. I am trying to bring down a module that will read EBCDIC files and convert them to ASCII. I need one that will handle packed fields as well. Not sure this one is it. Have you read the perlebcdic

Re: cryptic one liner explain

2009-01-30 Thread John W. Krahn
thebarn...@gmail.com wrote: Hi Hello, I run this command and pipe the output to a perl one liner. not quite sure how it parses the data: svmon -Pt3 | perl -e 'while(<>){print if($.==2 || $& && !$x++); $.=0 if (/^--+$/)}' That can be shortened to: svmon -Pt3 | perl -ne'print if $.==2 || $&

Re: how to copy elements into the next array

2009-01-28 Thread John W. Krahn
itshardtogetone wrote: Hi, Hello, How do I copy the first 10 elements of @a into @b? my @b = @a[ 0 .. 9 ]; John -- Those people who think they know everything are a great annoyance to those of us who do.-- Isaac Asimov -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For

Re: very basic questions

2009-01-28 Thread John W. Krahn
b chen wrote: i am completely new to perl, can you explain to me the following line of code in red. There is no red here, there is only black and white. how does this line of code grab a time value and assign it to $ time, how does assigment happend in this conditiona statement. while (<

Re: Simple regex problem has me baffled

2009-01-26 Thread John W. Krahn
Bill Harpley wrote: Hello, Hello, I have simple regex problem that is driving me crazy. I am writing a script to analyse a log file. It contains Java related information about requests and responses. Each pair of Request (REQ) and Response (RES) calls have a unique Request ID. This is a 5 d

Re: explanation of @INC

2009-01-23 Thread John W. Krahn
Scott Haneda wrote: On Jan 23, 2009, at 1:01 AM, Gunnar Hjalmarsson wrote: Scott Haneda wrote: ASSP required about 15 perl modules, I installed them, or wrote new portfiles for them to get them installed. I have all requirements for ASSP installed. I edit the ASSP source files to change the

Re: Using hashes in a format

2009-01-18 Thread John W. Krahn
Adam Jimerson wrote: Yea I read that dbmopen was superseded by the "tie" function but I couldn't figure out the permissions for it: tie(%HIST, 'NDBM_File', '/usr/lib/news/history', 1, 0); perldoc DB_File [ snip ] Default Parameters It is possible to omit some or all of the final

Re: Using hashes in a format

2009-01-18 Thread John W. Krahn
Adam Jimerson wrote: I am working on a program that will act as a contact manager of sorts, it uses two hashes to store everything (although the second one is commented out because I am not ready to work with it). I am using the format function to display everything but I don't know how to ge

Re: OO confusion

2009-01-11 Thread John W. Krahn
Dr.Ruud wrote: Jenda Krynicky wrote: my $data = do {local $/; }; is better written as my $data; { local $/; $data = }; For smallish files it doesn't matter much. Or perhaps: read DATA, my $data, -s DATA; John -- Those people who think they know everything are a great annoyance to t

Re: quick regex question

2009-01-09 Thread John W. Krahn
Chris Knipe wrote: Hi, Hello, I have two lines (well, 1 line is headers, then there follows a range of data)... # INTERFACE RADIO-NAME MAC-ADDRESS AP SIGNAL-STRENGTH TX-RATE UPTIME 0 interface_name radio 00:0C:42:1F:2C:8D yes -

Re: OO confusion

2009-01-08 Thread John W. Krahn
root wrote: The following script gives me confusing results. I've not delved into OOP before and am surprised when something appears to work but gives wrong answers. Explicitly Digest::MD5's md5_hex gives wrong answers if called as Digest::MD5->md5_hex. OK, I've figured out that it shou

Re: print on the same line

2009-01-06 Thread John W. Krahn
h3xx wrote: I find it's easier (and in this case totally doable) if you make something like this: for my $count (10 .. 0) { You can't do that in Perl. The range operator has to have the smaller number on the left and the larger number on the right otherwise it will return an empty list and

Re: trouble with 'tr' command

2009-01-06 Thread John W. Krahn
Tony Esposito wrote: Hello, Hello, Trying to do the following and the variable $field_term does not transiterate. The $foo becomes "name$age$grade$school$semester". #!/usr/bin/perl my $field_term = '|'; my $foo = "name,age,grade,school,semester"; $foo =~ tr/,/$field_term/; __END__

Re: inverting List::Compare

2009-01-04 Thread John W. Krahn
John Refior wrote: Rob Dixon wrote: David Newman wrote: # get files open(DAT, $lfile) or die("unable to open"); my @Llist = ; close(DAT); You should include the $! variable in the die string so that you know why the open failed. I suggest my @llist; { open my $fh, '<', $lfile or d

Re: inverting List::Compare

2009-01-03 Thread John W. Krahn
David Newman wrote: On 1/2/09 5:22 PM, Rob Dixon wrote: David Newman wrote: my $lfile = $ARGV[0]; my $rfile = $ARGV[1]; It would also be nice to make sure that there are in fact two parameters die "The parameters must be the the two files for comparison" unless @ARGV == 2; my

Re: inverting List::Compare

2009-01-03 Thread John W. Krahn
Rob Dixon wrote: David Newman wrote: foreach my $union (@union) { print "$union"; } You shouldn't put $union in quotes, and the loop is better written as print for @union; print @union; Should work just as well. John -- Those people who think they know everything are a grea

<    3   4   5   6   7   8   9   10   11   12   >