|
|
Up |
|
|
  |
Author: llc00llc00
Date: Jan 11, 2008 18:28
Hi,
Title: Applied Perl
Authors: Peter Williams
Publisher: M&T books
ISBN: 0764547836
I recently bought above book, I unable to download the source code, as
the site www.peterwilliams.net is no longer online. Could anyone point
me to another download link.
Thanks in advance.
LC
|
| |
|
| |
no comments
|
|
  |
Author:
Date: Jan 11, 2008 18:20
Hi,
Title: Applied Perl
Authors: Peter Williams
Publisher: M&T books
ISBN: 0764547836
I recently bought above book, I unable to download the source code, as
the site www.peterwilliams.net is no longer online. Could anyone point
me to another download link.
Thanks in advance.
LC
|
| |
|
| |
no comments
|
|
  |
Author: PerlFAQ ServerPerlFAQ Server
Date: Jan 11, 2008 18:03
This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .
--------------------------------------------------------------------
8.9: How do I ask the user for a password?
(This question has nothing to do with the web. See a different FAQ for
that.)
There's an example of this in "crypt" in perlfunc). First, you put the
terminal into "no echo" mode, then just read the password normally. You
may do this with an old-style ioctl() function, POSIX terminal control
(see POSIX or its documentation the Camel Book), or a call to the stty
program, with varying degrees of portability.
You can also do this for most systems using the Term::ReadKey module
from CPAN, which is easier to use and in theory more portable.
use Term::ReadKey;
ReadMode('noecho');
$password = ReadLine(0);
|
| Show full article (1.70Kb) |
|
no comments
|
|
  |
Author: SteveSteve
Date: Jan 11, 2008 15:20
When you use DBI to add a new record to a SQLite table, for which the
primary key column uses AUTOINCREMENT, is there a way to retrieve what
was the ID value generated for the record you just added?
|
| |
|
1 Comment |
|
  |
Author: SteveSteve
Date: Jan 11, 2008 14:35
Forgive a newbie question, but I'm hoping that someone can shed some
light for me on weirdness I'm seeing when trying to access a particular
hash from an array-of-hashes. I had a lot of difficulty assigning a
particular element to its own variable, but after some experimentation I
found that this works:
my @array = MyModule->getArrayOfHashes();
my $hash = $array[$index];
%%hash = %%$hash;
I have to first create the variable in scalar context, then do a funky
dereferencing thing while changing the context to hash. For one thing,
I'd like to better understand what is really going on here... I just
stumbled across this solution through experimentation and dumb luck, I
don't really understand it. Secondly, I'm wondering if there's some
shorthand technique for doing this that doesn't require three lines of
code. Thanks in advance!
|
| |
|
3 Comments |
|
  |
Author: kjkj
Date: Jan 11, 2008 14:06
Here's the problem. I'm trying to test some code that uses CGI.pm,
running on Linux. I want to do this "locally", without involving
an HTTP server (Apache, etc.).
Each of the intended tests will result in the execution of the
following code from CGI.pm:
read(\*STDIN, $$buff, $len, $offset);
I want the input that is read by this line to come from a scalar
variable (a different one for each test). But I can't get CGI to
read different inputs each time.
The following snippet illustrates the problem:
use CGI ();
sub test {
my $in = shift;
$ENV{ REQUEST_METHOD } = 'POST';
$ENV{ CONTENT_TYPE } = 'text/plain';
$ENV{ CONTENT_LENGTH } = length $in;
close STDIN;
open STDIN, '<', \$in or die $!;
|
| Show full article (1.31Kb) |
|
2 Comments |
|
  |
Author: sgsg
Date: Jan 11, 2008 13:34
On Jan 10, 3:27Â pm, Gunnar Hjalmarsson wrote:
> sg wrote:
>> On Jan 10, 12:54 pm, Gunnar Hjalmarsson wrote:
>>> sg wrote:
>
>>>> open  ( MAIL, "|/usr/bin/mail $email") or die;
>
>>> Try sendmail instead of mail:
>
>>> open MAIL, "|/usr/sbin/sendmail -t $email" or die $!;
>
>> 2. Both, /usr/bin/mail and /usr/sbin/mail -t are correctly
>> interpreting "HIGH" priopity parameter.
>
> [guess you meant to say: /usr/sbin/sendmail]
>
> Funny, I thought that Keith was right in that 'mail' doesn't allow
> message headers to be set the way you described.
>
> -- ...
|
| Show full article (0.76Kb) |
|
no comments
|
|
  |
Author: nunnun
Date: Jan 11, 2008 13:27
I have a comma-delimited text file (example data below). The problem is
that *some* of the lines contain commas within the second field (named
DESC) which is obviously a problem.
I'd like to replace any such commas with a space followed by a hyphen.
Actual sample data:
SKU,DESC,LIST,COST,FLAG1,FLAG2,FLAG3,RELATED,FLAG4
0090 ,CUP-HOOK ,0012.34,0007.40,N,O, ,254-61,001
0110 ,HOOK ,0008.71,0006.53,Y,O, , ,001
0120 ,HOOK, TAPERED ,0004.57,0002.74,N,O, ,254-72 ,001
0130 ,HOOK, RED ,0003.11,0002.33,N, , ,254-79 ,001
What I'd like to and up with:
SKU,DESC,LIST,COST,FLAG1,FLAG2,FLAG3,RELATED,FLAG4
0090 ,CUP-HOOK ,0012.34,0007.40,N,O, ,254-61,001
0110 ,HOOK ,0008.71,0006.53,Y,O, , ,001
0120 ,HOOK - TAPERED ,0004.57,0002.74,N,O, ,254-72 ,001
0130 ,HOOK - RED ,0003.11,0002.33,N, , ,254-79 ,001
There *may* be lines which have more than one comma in the DESCR field.
but luckily the 3rd field always has the format XXXX.XX (four digits,
decimal, 2 digits)
|
| Show full article (1.18Kb) |
|
8 Comments |
|
  |
Author: Yuri ShtilYuri Shtil
Date: Jan 11, 2008 13:11
Is there a module to parse named function parameters in Getopt::Long style?
What I have in mind is something like:
# Call function
&foo('-p1' -> $v1, '-p2' => $v2);
#Define function
sub foo {
my $options = PARSER(@_);
my $v1 = $options->{'p1'};
# ....
}
|
| |
|
2 Comments |
|
  |
|
|
  |
Author: PerlFAQ ServerPerlFAQ Server
Date: Jan 11, 2008 12:03
This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .
--------------------------------------------------------------------
8.28: How can I call backticks without shell processing?
This is a bit tricky. You can't simply write the command like this:
@ok = `grep @opts '$search_string' @filenames`;
As of Perl 5.8.0, you can use "open()" with multiple arguments. Just
like the list forms of "system()" and "exec()", no shell escapes happen.
open( GREP, "-|", 'grep', @opts, $search_string, @filenames );
chomp(@ok = );
close GREP;
You can also:
|
| Show full article (2.18Kb) |
|
no comments
|
|
|
|
|
|
|