What is a good starter perl book to learn perl.
Best learning Perl book is 'Learning Perl'. Also known as the Lama
book. There are other good texts also, but imho that is by far the
best.
Hello everyone. I'm new here, so please forgive me for replying to a
question before asking one, but
Hello,
I'm wanting to test for the presence of two or more words, from a short
list of words, in an address input field in a Perl shopping cart, i.e. both
'box' and 'street', or both 'apo' and 'avenue', etc. and pop up a message.
I've found how to do "or" searches with regex, but not "
Three hours later, I finally had a brainstorm, and came up with the
idea to count the number of occurrences of the words I'm looking for. Here's
what I came up with:
my $str = "PO Box 6545 / 3546 Termbo Street";
my $address_count = 0;
$address_count++ while ($str =~ /box|street|avenue|
Hi Chris,
> It is detecting but not testing if any particular 2 words are in a
> text field and I think that's what you explained you were testing for.
Sorry if my first post was misleading. Those were just some examples.
I'm looking only for an occurrence of _any_ two words in that li
Hello,
I read somewhere that it's bad practice anymore to call a subroutine
like this:
&subroutine();
I've also read where it's faster to call a sub like this:
&subroutine;
than it is to call like this:
subroutine();
Is this true? I searched but I can't find a good re
Thanks to both Peter Scott, and Brian Fraser (who wrote me off-list).
Very informative. I'm cleaning up a very old script that uses the &subroutine
construct and learning more Perl in the process.
> If you're worried about the speed overhead of one vs the other then either
> you are w
On Apr 14, 2011, at 10:15 AM, Uri Guttman wrote:
> goto just shouldn't be in your vocabulary. there is no reason for it at all
> in any decent language, especially perl.
I've been following this thread and I'm just curious. If goto is so
bad, why did they add it to Perl?
Marc
--
To un
On Apr 15, 2011, at 2:11 AM, Shlomi Fish wrote:
> 1. Don't use bareword file-handles.
>
> 2. Use the three-args open:
>
> open (my $file_our, '>>', 'cmdout') or die "Cannot open cmdout: $!";
What about writing it like this:
open ('FILEOUT', '>>', 'cmdout') ||die "cant open cmdout: $! \
On Apr 15, 2011, at 8:37 AM, Alan Haggai Alavi wrote:
>> open ('FILEOUT', '>>', 'cmdout') ||die "cant open cmdout: $! \n";
>>
>> Is that O.K.?
>
> You are still using a bareword filehandle.
Putting single quotes around the filehandle allows it to pass Perl
Critic, so I was just cu
I realize that this list may not be the best, or even most appropriate,
place to ask this question, but I'm just so curious that I'm losing sleep over
it! =;)
What is the best way to embed perl in an HTML file that is _not_
located under the cgi-bin directory? I started learnin
On Apr 22, 2011, at 10:35 AM, shawn wilson wrote:
> either you're phrasing things wrong or i'm misunderstanding things.
It's probably the former. =:\ I'm looking for a way to add snippets of
perl to my HTML pages, something similar to what PHP offers . At this point, I don't need power
On Apr 22, 2011, at 10:21 AM, Agnello George wrote:
> my $tt = Template->new( INCLUDE_PATH => "/var/template" ) || die
> "template process failed:$!";
> $tt->process("form.tmpl",\%tag) || die $tt->error();
It appears that I'd have to explicitly name the template file in my
script. If t
On Apr 22, 2011, at 11:20 AM, shawn wilson wrote:
> says server side includes to me.
> says template toolkit
Thanks, Shawn. I'll give these a try, as well as the others you
mentioned in your previous email. I hadn't heard of PerlDancer before, but it
looks interesting. I ha
> I don't understand why you involve cgi-bin in your question,
I was trying to be concise, and not take up too much space and time on
something that may not have been appropriate for this list, but apparently I
was more vague than concise. =:\ Sorry.
I've been working with an o
Are there any current open source Perl shopping carts out there? The
only carts I've been able to find are either ancient or are written in PHP.
I know about Interchange, but it appears that you have to run an
installer(?), which my ISP won't allow me to do (I can't switch ISP's
On Apr 28, 2011, at 6:49 PM, Jeff Pang wrote:
>>Are there any current open source Perl shopping carts out there? The
>> only carts I've been able to find are either ancient or are written in PHP.
>
> I don't know there is such one.
That's too bad. Back in 2005, I read an artic
Can someone recommend a good ISP that keeps up with Perl? Right now
we're with A2 Hosting and they're still stuck at version 5.8.8, and they refuse
to upgrade because, and I quote,
"we unfortunately cannot perform a global upgrade on perl as it may cause
severe problems with other use
On May 11, 2011, at 4:26 AM, Paul Johnson wrote:
>> I wonder what you urgently need that isn't in 5.8.8? Yes, 5.10/5.12 has
>> a few nice things in it, but nothing life-changing.
>
> I suppose the biggest things aren't really language features as such.
> 5.14.0 will very shortly be released. Tha
On May 11, 2011, at 12:49 PM, shawn wilson wrote:
> besides, it's not like cPanel (or anything else) can't tell perl to
> 'use 5.8.8;' - so what is the point?
My point is simply this - perception. There are plenty of hosts out
there telling people to use them because they have the lates
Good Morning,
I could use some help figuring out where a warning is coming from.
My shopping cart script has the following sub:
695 sub get_ud {
696 my ($log, $pass) = $main::global->{login} ?
($main::global->{form}->{'userlogin'}, $main::global->{form}->{'userpass'}) :
();
On May 31, 2011, at 9:54 AM, Jim Gibson wrote:
> $log and $pass are ASSIGNED in line 696, but they are apparently being
> assigned an undefined value (undef in Perl-speak).
Thanks a million, Jim. You were absolutely correct. I didn't stop to
think about the variable result being undefi
Maybe it's too early in the morning here, but I can't seem to remember
how to use a lexical $variable that is defined inside a foreach loop, outside
of that loop.=:\
Here's the loop:
foreach my $name (split (/, */, $names)) {
next unle
On Jun 3, 2011, at 8:45 AM, Alan Haggai Alavi wrote:
> Here, the scope of $name is limited to the foreach loop and not outside it.
> So, you will have to declare the variable again for use outside the loop.
But wouldn't that make the second "$name" a different variable? I'm
not at my c
C.DeRykus wrote:
> One option is an outer enclosing block that'll extend the scope of $name to
> that entire block:
Jim Gibson wrote:
> Declare the variable just before the loop, and remove the 'my' from the
> foreach statement:
Thanks for the responses. I was able to get it to work
On Jun 3, 2011, at 10:22 AM, Uri Guttman wrote:
>> s>my $sortstr = substr("00$totalcells", -2);
> that looks like you are forcing leading 0's. the common idiom for that
> is sprintf "%02d", $totalcells. your way works but is harder to read.
Thanks, Uri. I didn't catch that.
On Jun 3, 2011, at 1:38 PM, Shawn H Corey wrote:
> That implies something is wrong with your logic.
Yep. I came to the same conclusion. =:)
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
Is there a list of Perl features/removals (since version 5) and when
they were introduced? I've searched for one but have come up empty handed.
Something like this:
Perl 5.10.0 introduced:
given-when
say
Perl 5.12.0 introduced:
...
It would be nice to see at a glance
On Jun 7, 2011, at 3:48 PM, Shawn H Corey wrote:
> See `perldoc perl` and search for:
>
> perlhistPerl history records
> perldelta Perl changes since previous version
> perl51311delta Perl changes in version 5.13.11
> perl51310del
I ran across something interesting today. I'm getting different
results for an array depending on how it's used, as follows:
say @fieldnames;
prints
UIDGroupNamelastmodcategoryhtmlhidettsortorder
-
say "fieldnames = " . @fieldnames;
prints
fieldnames = 7
-
say "fieldnames =
On Jun 8, 2011, at 10:25 AM, Jim Gibson wrote:
> Because Perl is smart! It treats arrays differently depending upon the
> context.
On Jun 8, 2011, at 10:22 AM, Octavian Rasnita wrote:
> When you quote an array, the elements of that array will be separated by the
> content of variable $".
I've written a 'create_sql_table' routine which starts off by pulling
the file name (sans suffix) from a path. I've posted four code snippets below.
All work fine, but I'm curious to know if there is a better (or more elegant)
way
to do it?
The second example is one line shorter
On Jun 9, 2011, at 7:52 AM, Shawn H Corey wrote:
> Use File::Spec and File::Basename together.
From what I read, I thought they did the same thing, but from your post
it appears that there may be differences. What's the advantage in using both
instead of one or the other? Are they not
I'd like to find a way to make a Perl script "modular". What I mean is
that I want to be able to distribute a script either with or without a
particular module/package/lib and have the main script run no matter if it's
included or not.
What I'm trying to come up with is a "lite
On Jun 9, 2011, at 2:46 PM, John SJ Anderson wrote:
> my $module_is_enabled = 0;
> eval 'use My::Special::Module';
> $module_is_enabled = 1 unless $@;
>
> should do what you're looking for.
John,
Thanks for the code. Between that and wrapping a call to an external
sub in an if stat
O.K. I've finished my code to create a MySQL db and/or table, and I'd
appreciate hearing your comments. It works well, but it needs to be cleaned up
before going live. I've left some testing code in. Go ahead and be brutally
honest. I've learned so much from this list already.
Than
On Jun 11, 2011, at 2:21 AM, Shlomi Fish wrote:
> Very well, I'll comment on your code.
Thanks, Shlomi. Much appreciated.
>>my $username = 'root';
>>my $password = 'root';
>>my $host = "127.0.0.1:8889";
>>my $db = "test_dbb";
> I hope you are not connecting to
Dr. Ruud wrote:
> Because of RaiseError, that 'or die' is unreachable code
That's good to know. I wasn't aware of that. I'm reading up on it
now. Thanks!
Gurpreet Singh wrote:
> Just use a boolean "read_Primary_Key" (default false) and then true after
> reading the first line.
I'd like to find a way to check if an e-mail address that is entered on
a form is valid or, at the very least, just not invalid. Checking CPAN, I ran
across a module called Email::Verify::SMTP. Has anyone used this before? If
so, what are your impressions?
If this is not a
Octavian,
> I recommend Email::Valid.
Any particular reason?
Marc
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On Jun 27, 2011, at 12:04 PM, Jim Gibson wrote:
> 'perldoc -q address' "How do I check a valid mail address?"
Thanks, Jim, I'm reading that now. However, after glancing at it, I
may not have been clear in what I actually want. I'm looking to see if it's
valid as far as preventing an
On Jun 27, 2011, at 12:20 PM, Wagner, David wrote:
> Unless you make it a two step process: 1) Send email and individual has
> to reply or click an url, I don't believe you can know if the account is
> active, etc WITOUT the sending.
I can see how that would work fine for a forum,
On Jun 27, 2011, at 1:27 PM, Bob McConnell wrote:
> The problem with this is that, due to the spam plague, most servers will
> no longer tell you if an address is valid. Many do not even return a
> bounce message, but silently discard any and all mail for unknown
> addresses.
Good points.
Rick,
Thank's for the script! I appreciate your help.
Marc
On Jun 27, 2011, at 5:24 PM, Rick Sanders wrote:
> Hi,
>
> I posted a reply to your question but it hasn't shown up yet so maybe there's
> a problem with my News server. Anyway, here is a script that should let you
> do v
On Aug 17, 2011, at 6:58 PM, Randal L. Schwartz wrote:
> Golfers do NOT understand the DAMAGE they are doing to Perl's
> perception outside the Perl community,
What is golf?
Marc
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@
I have a web form where people enter their address info and I want to
make sure that the first three digits of their Zip Code correspond to their
State.
So I'm creating a hash of arrays that contains a list of Zip Codes for
the United States. I've also written a foreach loop to
On Feb 6, 2012, at 1:42 PM, Steve Bertrand wrote:
> This may be easier. It uses the hash elements directly as an array, then uses
> grep to see if the zip code is within the specific state. It returns true if
> the state owns that zip code, and false if it doesn't.
>
> if ( grep( /^$customers_z
I'm trying to set the Return-Path in emails that I send out, but I'm
not having any luck. Here's the code I'm trying:
use strict;
use warnings;
use MIME::Lite;
my $msg = MIME::Lite->new (
From => 'sen...@example.com',
To
On Apr 23, 2012, at 5:06 PM, sono...@fannullone.us wrote:
> I'm trying to set the Return-Path in emails that I send out, but I'm not
> having any luck.
Apparently the culprit is sendmail, which is the default for
Mime::Lite. If I use SMTP instead, I'm able to alter the Return-Path.
$m
Unfortunately, I can't switch to SMTP right now (long story) and so I
need to find a way to get Mime::Lite to send the Return-Path. Does anyone know
how to do this?
If Mime::Lite can't do it, does anyone have another module they can
recommend?
The reason I need to do t
Hi Bob,
Thanks for the reply.
> According to the RFC's, "Return-path" is reserved for use by the transport
> servers. It is likely your server is stripping out the suggestion you have
> put in there.
But I can set it using SMTP, so does sendmail handle things
differently? Unf
I'm having a problem with the following code:
#!/usr/bin/perl
use strict;
use warnings;
my $xtra = 'mail.example.com';
my $host = 'localhost' unless (defined ($xtra));
print $host;
I get the message "Use of uninitialized value $host in print". Does
anyone know why this doesn'
Hi Shlomi,
Thanks for getting back to me.
> What you should do is:
>
> [CODE]
>
> my $host;
> unless (defined($xtra))
> {
> $host = 'localhost';
> }
Unfortunately, that gives me the same error. I had tried it before,
but I was just trying for a one-liner. ;)
> It's a b
On Apr 28, 2012, at 7:32 AM, Lesley Binks wrote:
> Says the $host identifier will be assigned the value 'localhost' only if
> $extra
> is not defined.
>
> But $extra is defined as 'mail.example.com' so $host won't be.
That makes sense. What I'm trying to do is set $host to one of the
Shlomi,
> It's a bad idea to declare variables with a trailing conditional statement
Never mind my "why" question. It finally dawned on me that the unless
statement will not set the $host variable. And I thought sleeping on it would
help. :\
Marc
--
To unsubscribe, e-mail: beginners-
Shawn,
> are you sure this is what you want?
I'm not sure of anything anymore. ;)
I found something that sets $host properly:
my $xtra = 'mail.example.com';
my $host = 'localhost';
$host = $xtra if (length $xtra > 0);
Can anyone see any holes in this code?
Marc
--
On Apr 28, 2012, Lesley Binks wrote:
> To be robust, you might need to check that $xtra is defined AND has something
> sensible in it using a regexp.
Well, after being set straight to the error of my ways, I finally have
code that seems to work in any situation:
my $mail_field; # set
On Apr 28, 2012, Shawn H Corey wrote:
> Moral of the story: use meaningful variable names.
Yep, you're right. =:\ I thought it was going to be a simple question
about the unless statement. Turns out I was headed down the wrong path, so I
changed the variable name to make it clear. Ne
Does anyone know how to update Perlbrew to the latest version? I've
searched their site but I haven't found updating instructions (could be my
Google fu if off today =:\ ). Are you supposed to just overwrite the previous
version instead of updating?
Thanks,
Marc
--
To unsubscribe, e-m
On May 3, 2012, at 1:39 PM, Paul Johnson wrote:
> If you run "perlbrew" or "perlbrew help" you'll see the main commands.
> The one you want is "perlbrew self-upgrade". Just run that and it'll do
> the rest.
Thanks a million, Paul. That did it. It took about 2 seconds to
upgrade - it's
On May 4, 2012, at 11:01 PM, Jim Gibson wrote:
> Consider the Text::Template module, which allows you to embed Perl code in
> your document. I have used it for generating C++ code.
Jim,
How does Text::Template compare to Mason2 for something like this?
Have you ever used it?
Marc
--
I'm trying the following code from Programming Perl, but I'm get the
error "Can't call method "type" on unblessed reference at untitled text 10 line
23". I've checked the errata page, but there's nothing listed for it.
Searching on the error message brings up pages about unblessed refe
Are there any differences between these two idioms if only one or zero
arguments are passed to them?
my ($mode) = @_;
my $mode = shift;
If so, why would you chose one over the other?
It seems to me that they behave exactly the same for this purpose, but
maybe there's a
On May 20, 2012, at 10:07 PM, David Christensen wrote:
> I've updated function_arguments.pl with Benchmark, below. f_direct() is the
> fastest, f_shift() is in the middle (12% slower), and f_assign() is the
> slowest (37%).
David,
Are you saying that it would be faster to do:
my $this
On May 20, 2012, at 8:28 AM, Shlomi Fish wrote:
> The problem is that «$self->animals» returns an (unblessed) array reference
> and
> not the list of individual animals, so you should do something like:
>
> for my $animal (@{ $self->animals }) {
Thanks, Shlomi. That did it. Moose is a
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.
I'm curious as to why you say this. If one way is faster than another,
wouldn't it be better to do it that way, as long as it doesn't c
> For one thing, there is the "Lies, Damned Lies and Benchmarks" factor
I must have missed the e-mail that said "DOG PILE!!!". =;)
Thanks to everyone for the explanations - all good food for thought.
That's why I'm here.
Marc
--
To unsubscribe, e-mail: beginners-unsubscr...@pe
A script that I'm refactoring has global variables in two different
styles, e.g.:
$main::global->{form}->{'mailprog'}
$main::global->{form}->{mailprog}
The quote marks don't seem to make a difference, so what would be the
advantage of using them? What are they and what do they
On May 23, 2012, at 5:35 PM, John W. Krahn wrote:
> Your question is not about quoting variables, which is bad, but about quoting
> hash keys.
On May 23, 2012, at 5:25 PM, Shawn H Corey wrote:
> Yes, you can leave the quotes off if the key contains only alphanumerics.
> Otherwise you need to
Is it possible to use a shebang line, like #!/usr/bin/env perl, so that
scripts will use the currently selected version of Perl with perlbrew?
According to the help, it appears that perlbrew only changes the version for
the CLI:
COMMAND: SWITCH
Usage: perlbrew switch [ ]
Swi
Shawn,
> I don't know anything inside perlbrew that will help, but you could do this:
Apparently this is a know issue with perlbrew. I just found this page:
https://github.com/gugod/App-perlbrew/issues/70
> sudo ln -s /Users/marc/perl5/perlbrew/perls/perl-5.16.0/bin/perl
> /usr/local
Chris,
> Yes, the `#!/usr/bin/env perl` shebang should do. I've used it with perlbrew
> myself.
How are you getting that to work? When I try it, it uses the version
of Perl located at /usr/bin/perl, not the version that's selected with perlbrew.
Marc
--
To unsubscribe, e-mail: beginne
On Jun 3, 2012, at 6:06 AM, Octavian Rasnita wrote:
> but a user has only a single cron job so it is not such a big issue.
And therein lies the rub. Why can't perlbrew do that for us
automatically? perlbrew switch XXX... and you're done!
Your solution makes sense if you only c
On Jun 3, 2012, at 11:18 AM, Paul Johnson wrote:
> I'm sure gugod doesn't need a dozen people asking him the same thing.
If I'm the only one who wants this, then it won't be a priority for him
- and it shouldn't be. However if enough people want it, maybe he'll do it.
>> It does it for
Would someone be so kind as to explain the following, or at least point
me to further reading?
$item =
$main::global->{open}->{catalog}->SurfDB::split_line($main::global->{form}->{'itemid'});
The part I'm having trouble understanding is
"$main::global->{open}->{catalog}->". Wh
On Jun 7, 2012, at 10:19 PM, Brock wrote:
> Finally to your last question, how is this different than just calling the
> package::sub directly? With a method call the instance variable, in this case
> $catalog, always gets passed as the first parameter to the method. Usually
> people name it $s
75 matches
Mail list logo