AW: print sub code

2010-05-20 Thread Thomas Bätzler
Tech list asked: > Let's say I have a module XYZ with a sub in it call ABC. I'd like to > print the source code of XYZ::ABC. > > My reason for this is I accidentally overwrote a module with an older > version, but I still have httpd running which has it loaded in memory. You can't print the "so

AW: Good/best practice - pre-declare variables

2010-05-20 Thread Thomas Bätzler
HACKER Nora wrote: > Obviously, my point wasn't clear enough, I'm sorry for that. The > variable in the code extract that I'm really bothering about is the > $sdb: It is needed in the SWITCH of a sub-function, but this construct > only works if I pre-declare the $sdb in the calling function backup

AW: Good/best practice - pre-declare variables

2010-05-20 Thread HACKER Nora
Hi Shlomi, Thanks for your reply. > From a cursory look at your program, it seems that you can just set up > $mode > as a global variable, and keep it at that instead of just passing it > around. > Alternatively, maybe you'd like to define a class and keep the mode > variable > there as a propert

Re: grep and regex

2010-05-20 Thread Akhthar Parvez K
On Thursday 20 May 2010, Shawn H Corey wrote: > #!/usr/bin/perl > > use strict; > use warnings; > > use Data::Dumper; > > # Make Data::Dumper pretty > $Data::Dumper::Sortkeys = 1; > $Data::Dumper::Indent = 1; > > # Set maximum depth for Data::Dumper, zero means unlimited > local $Data::Dumpe

Re: append to a hash?

2010-05-20 Thread Bryan R Harris
>> "BRH" == Bryan R Harris writes: > > BRH> I have code that looks like this: > > BRH> ** > BRH> if ($props =~ /\S/) { > BRH> %{$ptr[-1]->[-1]} = ($props =~ m/\s*([^=]+)="([^"]+)"/g); > > where is @ptr set? what are you using it for? Earlier

Re: grep and regex

2010-05-20 Thread Shawn H Corey
On 10-05-20 03:52 PM, Uri Guttman wrote: i didn't say it was for output but for debugging. and i didn't say YOU shouldn't do it. i wrote for others to learn when to and not to use Dumper. it isn't always the best choice. you can use it all the time. they don't need to. simpler print/map is fine f

print sub code

2010-05-20 Thread Tech list
Let's say I have a module XYZ with a sub in it call ABC. I'd like to print the source code of XYZ::ABC. My reason for this is I accidentally overwrote a module with an older version, but I still have httpd running which has it loaded in memory. -- To unsubscribe, e-mail: beginners-unsubscr

Re: append to a hash?

2010-05-20 Thread Uri Guttman
> "BRH" == Bryan R Harris writes: BRH> I have code that looks like this: BRH> ** BRH> if ($props =~ /\S/) { BRH> %{$ptr[-1]->[-1]} = ($props =~ m/\s*([^=]+)="([^"]+)"/g); where is @ptr set? what are you using it for? BRH> } BRH> My proble

append to a hash?

2010-05-20 Thread Bryan R Harris
I have code that looks like this: ** if ($props =~ /\S/) { %{$ptr[-1]->[-1]} = ($props =~ m/\s*([^=]+)="([^"]+)"/g); } ** My problem is that I only want to append the properties and their values to that hash, not replac

Re: grep and regex

2010-05-20 Thread Uri Guttman
> "SHC" == Shawn H Corey writes: SHC> On 10-05-20 03:17 PM, Uri Guttman wrote: >>> "SHC" == Shawn H Corey writes: >> SHC> On 10-05-20 02:07 PM, Uri Guttman wrote: >> >> not a major point, but why do you use dumper just to print a list of >> >> tokens? i use dumper for deep

Re: Good/best practice - pre-declare variables

2010-05-20 Thread Shlomi Fish
On Thursday 20 May 2010 13:52:58 HACKER Nora wrote: > Hello, > > I have a programme for database backup / recovery / some other tasks > with several modes (e.g. ackup etc.) in wich a certain function is > called. In this function I do a SWITCH, depending on the mode that the > main programme is st

Re: grep and regex

2010-05-20 Thread Shawn H Corey
On 10-05-20 03:17 PM, Uri Guttman wrote: "SHC" == Shawn H Corey writes: SHC> On 10-05-20 02:07 PM, Uri Guttman wrote: >> not a major point, but why do you use dumper just to print a list of >> tokens? i use dumper for deeper stuff where i can't just print the data >> easily wit

Re: grep and regex

2010-05-20 Thread Uri Guttman
> "SHC" == Shawn H Corey writes: SHC> On 10-05-20 02:07 PM, Uri Guttman wrote: >> not a major point, but why do you use dumper just to print a list of >> tokens? i use dumper for deeper stuff where i can't just print the data >> easily without some code. even single level hashes i wil

Re: grep and regex

2010-05-20 Thread Shawn H Corey
On 10-05-20 02:07 PM, Uri Guttman wrote: not a major point, but why do you use dumper just to print a list of tokens? i use dumper for deeper stuff where i can't just print the data easily without some code. even single level hashes i will print directly as i can format it my way and not dumper's

Re: grep and regex

2010-05-20 Thread Uri Guttman
> "SHC" == Shawn H Corey writes: SHC> my @data = qw( The quick brown fox jumped over the lazy dogs. ); SHC> my $regx = qr{ [aeiou] }msx; SHC> my @matches = map { /($regx)/ } @data; SHC> print '@matches : ', Dumper \...@matches; not a major point, but why do you use dumper just to pri

Re: grep and regex

2010-05-20 Thread Shawn H Corey
On 10-05-20 12:52 PM, Akhthar Parvez K wrote: Hi all, Can Perl regex match a string in a list (like Perl grep)? eg:- #won't work $_ = @data; my @matches = /($regx)/g; #works, but not as quite really wanted since it would show the line contains the string, not just the matched string: my @matche

grep and regex

2010-05-20 Thread Akhthar Parvez K
Hi all, Can Perl regex match a string in a list (like Perl grep)? eg:- #won't work $_ = @data; my @matches = /($regx)/g; #works, but not as quite really wanted since it would show the line contains the string, not just the matched string: my @matches = grep /($regx)/, @data; So, can Perl grep s

Re: Merging YAML nodes/streams

2010-05-20 Thread Tom
On Fri, May 14, 2010 at 12:21:21PM -0400, Jay Savage wrote: > > > > CODE > > #!/usr/bin/perl > > use YAML::Syck; > > use Data::Dumper; > > > > my ($yaml) = Load(<<'...'); > > --- > > nameserver: > >  - 172.23.0.5 > >  - 172.23.0.6 > > randomvar: > >  - ela

Good/best practice - pre-declare variables

2010-05-20 Thread HACKER Nora
Hello, I have a programme for database backup / recovery / some other tasks with several modes (e.g. ackup etc.) in wich a certain function is called. In this function I do a SWITCH, depending on the mode that the main programme is started with. In one of the cases of SWITCH (e.g. ecovery) I use a