On Apr 12, 2005 4:24 PM, David Gilden <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am trying to create case statement, and I am not sure I am on the right
> track,
> any comments?
perldoc Switch
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9
{deep}{hash} is a hash reference)
This will speed things up, and perhaps make code more readable.
I'll leave you to read up on how Perl does OO... not pretty but an
interesting and powerful approach.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+1
> I want to capture the return value of a "C" program
> called inside a perl script. How to do this?
perldoc -f system
To find out that you need $? and/or ($? >> 8).
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-
Can't call method "startR" on an undefined value at (eval
> 10)[/usr/local/lib/perl5/5.8.5/perl5db.pl:620] line 2.
Read the documentation:
http://search.cpan.org/~gmpassos/Statistics-R-0.02/lib/Statistics/R.pm
Note the 0.02 version number - you may have a rough ride.
Jonathan P
robably be better
> > than any suid program.
>
> Yes, i had consider this option too, maybe this can be the better
> solution, but what do you say about a C wrapper?
Depends on your knowledge of C security issues.
A carefully written C wrapper is going to be more secure than a
caref
unt.
* Using the existing samba web administration interface is not
possible - even if automated.
I would consider changing the group of smb.conf to say "lp", then the
permissions to 664. That would probably be better than any suid
program.
Jonathan Paton
--
#!perl
$J=' '
27; for 1, 3, 0, 2;
The eval is required because you can only set $_ to a constant
value.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 >=~/ \S\S \S\S /gx) {m/(
guess that named pipes and anonymous pipes
are implemented using the same code. The difference is
how the connection is established.
UNIX vs INET is another story. On loopback, I guess INET would
easily achieve 100MB/sec, and I think UNIX domain sockets
would be faster still.
Jonathan Paton
--
#
INET sockets?
I believe so, but the difference might not be that great. Which
seams more appropriate?
May the man pages help you in your quest.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 0
an avoid
having to ask. Perhaps the example had a misprint.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 >=~/ \S\S \S\S /gx) {m/(
\d+) (.+) /x,, vec$ J,$p +=$2 ,8,=
#x27;t rely on
nobody noticing.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 >=~/ \S\S \S\S /gx) {m/(
\d+) (.+) /x,, vec$ J,$p +=$2 ,8,= $c+= +$1} warn $J,,
--
> i'm trying to figure out how to split a file delimited
> by commas and newlines.
Sounds like a CSV file to me, and for those you look on
CPAN for a ready made solution.
http://search.cpan.org/search?query=CSV&mode=module
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq&
m easy (if you get Win32:API or similar to do it) to hard (writing drivers
or using the XS layer).
I am not qualified to write about Win32::API.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00
quot;, unpack('C4', $ip);
}
$resolved{$name} = $ip;
}
Notice I have introduced a more meaningful loop variable,
removed "" as the default and used a hash instead.
I suggest you have the code reviewed.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10
dd it on.
If you need more information, please include the module name
you are using.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 >=~/ \S\S \S\S /gx) {m/(
\d+) (.+)
scoped, using my,
then you wouldn't have to undef them. With strict you will HAVE
to learn to use "my" and "our".
> }
> }
>
So, the main lesson of the day is USE STRICT. You will save
days of debugging, which must qualify as being kind (if not gentle ;-)
Jon
your real
problem is when you have week 53. I think you need to only accept
the same or next year for today, and make adjustments if week 53
crops up.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
temporary directory. Debugging this would be too much
like work, maybe someone else would be interested. Sorry.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 >=~/ \S\
he chroot jail.
chroot should never be an excuse for running untrusted or
poor quality software. It is simply another layer of security,
which usually restricts damage if the code is exploited.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 0
> Is there a way to build splice portion: [9,10,11,15,25,28,31,32,34]
> ...
Yes, put those in an array. Like:
my @array = (9,10,11,15,25,28,31,32,34);
my $spliced = @[EMAIL PROTECTED];
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+1
h google for others!
> Perl is an eccentric language to be sure, ...
Not as much as the programmers that use it ;-)
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-
ou have
worked on the problem first. Minimum boilerplate for all scripts
should be:
use strict;
use warnings;
Documentation available via perldoc.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4
.
Why are you doing this? Is most of your experience with C?
Jonathan Paton
On Thu, 16 Dec 2004 19:18:06 +0200, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello,
>
> i have intensively searched the web for a solution on the following problem,
> but could not find any
mplete
pathname (including filename) plus "/passwd", if that directory exists for
reading.
Or more clearly:
if (-r "$_/password") {
$chambers{$filename} = "$fullname/passwd"
}
The documentation for File::Find is the key to your troubles.
Jonathan Paton
--
#!perl
$
d and try. If the toolkit returns
an error then you know you don't have one.
In the situation you want to use X if available, terminal
otherwise, wouldn't it be better just to use an option?
More detail, better answers!
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+
n the new process will reopen
STDIN with
input coming from the keyboard. Or something like that.
I think you need to search for unix systems programming (in C). Once you know
how it is done in C, work out how to do the same in Perl.
Jonathan Paton [Writing of things I have little experien
also diff against a previous
version.
You could split your long(ish) script down in to smaller parts.
If you are really stuck, and you ARE using whitespace effectively,
then send a copy to MY mailbox (***NOT THE LIST***).
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional
(
{ ip => ...,
agent => ...,
type => ...
},
...
);
Then you could do:
my @robots = grep { $_->{type} eq "robot" } @array
There are MANY alternatives.
---
A word about the task:
What happens when multiple agents use the same IP address?
Jonathan P
Hi,
I can only guess at the source of the problem. I think it is because that web
site requires cookies. The solution is to have a cookie jar, like:
my $agent = LWP::UserAgent->new();
$agent->cookie_jar({});
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-
Dear Kevin,
There are thousands of examples of POD on CPAN. E.g.
http://search.cpan.org/src/DCONWAY/Parse-RecDescent-1.94/lib/Parse/RecDescent.pod
Jonathan Paton
On Thu, 09 Dec 2004 09:17:50 -0500, KEVIN ZEMBOWER <[EMAIL PROTECTED]> wrote:
> Can anyone suggest a small mod
od
as my Perl ;-)
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
27;m trying to wrap the ReadKey call in an infinite loop, but it breaks
> as soon as I add the loop. Take away the loop, or convert the ReadKey
> to blocking, and it works just fine. Here's the test code snippet I'm
> using:
Jason,
Have you tried placing the two Read
Dear John,
It is likely that you cannot store complex datastructures in cookies. (at least
how the CGI module is currently written). You could try encoding the data
to a string.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED
grammers, but not the
type people hire to reverse engineer. Obfuscated code is likely to be
poor quality code (lack of pride - bugs hidden away).
http://www.stunnix.com/prod/po/sample.shtml
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PRO
be more useful to other projects.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 >=~/ \S\S \S\S /gx) {m/(
\d+) (.+) /x,, vec$ J,$p +=$2 ,8,= $c+= +$1} w
die "Invalid output from ifconfig! Received: $ppp0\n"
}
Reason: By using a postfix conditional, you are placing emphasis on the
error message not the condition that follows it. I wouldn't normally expect
a postfix conditional to also have important side effects. You may not
agre
you can just
sleep for a second or two and then retry.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 >=~/ \S\S \S\S /gx) {m/(
\d+) (.+) /x,, vec$ J,$p +=$2 ,8,
t mode goes even further.
Also consider where you want to display your errors. Usually, if you die
in a CGI script then the server logs get the die message. The user gets
500 - Internal Server Error and little else.
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7
@array = split //, $string;
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
Dear Graeme,
The problem is with your employers filtering software, as the copy of the
same message I received was unaltered. Perl beginners is not the place
to ask about this.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<h
ight" (and "track"). This RFC is
essentially that design (not surprisingly, since Damian wrote it), so
it will be accepted, albeit with several tweaks. "
Link:
http://dev.perl.org/perl6/apocalypse/A04.html
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additio
rint scalar (('Jan', ...)[-1]);
Or even:
print + (('Jan', ...)[-1]);
As always there is plenty of alternatives.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
monly used. A better way is to use the Error module.
perldoc Error
Sidenote: Consider transactions if your DB supports them, depending on
what you are doing.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.per
itle? Not until after you find the tags!
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
> Example, which works:
>
> %hasha = ( 'b' => 'c', 'd' => 'e' );
> %hashb = ( 'f' => 'g' );
> @array = ( \%hasha );
> push (@array,\%hashb);
Also can be written as:
my @array = {
b => 'c',
perldoc Carp;
If that doesn't do what you want, then:
perldoc -f eval
else just set $@ and return undef. This is a bad solution I think.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org
> if I make a module, say Foobar.pm how do you make it so if a function
> returns false you can die $!; ?
Return undef or 0, just like you are doing. Both your calls to baz have an
argument, so 1 is returned both times. I prefer undef for false.
Jonathan Paton
--
To unsubscribe,
For the 5.6 PPM repository, use:
ppm install http://theoryx5.uwinnipeg.ca/ppmpackages/GD.ppd
__END__
Talk about pain! I couldn't install it due to (Bad protocol 'tcp')
messages. You don't mention anything like that, so maybe... just
maybe you'll get GD installed.
Jo
is one a thousand
times over. Looking at RT for perl 5, the first bug report was in 1999! Maybe
the fix is to make the regex engine significantly slower - hence no action.
Alternatives are quicker anyway.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-ma
didn't manifest itself with your code.
I strongly recommend perlbug. I will add to it.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
et 2.6.5-1.358 #1 Sat May 8 09:04:50 EDT 2004 i686
athlon i386 GNU/Linux
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
e,
it is a script that passes configuration data to the compiler. Many
other libraries use a similar script. You need to include this... but
you have additional problems if it's written in sh.
I would expend my effort on getting GD using PPM.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL
PS:
The Perl Cookbook (May 1999 edition) describes all three of the
techniques properly in recipe 7.8, 7.9 and 7.10. I recommend the
cookbook if you don't already have it.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
inal or the
changed version - not somewhere in between.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
D] mailing list now [EMAIL PROTECTED] for perl golf].
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
Dear Mike,
Surprised you've been stumped for 3 hours, but sometimes the
most obvious bugs are the hardest to find. In your code you have:
...
&printSequence;
foreach my $id (@list) {
...
That function call is causing your problem.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL
older versions of perl I found eval
leaked badly (a simple loop with eval) ballooned well
beyond 100Mb... and climbed.
How much code is involved?
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/>
Dear Manas,
Use the CGI module, which provides a upload() method. In fact, I
googled about for a tutorial that didn't use perl 4's cgi-lib module.
Read:
http://www.sitepoint.com/article/uploading-files-cgi-perl
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For
:
Wide character in print at unicode.pl line 8.
3 = ÅÃ* was smily *Ä* was smily *ÄreÃenu* was smily *
So it appears that it works properly for me. Maybe you should try the
latest version of perl...
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EM
ticularly "beginner" way to do it though.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
Dave,
Yes, look up references in your books.
E.g.
sub example {
my @data = qw;
return [EMAIL PROTECTED];
}
my $reference = example();
for my $word (@{ $reference }) {
print "$word\n";
}
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional comman
e day, if you
aren't using ActivePerl.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
}
}
return \%result;
}
1;
sub trim {
my $string = shift;
$string =~ s/\xa0//;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
I can provide the HTML it is working on off-list, if you want.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
ove untested... E&OE]
I guess there is plenty of alternative ways to achieve this task.
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
ent it all.
Benefits? You can adapt algorithms to work with data they weren't
intended to work with. Or work with external data that closely
matches perl's data types. E.g. DBM files can be represented as a
multilevel hash - but I would still prefer to see DBI used instead.
Jo
In daten_einlesen() you have:
my [EMAIL PROTECTED];
which sets $datenbank to the number of elements in @_ (the arguments
to the subroutine).
You probably want:
my ($datenbank) = @_;
Or:
my $datenbank = shift;
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional
Easy.
When using strict you must use brackets around subroutine and method
calls... I.E.
$object->METHOD(args...)
You need:
my $message=$pop3->RETR($msg_id);
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn
"First".
Jonathan Paton
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
< $length) {
$max_length = $length;
}
}
},
Fifth => sub {
my $max_length = 0;
my $datum;
while (($datum) = each %data) {
my $length = length $datum;
if ($max_length < $length) {
$max_length = $length;
69 matches
Mail list logo