[23865] in Perl-Users-Digest
Perl-Users Digest, Issue: 6068 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 2 18:05:56 2004
Date: Mon, 2 Feb 2004 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 2 Feb 2004 Volume: 10 Number: 6068
Today's topics:
'Eval'uating a variable (Prabh)
Re: 'Eval'uating a variable <noreply@gunnar.cc>
Re: A Grep and a couple Awks <and a lot of Tassilo help <gnari@simnet.is>
Re: A Grep and a couple Awks <and a lot of Tassilo help <uri@stemsystems.com>
Re: add multiple email to script <gnari@simnet.is>
Checking to see if a paticular file exists (vijay)
Re: Checking to see if a paticular file exists (Walter Roberson)
Deleting lines matching regexp. <nikita@spam.mondenet.com>
Re: Deleting lines matching regexp. (Walter Roberson)
Re: Deleting lines matching regexp. <nikita@spam.mondenet.com>
Re: Deleting lines matching regexp. <jill_krugman@yahoo.com>
Re: Deleting lines matching regexp. <gnari@simnet.is>
Getopt::Std problem <dads_a_linux_geek@yahoo.com>
Re: Getopt::Std problem (Walter Roberson)
Re: Getopt::Std problem <dads_a_linux_geek@yahoo.com>
Re: Getopt::Std problem <usenet@morrow.me.uk>
Re: Getopt::Std problem <dads_a_linux_geek@yahoo.com>
Re: Getopt::Std problem <uri@stemsystems.com>
help installing Storable module <mike@nospam.com>
Re: Help with creating Movies Database <gnari@simnet.is>
Re: Help with creating Movies Database <tassilo.parseval@rwth-aachen.de>
Re: Help with creating Movies Database <gnari@simnet.is>
Re: How to match some characters different to each othe <tore@aursand.no>
Knight's tour in perl ithreads (Walter Roberson)
MIME::Base64.pm <todd@asgweb.net>
Re: network card <Joe.Smith@inwap.com>
Re: One liner: "&&" all elements of array <usenet@morrow.me.uk>
Re: Perl For Amateur Computer Programmers <usenet@morrow.me.uk>
Re: Perl For Amateur Computer Programmers (Walter Roberson)
Re: Perl For Amateur Computer Programmers <bik.mido@tiscalinet.it>
Re: Perl For Amateur Computer Programmers <jwkenne@attglobal.net>
Re: perl v-drive/webfolder program <Joe.Smith@inwap.com>
Re: When is a program too big for one file? <gnari@simnet.is>
Re: When to "use strict" when teaching? <usenet@expires03-2004.tinita.de>
Re: When to "use strict" when teaching? <cwilbur@mithril.chromatico.net>
Re: When to "use strict" when teaching? <no_spam_for_jkeen@verizon.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 2 Feb 2004 13:50:02 -0800
From: Prab_kar@hotmail.com (Prabh)
Subject: 'Eval'uating a variable
Message-Id: <e7774537.0402021350.3631a43a@posting.google.com>
Hello all,
I've a question about the using the eval function at runtime.
I can evaluate a varible, $foo, as
my $bar = eval($foo) ;
But when theres some extra string at the end of $foo, the eval fails
to return any value,
my $bar = eval($foo/moretext) ;
The value of $foo is to be interpolated at the run-time.
If at runtime it interpolates as, "/home/123user", is it possible for
me to eval my $bar as "/home/123user/moretext".
Reason I ask,
I've a file full of property settings, one of which sets the location
of logfile, as follows,
logfile = ${USER_HOME}/logfiles/log.txt
My program traverses through this properties file, finds a match for
logfile setting, gets the value of this setting and needs to expand
the USER_HOME variable as follows,
==============================================================================
if ( $line =~ /^logfile/ )
{
my $log_to_file = (split(/(\s)*\=(\s)*/, $line))[1] ;
# BTW, is 'split' the best way to obtain the value.
# I tried using the regular expressions, but cant find a way to do
# w/o an 'if conditional.'
}
$log_to_file_after_eval = eval($log_to_file) ;
==============================================================================
The eval returns null. So, I'm doing it the hacky way, extracting the
environment variable part of it ( the text between "${" and "}" ) and
splitting it from the rest of the setting value.
==============================================================================
if ( $log_to_file =~ m/^\s*\$\{(.*)\}(.)*/ )
{
$user_home_path = $1 ;
$rest_of_path = $2 ;
# Put the "${ENV" in front of it, to supply it to eval.
$user_home_path = '$ENV{'."$user_home_path"."}' ;
}
$after_eval = eval($user_home_path} ;
$user_home_after_eval = "$after_eval"."$rest_of_path" ;
print "This is path after eval: $usr_home_after_eval\n";
==============================================================================
I'm wondering if theres a more elegant solution for this.
I've a feeling this might get more and more complicated, like some
users may not wrap the variable with {}.
Thanks for your time,
Prab
------------------------------
Date: Mon, 02 Feb 2004 23:23:06 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: 'Eval'uating a variable
Message-Id: <bvmigu$tl0e4$1@ID-184292.news.uni-berlin.de>
Prabh wrote:
> But when theres some extra string at the end of $foo, the eval
> fails to return any value,
>
> my $bar = eval($foo/moretext) ;
>
> The value of $foo is to be interpolated at the run-time. If at
> runtime it interpolates as, "/home/123user", is it possible for me
> to eval my $bar as "/home/123user/moretext".
my $bar = eval($foo) . '/moretext';
The rest of your questions make little sense without sample data.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 2 Feb 2004 19:30:50 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: A Grep and a couple Awks <and a lot of Tassilo help>
Message-Id: <bvm8fk$ma9$1@news.simnet.is>
"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7r7xeja81.fsf@mail.sysarch.com...
> >>>>> "A" == Agrapha <brian@box201.com> writes:
>
> what i like to do is make a usage sub like this:
>
> sub usage {
> my ( $err_text ) = @_ ;
> $err_text ||= '' ; # stop undef warnings
> ...
In this kind of cases I like to do:
sub usage {
my $err_text = shift || 'defaultvalue' ;
...
of course that might not work as expected when '0' is a legal
parameter, different from default, but is applicable in many
situations.
gnari
------------------------------
Date: Mon, 02 Feb 2004 20:53:29 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: A Grep and a couple Awks <and a lot of Tassilo help>
Message-Id: <x7d68xgq47.fsf@mail.sysarch.com>
>>>>> "g" == gnari <gnari@simnet.is> writes:
g> "Uri Guttman" <uri@stemsystems.com> wrote in message
g> news:x7r7xeja81.fsf@mail.sysarch.com...
>> >>>>> "A" == Agrapha <brian@box201.com> writes:
>>
>> what i like to do is make a usage sub like this:
>>
>> sub usage {
>> my ( $err_text ) = @_ ;
>> $err_text ||= '' ; # stop undef warnings
>> ...
g> In this kind of cases I like to do:
g> sub usage {
g> my $err_text = shift || 'defaultvalue' ;
g> ...
i just stay away from shift @_ in most cases. i do use it where it does
something important (like when i want to use a shorter @_ in more calls)
but i stick with my () = @_ in almost all cases.
and in this case you could do (but i wouldn't!):
my( $err_text ) = ( @_, '' ) ;
which works for empty @_ which is the only case i was concerned about
(stopping the undef warning). now this still fails with:
usage( undef ) ;
but that coder deserves to get the warning!
:)
g> of course that might not work as expected when '0' is a legal
g> parameter, different from default, but is applicable in many
g> situations.
but who uses '' or '0' as an error string? so that is fine for usage().
anyhow, my main point is writing a usage sub is a good idea. and there
is a module to make the pod and usage use common text. i saw some hacks
for this once and i used them on a coupld of scripts on a project IIRC.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Mon, 2 Feb 2004 19:35:23 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: add multiple email to script
Message-Id: <bvm8o5$mav$1@news.simnet.is>
<bbhtigger@hotmail.com> wrote in message
news:tihTb.15783$QJ3.14976@fed1read04...
> help, How do I add multiple emails to this script
>
> # if you would like to be notified of uploads, enter your email address
> # between the SINGLE quotes. leave this blank if you would not like to be
notified
> $notify = 'help@help.com';
have you tried try:
$notify = 'help@help.com, help2@help.com';
if that does not do it try using ';' or spaces instead of ','
gnari
------------------------------
Date: 2 Feb 2004 13:10:59 -0800
From: vijaysenthilv@yahoo.com (vijay)
Subject: Checking to see if a paticular file exists
Message-Id: <8fec0185.0402021310.7fde47ad@posting.google.com>
Hi
I'm trying to check to see if a paticular file exist on the machine,
i'm unable to check for files insides directories which have space in
between their names, If i run the script from the command prompt they
seem to run fine, but when i try to open the script on a browser, it
is not able to even open the directory, i get a Invalid Argument
Error,This does not happen for directories which do not have a space
in their name.Any help is greatly appreciated
Sincerly
Vijay
------------------------------
Date: 2 Feb 2004 21:38:11 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Checking to see if a paticular file exists
Message-Id: <bvmg03$bi9$1@canopus.cc.umanitoba.ca>
In article <8fec0185.0402021310.7fde47ad@posting.google.com>,
vijay <vijaysenthilv@yahoo.com> wrote:
: I'm trying to check to see if a paticular file exist on the machine,
:i'm unable to check for files insides directories which have space in
:between their names, If i run the script from the command prompt they
:seem to run fine, but when i try to open the script on a browser, it
:is not able to even open the directory, i get a Invalid Argument
:Error,This does not happen for directories which do not have a space
:in their name.Any help is greatly appreciated
How are you passing the directory name in to the CGI script? If you
are passing it through the GET method (i.e, the directory name
is part of the URL) then make sure that you replace each space
with the character triple %20 -- .e.g,
http://www.yahoo.com/~vijaysenthilv/cgi-bin/checkfile/hi there #wrong
http://www.yahoo.com/~vijaysenthilv/cgi-bin/checkfile/hi%20there #better
--
Live it up, rip it up, why so lazy?
Give it out, dish it out, let's go crazy, yeah!
-- Supertramp (The USENET Song)
------------------------------
Date: Mon, 02 Feb 2004 14:08:52 -0500
From: Nikita Synytskyy <nikita@spam.mondenet.com>
Subject: Deleting lines matching regexp.
Message-Id: <bvm732$tj930$1@ID-30174.news.uni-berlin.de>
I feel this should be so obvious, but it isn't...
From the command line, I'm trying to delete all lines matching a
particular regexp. I know how to do a substitution:
perl -wpi -e "s/foo/bar/g" filename.ext
Now, how do I delete all lines that contain "foo"?
Nikita.
------------------------------
Date: 2 Feb 2004 19:20:40 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Deleting lines matching regexp.
Message-Id: <bvm7u8$83m$1@canopus.cc.umanitoba.ca>
In article <bvm732$tj930$1@ID-30174.news.uni-berlin.de>,
Nikita Synytskyy <nikita@spam.mondenet.com> wrote:
:I feel this should be so obvious, but it isn't...
: From the command line, I'm trying to delete all lines matching a
:particular regexp. I know how to do a substitution:
:perl -wpi -e "s/foo/bar/g" filename.ext
:Now, how do I delete all lines that contain "foo"?
I swear essentially the same question was asked not more than 2 days ago...
perl -wni -e 'print unless /foo/" filename.ext
--
Warning: potentially contains traces of nuts.
------------------------------
Date: Mon, 02 Feb 2004 14:39:16 -0500
From: Nikita Synytskyy <nikita@spam.mondenet.com>
Subject: Re: Deleting lines matching regexp.
Message-Id: <bvm8s2$ijgis$1@ID-30174.news.uni-berlin.de>
Walter Roberson wrote:
> :Now, how do I delete all lines that contain "foo"?
>
> I swear essentially the same question was asked not more than 2 days ago...
>
> perl -wni -e 'print unless /foo/" filename.ext
I can believe it, too! It's obvious if you know the answer, otherwise
you'll spend a day searching.
Thanks for the speedy reply.
Nikita.
------------------------------
Date: Mon, 2 Feb 2004 19:32:19 +0000 (UTC)
From: J Krugman <jill_krugman@yahoo.com>
Subject: Re: Deleting lines matching regexp.
Message-Id: <bvm8k3$oi7$1@reader2.panix.com>
In <bvm7u8$83m$1@canopus.cc.umanitoba.ca> roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:
>perl -wni -e 'print unless /foo/" filename.ext
^
Minor typo there.
Also, to the OP I would advise to use the variant
perl -i.bak -wne 'print unless /foo/' filename.ext
so that, in case your command-line Perl doesn't attain its customary
brilliance, you will be able to try again.
jill
------------------------------
Date: Mon, 2 Feb 2004 19:43:45 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Deleting lines matching regexp.
Message-Id: <bvm97r$mcd$1@news.simnet.is>
"Nikita Synytskyy" <nikita@spam.mondenet.com> wrote in message
news:bvm732$tj930$1@ID-30174.news.uni-berlin.de...
> I feel this should be so obvious, but it isn't...
>
> From the command line, I'm trying to delete all lines matching a
> particular regexp. I know how to do a substitution:
>
> perl -wpi -e "s/foo/bar/g" filename.ext
use -n instead of -p
> Now, how do I delete all lines that contain "foo"?
perl -wni -e "print unless /foo/" filename.ext
the -p is just like -n with implicit print
gnari
------------------------------
Date: Mon, 02 Feb 2004 14:40:22 -0500
From: S <dads_a_linux_geek@yahoo.com>
Subject: Getopt::Std problem
Message-Id: <bvm93c$9mi$1@newslocal.mitre.org>
Hi,
I'm using Getopt::Std in a script that I'm writing. While testing
boundary conditions, I notice some strange behavior. Here's the code
snippet in question:
use vars qw /%option/;
getopts('avs:m', \%option) or die Usage();
die "You did not enter any options - run $0 -h to view options\n" if !
%option;
Now, if I run my script with the -s option, but no argument, it dies as
expected, except for the following:
1 at ./make-acct-ctl.pl line 14.
Can anyone help to explain/correct this?
------------------------------
Date: 2 Feb 2004 19:47:59 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Getopt::Std problem
Message-Id: <bvm9hf$8q5$1@canopus.cc.umanitoba.ca>
In article <bvm93c$9mi$1@newslocal.mitre.org>,
S <dads_a_linux_geek@yahoo.com> wrote:
:I'm using Getopt::Std in a script that I'm writing. While testing
:boundary conditions, I notice some strange behavior. Here's the code
:snippet in question:
:use vars qw /%option/;
:getopts('avs:m', \%option) or die Usage();
:die "You did not enter any options - run $0 -h to view options\n" if !
:%option;
:Now, if I run my script with the -s option, but no argument, it dies as
:expected, except for the following:
:1 at ./make-acct-ctl.pl line 14.
:Can anyone help to explain/correct this?
What exactly does Usage() compute? Is it possible that Usage() is
returning the 1 ? It should return a list, but perhaps along the
way you have an accidental scalar context that is converting a
list containing a single string into scalar(@thatlist) which
would be 1 ?
--
"There are three kinds of lies: lies, damn lies, and statistics."
-- not Twain, perhaps Disraeli, first quoted by Leonard Courtney
------------------------------
Date: Mon, 02 Feb 2004 14:50:05 -0500
From: S <dads_a_linux_geek@yahoo.com>
To: Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca>
Subject: Re: Getopt::Std problem
Message-Id: <401EA9ED.6050009@yahoo.com>
Walter Roberson wrote:
> In article <bvm93c$9mi$1@newslocal.mitre.org>,
> S <dads_a_linux_geek@yahoo.com> wrote:
> :I'm using Getopt::Std in a script that I'm writing. While testing
> :boundary conditions, I notice some strange behavior. Here's the code
> :snippet in question:
>
> :use vars qw /%option/;
> :getopts('avs:m', \%option) or die Usage();
> :die "You did not enter any options - run $0 -h to view options\n" if !
> :%option;
>
> :Now, if I run my script with the -s option, but no argument, it dies as
> :expected, except for the following:
>
> :1 at ./make-acct-ctl.pl line 14.
>
> :Can anyone help to explain/correct this?
>
> What exactly does Usage() compute? Is it possible that Usage() is
> returning the 1 ? It should return a list, but perhaps along the
> way you have an accidental scalar context that is converting a
> list containing a single string into scalar(@thatlist) which
> would be 1 ?
>
sub Usage
{
print <<HELP;
$0 -s <server> | -v | -a | -m
HELP
}
------------------------------
Date: Mon, 2 Feb 2004 20:02:56 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Getopt::Std problem
Message-Id: <bvmadg$jni$2@wisteria.csv.warwick.ac.uk>
S <dads_a_linux_geek@yahoo.com> wrote:
> Walter Roberson wrote:
> > What exactly does Usage() compute? Is it possible that Usage() is
> > returning the 1 ? It should return a list, but perhaps along the
> > way you have an accidental scalar context that is converting a
> > list containing a single string into scalar(@thatlist) which
> > would be 1 ?
> >
> sub Usage
> {
> print <<HELP;
>
> $0 -s <server> | -v | -a | -m
>
> HELP
> }
Well, there you go then: print() returns 1 if the print succeeds. You
probably meant
return <<HELP;
...
Ben
--
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based
on the strictest morality. [Samuel Butler, paraphrased] ben@morrow.me.uk
------------------------------
Date: Mon, 02 Feb 2004 15:05:43 -0500
From: S <dads_a_linux_geek@yahoo.com>
To: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Getopt::Std problem
Message-Id: <401EAD97.1050602@yahoo.com>
Ben Morrow wrote:
> S <dads_a_linux_geek@yahoo.com> wrote:
>
>>Walter Roberson wrote:
>>
>>>What exactly does Usage() compute? Is it possible that Usage() is
>>>returning the 1 ? It should return a list, but perhaps along the
>>>way you have an accidental scalar context that is converting a
>>>list containing a single string into scalar(@thatlist) which
>>>would be 1 ?
>>>
>>
>>sub Usage
>>{
>>print <<HELP;
>>
>>$0 -s <server> | -v | -a | -m
>>
>>HELP
>>}
>
>
> Well, there you go then: print() returns 1 if the print succeeds. You
> probably meant
>
> return <<HELP;
> ...
>
> Ben
>
>
you are correct!!! thanks!
------------------------------
Date: Mon, 02 Feb 2004 20:55:42 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Getopt::Std problem
Message-Id: <x7ad41gq0i.fsf@mail.sysarch.com>
>>>>> "S" == S <dads_a_linux_geek@yahoo.com> writes:
S> sub Usage
S> {
S> print <<HELP;
S> $0 -s <server> | -v | -a | -m
S> HELP
S> }
see my comments in another current thread on how to do a better usage
sub. the usage sub should do the die/exit itself. and it should take an
error string argument. this makes usage calls much cleaner in the main code.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Mon, 2 Feb 2004 16:39:36 -0500
From: "Mike G." <mike@nospam.com>
Subject: help installing Storable module
Message-Id: <_rzTb.576$K6.235@bos-service2.ext.raytheon.com>
Hello,
I would like to use the storable-2.08 module on Sun.
I don't have access to overwrite our Perl system files. Which are at an old
version, Perl 5.4.
In the past I have installed Perl modules into my home directory under a dir
called "lib" and accessed them through there.
I can't seem to figure out how to do this with Storable.
I get this error:
Can't load '/usr2/users/mikeg/lib/auto/Storable/Storable.so' for module
Storable: ld.so.1: /usr/bin/perl: fatal: relocation error: file
/usr2/users/mikeg/lib/auto/Storable/Storable.so: symbol PL_sv_undef:
referenced symbol not found at
/usr/perl5.004/lib/sun4-solaris/5.00404/DynaLoader.pm line 166.
Any idea's?
Thanks,
-Mike
------------------------------
Date: Mon, 2 Feb 2004 19:50:56 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Help with creating Movies Database
Message-Id: <bvm9la$md6$1@news.simnet.is>
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message
news:bvkqnk$53l$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach Tad McClellan:
> When looking at this sequence:
>
> &open_file("FILE1",">>",$filename);
> write_file('FILE1', join '|', $NameText,
$moviedescription,"$moviecast\n";
> close FILE1;
>
> I get pain in my stomach. In the first two lines, "FILE1" is used as a
> string, while in the last line it is used as a filehandle. This can only
> work if the filehandle is created in open_file() through a symbolic
> reference or so.
>
> We need to see the code of open_file() and write_file().
no, I think we actually do not need to see that
I would much rather help the OP with some of his own code.
gnari
------------------------------
Date: 2 Feb 2004 20:14:10 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Help with creating Movies Database
Message-Id: <bvmb2i$9nh$1@nets3.rz.RWTH-Aachen.DE>
Also sprach gnari:
> "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message
> news:bvkqnk$53l$1@nets3.rz.RWTH-Aachen.DE...
>> Also sprach Tad McClellan:
>> When looking at this sequence:
>>
>> &open_file("FILE1",">>",$filename);
>> write_file('FILE1', join '|', $NameText,
> $moviedescription,"$moviecast\n";
>> close FILE1;
>>
>> I get pain in my stomach. In the first two lines, "FILE1" is used as a
>> string, while in the last line it is used as a filehandle. This can only
>> work if the filehandle is created in open_file() through a symbolic
>> reference or so.
>>
>> We need to see the code of open_file() and write_file().
>
> no, I think we actually do not need to see that
>
> I would much rather help the OP with some of his own code.
There were no use() or require() statements in the code he posted, so I
assume that these are functions defined by him.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Mon, 2 Feb 2004 20:32:34 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Help with creating Movies Database
Message-Id: <bvmc3d$mml$1@news.simnet.is>
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message
news:bvmb2i$9nh$1@nets3.rz.RWTH-Aachen.DE...
> Also sprach gnari:
>
> >> We need to see the code of open_file() and write_file().
> >
> > no, I think we actually do not need to see that
> >
> > I would much rather help the OP with some of his own code.
>
> There were no use() or require() statements in the code he posted, so I
> assume that these are functions defined by him.
well,
a) this was obviously not a complete program.
b) the way he said 'modify the code' somehow suggested to me that the code
was felched from the net. (I used the admittedly buggy ESP module for that)
c) if it was his own code, he would have realized that he was not posting
the
most critical part, namely the open_file() and write_file() subs.
I think you give the OP to much benefit of doubt.
gnari
------------------------------
Date: Mon, 02 Feb 2004 23:19:19 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: How to match some characters different to each other?
Message-Id: <pan.2004.02.02.15.00.12.950131@aursand.no>
On Mon, 02 Feb 2004 14:47:57 +0100, Georg Wittig wrote:
> In perl 5.8.3 I need to match a sequence of 7 to 11 characters that
> are different to each other.
What do you mean, actually? Do you want to make sure that the characters
on position 7 through 11 are unique?
> sub find711 {
> my ($arg) = shift;
> my ($string);
> my (%chars) = ();
> if ($arg =~ /([a-z]{7,11})/) {
> $string = $1;
> @chars{split(//,$string)}++;
> return 1 if keys (%chars) == length ($string);
> }
> return 0;
> }
You don't need all those parantheses. Your sub seems to be better off
written like this, IMO:
sub find711 {
my $arg = shift;
my %chars;
if ( $arg =~ m,([a-z]{7,11}), ) {
@chars{split(//, $1)}++;
return 1 if keys %chars == length( $string );
}
return 0;
}
I still don't understand what your problem _really_ is, so if you could
give us some examples...?
--
Tore Aursand <tore@aursand.no>
"Omit needless words. Vigorous writing is concise. A sentence should
contain no unnecessary words, a paragraph no unnecessary sentences,
for the same reason that a drawing should have no unnecessary lines
and a machine no unnecessary parts." -- William Strunk Jr.
------------------------------
Date: 2 Feb 2004 22:17:13 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Knight's tour in perl ithreads
Message-Id: <bvmi99$cl3$1@canopus.cc.umanitoba.ca>
For my amusement / edification, I implimented the generalized
chess "Knight's Tour" problem in perl ithreads with message
passing.
The current version is certainly not the most efficient possible,
and it probably has an off-by-one error in what it thinks of
as a complete solution (I haven't run it long enough to -produce-
a complete solution... it's not the fastest program in the world.)
It's also not intended as a paragon of clean perl coding.
If someone happens to be interested in amusing themselves with
it, or interested in examining an example of threads and message
passing at work, then send me email and I'll send you the source.
[The source isn't terribly long, but I don't have active WWW
pages at the moment or I'd just post a link to it.]
Here's some sample output on the 5x5 board (which isn't solvable btw):
Found partial solution length 23. It's 0 7 4 13 24 17 10 1 8 19 22 15 6 3 14 23 16 5 2 9 18 11 0
:1 :2 :3 :4 :5 :
-+----+----+----+----+----+
1 |23 |8 |19 |14 |3 |
-+----+----+----+----+----+
2 |18 |13 |2 |9 |20 |
-+----+----+----+----+----+
3 |7 |22 |0 |4 |15 |
-+----+----+----+----+----+
4 |12 |17 |6 |21 |10 |
-+----+----+----+----+----+
5 |0 |0 |11 |16 |5 |
-+----+----+----+----+----+
Found partial solution length 23. It's 0 11 20 17 24 13 6 15 22 19 8 1 10 21 18 9 2 5 16 23 14 7 4
:1 :2 :3 :4 :5 :
-+----+----+----+----+----+
1 |1 |12 |17 |0 |23 |
-+----+----+----+----+----+
2 |18 |7 |22 |11 |16 |
-+----+----+----+----+----+
3 |13 |2 |0 |6 |21 |
-+----+----+----+----+----+
4 |8 |19 |4 |15 |10 |
-+----+----+----+----+----+
5 |3 |14 |9 |20 |5 |
-+----+----+----+----+----+
--
Rump-Titty-Titty-Tum-TAH-Tee -- Fritz Lieber
------------------------------
Date: Mon, 02 Feb 2004 15:20:01 -0700
From: Todd Anderson <todd@asgweb.net>
Subject: MIME::Base64.pm
Message-Id: <401ECABE.1CA68039@asgweb.net>
Hello,
After installing mime-base.64.pm i get the following error.
Any help in determinig why is appreciated.
Thanks in advance for your help.
[Mon Feb 2 14:37:22 2004] Base64.pm: [Mon Feb 2 14:37:22 2004]
Base64.pm: Can't locate loadable object for module MIME::Base64 in @INC
(@INC
contains: /usr/libdata/perl/5.00503/mach /usr/libdata/perl/5.00503
/usr/local/lib/perl5/site_perl/5.005/i386-freebsd
/usr/local/lib/perl5/site_perl/5.005 .) at
/usr/local/www/vhosts/fred.com/htdocs/cart.cgi line 3539 BEGIN
failed--compilation aborted at
/usr/local/www/vhosts/fred.com/htdocs/cart.cgi line 3539.
------------------------------
Date: Mon, 02 Feb 2004 21:19:44 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: network card
Message-Id: <Q9zTb.162331$Rc4.1267772@attbi_s54>
Xaver Biton wrote:
> Ok, sorry if was unclear. In windows, wenn you go in dial-up and network
> connection, you can click on new connection and create it manually with the
> wizard, what I want to do is actually automating the whole process with a
> perl script. Now, if a connection exist I can manipulate it with IPHeper and
> IPConfig, but if does't exist, how do I create a new one?
Are you trying to set up a network connection that will use a dial-up
ISP of your own choosing without the user being aware of it?
That's a technique used by porn sites to force unwitting users to
rack up expensive long-distance telephone charges.
------------------------------
Date: Mon, 2 Feb 2004 20:00:10 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: One liner: "&&" all elements of array
Message-Id: <bvma8a$jni$1@wisteria.csv.warwick.ac.uk>
Irving Kimura <irving_kimura@lycos.com> wrote:
>
> # removes duplicates from an array, preserving original order
> @no_repeats = do { my %h; grep !$h{$_}++, @has_repeats };
>
> ...which I found recently in an old c.l.p.m. post, and which make
> Pythonites clutch their heads and run out of the room screaming.
Oh, come on, that's perfectly clear... :)
> I'm looking for the most compact way in Perl to take the logical
> and of all the elements of an array or list. The best I can come
> up with is this:
>
> !grep !$_, @array;
>
> (The corresponding logical or is equally long:
>
> !!grep $_, @array;
>
> The initial !! ensures a scalar result even in a list context.)
The 'or' can be shortened by one character:
+grep $_, @array;
. Other than that, I'd warrant these are the shortest for arbitrary
operands.
If you can guarantee 0 or 1, then "@array"!~/0/ works, with
"@array"=~/1/ for or; if you can further guarantee $"="" then
0+"@array" works for or.
Ben
--
"The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching."
-Assyrian stone tablet, c.2800 BC ben@morrow.me.uk
------------------------------
Date: Mon, 2 Feb 2004 19:26:09 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Perl For Amateur Computer Programmers
Message-Id: <bvm88h$i94$1@wisteria.csv.warwick.ac.uk>
Michele Dondi <bik.mido@tiscalinet.it> wrote:
> A Megabyte is not a *million* bytes. This mathematically boils down to
> the fact that the equation 5^n=2^m doesn't have a solution in integers
> (>0) and that computers tend to privilege powers of two. But n=3, m=7
> is quite a good approximation and a "better" one , for a precise
> definition of "better", involves considerably larger numbers.
Eh? What do powers of 5 have to do with the price of cheese? Don't you
mean 10^3 ~~ 2^10?
And, just to be pedantic, ISO call a million bytes a megabyte (MB),
and 1024^2 bytes a megibyte (MiB), for the sake of consistency with
the rest of the ISO system.
Ben
--
EAT
KIDS (...er, whoops...)
FOR ben@morrow.me.uk
99p
------------------------------
Date: 2 Feb 2004 19:38:20 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Perl For Amateur Computer Programmers
Message-Id: <bvm8vc$8hp$1@canopus.cc.umanitoba.ca>
In article <bvm88h$i94$1@wisteria.csv.warwick.ac.uk>,
Ben Morrow <usenet@morrow.me.uk> wrote:
|Michele Dondi <bik.mido@tiscalinet.it> wrote:
|> A Megabyte is not a *million* bytes. This mathematically boils down to
|> the fact that the equation 5^n=2^m doesn't have a solution in integers
|> (>0) and that computers tend to privilege powers of two. But n=3, m=7
|> is quite a good approximation and a "better" one , for a precise
|> definition of "better", involves considerably larger numbers.
|Eh? What do powers of 5 have to do with the price of cheese? Don't you
|mean 10^3 ~~ 2^10?
10 = 5 * 2, so 10^n = 5^n * 2^n. If you then factor out the 2^n on
both sides, you get the form 5^n ~= 2^m .
--
Positrons can be described as electrons traveling backwards in time.
Certainly many Usenet arguments about the past become clearer when they
are re-interpreted as uncertainty about the future.
-- Walter Roberson
------------------------------
Date: Tue, 03 Feb 2004 21:02:33 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl For Amateur Computer Programmers
Message-Id: <i8dv10hr9di2mpcbkkmesnubvf7ku614qe@4ax.com>
On 2 Feb 2004 10:47:54 GMT, "Tassilo v. Parseval"
<tassilo.parseval@rwth-aachen.de> wrote:
>> It is *by no means* an escape sequence and there is not such a thing
>> called "Escape Sequence command modifier".
>
>Sure it is an escape sequence. From perlop.pod:
>
> The following escape sequences are available in constructs that inter-
> polate and in transliterations.
Once again I stand corrected! I thought that "escape sequences" would
necessarily involve the ESC charachter as in ANSI escape sequences,
i.e. \e aka \x1B (IIRC).
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: Mon, 02 Feb 2004 21:41:54 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Perl For Amateur Computer Programmers
Message-Id: <CuzTb.851$fA.591792@news4.srv.hcvlny.cv.net>
Ben Morrow wrote:
> Michele Dondi <bik.mido@tiscalinet.it> wrote:
>>A Megabyte is not a *million* bytes. This mathematically boils down to
>>the fact that the equation 5^n=2^m doesn't have a solution in integers
>>(>0) and that computers tend to privilege powers of two. But n=3, m=7
>>is quite a good approximation and a "better" one , for a precise
>>definition of "better", involves considerably larger numbers.
> Eh? What do powers of 5 have to do with the price of cheese? Don't you
> mean 10^3 ~~ 2^10?
The immediate instinct of any mathematician is to take out the common
factors. Thus: 5^3 ~~ 2^7.
> And, just to be pedantic, ISO call a million bytes a megabyte (MB),
> and 1024^2 bytes a megibyte (MiB), for the sake of consistency with
> the rest of the ISO system.
Quite so, except it's "mebi"--"bi" for "binary". Kibi (Ki), Mebi (Mi),
Gibi (Gi), Tebi (Ti), Pebi (Pi), and Exbi (Ei).
--
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
-- Charles Williams. "Judgement at Chelmsford"
------------------------------
Date: Mon, 02 Feb 2004 21:26:55 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: perl v-drive/webfolder program
Message-Id: <ygzTb.162336$Rc4.1267919@attbi_s54>
seansan wrote:
> Does the diskquota belong to the real (web) user?
That is something you will have to ask your service provider about.
More likely than not, you will get charged for any warez files
stored on your part of the server.
------------------------------
Date: Tue, 27 Jan 2004 21:39:09 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: When is a program too big for one file?
Message-Id: <bv6lvh$tq9$1@news.simnet.is>
<$_@_.%_> wrote in message
news:OtARb.12448$x05.11156@nwrdny03.gnilink.net...
> HI, this application im currently developing is already
> 737 lines long, 501 of which are all callbacks.
>
> It is my understanding that there is a way to split
> perl programs accross multiple files, but im not sure at what
> point one should think about doing this.
when it is starting to bother you, the programmer/maintainer.
when you find that some parts oer more or less self-contained
and independent from other parts, and might be reusable in
other projects
when more than one person are working on different
parts of the program
how to do it, depends on how you want to split it
- .pm modules
- require
- do
- cat part1 part2 part2 > prog.pl
- use a Makefile to cat part1 part2 part2 > prog.pl
- probably many other ...
perldoc -f require
perldoc -f do
perldoc perlmod
perldoc perlmodlib
gnari
------------------------------
Date: 2 Feb 2004 19:58:03 GMT
From: Tina Mueller <usenet@expires03-2004.tinita.de>
Subject: Re: When to "use strict" when teaching?
Message-Id: <bvma4a$tqi4r$1@ID-24002.news.uni-berlin.de>
Simon Andrews wrote:
> 1) When do you think it's best to introduce strictures into the programs
> people write.
just teach them from the start on, that and why it is important to
declare every variable, and to declare it in the smallest
possible scope. explain my(), our(), use vars() etc. then mention
that there is this very helpful pragma called 'strict' that will
find undeclared variables (and do other things), and i think
people will use it. IMHO this is better than introducing strict
as a must.
this is how perlintro.pod does it, and i like that.
regards, tina
--
http://www.tinita.de/ http://www.perlquotes.de/ http://www.darkdance.net/
Enter the Doors of P e r c e p t i o n
http://www.perl-community.de/ http://berlin.pm.org/
- the above mail address expires end of march 2004 -
------------------------------
Date: Mon, 02 Feb 2004 20:29:46 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: When to "use strict" when teaching?
Message-Id: <87znc1xmnb.fsf@mithril.chromatico.net>
>>>>> "JL" == Juha Laiho <Juha.Laiho@iki.fi> writes:
JL> I think I'd try to get the students use warnings and
JL> strictures from the start. But this depends on how much things
JL> your students allow as "just do it this way", without
JL> questioning and/or requiring in-depth explanation.
Students tend not to like being told "Just do it this way, because I
said so" -- but they're often willing to put up with "Do it this way
for now; there are times you will want to do something differently,
but I can't explain everything at once, and this is something I'll
explain later." Especially if you actually *do* explain bits of it
later on.
Charlton
--
cwilbur at chromatico dot net
cwilbur at mac dot com
------------------------------
Date: Mon, 02 Feb 2004 22:53:32 GMT
From: "Jim Keenan" <no_spam_for_jkeen@verizon.net>
Subject: Re: When to "use strict" when teaching?
Message-Id: <MxATb.12699$bn1.6653@nwrdny02.gnilink.net>
"Simon Andrews" <simon.andrews@bbsrc.ac.uk> wrote in message
news:bvlvj6$36g$1@south.jnrs.ja.net...
> 1) When do you think it's best to introduce strictures into the programs
> people write.
I don't fundamentally disagree with the other posters to this thread who
say, "Use 'use strict;' from the start." However, I want to note that there
exists at least one alternative approach. In Learning Perl ("llama"), 3rd
edition, Randal Schwartz introduces 'use warnings;' in Chapter 2 (Scalars)
but defers 'use strict;' until Chapter 4 (Subroutines). When I last taught
introductory Perl, I used Randal's book and followed his approach for at
least the first 6 chapters.
> 2) How much Perl do you reckon people can comfortably take in one
> sitting? I'm in the nice position of being able to spread the training
> in short sesssions over several weeks so that people don't get
> overloaded (most will never have done any programming before at all).
The latest edition of the llama book benefits from Randal's/Stonehenge's
experience in teaching Perl many times. Each chapter is designed to fit
into a 45-minute presentation. I suspect that they are generally teaching
Perl to already experienced programmers. My teaching experience was mainly
with programming novices; I generally covered 2 chapters in a 140-minute
session.
jimk
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6068
***************************************