Re: how to print "\n" in the output file

2006-11-05 Thread Robin Norwood
"Mihir Kamdar" <[EMAIL PROTECTED]> writes: > 1. (*) text/plain > > hi, > > I am a beginner in Perl. I am trying to automatically generate a perl test > case file which, on executing, would return HTTP response code and response > time,etc. In the output file that I am getting I want the

Re: Database migration

2006-10-17 Thread Robin Norwood
updating the target db as you go. For large sets of data, option '1' can use up available memory, and option '2' can be very slow due to the number of 'round trips' to and from the databases. So a 'batching' solution might be a good idea. Of course, if t

Re: subroutine in LWP - in order to get 700 forum threads

2006-08-26 Thread Robin Norwood
eParser->new(\$r->content) or die "Parse > error in $page: $!"; > # just printing what was collected > print Dumper get_thread($stream); > # would instead have database insert statement at this point >} else { &

Re: subroutine in LWP - in order to get 700 forum threads

2006-08-26 Thread Robin Norwood
merlyn@stonehenge.com (Randal L. Schwartz) writes: >>>>>> "Robin" == Robin Norwood <[EMAIL PROTECTED]> writes: > > Robin> But Google does use the data in indexes for personal gain...it derives > Robin> significant revenue from the advertising don

Re: subroutine in LWP - in order to get 700 forum threads

2006-08-26 Thread Robin Norwood
merlyn@stonehenge.com (Randal L. Schwartz) writes: >>>>>> "Robin" == Robin Norwood <[EMAIL PROTECTED]> writes: > >>> DO NOT ATTEMPT TO DO THIS > > Robin> Really? If I understood the OP correctly, all he wants to do is > 'screen &

Re: subroutine in LWP - in order to get 700 forum threads

2006-08-26 Thread Robin Norwood
ing calls to sleep inside some of those loops. After he gets the data, he could do something unethical with it - like republish it. But just getting the data doesn't seem wrong to me. As I said above, I am not a lawyer! The above should not be taken to mean I think it is legal to do this. But it

Re: replace multiple tokens

2006-08-25 Thread Robin Norwood
gt; af = a...x name=taga_0 #...d name=tagb_0 f...r name=tagc_0 xxnn > b4 = h...e name=taga_4 t...g name=tagb_4 k name=tagc_4 nn > af = h...e name=taga_1 t...g name=tagb_1 k name=tagc_1 nn > > Any help will be greatly appreciated. > jwm -- Robin Norwood Red Hat, Inc. "The

Re: line command in perl

2006-08-23 Thread Robin Norwood
e of a specific function such > as splice. Which line code am I supposed to issue? I > tried perldoc splice or perldoc perlfunc splice but it > didn't work. -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone." -Lao Tzu, Te Tao Ching --

Re: Writing to XML using XML::Writer

2006-08-09 Thread Robin Norwood
uot;)->children("guy")) > { > print " User: " . $element->child("user")->value . "\n"; > > print " Date of Birth: " . > $element->child("date-of-birth")->value . "\n"; > > p

Re: substitute character in variable

2003-09-12 Thread Robin Norwood
nt $string; returns: How much quod quuld a quodchuck chuck if a quodchuck could chuck quod? Note the 'g' tacked on to the end of the substitution... -RN -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone." -Lao Tzu, Te Tao Ching -- To unsub

Re: Kinda Perl

2003-07-26 Thread Robin Norwood
tures, etc. If I had to guess, I'd say $5/mo. -RN -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone." -Lao Tzu, Te Tao Ching -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Looking for elegance ...

2003-07-10 Thread Robin Norwood
xcessively precise in unimportant matters) > or 'foppish' (affectedly refined in manners). Also there is no > 'persnickety' which must be American English. Divided by a common > one eh? I imagine you're correct on the 's' version being American English - I'

Re: Looking for elegance ...

2003-07-10 Thread Robin Norwood
eaded, snooty, snot-nosed, snotty, stuck-up, too big for one's breeches, uppish] Which doesn't sound very flattering... :-) I think we can safely assume that Jamie meant the other definition... -RN ("a snotty little scion of a degenerate family") -- Robin

Re: Looking for elegance ...

2003-07-10 Thread Robin Norwood
d five are extracted to a list. Sub-string four is extracted to its > own variable. > > Suggestions? Well, a slice instead of pushing individual elements helps a little bit: @list = (@tmp_list[0 .. 3], $tmp_list[5]); -RN -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet n

Re: Creating a hash of arrays from row data

2003-07-10 Thread Robin Norwood
perl/deep_copy.pl Use of uninitialized value in concatenation (.) or string at perl/deep_copy.pl line 19. what type is ? at perl/deep_copy.pl line 19. While with the corrected line gives the following (correct) error: $ perl perl/deep_copy.pl what type is SCALAR(0x8107e04)? at perl/deep_copy.pl line 20

Re: Stat() - Getting one element

2003-07-07 Thread Robin Norwood
# empty hashref @{$times}{qw/atime mtime ctime/} = # a slice of the hashref... (stat("filename"))[8 .. 10]; # to which we map some of the fields of stat() print $times->{mtime}; # should yield the same as (stat("filename"))[9] Don't worry if the last snippe

Re: Data Structures in Perl

2003-07-06 Thread Robin Norwood
he above is: foreach my $order (@orders) { print $order->order_number(); } This iterates over each element in the array @orders, and places them in turn in a variable called '$order'. Do it this way, and you don't have to worry about the index of the array at all. -

Re: Objects and inheritance....

2003-07-03 Thread Robin Norwood
ct_id # in cs2600.pm } } # One of the important bits in the above is that while ipaddress() is # found in NetDevice.pm, in this case it is a method of the # NetDevice::Cisco::cs2600 *object* ($self) we just created. $self->_init; # _init() from cs2600 if

Re: Objects and inheritance....

2003-07-02 Thread Robin Norwood
, %valid_fields) } sub object_id { my $self = shift; my $id = shift; if (defined $id) { $self->{object_id} = $id; } return $self->{object_id}; } 1; __END__ testme.pl: use Data::Dumper; use NetDevice::Cisco::cs2600; my $cisco = new NetDevice::Cisco::cs2600(ipaddress => &q

Re: How to check Array Uniqueness without Modul Array::unique

2003-07-01 Thread Robin Norwood
5/s (n=1) As you can see, grep_compare performs somewhat worse than keys_compare, and short_circuit cleans up. Of course, short_circuit won't perform quite as well as the other two when dealing with arrays that are usually unique, but as far as I can tell, short_circuit's worst

Re: How to check Array Uniqueness without Modul Array::unique

2003-07-01 Thread Robin Norwood
uld be: if (grep {$seen{$_}++} @array) { > # at least one element is twice >} else { > # unique >} > } -RN -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone." -Lao Tzu, Te Tao Ching -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: examples of place holders

2003-06-16 Thread Robin Norwood
ank, or if you have a line like 'Bill Clinton,' ($phone ends up being undef) > --i'm going to test this to see if i can > --use my text file to put data into the > --query ... > > --it may just be that i will have to do > --this in a two or three step process. Yes, you will need to do two steps - at least I know of no other way. Good luck! -RN -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone." -Lao Tzu, Te Tao Ching -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: examples of place holders

2003-06-16 Thread Robin Norwood
($owner, $columns, $def) = $sth->fetchrow) { # ...whatever... } So this should get all of the tables owned by 'Bill' with 32 or fewer columns. When the query is run, the question marks are replaced by the params to 'execute', in order. The technical details are best lef

Re: concatonate to file?

2003-06-16 Thread Robin Norwood
27;ll notice I used strftime to get the date instead of parsing `date` - probably easier and more correct. For my script, I also check to make sure the directory in $target_dir doesn't already exist - this may or may not apply for your application, though. -RN -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone." -Lao Tzu, Te Tao Ching -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Regex Consult

2003-06-13 Thread Robin Norwood
doesn't really > validate the entry but you got me thinking about what I can do with > the split. (You also forced me to read up on s/printf and scalar > context to figure out what the heck you were doing.) Peter, You should probably also look at the Date::Parse module, it can p

Re: adding hash reference into hash

2003-03-03 Thread Robin Norwood
ash2Ref ); print Data::Dumper->Dump([(%containerHash)]); foreach my $hkey (keys %containerHash) { # 'hash1', then 'hash2' foreach my $intkey (keys %{$containerHash{$hkey}}) { # the keys of $intHash1Ref and $intHash2Ref my $value = $containerHash{$hkey}->{$intkey}; print "$hkey: key = '$intkey', value = '$value'"; } } -RN -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone." -Lao Tzu, Te Tao Ching -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: use as configuration language

2003-02-05 Thread Robin Norwood
dodgy) parser. If fact I'm trying to do it this way because I have found multiple >errors in the original configuration file parser for my program! Well, since you mention that Freezethaw wasn't available, I assume installing from CPAN isn't an option - if it is, you could

Re: ifelsif/hash errors - question

2002-08-29 Thread Robin Norwood
quot;american_phone", zipcode => '/^\s*\d{5}(?:[-]\d{4})?\s*$/', state => "state", }, }, #<should be ';' # County names; region email, county em

Re: Error when I try to use perldoc

2002-08-29 Thread Robin Norwood
#x27;t in your path - IIRC cmd.exe is the windows 2000 equivelent of 'command.com' - the dos shell. That being said, I don't think I remember where it's located - good luck. :-) -RN -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone.&quo

Re: Word and Outlook

2002-08-27 Thread Robin Norwood
'$100,000,000' ); foreach my $key (keys %repl) { $temp =~ s/\{$key\}/$repl{$key}/gi; } print $temp; ' Replacing 'print $temp', with whatever e-mail code you wish to send. You could, for instance, loop over an array of user records, do the substitution for eac

Re: Regexp

2002-08-26 Thread Robin Norwood
david <[EMAIL PROTECTED]> writes: > Robin Norwood wrote: > > From david's headers: > > > > User-Agent: KNode/0.7.1 > > > > Time to change news readers, I think... :-) > > > > -RN > > > > just curious. what news reader y

Re: Regexp

2002-08-26 Thread Robin Norwood
busy doing something else... > yes, the reason why the string is much shorter is becasue i am lazy to > type... believe it or not, my news reader do not allow(for some unknown > reason) me to copy and paste outside of it's own window! >From david's headers: User-Agent: KNod

Re: Regexp

2002-08-26 Thread Robin Norwood
ber that is: >74a6b3b0.d1cd11d4.896e.00:b0:d0:83:b4:9b > > how do i get that the easiest way? all $_ are the same they are all within brackets >[text here variables, exept . and :] > > //Dave ' m/\[uuid\s+(.*)\]/; my $uuid = $1; ' Should be sufficient. -RN -

Re: need help extracting words from a string

2002-08-20 Thread Robin Norwood
e fields found! '@line'\n"; #or whatever you need to do } elsif (scalar @line == 2) { print "Two fields found! '@line'\n"; #or whatever... } else { print "Unusual line! ",scalar @line," columns found. '@line'\n"; } } close FILE; ' -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone." -Lao Tzu, Te Tao Ching -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Compare dates

2002-08-15 Thread Robin Norwood
# '1029438722' print scalar localtime($time); # 'Thu Aug 15 15:12:02 2002' ' Run both your dates through Date::Parse, and compare them numerically. Good enough? -RN -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains

Re: Formatting date, time

2002-08-13 Thread Robin Norwood
is 'unixtime'. localtime in array context returns a 'time array', whose format you can read about in the docs. strftime uses an ansi c standard time format string - there are several places you can look up the possible arguments. -RN -- Robin Norwood Red Hat, Inc. "

Re: Sorting a list by...

2002-08-10 Thread Robin Norwood
Kevin Pfeiffer <[EMAIL PROTECTED]> writes: > Robin Norwood writes: > > Samuel Brown <[EMAIL PROTECTED]> writes: > > > Hi ya, > > > > > > I'm teaching myself Perl and I have a log file around 1GB that I need > > > to sort by month |

Re: Sorting a list by...

2002-08-09 Thread Robin Norwood
ered; #The tm_conv function just strips out the ':'s - I'm assuming the #timestamps are in '24-hour' format. Calling this function in the #middle of the sort like this is absolutely terrible; it will slow #down the sort tremendously. I should be shot for writing this code. sub tm_conv { my $tm = shift; $tm =~ tr/://d; return $tm; } ' -RN (Who should never be allowed near a keyboard again) -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone." -Lao Tzu, Te Tao Ching -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: sendmail problem

2002-08-01 Thread Robin Norwood
;) or die > "Cannot fork for send mail: $! \n"; > print SENDMAIL<<"EOF"; > From: ltran\@my > To: you\@yourhost > cc: myboss\@my > Subject: Report > > Howdy, > I'm sending you bla bla > EOF > while (){ > print SENDMAIL $

Re: sendmail problem

2002-08-01 Thread Robin Norwood
size of an < >document - but someone more knowledgable will have to answer that > >part. > > I was under the impression that a variable size is limited only by what your > hardware can handle before currently available memory is filled. Well yeah...'as big as you need, limited by

[Robin Norwood ] Re: Extract text from argument

2002-08-01 Thread Robin Norwood
File::Spec->splitpath( $test ); But I still recommend that you read over the documentation for it - it has several other useful functions. -RN "FlashGuy" <[EMAIL PROTECTED]> writes: > I took a look on www.perldoc.com and checked out "split". I can't figure ou

Re: Extract text from argument

2002-08-01 Thread Robin Norwood
the last "\" and put that into >a variable. > There could only be one "\" in the path or possibly more. This will vary based on >directory structure. > > How would I go about this? use File::Spec->splitpath - Look for 'splitpath' in `perldoc File

Re: sendmail problem

2002-08-01 Thread Robin Norwood
_; } close(INPUT); > close(SENDMAIL) or warn "sendmail dinnot close > nicely"; > }# end sendownermail This way, no more than one line of is in memory at one time. -RN -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone." -Lao Tzu, Te Tao Ching -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Perl Array Question

2002-07-31 Thread Robin Norwood
RACT_log' - use either the number of elements in the aray '$u < @KEY_SNR_RACT_LOG', or the index of the last element in the array '$u <= $#KEY_SNR_RACT_LOG' in the inner for loop. The second method is much more correct, actually. There are better ways to do this, but this post is getting long enough as it is. I would recommend a good look at the references and data structures chapters of 'Programming Perl'. They should help with understanding how to deal with more complicated data like this. Wow, that was a long post. Hope it made sense... All of this code is pretty much completely untested. Beware typos, logic errors, and gremlins. -RN -- Robin Norwood Red Hat, Inc. "The Sage does nothing, yet nothing remains undone." -Lao Tzu, Te Tao Ching -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Down and dirty duplicate deleter

2002-07-30 Thread Robin Norwood
hree one two five/; my @uniq; %seen = (); foreach $item (@list) { push (@uniq, $item) unless $seen{$item}++; } #@uniq now contains qw/one two three five/; '@list' is the original array, and '@uniq' is the unique elements from that array. This method does not change @

Re: Regex Problem

2002-07-28 Thread Robin Norwood
e the first '$' in the substitution part of your regexp: #!/usr/bin/perl -lw #the 'l' adds a newline to the end of any 'print' my $foo = '${bar}'; print $foo; $foo =~ s/\$\{(\w+)\}/\$$1/g; print $foo; OUTPUT - ${bar} $bar You are getting the warning

Re: function for finding the index of an element in an array?

2002-07-25 Thread Robin Norwood
7; found at index(es): " . join(", ", @locations); } else { print "String '$value' not found."; } display: String 'BCDE' found at: 0, 4 If you find yourself using 'for', it's often best to stop and think for a bit about a more '