Re: My progress in Perl

2023-08-08 Thread Steve Park
own wrote: > Steve, > > > > I agree. Someone just starting out should go with Python. It pains me to > say it, but Perl isn’t a good skills investment. > > > > My team and I program every day in Perl – we have 100’s of libraries and > system integrations. I lo

Re: My progress in Perl

2023-08-07 Thread Steve Park
Honestly, my advise is if you are beginning to learn programming using perl in 2023. Don't. Pick up python and go from there. If you already know some perl and want to advance, yes go right ahead. 2023, is perl dead? no. It's a tool and it's still a swiss army of programming language and lot can

Re: Getting 2/8 as output

2015-06-15 Thread Steve Hart
{ local $, = "\n"; print %test; } On Sat, Jun 13, 2015 at 9:37 AM, rakesh sharma wrote: > Hi > > I am printing a hash but I tried to concatenate the new line operator and > I am getting 2/8 as output; > > print %hash."\n"; > > output is 2/8. I am not able to make the output. 2 could be the i

Re: Brackets in scalar and array

2014-05-29 Thread Steve Kaftanski
");" and that just having one thing isn't a problem; but he also notes farther down http://perldoc.perl.org/perlfaq4.html#What-is-the-difference-between-a-list-and-an-array%3f for completeness. Hope this helps! -Steve Kaftanski, MadMongers.org (Madison.pm Wisconsin). On Thu, M

Re: use sys::virt module to manage VM in kvm

2014-03-27 Thread Steve Kaftanski
sed again. So, I cannot tell you how to use this exactly (since I didn't know about this until a few minutes ago), but I assure you we will be investigating this ourselves now; thanks! -Steve K. On Thu, Mar 27, 2014 at 2:27 AM, lesleyb wrote: > On Wed, Mar 26, 2014 at 06:43:47PM -0700,

Re: Database interface

2013-02-04 Thread Steve
于 2013-2-5 6:12, Simon Alfredsson 写道: Is there a way to write a perl script that upon opening it in locally in web browser would present a interface to a database that is also stored locally? What modules (beyond DBI) would be easy to use? Could take a look at the ORM system DBIx::Class which

AnyEvent and POE

2013-02-03 Thread Steve
Good day, what's the difference between AnyEvent and POE? I know both them are framework for event programming, if I should choose one, which is more advanced in today? Thanks. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org htt

Re: lexical scope

2012-06-05 Thread Steve Bertrand
On 05/06/2012 6:31 PM, Steve Bertrand wrote: On 05/06/2012 3:49 PM, Shawn H Corey wrote: On 12-06-05 05:43 PM, Bill Stephenson wrote: Maybe this is what you need? #!/usr/bin/perl use warnings; use strict; my @array; while ( my $line = ) { chomp $line; push (@array = split(/\s+/, $line,-1

Re: lexical scope

2012-06-05 Thread Steve Bertrand
]; I'm not on a box I can test this with, but won't that push an array ref into the hash? Do you mean to surround it with parenthesis instead, or am I missing something? Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@per

Re: shift vs @_

2012-05-21 Thread Steve Bertrand
untered extremely elaborate code that requires extreme optimization a few times. Please remember... this is a *beginner* list. Promoting premature optimization before clarity is not in the best interest of the intended audience imho. Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org F

Re: shift vs @_

2012-05-21 Thread Steve Bertrand
On 2012-05-21 14:51, Shawn H Corey wrote: On 12-05-21 04:32 PM, Steve Bertrand wrote: On 2012-05-21 14:12, sono...@fannullone.us wrote: Hi Paul, Please don't care about this until your code is running correctly but too slowly and profiling has determined that this is the bottleneck.

Re: shift vs @_

2012-05-21 Thread Steve Bertrand
e args passed in as a single hash ref. In cases I don't use that type of API, it is because the sub only takes one or two args, in which a couple of shift lines isn't much extra typing). Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: shift vs @_

2012-05-21 Thread Steve Bertrand
27;shift' => 'my @args = qw(a b c); shift_off(@args);', }); sub shift_off { my $x = shift; my $y = shift; my $z = shift; } sub copy { my ( $x, $y, $z ) = @_; } Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Using the ternary operator to concat a string not working like I think?

2012-04-03 Thread Steve Bertrand
#x27;s the link to the perlop conditional op section again: http://perldoc.perl.org/perlop.html#Conditional-Operator Cheers, Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Using the ternary operator to concat a string not working like I think?

2012-04-03 Thread Steve Bertrand
st = ( one => "first", two => "second" ); $test{one} .= ( $test{one} eq 'first' ) ? " is the worst\n" : " is the best\n"; print "$_" for values %test; Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Proc::PID::File - non-default location

2012-03-27 Thread Steve Bertrand
create (bless) a new object with itself. The code in the module is not designed to allow this. From what I can tell, you should be using $pid->alive() as opposed to $pid->running(). Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: printing hashes

2012-03-25 Thread Steve Bertrand
ld tell, your problem wasn't an issue with the references themselves, it was you overlooked the layout of your data structure. Your original Dumper output can help with that visually. If there is anything I didn't explain well, just say so. Good job on your attempts. Steve

Re: printing hashes

2012-03-25 Thread Steve Bertrand
}{$hr}"; } and see if it fixes your problem. Here is the output. If it is not what you desire the output to be, just say so. If it is, let us know. Once we get it sorted, I'll try to explain why it was breaking :) Output: 149:00 101 202 203 204 205 1

Re: printing hashes

2012-03-25 Thread Steve Bertrand
;' Show us what you have so far if you need help with a specific code segment. Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: printing hashes

2012-03-25 Thread Steve Bertrand
On 2012-03-25 12:02, Chris Stinemetz wrote: How would I return the values along with the keys that meet the criteria from the sub routine? On Mar 25, 2012 10:04 AM, "Rob Dixon" wrote: Keeping with the use of $_, replace the following 'print map' statement to the following: print map "$_

Re: work with hexadecimal values

2012-03-08 Thread Steve Bertrand
between the two. While playing around, I found this: perl -e 'printf "%X\n", $_ for ( 0x415a+1 .. 0x415f-1 ) ...prints: 415B 415C 415D 415E Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: work with hexadecimal values

2012-03-08 Thread Steve Bertrand
On 2012-03-08 08:41, John W. Krahn wrote: sunita.prad...@emc.com wrote: Hi Hello, I have one range of hexadecimal numbers like : 415A till 415F . I need to find all other numbers between this 2 . Is there any Perl function which will help to find all numbers or any other way in Perl ? $ pe

Re: work with hexadecimal values

2012-03-08 Thread Steve Bertrand
? $ perl -e'printf "%X\n", $_ for hex( "415A" ) .. hex( "415F" )' Sweet. Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Access class symtab by dereferencing an object

2012-03-03 Thread Steve Bertrand
On 2012-03-03 14:18, Paul Johnson wrote: On Sat, Mar 03, 2012 at 01:51:28PM -0500, Steve Bertrand wrote: Is there a proper way to do this that someone could point out? no strict "refs"; foreach my $entry ( keys %{ ref($dog) . "::" }) But why? If you really need class i

Access class symtab by dereferencing an object

2012-03-03 Thread Steve Bertrand
n't know what class an object belongs to. Here is some pseudocode of what I'm trying unsuccessfully to achieve: my $dog = Animal->new(); foreach my $entry ( keys %{ ref $dog }:: ){ ... } Is there a proper way to do this that someone could point out? Thanks, Steve -- T

Re: read from command line

2012-03-03 Thread Steve Bertrand
en $filename: $!"; my @line = ; That sucks in the entire file into @line all at once, so remove it. while () { print $_; } the while() block should be rewritten as such: while ( my $line = <$file> ){ print $line; } Steve -- To unsubscribe, e-mail: beginners-

Re: Can recursion eliminate nested foreach() loops?

2012-02-26 Thread Steve Bertrand
On 2012-02-26 23:55, Rob Dixon wrote: On 27/02/2012 02:30, Steve Bertrand wrote: I know this isn't a beginner's question, but I know there are geniuses here. Is there a way to simplify this within Perl? Hi Steve Much of the complexity comes from working with the nested data

Re: Can recursion eliminate nested foreach() loops?

2012-02-26 Thread Steve Bertrand
On 2012-02-26 21:52, Shawn H Corey wrote: On 12-02-26 09:30 PM, Steve Bertrand wrote: I know this isn't a beginner's question, but I know there are geniuses here. Is there a way to simplify this within Perl? There is no simplify way of doing this. Separate off the first attribute

Re: Can recursion eliminate nested foreach() loops?

2012-02-26 Thread Steve Bertrand
On 2012-02-26 21:52, Shawn H Corey wrote: On 12-02-26 09:30 PM, Steve Bertrand wrote: I know this isn't a beginner's question, but I know there are geniuses here. Is there a way to simplify this within Perl? There is no simplify way of doing this. Separate off the first attribute

Can recursion eliminate nested foreach() loops?

2012-02-26 Thread Steve Bertrand
d recursion but I can't figure it out. The only thing I could come up with was generating code like code2 as a string and eval()ing it...a poor solution. ... I know this isn't a beginner's question, but I know there are geniuses here. Is there a way to simplify this withi

perl -E

2012-02-24 Thread Steve Bertrand
Hi all, Lately, I have seen many command-line one-liners floating around with the -E argument: perl -E '#do stuff' Could somebody kindly remind me which perldoc I need to review to find out about the differences between -e and -E? Steve -- To unsubscribe, e-mail: beginner

Re: something about "strict"

2012-02-14 Thread Steve Bertrand
t' is not something that is "available as needed". As was pointed out earlier in this thread, the use of 'my' to localize the variable is all that was required. Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: unexpected results

2012-02-08 Thread Steve Bertrand
7;click' for me. (poor Gilligan, he died lonely, as I cut him off completely from CoCoNet :) Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Perl Module to parse any other Perl script/module to fetch stats about data-structures

2012-02-08 Thread Steve Bertrand
t follow single elements. I would suspect that this would be something that would have to run against the file itself, even prior to compile. Curious task. Might I ask what the purpose of your desire is? Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-ma

Re: Foreach loop and hash of arrays

2012-02-06 Thread Steve Bertrand
f the state owns that zip code, and false if it doesn't. Therefore, if it is true, $match will be set to yes. #!/usr/bin/perl use strict; use warnings; my %states = ( AL => [ '350','351', ], AK => [ '995','996', ], AZ =>

Re: Parsing a microarray data file

2012-01-26 Thread Steve Bertrand
)[6] =~ /^[CD]/) { push( @array, $_ ); } ...but oftentimes brevity is not nice on the eyes, especially in a program longer than five or six lines :) Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Jennifer the starlet

2011-09-19 Thread Steve Berg
> This has become another long message. I am copying it to your email. > > I suspect that Jennifer is deleting my messages without reading them, as > I sent her a text recently to ask her to contact Gma as she was unwell. > She has had no contact from J for several weeks, although she told me > th

Re: assigning hash key to reference of array question

2011-02-28 Thread steve park
I am not sure if I am still in mailing list. so cc'ing myself. On Mon, Feb 28, 2011 at 2:47 PM, steve park wrote: > > I have a below program and I am not doing it right. > Currently, only last ip pool is going in since I am putting them w/ key to > values(so only last one show

assigning hash key to reference of array question

2011-02-28 Thread steve park
I have a below program and I am not doing it right. Currently, only last ip pool is going in since I am putting them w/ key to values(so only last one shows up when I print). How can I aggregate and assign them to server_1 so that when I print below will show up? server_1 10.1.1.1 10.1.1.2 10.1.1

Re: Unique list

2010-09-16 Thread Steve Bertrand
uld post an example of your desired results, along with the code you've tried for your homework. Cheers ;) Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: script for shutdown remote machine

2010-09-05 Thread Steve Bertrand
you've tried, and the CPAN search text that you supplied that didn't provide you with the results you were after. Cheers, Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Accessing array from Perl & DBI using Template Toolkit

2010-08-11 Thread Steve Bertrand
vel_tmpl_data{ db_data } = \...@loop_array; Then, you can either create an explicit reference to the top level hash like this: my $tmpl_data_ref = \%top_level_tmpl_data; ...or just skip that step and create the ref as you pass the data into TT. I hope this is what you were after. Note that I prefer to use references directly as opposed to creating array and hash first, but I thought that it would be better in this case if I explicitly did things the long way. Cheers, Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Piping commands into cli perl

2010-07-12 Thread Steve Bertrand
On 2010.07.12 10:31, Shlomi Fish wrote: > On Monday 12 Jul 2010 17:18:12 Steve Bertrand wrote: >> On 2010.07.09 21:57, Uri Guttman wrote: >>>>>>>> "SB" == Steve Bertrand writes: >>> SB> On 2010.07.09 21:40, Uri Guttman wrote: >>>

Re: Piping commands into cli perl

2010-07-12 Thread Steve Bertrand
On 2010.07.09 21:57, Uri Guttman wrote: >>>>>> "SB" == Steve Bertrand writes: > > SB> On 2010.07.09 21:40, Uri Guttman wrote: > > >> what input? i see none there. but what you want is either -p or -n. both > >> are among t

Re: Piping commands into cli perl

2010-07-09 Thread Steve Bertrand
On 2010.07.09 21:57, Uri Guttman wrote: >>>>>> "SB" == Steve Bertrand writes: > > SB> On 2010.07.09 21:40, Uri Guttman wrote: > > >> what input? i see none there. but what you want is either -p or -n. both > >> are among t

Re: Piping commands into cli perl

2010-07-09 Thread Steve Bertrand
On 2010.07.09 21:40, Uri Guttman wrote: >>>>>> "SB" == Steve Bertrand writes: > > SB> But alas, I get nothing, so I tried this as my last line, thinking that > SB> the input would be put in $_: > > SB> perl -e '$_ =~ s/.*\s+//;

Piping commands into cli perl

2010-07-09 Thread Steve Bertrand
$1, " ", $2}' \ | awk '{FS=" "} {print $1, " ", $3}' \ | egrep "^lib/ISP/User.pm$" \ | perl -p -e 's/.*\s+//' But alas, I get nothing, so I tried this as my last line, thinking that the input would be put in $_: perl -e &#x

Re: I don't wont to create more lines of code then the necessary

2010-07-09 Thread Steve Bertrand
the compiler when you clobber a subroutine's argument list, so it's better if you assign the results of a split() explicitly to an array (or list). Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Substitution Problem

2010-06-28 Thread Steve Bertrand
dumbness). > > s/\((\d+)\)/(_$1_ (mip://050adf60/mypage.php?$1) )/g; > > Excellent! Works perfectly. Thank you so much! Perhaps you could post the code you originally started with, so that you/others can understand how/why John's hack works, particularly if your data ever changes. Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: No paths in Test-Harness-3.21.tar

2010-06-21 Thread Steve Bertrand
this issue for now. Please post the workaround for the archives, if you wouldn't mind. Cheers, Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Problems constructing a hash of hashes

2010-06-16 Thread Steve Bertrand
r further information. I keep forgetting that I'm not the only one who knows what Google is. Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Multi page form - cgi

2010-06-16 Thread Steve Bertrand
lowing modules contain exceptionally good documentation, specifically introductory tutorials...particularly DBIx::Class. All have active mail lists, and strong communities of people who are always willing to help. http://cgi-app.org/ http://search.cpan.org/~samtregar/HTML-Template-2.6/Template.pm http:

Re: A subroutine to find every occurrence of a substring in a string?

2010-06-10 Thread Steve Bertrand
> find it again). By documenting where it came from, you are no longer > plagiarizing (but you may be violating copyright). > > [1] : http://en.wikipedia.org/wiki/Larry_Wall#Virtues_of_a_programmer Very well said chas... Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.o

A story

2010-05-27 Thread Steve Bertrand
I once had a sub, taking a single param, kept passing it in until I was damned. All of a sudden, the sub needed two, I knew right then, that I was through. The undef was nice, naughty with spice, but the hrefs as params was what I should do. If you think a sub, will only accept one, accept param

Developer docs

2010-05-27 Thread Steve Bertrand
my current documentation methodology so that people can still enjoy my user docs, while I can review my devel docs within a separate `perldoc' page? Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: How to get environment variables from child shell

2010-05-27 Thread Steve Bertrand
t up the env themselves. In this case, since you do have read access to the parent csh file, you can grok those filenames, read into them, and find out what env vars you need to set prior to executing anything. fwiw, I have had to do this in the recent past. Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: maping a network with perl

2010-05-19 Thread Steve Bertrand
On 2010.05.19 20:59, Steve Bertrand wrote: > On 2010.05.19 15:05, Bob McConnell wrote: >> From: Brian >> >>> On May 19, 2010, at 1:19 PM, packet wrote: >>> >>>> How can we map a network in perl? >>>> >>>> i was just thinking how

Re: maping a network with perl

2010-05-19 Thread Steve Bertrand
ng, I'd recommend doing so in a very confined space... If you are serious network person, there are a lot of good scripts written in Perl for Cacti that you can examine and use as potential roadmaps: http://www.cacti.net/additional_scripts.php Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Need help with writing recursive menu in Perl.

2010-05-18 Thread Steve Bertrand
the next menu (if Alpha is selected A1, A2, A3 & so on) and > store it in var2. > > Can you please help me write a little routine. I'm getting stressed > out with this but no luck. Please help, Friends. Sure, just post what you have so far, and someone will gladly help you fix

Re: data dumper

2010-05-17 Thread Steve Bertrand
Thanks Uri, I understand, and with your explanation, I now know I understood the purpose of Dumper correctly. Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: data dumper

2010-05-17 Thread Steve Bertrand
c, Storable is part of the base now, yes? Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Using # instead of / as REGEX search delimiter

2010-05-10 Thread Steve Bertrand
S+?)/#) { print "$str\n"; } See 'perldoc perlop', specifically the "Quote and Quote-like Operators". Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: how to arrange a default action in a dispatch table

2010-05-07 Thread Steve Bertrand
s the highlight completely out > the window. Emacs is apparently using the quotes as part of how it > finds what to highlight. > > I noticed it long ago, and usually just put the quotes in for that reason. > > I wondered if you have some elisp in ~/.emacs that clears that u

Re: how to arrange a default action in a dispatch table

2010-05-07 Thread Steve Bertrand
On 2010.05.07 19:37, Steve Bertrand wrote: > (fwiw, and I don't have time to get into the rest of the code right now, > I prefer whitespace, so I'd write that as): > > my @ar1 = qw ( > r2one > r2two > r2three # comment,

Re: how to arrange a default action in a dispatch table

2010-05-07 Thread Steve Bertrand
On 2010.05.07 19:58, Uri Guttman wrote: >>>>>> "SB" == Steve Bertrand writes: > SB> (fwiw, and I don't have time to get into the rest of the code right now, > SB> I prefer whitespace, so I'd write that as): > > SB> my @ar1 = qw (

Re: how to arrange a default action in a dispatch table

2010-05-07 Thread Steve Bertrand
On 2010.05.07 19:37, Steve Bertrand wrote: > On 2010.05.07 19:02, Harry Putnam wrote: > >> It looks pretty awkward, the way I just kind of wedged the default >> action in there... is there a more canonical way of doing that? > > I have to be honest ;) > > There

Re: how to arrange a default action in a dispatch table

2010-05-07 Thread Steve Bertrand
'; my $arcnt = 1; for my $element ( @ar1 ) { push @exp,$element; $arcnt++; if (( $arcnt % 4 ) == 0 ) { dispt( $r1name, @exp ); # my instincts say that $arcnt should be reassigned # within this for loop... @exp = (); $arcnt = 1; } } ...much easier to grok (for me anyway) ;) Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: how to denote the like symbol % in perl program

2010-05-04 Thread Steve Bertrand
n"; > print "\tdefault tablespace_name: $tablespace \n"; > } > > if ($sth->rows == 0) { >print "No names matched $name',\n\n"; > } > $sth->finish; > print "\n"; > print "Enter name> "; > } > $dbh->disconnect; > > $rv = $sqlQuery->execute > or die "can't execute the query: $sqlQuery->errstr"; > Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: how to denote the like symbol % in perl program

2010-05-04 Thread Steve Bertrand
gt;search( { plan => { -like => "%$plan_name%" }}, { plan_status => $status }, ); while ( my $record = $rs->next ) { ...show us what you have so far... Steve -- To unsubscribe,

Re: Dispatch table using Tie::RegexpHash

2010-04-29 Thread Steve Bertrand
On 2010.04.29 23:23, Uri Guttman wrote: >>>>>> "SB" == Steve Bertrand writes: > > SB> use Tie::RegexpHash; > > SB> my $number = qr/^\d+$/; > SB> my $alpha = qr/^\w+$/; > > SB> tie my %dt, 'Tie::RegexpHash'; >

Dispatch table using Tie::RegexpHash

2010-04-29 Thread Steve Bertrand
ters ]; }, run => \&run, ); sub run { my $param = shift; $dt{ common }( $param ) ; $dt{ run }( $dt{ $param } ); } $dt{ run }( $input ); __END__ ... I've never used Tie::RegexpHash before, so if you can see what I was trying to do with

Re: about dispatch tables

2010-04-29 Thread Steve Bertrand
my $param = shift; print "3\n"; my $num = get_num(); $dt{ $param }( $num ); } sub get_num { return int( rand( 3 ) +1 ); } $dt{ $input }( $input ); Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: about dispatch tables

2010-04-28 Thread Steve Bertrand
w things that will expand your understanding of how to find what you are looking for, and more importantly, where to look. Dispatch tables are great, but I'm sensing that it may help you if you get a briefing of recursion as well. Cheers, Steve ps. still one of my very favourite quote

Re: about dispatch tables

2010-04-27 Thread Steve Bertrand
d more importantly, where to look. Dispatch tables are great, but I'm sensing that it may help you if you get a briefing of recursion as well. Cheers, Steve ps. still one of my very favourite quotes that I have ever read: "I sometimes enjoy the mind-bending exercise of imagining

Re: about dispatch tables

2010-04-27 Thread Steve Bertrand
de that shows exactly what you've tried? Even extremely broken code that doesn't work at all is imho better than paraphrasing in many cases. Cheers, Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: ExtUtils::MakeMaker, execute Perl code during "make test"

2010-04-16 Thread Steve Bertrand
On 2010.04.16 11:32, Philip Potter wrote: > On 16 April 2010 14:38, Steve Bertrand wrote: >> This particular test: > It sounds like your test isn't a test, it's a setup tool. Tests in > projdir/t are there to test if the stuff in projdir/lib or > projdir/blib works

Re: ExtUtils::MakeMaker, execute Perl code during "make test"

2010-04-16 Thread Steve Bertrand
On 2010.04.16 09:15, Philip Potter wrote: > On 16 April 2010 13:20, Steve Bertrand wrote: >> I use prove often, usually when I want to quickly and non-verbosely (-Q) >> work with a single test file that I'm currently adding new tests to, or >> to ensure existing tests st

Re: ExtUtils::MakeMaker, execute Perl code during "make test"

2010-04-16 Thread Steve Bertrand
On 2010.04.16 03:36, Philip Potter wrote: > On 16 April 2010 02:05, Steve Bertrand wrote: >> On 2010.04.15 18:50, Steve Bertrand wrote: >> What I've done to 'rectify' the issue so that it is clear that the >> config files differ, is rename the test to the h

Re: how to create a hash on the fly

2010-04-15 Thread Steve Bertrand
ences* alone. Whether that is a good thing or not is not for me to decide. It's something that you need to decide. However, if you have a solid foundation, focusing on references will expand your Perl world exponentially. I can promise you that. > Lets see why I cannot ingrain them in my head.

Re: how to create a hash on the fly

2010-04-15 Thread Steve Bertrand
y with references. Many people use dispatch tables to automate processes that follow the rabbit no matter how deep the hole, or how many branches the hole has ;) > Going to code now. Will be back if I get stuck && *thanks* all. Good luck, there's always been someone here to provide feedback. Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: ExtUtils::MakeMaker, execute Perl code during "make test"

2010-04-15 Thread Steve Bertrand
On 2010.04.15 18:50, Steve Bertrand wrote: > Hi all, > > In one of my projects, I've written a test file t/22-upgrade.t. [..snip..] > However, when I run "make test", the Perl code for print does not execute. Replying my own post, this project is currently only u

ExtUtils::MakeMaker, execute Perl code during "make test"

2010-04-15 Thread Steve Bertrand
e on the best way to allow print statements to be sent to STDOUT for only select tests within a specific test file. Can I override the 'test' target in the Makefile.PL, or is there something that I can do within the test file itself? Cheers, Steve -- To unsubscribe, e-mail: beginners-unsub

Re: Nested if and elsif and else

2010-04-14 Thread Steve Bertrand
d to without having to worry about placement). #!/usr/bin/perl use warnings; use strict; my $dt = { simple => sub { print "Simple, anon sub inline\n" }, easy=> sub { my $num = 1; print $num*2 ."\n";}, complex => \&complex, # coderef to external sub, }

Re: Copy file from one server to another

2010-04-14 Thread Steve Bertrand
ithin the web page. > > What would the code look like to do this? I would use SSH. Just make sure that you have set up password-less authentication, and that the user you are logging in with has permissions on the file. #!/usr/bin/perl use warnings; use strict; use Net::SCP qw( scp );

Re: Using References in Modules within threads

2010-04-07 Thread Steve Bertrand
the need or desire to ever have to see a *nix system with a GUI ( I feel the same way about a router having a web interface ;) Now, I'm not saying that I have, or ever would run Perl on Windows though... :) Steve ps. This would be off topic if I didn't include some code: #!/usr/bin/

Re: Getting a subroutine reference from an object instance

2010-04-07 Thread Steve Bertrand
/www.shadowcat.co.uk/blog/matt-s-trout/madness-with-methods/ At a quick glance, that is going to be a very nice read. I can already tell it will solve at least one bug that I still have active and not yet been able to fix in one of my larger applications. Thanks Shlomi, and everyone else

Re: Storing a Hash Inside An Array

2010-03-26 Thread Steve Bertrand
You can extract information by name as opposed to by index. What happens if you remove a server? Your indexes may become mal-aligned, requiring changes to your code. Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Storing a Hash Inside An Array

2010-03-26 Thread Steve Bertrand
a hash reference that contains the specifics of # the server in question my $server1_info = { ftpserver => 'localhost', ftpuser => 'steve' }; my $server2_info = { ftpserver => 'remote',ftpuser => 'dave' }; my $server3_info = { ftpserver => &#

Re: Storing a Hash Inside An Array

2010-03-26 Thread Steve Bertrand
eciated, I can't understand why you want to use the array at all. Unless I'm missing something, just use a hash directly: #!/usr/bin/perl use strict; use warnings; my %config; $config{ ftpserver } = 'localhost'; $config{ ftpuser } = 'steve'; $config{ ftppass }

Re: Object Oriented

2010-03-24 Thread Steve Bertrand
by Randal Schwartz to be quite a good primer and well worth the money. Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: assign s/// value to a scalar

2010-03-11 Thread Steve Bertrand
; ...assigns '1' to $url because =~ binds tighter and assigns a 'true' value to $url, whereas: ( $url ) = $file =~ m{ (.*) /A/\d+.html }x; ...$url here is evaluated first, and assigned the actual string afterwards? iow, is it simply an arithmetic thing, that can also be s

Writing tests for module utility scripts

2010-03-10 Thread Steve Bertrand
ommand-line itself? Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Fwd: Re: question on software development

2010-03-04 Thread Steve Bertrand
erl binary - create a picture --- either - associate your picture to a shortcut to the program, or; - associate your picture to a file extension that is unique or: ask a question that has some code in it. A Research Associate from Harvard wouldn't be asking questions this way on this li

Re: question on software development

2010-03-04 Thread Steve Bertrand
e at Harvard University? Call Bill Gates, he'll show you the way. Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Shorthand for binary bitwise math?

2010-02-22 Thread Steve Bertrand
definition for "beginner question". With that said, I don't like it that Uri has to spend his time spitting out the rules on a frequent basis (especially recently). Also, I am disgusted with name calling, regardless of ANY situation... that is completely unacceptable, especially on thi

Re: sequential value check

2010-02-09 Thread Steve Bertrand
190 ttl=64 DF id=21409 sport=80 flags=SA seq=0 win=5840 rtt=102.8 ms"; > # As seen above, what I am looking for is pulling the id= field $ping_result =~ m{ .* id=(\d+) }xms; my $ping_id = $1; print "$ping_id\n"; % ./id.pl 21409 Steve -- To unsubscribe, e-mail: beginners-

Re: sequential value check

2010-02-09 Thread Steve Bertrand
_result ( @hping_array ) { $ping_result + 10; #... 60 lines of code print "$ping_result\n"; } You will appreciate this in longer programs, as it is very clear as to what the variable is for, and which scope it belongs to. Steve -- To unsubscribe, e-mail: beginners-uns

Re: sequential value check

2010-02-09 Thread Steve Bertrand
Steve Bertrand wrote: > Curt Shaffer wrote: >> #!/usr/bin/perl >> use warnings; >> use strict; >> my $hping; >> my $hping_compare; >> my @hping_array = (); >> >> >> for (1 .. 5){ >> >> $hping = `sudo hping3 www.microso

Re: sequential value check

2010-02-09 Thread Steve Bertrand
_ where possible, here is one way to do it: > elsif ($_ ge $hping_compare){ elsif ( ( $_ + 100 ) >= $hping_compare ) { > print "Appears to be load balancing\n"; > } > else{ > print "Does not appear to be load balancing\n"; > } > }

Re: AW: Warning: Use of uninitialized value

2010-01-29 Thread Steve Bertrand
Thomas Bätzler wrote: > Bob Williams asked: >> I am trying to split the lines in a file into two halves (at the first >> space) each half going into an array. The code I have written is below. > >> ---Code--- >> #!/usr/bin/perl >> use warnings; >> #use strict; > > use strict; # unless you know w

  1   2   3   4   5   6   7   8   9   10   >