Randal L. Schwartz
Oct 4 2003, 02:07 PM
QUOTE |
"Jason" == Jason Normandin <[Email Removed]> writes:
|
Jason> How can I reverse this ? ( Convert date/time format to UNIX timestamp )
There's a myriad of ways. Visit search.cpan.org and type "date" or
"time". The most flexible is probably Date::Manip, which can convert
"third friday in may 2005" to a date. :)
If you already have the y/m/d/h/m/s pieces, you can use the core modules
such as Time::Local to get back to an epoch.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +
<[Email Removed]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Lasse Hubinette
Oct 6 2003, 05:28 AM
Hi,
I have an interface written in Perl between two different systems. The
perl program is started with
case 1:
program.pl -n <integer> -m getPrice -t <string>
case 2:
program.pl -n <integer> -m enterDeal -t <string>
For case 1 the deciamal separator becomes "," and for case 2 it
becomes ".", and I don't know why. They are using different logic to
interface between the system but nothing that should mess up the
decimal separator. I have as part of the program written out all the
envrionment variables and they are exactly the same. So my question is
what decides the perl decimal separator in a program?
My LC settings are:
LC_MONETARY = sv
LC_CTYPE = sv
LC_MESSAGES = C
LC_NUMERIC = sv
Regards
Lasse
James Edward Gray II
Oct 6 2003, 12:30 PM
I believe you meant to send this message to the Perl Beginner's List.
On Monday, October 6, 2003, at 01:51 AM, vaishali wrote:
QUOTE |
I am having my text file called ldap1.txt in the following format
uid : department : branch vaishali.chitale : Corporate Entertainment : Mumbai rajesh.chandran : Planet M - Powai (Retail) : pune
I have written a code so that I can take department and branch according to uid in my program but this code is not working .
|
Let's see if we can fix it up.
QUOTE |
# open ldap1 text file and chunk the elements into a hash
open(F,'<'.$file_name) or die "Can't open $file_name: $!n";
|
Good start.
Why store the whole file in an array so you can later walk it line by
line? Let's just do all our processing right here, instead of the line
above. Here's how I would do it:
my %lp1;
while (<F>) {
my($uid, $department, $branch) = split /s*:s*/, $_;
$lp1{$uid} = { department => $department, branch => $branch };
}
Nothing below this line is needed, but I'll go through it with comments
anyway
QUOTE |
my %lp1;
for my $file (@file) { my @lp1=(split(/s*:s*/,$file))[0];
|
This is the program's main problem. You're splitting the fields and
then throwing away all but the first one with your indexed list
assignment. That's why you're seeing uninitialized warnings, $lp1[1]
and $lp1[2] never receive a value. You could fix this by removing the
( ... )[0] around your split.
Hope that helps.
James
QUOTE |
$lp1{$lp1[0]}{'department'}=$lp1[1]; $lp1{$lp1[0]}{'branch'}=$lp1[2];
}
undef @file;
In above code I am not able to print department and branch it is giving me error for the following
$lp1{$lp1[0]}{'department'}=$lp1[1]; $lp1{$lp1[0]}{'branch'}=$lp1[2];
Use of uninitialized value
what is the problem ?
--- NOTICE----------------------------------------------------------------- --------------------------------- This E-mail (including the attachment/(s) if any ) has been scanned for viruses and dangerous content. For more information mail to [Email Removed] ----------------------------------------------------------------------- ------------------------------------ --- DISCLAIMER------------------------------------------------------------- --------------------------------- The contents of this E-mail (including the contents of the enclosure/(s) or attachment/(s) if any) are privileged and confidential material of Bennett, Coleman & Co. Ltd. (BCCL)and should not be disclosed to, used by or copied in any manner by anyone other than the intended addressee/(s). If this E-mail (including the enclosure/(s) or attachment/(s) if any ) has been received in error, please advise the sender immediately and delete it from your system. The views expressed in this E-mail message (including the enclosure/(s) or attachment/(s) if any) are those of the individual sender. ----------------------------------------------------------------------- ------------------------------------
|
Thomas btzler
Oct 7 2003, 10:34 AM
Hi,
Jerry Preston <[Email Removed]> asked:
QUOTE |
I am trying to change some text from:
if ( (fabs(log(im[ii]/im[ii-1])/vstep) fabs(3*log(im[ii-1]/im[ii-5])/(4*vstep)) ) && ((im[ii] > ifr[x]) || (im[ii-1] > ifr[x])) ) { to if ( (fabs(log(im[ii]/im[ii-1])/vstep) > fabs(3 * log(im[ii-1]/im[ii-5])/(4 * vstep)) ) && ((im[ii] > ifr[x]) || (im[ii-1] ifr[x])) ) { ^^^ ^^^ with the following:
s/(?=[A-z|0-9]+)*(?=[A-z]+)/' * '/g;
What am I doing wrong?
|
Hm, wouldn't this do the job?
s/s*(*{1,2})s*/ $1 /g;
HTH,
Thomas
Joel R Stout
Oct 7 2003, 02:32 PM
Good place to ask. Jenda and some others are great with perl and M$. One
thing I've done in the past is to write HTML but save it as a *.doc.
Example:
Open a file and write:
<html><h1>test</h1><br/><p><b>test</b> <i>test</i> <u>test</u></p></html>
Save it as test.doc.
Open it in Word. It show the formatting. The user can then edit and save
as a doc file (though the first option will be to save it as a htm file).
Joel
-----Original Message-----
From: John [mailto:[Email Removed]]
Sent: Tuesday, October 07, 2003 8:16 AM
To: Perl Beginners
Subject: Microsoft Word Creation
I want to create a doc file that will contain my text, fonts, sizes as if i
wrote manually.
Can i do that thing?
James Edward Gray II
Oct 7 2003, 12:14 PM
Again, you MUST send these to the Perl Beginner's List, if you want
answers.
On Monday, October 6, 2003, at 10:48 PM, vaishali wrote:
QUOTE |
thanks my problem is solved I am having another query. I am having mysql and the table is sms_log. In that my sender field format is
xyz abc <[Email Removed]
I want only the part ie after < sign and before @ sign ie only xyz.abc. How to extract this part from the above field
|
my $address = 'xyz abc <[Email Removed]>';
my $name;
if ($address =~ /<([^@]+)@/) { $name = $1; }
else { die "Malformed address $address.n"; }
James
Roberts Mr Richard L
Oct 7 2003, 06:43 PM
I am using NET::SSH::Perl. Login is correct. mkdir is correct. Yet when I
try to pass a local file to remote host to copy file to newly created
directory, it fails:
code:
use Net::SSH::Perl
my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $pass);
print $ssh->cmd("mkdir $site);
print $ssh->cmd("cd $site); #does not change directory tested using
"cmd("pwd")"
print $ssh->cmd("cp $filename");
etc...
Any help would help.
thanks in advance
Richard
-----Original Message-----
From: Rob Dixon [mailto:[Email Removed]]
Sent: Tuesday, October 07, 2003 3:44 PM
To: [Email Removed]
Subject: Re: Holding File handles in a {} anonymous hash
Dan Anderson wrote:
QUOTE |
I have a module that works with a couple of different file handles. Is it possible to hide them within an anonymous hash? {} (i.e. the objects data). Right now I have:
if (condition_is_met()) { open("FILE","<file"); }
This is in the main body of my package (and thus, I assume, accessible by all functions). Is it better to use tighter encapsulation (i.e. a closure or throwing it into an anonymous hash) or just to leave it in the body?
|
I think you'd be safe like this, except that if you have a lot of them
then you dont' know what the filehandle is going to be called. Here
you've used *Package::FILE, but there's no general way of getting to
that package name from any given filename. How about a hash of glob
references?
Here's a closure with a subroutine which keeps a list of handles for
each file it has already opened. The program just uses it to print
the next line from alternate files.
I hope this helps.
Rob
use strict;
use warnings;
line_from ('filea');
line_from ('fileb');
line_from ('filea');
line_from ('fileb');
line_from ('filea');
line_from ('fileb');
{
my %filehandle;
my $fh;
sub line_from {
my $file = shift;
$fh = $filehandle{$file};
unless (defined $fh) {
open $fh, $file or die $!;
$filehandle{$file} = $fh;
}
print scalar <$fh>;
}
}
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
John
Oct 7 2003, 02:52 PM
Have you got the code to test if you concept is what i need?
----- Original Message -----
From: "Stout, Joel R" <[Email Removed]>
To: "'John'" <[Email Removed]>; "Perl Beginners" <[Email Removed]>
Sent: Tuesday, October 07, 2003 6:32 PM
Subject: RE: Microsoft Word Creation
QUOTE |
Good place to ask. Jenda and some others are great with perl and M$. One thing I've done in the past is to write HTML but save it as a *.doc. Example:
Open a file and write: <html><h1>test</h1><br/><p><b>test</b> <i>test</i> <u>test</u></p></html
Save it as test.doc.
Open it in Word. It show the formatting. The user can then edit and save as a doc file (though the first option will be to save it as a htm file).
Joel
-----Original Message----- From: John [mailto:[Email Removed]] Sent: Tuesday, October 07, 2003 8:16 AM To: Perl Beginners Subject: Microsoft Word Creation
I want to create a doc file that will contain my text, fonts, sizes as if i wrote manually.
Can i do that thing?
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed]
|
Wiggins D'Anconia
Oct 7 2003, 08:06 PM
------------------------------------------------
On Tue, 7 Oct 2003 16:09:44 -0400 , Roberts Mr Richard L <[Email Removed]> wrote:
QUOTE |
<Please start a new thread when appropriate.>Sorry, new to discussion group yet thanks for the advice.
|
Also remember to group reply so others can help and be helped.
QUOTE |
<My first question is, are you trying to copy a file from the local system to the remote?> is what I am attempting. Using Net::SSH::Perl I can logon to remote host, create $directory, yet when I try to copy a local file to remote host it bails. I ran: perl -e 'use Net::SFTP;' and errors so module is not installed. Yet Net::FTP does resolves. So now I am making a new connection using Net::FTP and resolving error for login. I would like to go back to use Net::SSH::Perl and open a connection, create a directory, copy a local file to remote host and bail. Any suggestions would be appreciated.
|
Net::SFTP and Net::FTP are very different animals. The second is a base module used for plain old boring FTP which unless you have access to use it and a specific reason you shouldn't bother. In your case you want the former, the good news is if you have Net::SSH::Perl installed and working (which it sounds as if you do) then you should have no problem getting Net::SFTP to work, since it mainly relies on Net::SSH::Perl. I would suggest installing it and reading through its docs, it can be found on CPAN (http://search.cpan.org/~btrott/Net-SFTP-0.05/lib/Net/SFTP.pm).
Net::SSH::Perl is for sending multiple single commands (not a typo that is what I mean) to a remote shell session (or a single single command depending on the protocol (again that is what I mean)). And standard 'cp' is for doing "local" file system copies (not going to get into NFS, etc. debate). What you are looking for is sftp/scp which is implemented by Net::SFTP.
Conveniently Net::SFTP also provides a 'do_mkdir' method. A combination of the do_mkdir and put methods should fix you up.
A warning/caveat: Net::SFTP is significantly slower than standard openssh's 'scp' I suspect because the encryption/decryption is handled in Perl rather than C though mileage may vary. Other viable solutions are available if this becomes a problem, but they involve shelling out which is not nearly as elegant.
http://danconia.org
Thomas btzler
Oct 8 2003, 07:41 AM
Jerry Preston <[Email Removed]> asked:
QUOTE |
I am trying to break down the following:
printf("numsteps=%d i=%d im=%g vfr=%g n",numsteps,i,imeas,vforce); into "numsteps= numsteps i=i im=imeas vfr=vforce n"
printf ("noriginal cap = %g, offset = %g", *ci, cap_offset); into "noriginal cap = ci, offset = cap_offset";
I am wanting to improve my limited regex skills. Is the above possible or is there a better way with one method?
|
Off the top of my head:
s/printfs*(*(".*?").*?);/$1;/g
Anchoring the end of the pattern with ");" should
insure you against mismatches when there is a
function call instead of a variable in the argument
list. Still, the pattern fails for weird templates
like
printf("some "quoted" text" ();", foo, baz, bar );
If you want to have a bullet-prrof solution, you
should check out Text::Balanced, which takes care of
stuff like balanced quotes, brackets and such.
HTH,
Thomas
Shaun Fryer
Oct 10 2003, 12:44 AM
On Thu, Oct 09, 2003 at 04:15:41PM +0200, [Email Removed] wrote:
QUOTE |
Hi, I'm quite new to Perl scripting, so any help could be really most valuable. I'm trying to write a Perl script which creates a Form (I know how to create a form with HTML or Php), and after the user has compiled the form and pressed the submit button, the same script should parse the input and show the user an HTML page with the elaboration of the input the user has inserted. Thanks to anyone who can help me.
|
For starters, if you haven't already, read `perldoc CGI`. After that, I'd
recommend two other modules which I've found myself becoming excedingly
attached to, CGI::Session and HTML::Template. They may have a slightly
steep learning curve if you're new to perl, but the time savings should
make it well worth the effort.
--
=====================
Shaun Fryer
=====================
http://sourcery.ca/ ph:
=====================
Science is like : occasionally something useful
comes out of it, but that's not why we do it.
-: Richard Feynmann
Rob Dixon
Oct 14 2003, 01:58 PM
Hi Dermot.
Dermot Paikkos wrote:
QUOTE |
I am trying to create a hash and one element is an array. The hash comes from a csv file.
I use $/ = ",""n" because there is a new line in each record. The first 4 elements of each record are always the same and these are easily assigned to the hash. After that there are 20 other fields (keywords) for the record, some blank (that I'd rather discard).
I have 2 problems. One is looping through each record and managing to loop through $fields[4-20] while assigning them to an array. Two, is the reverse, accessing the array elements while printing/looping through the hash. I know a reference is needed here but my attempt at using the cookbook have failed me.
Below is what I have done so far and some sample data. If anyone has the time any advice would be appreciated.
#!/bin/perl
use strict;
|
And
use warnings;
QUOTE |
# Open a cvs file and put contents into images. # File should have fields in this following order: # 1, SPLNUM 2, Photographer, 3, Title, 4, Credit and captions, # 5, keywords.
my ($l,$i,$k,$v,$w); # Predefined global variables;
|
These variables need to have better names so that it's more
obvious what they're for.
QUOTE |
my %headers; my (@words);
$/ = ",""n"; # This defines the record separator as
|
This is a lot clearer written:
$/ = qq(,""n)
QUOTE |
# ,""n. Note: the csv file will have a newline # between the credit line and the caption.
my $infile = shift; # Input file
open(FH,"$infile") or die "Can't open $infile: $!n";
# Read in the file, a record at a time.
while (defined($i = <FH>) ) {
#print "Record $. = $in";
# parse_csv (stolen from a book) takes care of any # unusual characters that might appear in the keywords # such as commas, &, [ ...etc.
my @lines = parse_csv($i);
# print "$lines[0] = $lines[0]n";
# Fields 0,1,2,3 are all pre-defined. 0 => number, 1 => photog, # 2 => title, 3 => credit and caption, 4 and on => keywords.
$headers{'splnum'} = $lines[0];
$headers{'photog'} = $lines[1];
$headers{'title'} = $lines[2];
($headers{'credit'}) = ($lines[3] =~ /CREDIT: (.*/.*RARY)/); (my $cap) = ($lines[3] =~ /.RARY.(.*)/s); (my $caption = $cap) =~ s/n//g; # Throw away any extra newlines.
($headers{'caption'}) = ($caption);
|
It's simpler to assign slices of the hash. Also, using 'splice'
will remove the used elements from the @lines array.
@headers{ qw/ splnum photog title /} = splice @lines, 0, 3;
@headers{ qw/ credit caption / } =
shift (@lines) =~ /CREDIT:s+(.*/.*?LIBRARY)[sxA0]+(.*S)/;
Note the character class [sxA0] which is all whitespace characters
plus non-breakable space xA0 which appears between the credit and
caption fields of our data.
You have mutiple spaces in the 'caption' text, compress them to single
spaces like this if you need to:
$headers{caption} =~ s/s+/ /g;
QUOTE |
# The rest of the fields in the records will be keywords and these may # vary in number but there shouldn't be more than 20.
|
All of the elements of @lines are now keywords, so there's no need
to start at offset 4.
QUOTE |
my $sizeof = 4; my ($d,$keyw_ref); my @keywords;
for ($d = 4; $d <= 20; ++$d ) { print "$lines = $lines[$d] $sizeof = $sizeofn"; push(@keywords,$lines[$sizeof]);
} $keyw_ref = @keywords;
$headers{'keywords'} = $keyw_ref;
|
Strip leading and trailing spaces from each element and push the
result directly into the hash field if the result has a non-zero
length:
foreach (@lines) {
s/^s+//;
s/s+$//;
push @{$headers{keywords}}, $_ if length;
}
QUOTE |
# Print the hash keys and values so I can see if everything has been # assigned correctly
while ( ($k,$v) = each %headers ) { if ( $k =~ /keywords/ ) { my $item; foreach $item (@$keyw_ref) { print "$itemn"; } i # End of foeach $item } # End of if
print "$k => $vn"; } # End of while
} # End of mail while.
|
There's not much wrong with this except that you're using $keyw_ref
which is left over from previous code instead of using the array
reference out of the hash. Also you'd have no need to comment each
block's closing brace if you indented the blocks. Try this:
while ( my ($k, $v) = each %headers ) {
print "$k => ";
if ( $k eq 'keywords' ) {
print "n $_" foreach @$v;
print "n";
}
else {
print "$vn";
}
}
QUOTE |
# ==== SUBS =====
sub parse_csv {
my $text = shift; my @new = (); push(@new, $+) while $text =~ m{ "([^"\]*(?:\.[^"\]*)*)",? | ([^,]+),? | , }gx;
#push(@new, undef) if substr($text, -1,1) eq ','; # omitted this as I hoped to discard the # empty fields.
return @new; }
|
I think that should do what you need.
I hope it helps,
Rob
Lonewolf
Oct 20 2003, 03:12 PM
If you are root on your own system and have access to the command line do
this:
root>perl -MCPAN -e shell
when it comes up to the shell put this in:
o conf prerequisites_policy follow
It will automagically go after the prerequisites for the current Module that
you are installing.
Robert
QUOTE |
On Mon, 20 Oct 2003 14:32:07 -0500 Robert Citek <[Email Removed]> wrote. Hello all,
What is the easiest way to install a module from CPAN that has several dependencies? Specifically, I want to install XML::Simple. However, that module depends on a few other perl modules. For now, I'm downloading the modules individually and installing them. But this seems to be a problem of dependencies that has already been solved by apt-get in the debian world
(and now for RPMs, too).
Is there an apt-get equivalent for perl modules? If so, what is it called? Can CPAN already do this? If so, please point me in the right direction. Have been googling, but nothing yet.
Thanks in advance.
Regards, - Robert
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed]
|
Jeff Westman
Oct 21 2003, 03:06 PM
Steve Grazzini <[Email Removed]> wrote:
QUOTE |
On Tue, Oct 21, 2003 at 12:17:17PM -0700, Jeff Westman wrote: # ... but can I do something like.... print "firstn" unless ($counter) else { print "secondn";
Not really. You could use the conditional operator, though.
print $counter ? "secondn" : "firstn";
|
True, but I was looking for a way to do this with a somewhat "buried" unless
keyword.
TA
-JW
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
Alan Perry
Oct 21 2003, 08:29 PM
On Tuesday, October 21, 2003 16:01, Kevin Pfeiffer wrote:
QUOTE |
In article <[Email Removed]>, Steve Grazzini wrote:
On Tue, Oct 21, 2003 at 01:06:44PM -0700, Jeff Westman wrote: Steve Grazzini <[Email Removed]> wrote: On Tue, Oct 21, 2003 at 12:17:17PM -0700, Jeff Westman wrote: # ... but can I do something like.... print "firstn" unless ($counter) else { print "secondn";
Not really. You could use the conditional operator, though.
print $counter ? "secondn" : "firstn";
True, but I was looking for a way to do this with a somewhat "buried" unless keyword.
print +( qw(second first --> unless <--) )[ not $counter ];
??? :-|
|
I think the author was trying to be cute... I got a chuckle out of it!
print +( qw(second first --> unless <--) )[ not $counter ];
Basically, you are creating an anonymous (right term?) array, and printing
the "not $counter"'th element. So if $counter is 0, you print "first",
otherwise you print "second". The other stuff in the array is there just to
satisfy the "buried" unless requested by the OP. However, as you see here,
it does not use the keyword "unless", just a string "unless". The only
elements that will ever be accessed are "second" and "first"...
It could also be written as:
print +( qw(second first) )[ not $counter ];
HTH
Alan
Eurospace Szarindar
Oct 27 2003, 10:59 AM
Hi Dan,
To be sure to collect something, you could use the "nvl(VALUE_ORI,
replacement_value_if_VALUE_ORI_is_null)" function which will return
something if the entry value is null otherwise return the entry value..
select nvl( max(id), 0 ) from table_id ;
The "nvl" is an Oracle function but sure that there is something similar on
Mysql
=================SQL> create table table_id ( id integer );
Table created.
SQL> select max(id) from table_id;
MAX(ID)
----------
SQL> select nvl(max(id), 0) from table_id;
NVL(MAX(ID),0)
--------------
0
SQL> insert into table_id(id) values (1);
1 row created.
SQL> select nvl(max(id), 0) from table_id;
NVL(MAX(ID),0)
--------------
1
=================
Michel
-----Message d'origine-----
De: dan [mailto:[Email Removed]]
Date: dimanche 26 octobre 2003 14:40
: [Email Removed]
Objet: Re: RE : SQL Syntax quickie
The MAX(id) didn't return anything, i eventually settled for an idea posted
to
SELECT id FROM memodata ORDER BY id DESC
then take the first line value and ignore the rest. Ideally though i want
the last line with the highest id number. I know for a fact that another
INSERT won't happen before the SELECT because they happen immediately one
after the other.
FYI, i'm using MySQL and DBD::mysql if that's any more help.
Many thanks
Dan
"Tore Aursand" <[Email Removed]> wrote in message
news:[Email Removed]...
QUOTE |
On Sun, 26 Oct 2003 06:30:11 +0100, SIMON Cedric wrote: For your query, try "SELECT MAX(id) FROM table" That works with mysql.
That should "work" with most databases, but what happens if there's a new insert between the original insert and the SELECT statement above?
This _could_ be solved by locking the table before the insert, and then unlocking it again after you've select the maximum id from the same table.
-- Tore Aursand <[Email Removed]
|
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
Luke Bakken
Oct 27 2003, 02:43 PM
QUOTE |
-----Original Message----- From: Aaron Davies [mailto:[Email Removed]]
I'm trying to install BerkeleyDB via CPAN on my OS X 10.2.6 box, but the make phase bombs almost immediately. I've put the error log at <http://bellsouthpwp.net/d/a/davies42/bdbmake.txt>, since it's a little larger than I like to mail people. Can anyone give me a hand here?
|
BerkeleyDB.xs:74:2: #error db.h is from Berkeley DB 1.x - need at least
Berkeley DB 2.6.4
I'd go looking for that old db.h laying around somewhere.
Bob Showalter
Oct 27 2003, 03:52 PM
Octavian Rasnita wrote:
QUOTE |
Does anyone know if it is possible to find out the path in which a perl program is launched?
For example, I am in /var/www and I run the following command:
perl /home/script.pl
And I want it to give me the result:
/var/www
|
Use the standard Cwd module.
Aaron Davies
Oct 27 2003, 08:02 PM
On Monday, October 27, 2003, at 09:43 AM, Bakken, Luke wrote:
QUOTE |
-----Original Message----- From: Aaron Davies [mailto:[Email Removed]]
I'm trying to install BerkeleyDB via CPAN on my OS X 10.2.6 box, but the make phase bombs almost immediately. I've put the error log at <http://bellsouthpwp.net/d/a/davies42/bdbmake.txt>, since it's a little larger than I like to mail people. Can anyone give me a hand here?
BerkeleyDB.xs:74:2: #error db.h is from Berkeley DB 1.x - need at least Berkeley DB 2.6.4
I'd go looking for that old db.h laying around somewhere.
|
I tried hacking the Makefile to replace /usr/include/db.h, the version
from Apple's perl install, with /sw/include/db4/db.h, the version
installed by Fink, which is presumably more up to date, but it hasn't
helped much. Make now succeeds, but make test fails as shown below.
Furthermore, the script I'm installing BerkeleyDB in order to run
doesn't find it at all, as also shown.
***make test output***
12-220-219-110~/.cpan/build/BerkeleyDB-0.24% make test
PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/btree........dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/btree........dubious
Test returned status 0 (wstat 5, 0x5)
t/db-3.0.......dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/db-3.0.......dubious
Test returned status 0 (wstat 5, 0x5)
t/db-3.1.......dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/db-3.1.......dubious
Test returned status 0 (wstat 5, 0x5)
t/db-3.2.......dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/db-3.2.......dubious
Test returned status 0 (wstat 5, 0x5)
t/db-3.3.......dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/db-3.3.......dubious
Test returned status 0 (wstat 5, 0x5)
t/destroy......dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/destroy......dubious
Test returned status 0 (wstat 5, 0x5)
t/encrypt......dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/encrypt......dubious
Test returned status 0 (wstat 5, 0x5)
t/env..........dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/env..........dubious
Test returned status 0 (wstat 5, 0x5)
t/examples.....dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/examples.....dubious
Test returned status 0 (wstat 5, 0x5)
t/examples3....dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/examples3....dubious
Test returned status 0 (wstat 5, 0x5)
t/filter.......dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/filter.......dubious
Test returned status 0 (wstat 5, 0x5)
t/hash.........dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/hash.........dubious
Test returned status 0 (wstat 5, 0x5)
t/join.........dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/join.........dubious
Test returned status 0 (wstat 5, 0x5)
t/mldbm........skipped
all skipped: MLDBM is not installed on this system.
t/queue........dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/queue........dubious
Test returned status 0 (wstat 5, 0x5)
t/recno........dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/recno........dubious
Test returned status 0 (wstat 5, 0x5)
t/strict.......dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/strict.......dubious
Test returned status 0 (wstat 5, 0x5)
t/subdb........dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/subdb........dubious
Test returned status 0 (wstat 5, 0x5)
t/txn..........dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/txn..........dubious
Test returned status 0 (wstat 5, 0x5)
t/unknown......dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/unknown......dubious
Test returned status 0 (wstat 5, 0x5)
FAILED--20 test scripts could be run, alas--no output ever seen
make: *** [test_dynamic] Error 2
***attempt to run POPFile***
POPFile Engine loading
Loading...
{core: config logger mq}
Can't locate BerkeleyDB.pm in @INC (@INC contains:
/sw/lib/perl5/5.6.0/darwin /sw/lib/perl5/5.6.0 /sw/lib/perl5/darwin
/sw/lib/perl5 /System/Library/Perl/darwin /System/Library/Perl
/Library/Perl/darwin /Library/Perl /Library/Perl
/Network/Library/Perl/darwin /Network/Library/Perl
/Network/Library/Perl .) at Classifier/Bayes.pm line 50.
BEGIN failed--compilation aborted at Classifier/Bayes.pm line 50.
Compilation failed in require at POPFile/Loader.pm line 356.
--
__ __
/ ) / )
/--/ __. __ ________ / / __. , __o _ _
/ (_(_/|_/ (_(_) / / <_ /__/_(_/|_/ <__</_/_)_
Chris
Oct 29 2003, 01:41 AM
[Email Removed] (Roy Johnson) wrote in message news:<[Email Removed]>...
QUOTE |
[Email Removed] (Chris) wrote in message news:<[Email Removed]>... Thanks to Ingo for refering me to this group.
Please tell Ingo that the correct group is comp.lang.perl.misc since this group is no longer a public group. You can also try perl.beginners
You will get more responses from a public group. I can't answer your questions, but I'm sure someone can in comp.lang.perl.misc. In the meantime, it may help for you to take a look at perldoc perlsec
|
Thanks for the advice, I did reading the perl security and perl doc
and it gives me programming syntax.. I think my script program is not
the problem, there must be something else..
Tim Johnson
Oct 30 2003, 01:45 AM
Install DBI and DBD::ODBC. Then you should be able to do something like
this:
use DBI;
my $dbh = DBI->connect("dbi:ODBC:driver=Microsoft Access Driver
(*.mdb);dbq=PLACE_DB_NAME_HERE", '','') || die "$DBI::errstrn";
my $sthCreateTable = $dbh->prepare( q{CREATE TABLE 'MAIN' (server
varchar(50),service varchar(50),username varchar(50))} || die $dbh->errstr;
$dbh->execute || die $dbh->errstr;
-----Original Message-----
From: Bob X [mailto:[Email Removed]]
Sent: Wednesday, October 29, 2003 1:46 PM
To: [Email Removed]
Subject: Re: What's the Perl driver for MSAccess?
"Scott E Robinson" <[Email Removed]> wrote in message
news:[Email Removed]...
QUOTE |
Can anyone tell me what the Perl driver for MSAccess is called and how to use it to read a table?
Thanks,
Scott
Scott E. Robinson SWAT Team UTC Onsite User Support RR- EMB-2813N
|
DBD::ODBC
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
Try with $q->param("qty$i");
thereis no variable interpolation in '' but when u use "" variable interpolation works.
regards,
KM
------------------------------------------------------------------
On Fri, Oct 31, 2003 at 01:01:49PM -0500, radhika sambamurti wrote:
QUOTE |
Hi, I am trying to do this:
for( $i = 0; $i < 5; $i++) { $qty[$i] = $q->param('qty$i'); } I could say $q->qty0; $q->qty1; | | | $q->qty4;
and be done with it. That works. But I would rather do it from the loop. Why is my variable $i not being appended to qty form variable being passed? Any ideas?
Thxs. Radhika
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed]
|
--
Bob Showalter
Nov 3 2003, 01:24 PM
Olivier Wirz wrote:
QUOTE |
Hello,
I try to install DBI and DBD::Oracle on a Windows XP.
With DBI it works fine this way:
ppm install DBI
but it doesn't work with DBD::Oracle
install DBD::Oracle --> Searching for 'DBD::Oracle' returned no results
Is there a way to install it with ppm otherwise ?
|
Try
install DBD-Oracle
In general, you replace the '::' with '-' for ppm.
HTH
Richard Heintze
Nov 4 2003, 01:23 PM
I have just discovered the the following code causes
trouble when I have "use strict" and "use warn";
use strict;
use warnings;
my $k = $q->param('xyz');
print qq[ $k = $k ];
The problem is that if there is no GET/POST param
called xyz, we are concatenating with a null value
and, when using CGI with Apache HTTPD, this is not a
problem (except it tends to make for large error
logs).
However, when using it with IIS it is a big problem
because the warning text gets inserted into the HTML
output (which is a BIG problem if you are in the
middle of emitting javascript code).
Is there a way I can suppress only concatenation
warnings? I did perldoc strict and perldoc warnings
and could not determine if the supression I want is
possible.
Thanks,
Sieg
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
Richard Heintze
Nov 4 2003, 03:58 PM
I'm running perl 5.6.1 on Apache HTTPD V2.
I noticed some values were not appearing on the web
page.
After several hours I tracked it down to these line of
code. The concantenation is failing suddenly!
my $hidden="<table><tr><td>";
&FormElements($hidden...);
sub FormElements{
my $hidden = @_;
my $t1 = qq[<input type=text value=mumble>];
$$hidden .= $t1;
}
When single stepping thru this code with the
OpenPerlIDE debugger I see the new value of $$hidden
is just "<input type=text value=mumble>" AFTER THE
CONCATENATION! It just did a copy instead of a
concatenation! This explains where my table went when
I look at the web page!
I tried rewriting the problem line of code:
$$hidden = $$hidden.$t1;
This did not help -- same results!
I tried
$$hidden = qq[$$hidden$t1];
Same results! No concatenation again!
Am I loosing my mind?
Sieg
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
Richard Heintze
Nov 4 2003, 04:40 PM
Jenda,
Sorry -- I was not quoting my own code precisely and
I am using strict and warnings.
I am using parenthesis. I attached the exact code
for the subroutine below.
--- Jenda Krynicky <[Email Removed]> wrote:
QUOTE |
From: Richard Heintze <[Email Removed] After several hours I tracked it down to these line of code. The concantenation is failing suddenly!
my $hidden="<table><tr><td>"; &FormElements($hidden...);
sub FormElements{ my $hidden = @_;
This line is incorrect.
my $t1 = qq[<input type=text value=mumble>]; $$hidden .= $t1;
As use strict; would have told you.
The problem is that the my $hidden = @_; sets $hidden to the number of elements in @_. Not to the first parameter passed to FormElements().
So the $$hidden doesn't access the global $hidden variable, but a variable whose name is the number.
Try to print the $hidden inside the subroutine!
You want either my ($hidden) = @_; or my $hidden = shift(@_);
sub FormElements { |
my ($me,
$next,
$ev_count,
$curr_true, # integer array created in insert
data
$prob_innoc,
$prob_guilt,
$hidden) = @_;
# The first time we view the Enter Probabilities
page (display)
# we have the option of specifing admissibility (the
probability of the evidence being admissible in court)
# and the probability the fact is true.
#
# When there are subsequent assertions or suspects,
there is no need to allow the user to change this
information
# so we surpress the text edit box.
#
my $bReadOnly = !$me->bFirstSuspect(); #
$me->{pass}==0 && $next==1; # Can the user change
this? Yes, if this is the first Suspect/Assertion.
my $t3 = $me->{admissibility};
my $admis = sprintf "%3d", $t3->[$ev_count];
print
($me->bShowAdmissibility()?(qq[
<TD ALIGN="CENTER" STYLE="font-family:serif;
font-size:18px; font-weight: bold;
background-color:#ffcc00">]
.($bReadOnly?qq[$admis <INPUT class=debug
READONLY TYPE=TEXT NAME=prob_admis$ev_count SIZE="2"
VALUE="$admis" />]:qq[<INPUT TYPE=TEXT
NAME=prob_admis$ev_count SIZE="2" VALUE="$admis" />])
."</TD>"):"");
print qq[
<TD ALIGN="CENTER" STYLE="font-family:serif;
font-size:18px; font-weight: bold;
background-color:#ffcc00">];
# older code: $me->{base_type}=~"Rank" ||
$me->{base_type}=~"RA" || $me->{base_type}=~"Compare
Assertions"
# old code: ($me->{base_type} ==
&case_constants::btCompareAssertions ||
$me->{base_type} == &case_constants::btRankSuspects)
if ($me->MultiSuspectCase() && $bReadOnly){
# No input box here!
my $t2 = @{$$curr_true}[$ev_count]; # This is so
wierd. Why do I need to explicitly cast it?
$t2 = sprintf "%3.3f", ($t2<=0?0:$t2);
my $t3 = qq[<INPUT class=debug TYPE=TEXT
NAME="prob_true$ev_count" VALUE="$t2" SIZE=2>];
print $t2.$t3;
# Why does not this concatenation work?
$$hidden = $$hidden.qq[n<TR
class=debug><TD>prob_true$ev_count</TD><TD>$t3%</TD></TR>n];
}
else {
# Input box: user can alter this
print qq[ <INPUT TYPE="TEXT"
ID="prob_true$ev_count" NAME="prob_true$ev_count"
SIZE="7" OnChange="form_field_OnChange(this);"
MAXLENGTH="6">%</TD> ];
}
print qq|
<TD ALIGN="CENTER" STYLE="font-family:serif;
font-size:14px;background-color:#cc9900">
<INPUT ID="prob_guilt$ev_count"
NAME="prob_guilt$ev_count" SIZE="7"
OnChange="form_field_OnChange(this);" |;
if ($me->{pass}!=1){
print qq|
VALUE="|.($prob_guilt?$prob_guilt:"").qq|" |;
}
print qq| MAXLENGTH="6">%</TD>
<TD ALIGN="CENTER" STYLE="font-family:serif;
font-size:14px;background-color:#cc9900">
<INPUT TYPE="TEXT" ID="prob_innoc$ev_count"
OnChange="form_field_OnChange(this);"
NAME="prob_innoc$ev_count" SIZE="7" |;
if ($me->{pass}!=1){
print
qq|VALUE="|.($prob_innoc?$prob_innoc:"").qq|"|;
}
print " MAXLENGTH=6>%</TD>n";
}
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
Jeff 'Japhy' Pinyan
Nov 4 2003, 06:15 PM
On Nov 5, Tore Aursand said:
QUOTE |
On Tue, 04 Nov 2003 13:58:41 -0500, mgoland wrote: %hash=( 1 => funca(), 2 => funcb(), );
Try this:
%hash = (1 => &funca(), 2 => &funcb());
|
No; &foo is a reference to the foo function, but &foo() is a reference
to the return value of the call to &foo().
--
Jeff "japhy" Pinyan [Email Removed]
http://www.pobox.com/~japhy/RPI Acacia brother #734
http://www.perlmonks.org/ http://www.cpan.org/<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
Richard Heintze
Nov 4 2003, 07:15 PM
QUOTE |
I think what you want is this:
no warnings qw(uninitialized);
|
Would I put this immediately after "use warnings;"?
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
Tim Johnson
Nov 4 2003, 08:06 PM
Why do the subs execute? Because you told them to. When you type
funca(), you're telling Perl to execute funca, but don't pass it any
parameters. You don't "declare" subs in Perl the way you would in C.
The only place you declare a sub is in the "sub mySub{BLOCK}" statement.
You CAN prototype a subroutine to check variable types that are passed
to a sub, but that's a different story.
-----Original Message-----
From: [Email Removed] [mailto:[Email Removed]]
Sent: Tuesday, November 04, 2003 10:59 AM
To: [Email Removed]
Subject: ref's to subs
Hello Perler's
I am trying to create a hash where each key is a referance to subs. The
bellow code produces the expected result, with one unexpected
side-effect. Why are the subs executed when I only declare them ??
<- cut
#!/usr/local/bin/perl -w
%hash=( 1 => funca(),
2 => funcb(),
);
sub funca{
print "a";
}
sub funcb{
print "b";
}
<- paste
Thanks in Advance,
Mark G
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
Tim Johnson
Nov 4 2003, 10:27 PM
I think what you want is this:
no warnings qw(uninitialized);
Which should suppress only the warnings about an uninitialized value in
string or concatenation messages.
-----Original Message-----
From: Richard Heintze [mailto:[Email Removed]]
Sent: Tuesday, November 04, 2003 10:24 AM
To: [Email Removed]
Subject: Surpressing concatenation with null warnings
I have just discovered the the following code causes
trouble when I have "use strict" and "use warn";
use strict;
use warnings;
my $k = $q->param('xyz');
print qq[ $k = $k ];
The problem is that if there is no GET/POST param
called xyz, we are concatenating with a null value
and, when using CGI with Apache HTTPD, this is not a
problem (except it tends to make for large error
logs).
However, when using it with IIS it is a big problem
because the warning text gets inserted into the HTML
output (which is a BIG problem if you are in the
middle of emitting javascript code).
Is there a way I can suppress only concatenation
warnings? I did perldoc strict and perldoc warnings
and could not determine if the supression I want is
possible.
Thanks,
Sieg
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
Tim Johnson
Nov 5 2003, 12:17 AM
Yes. If you do it right after "use warnings;", then it will be in
effect for the rest of your script.
-----Original Message-----
From: Richard Heintze [mailto:[Email Removed]]
Sent: Tuesday, November 04, 2003 4:15 PM
To: [Email Removed]
Subject: RE: Surpressing concatenation with null warnings
QUOTE |
I think what you want is this:
no warnings qw(uninitialized);
|
Would I put this immediately after "use warnings;"?
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
Rajeev Prasad
Nov 5 2003, 03:47 AM
there has been one last post from my side, hope u will approve :)
its been one healthy and deep(??) discussion. thx, rajeev
__________________________________________________
There are as many paths as there are travellers...
QUOTE |
From: Casey West <[Email Removed] Reply-To: [Email Removed] To: Tim Johnson <[Email Removed] CC: "Randal L. Schwartz" <[Email Removed]>, [Email Removed] Subject: [ADMIN] Re: Training in the Middle and Far East Date: Tue, 4 Nov 2003 21:56:08 -0500
Okay folks, lets move on. I was hoping this thread would end on its own. :-)
Casey West
-- "Everything that can be invented has been invented." -- Charles H. Duell, Commissioner, U.S. Office of Patents, 1899.
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed]
|
_________________________________________________________________
MSN Messenger with backgrounds, emoticons and more.
http://www.msnmessenger-download.com/tracking/cdp_customize
Alan Perry
Nov 5 2003, 07:51 PM
Rob Dixon wrote:
QUOTE |
Scott E Robinson wrote:
Randal wrote:
Scott E Robinson wrote:
(And, sorry for the top-posting. I haven't figured out how to fix that!)
Uh, press the down arrow about a dozen times. How *hard* is that?
Lotus Notes adds a header to the top of the note which I *can* cut and paste to the bottom. It does not do the indentation with '>' characters that seems to be preferred.
Yep. Microsoft email clients are similarly distinctive! It doesn't help that Unix pundits claim the email ground as their own, but I tend to agree with their conclusion: that bottom-posting is best but with ad-hoc formatting.
I have taken to copying messages into my text editor as there is no email client that I know that can do what I want. Until I write it, that is :)
|
Someone has saved you the trouble... There is a program called Quotefix
that will clean up your stuff and do the "bottom posting" as so many seem to
prefer here. Seems to work very well for 99% of the messages it encounters.
Outlook version
http://home.in.tum.de/~jain/html-data/soft...tlook-quotefix/Outlook Express version
http://home.in.tum.de/~jain/html-data/software/oe-quotefix/
Bob Showalter
Nov 5 2003, 10:16 PM
Dan Anderson wrote:
QUOTE |
There doesn't seem to be what I want in CGI.pm. (I want to create a %GET and %POST hash of the form $HASH{NAME} = VALUE).
|
Look at perldoc CGI under "FETCHING THE PARAMETER LIST AS A HASH"
Rob Dixon
Nov 5 2003, 08:00 PM
Alan Perry wrote:
QUOTE |
Rob Dixon wrote:
I have taken to copying messages into my text editor as there is no email client that I know that can do what I want. Until I write it, that is :)
Someone has saved you the trouble... There is a program called Quotefix that will clean up your stuff and do the "bottom posting" as so many seem to prefer here. Seems to work very well for 99% of the messages it encounters.
|
Thanks Alan. That sort of thing would be my goal, except that 'Quotefix'
has a memory leak problem and crashes even Windows XP after a few days'
run. In W9x/ME it's fatal after only a few hours because of the limited
virtual address space.
Rob
Daniel Staal
Nov 5 2003, 08:19 PM
--On Wednesday, November 5, 2003 8:00 PM +0000 Rob Dixon
<[Email Removed]> wrote:
QUOTE |
Alan Perry wrote:
Rob Dixon wrote:
I have taken to copying messages into my text editor as there is no email client that I know that can do what I want. Until I write it, that is :)
Someone has saved you the trouble... There is a program called Quotefix that will clean up your stuff and do the "bottom posting" as so many seem to prefer here. Seems to work very well for 99% of the messages it encounters.
Thanks Alan. That sort of thing would be my goal, except that 'Quotefix' has a memory leak problem and crashes even Windows XP after a few days' run. In W9x/ME it's fatal after only a few hours because of the limited virtual address space.
|
Well, if that is what you are looking for, I would suggest you take a
look at Mulberry. It can shift, unquote, requote and rewrap lines
for you. (As well as my favorite 'paste quoted'.) Just look under
the 'Draft' menu. Avalible for Mac, Unix(Linux and Solaris) and
Windows.
Daniel T. Staal
---------------------------------------------------------------
This email copyright the author. Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes. This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------
Dan Anderson
Nov 5 2003, 10:25 PM
QUOTE |
Look at perldoc CGI under "FETCHING THE PARAMETER LIST AS A HASH"
|
Hmmm...seems like I was looking in the wrong place of the
documentation. Thanks.
-Dan
R. Joseph Newton
Nov 5 2003, 11:35 PM
Tim Johnson wrote:
Tim,
Please stop it! Each time I open one of your posts, I get a "Return
receipt requested" message. Whether or when I open one of your posts
is not, IMHO, your proper concern. I should not have to cancel or
approve each of these prompts just to read the list. Please adjust
your mailer settings, at least when posting to listservs.
Joseph
R. Joseph Newton
Nov 5 2003, 11:42 PM
Richard Heintze wrote:
QUOTE |
I think what you want is this:
no warnings qw(uninitialized);
Would I put this immediately after "use warnings;"?
|
I would recommend against it, unless you are intending to
keep all your programs very small. Any change to basic
browser/interpreter functionality, or to essetial built-in
operators, constructs, system variables, etc., should really
be localized. You can do this very painlessly:
my $k = $q->param('xyz');
{
no warnings 'uninitialized';
print qq[ $k = $k ];
}
Note that I left the assignment line out of the anonymous
block. This is in case you want to use this value or lack
of same later in your script, as any variable declared
within the block disappears from view after it finishes.
Joseph
Bob Showalter
Nov 6 2003, 05:43 PM
West, William M wrote:
QUOTE |
find (&transfer, $path);
sub transfer { my ($newpath, $oldstring, $newstring) = @_; otherstuff ($oldstring, $newstring);
# etc...
}
now- how do i pass parameters to transfer() when it's called with find??
i want the recursive fileprocessing to change file contents and put the changed file in a mirrored directory structure- i am doing well enough making the program, but the documentation had been hard to work with with regard to File::Find...
don't worry- i'm looking at perldoc File::Find too... :)
|
Good, then you'll see that $_ has file file name, and $File::Find::dir has
the directory name. As for $oldstring and $newstring, you can either put
them in global variables, or do something like:
find( sub { transfer($oldstring, $newstring) }, $path);
That arranges to pass $oldstring and $newstring to each invocation of
transfer.
HTH
Bob Showalter
Nov 6 2003, 06:37 PM
Bee wrote:
QUOTE |
open FH, ">1.txt"; binmode FH; binmode STDOUT; print FH "123m,zxnc,mzxnc,mzncm,zxc"; close FH;
Why the output still a text file ?
|
A file's a file. Terms like "text" and "binary" are just conventions. To the
OS, a file's just a collection of bytes.
What were you expecting to be in the file?
QUOTE |
Bee wrote: open FH, ">1.txt"; binmode FH; binmode STDOUT; print FH "123m,zxnc,mzxnc,mzncm,zxc"; close FH;
Why the output still a text file ?
|
Thanks everybody, the way I tried to make files to binary
format is just because I want to learn how to sysread and
syswrite. I suppose I can write some bytes anywhere I like,
without re-writing the whole file again...
So, for the advise of using "pack"... any example or hints ?
For what I am expecting to see in the content, I guess I would
see some monster chars I guess, at least not as is the content
itself.
Thanks in advise
Rob Dixon
Nov 7 2003, 02:00 PM
R. Joseph Newton wrote:
QUOTE |
Richard Heintze wrote:
I think what you want is this:
no warnings qw(uninitialized);
Would I put this immediately after "use warnings;"?
I would recommend against it, unless you are intending to keep all your programs very small. Any change to basic browser/interpreter functionality, or to essetial built-in operators, constructs, system variables, etc., should really be localized. You can do this very painlessly:
my $k = $q->param('xyz'); { no warnings 'uninitialized'; print qq[ $k = $k ]; }
Note that I left the assignment line out of the anonymous block. This is in case you want to use this value or lack of same later in your script, as any variable declared within the block disappears from view after it finishes.
|
Hi Joseph.
I agree wholeheartedly. Perl is already very flexible in the
DWIM department: it will allow both text concatenation and
arithmetic increment on an undefined value. I have always
been grateful for the, 'Are you sure you mean this?' that
'use warnings' gives. (I just wish that 'no uninitialised'
was also valid).
Rob
Zentara
Nov 7 2003, 02:45 PM
On Fri, 7 Nov 2003 08:24:36 +0800, [Email Removed] (Bee) wrote:
QUOTE |
So, for the advise of using "pack"... any example or hints ? For what I am expecting to see in the content, I guess I would see some monster chars I guess, at least not as is the content itself.
|
This might give you an idea:
To write:
#########################################
#!/usr/bin/perl
open(ZZ,"+>zz") or die "Can't open zz: $!";
binmode ZZ;
for(0..19){
$array[$_]= 2 * $_;
print "$array[$_] ";
$array1[$_]= pack ("L*",$array[$_]);
print ZZ $array1[$_];
}
close ZZ;
exit 0;
#########################################
To read:
########################################
#!/usr/bin/perl
use strict;
use warnings;
$/='undef';
my $in = shift || 'zz';
open (ZZ, "< $in") or die $!;
binmode ZZ;
my $file=(<ZZ>);
my @nums = (unpack "L*",$file);
print "@numsn";
close ZZ;
#######################################
--
Our body's 20 milligrams of beta radioactive Potassium 40
emit about 340 million neutrinos per day, which go at well-nigh
lightspeed to the ends of the universe!..even thru the earth.
Rob Richardson
Nov 11 2003, 01:23 PM
Greetings!
I am trying to build a class that has a hash of objects. Specifically,
the class is UserList, a list of users of a system. Users are
represented by instances of the User class. Each user has a login
name, a first name, a last name, a telephone number and an E-mail
address.
The UserList class has a hash named 'users'. The login name from the
User object will also be used as the key to the hash. The value of the
hash will be a reference the User object that has the given login name.
The login name is stored in two places: the hash key and the User
object.
The line of code that is supposed to add the new User object to the
'users' hash of the UserList object is:
$self->{'users'}->{$loginName} = $user; #<== This is line 47
The error message is:
"Can't use string ("interrobang") as a HASH ref while "strict refs" in
use at UserList.pm line 47, <USERLIST> line 1."
"Interrobang" is the login name of the only user in the data file I am
testing this script against.
I am pretty much trying to get this to work by trial and error. I have
another class in which a similar idiom works, but I don't understand
why it works and this doesn't. While I understand the concept behind
references, the mechanics of referencing and dereferencing in Perl are
still a mystery to me. Could someone explain why Perl thinks my string
is a hash reference instead of a key?
The complete script, with the classes, is short enough to be included
in this message. It is below.
Thanks very much!
Rob Richardson
Here's the User class:
use warnings;
use strict;
package User;
sub new
{
my $class = shift;
my $self = {};
$self->{'loginName'} = '';
$self->{'title'} = '';
$self->{'firstName'} = '';
$self->{'lastName'} = '';
$self->{'phone'} = '';
$self->{'email'} = '';
bless $self, $class;
return $self;
}
my $motto = "Where no one has gone before!";
Here are the new(), Load() and AddUser() methods of the UserList class:
sub new
{
my $class = shift;
my $self = {};
# Create an anonymous empty hash to hold users
$self->{'users'} = {};
bless $self, $class;
return $self;
}
sub Load
{
my $self = shift;
my $fileName = shift;
my $user;
open (USERLIST, $fileName) || die "cannot open database $fileName:
$!n";
if ($^O ne "MSWin32")
{
flock(USERLIST, 1);
}
while (<USERLIST>)
{
chomp;
AddUser (split /,/);
}
}
sub AddUser
{
my $self = shift;
my $user = new User;
($user->{'loginName'},
$user->{'title'},
$user->{'firstName'},
$user->{'lastName'},
$user->{'phone'},
$user->{'email'}) = @_;
my $loginName = $user->{'loginName'};
$self->{'users'}->{$loginName} = $user; <== This is line 47
}
Finally, here is my test script, which creates a UserList, reads users
from a file, adds them to the UserList object, and nothing else:
#!/usr/bin/perl
use warnings;
use strict;
use UserList;
my $theList = new UserList;
$theList->Load("c:\indigoperl\htdocs\data\user.in");
print "Done!";
__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
Jeff 'Japhy' Pinyan
Nov 11 2003, 01:43 PM
On Nov 11, Rob Richardson said:
QUOTE |
$self->{'users'}->{$loginName} = $user; #<== This is line 47
"Can't use string ("interrobang") as a HASH ref while "strict refs" in use at UserList.pm line 47, <USERLIST> line 1."
"Interrobang" is the login name of the only user in the data file I am testing this script against.
|
Right, and as I'm about to show, it's the first argument to your AddUser()
function.
QUOTE |
sub Load { my $self = shift; my $fileName = shift; my $user;
|
You don't use $user. Skipping ahead to the trouble-spot:
QUOTE |
while (<USERLIST>) { chomp; AddUser (split /,/);
|
That should be $self->AddUser(split /,/)...
.... because if it isn't:
QUOTE |
sub AddUser { my $self = shift;
|
Then $self will be the first value from (split /,/), which is the login
name.
QUOTE |
my $user = new User; ($user->{'loginName'}, $user->{'title'}, $user->{'firstName'}, $user->{'lastName'}, $user->{'phone'}, $user->{'email'}) = @_; my $loginName = $user->{'loginName'}; $self->{'users'}->{$loginName} = $user; <== This is line 47
|
And since $self is a string, and strict is on, $self->{...} is an error.
--
Jeff "japhy" Pinyan [Email Removed]
http://www.pobox.com/~japhy/RPI Acacia brother #734
http://www.perlmonks.org/ http://www.cpan.org/<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
Drieux
Nov 11 2003, 06:45 PM
On Tuesday, Nov 11, 2003, at 10:23 US/Pacific, Rob Richardson wrote:
[..]
QUOTE |
The error message is: "Can't use string ("interrobang") as a HASH ref while "strict refs" in use at UserList.pm line 47, <USERLIST> line 1."
"Interrobang" is the login name of the only user in the data file I am testing this script against.
|
[..]
I assume that you mean that the following is
in a separate Package:
QUOTE |
sub Load { my $self = shift; my $fileName = shift; my $user;
open (USERLIST, $fileName) || die "cannot open database $fileName: $!n"; if ($^O ne "MSWin32") { flock(USERLIST, 1); }
while (<USERLIST>) { chomp; AddUser (split /,/);
|
wouldn't it be nice if that was say
$self->AddUser(split /,/);
QUOTE |
} }
sub AddUser { my $self = shift; my $user = new User; ($user->{'loginName'}, $user->{'title'}, $user->{'firstName'}, $user->{'lastName'}, $user->{'phone'}, $user->{'email'}) = @_; my $loginName = $user->{'loginName'}; $self->{'users'}->{$loginName} = $user; <== This is line 47 }
[..] |
That way when we get INTO the AddUser() method and
shift off the $self, we know which Self we are talking
about, rather than shifting off the first element in
the line we read from <USERLIST>, eh no?
ciao
drieux
---
Jeff 'Japhy' Pinyan
Nov 12 2003, 07:26 PM
On Nov 12, Dan Anderson said:
QUOTE |
while (my %hash = %{ shift (@columns) }) { ... }
|
Here is the problem. When @columns is empty, it returns undef, and you
can't do %{ +undef }. So, do this:
while (my $href = shift @columns) {
# then use $href->{...}
# or do:
my %hash = %$href;
...
}
But I'd just use $href.
--
Jeff "japhy" Pinyan [Email Removed]
http://www.pobox.com/~japhy/RPI Acacia brother #734
http://www.perlmonks.org/ http://www.cpan.org/<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
Dan Muey
Nov 12 2003, 10:12 PM
QUOTE |
I recently changed the email address i use for this list and posted a question, i have never use this email address before and now i receiving regular spam to this address Is it Just me or has every one started to receive a lot of spam on address used for this list?
|
A little of both maybe,
I gets lots of garbage at my address. The problem is the same with all the
lists I subscribe to, they have web archives. Which means evil robots
can go and harvest our email addresses. So it's not just this list it's
Anytime you have an email address on a website. Even smart robots can
figure out address that attempt to conceal them selves. Even lists that
remove emial addresses ccompletely can still be spammed quite easily.
HTH
Dmuey
QUOTE |
Sorry of the off topic question its just most annoying
|
It is annoying - we hates spam!
At 22:12 12/11/2003, you wrote:
QUOTE |
I recently changed the email address i use for this list and posted a question, i have never use this email address before and now i receiving regular spam to this address Is it Just me or has every one started to receive a lot of spam on address used for this list?
A little of both maybe,
I gets lots of garbage at my address. The problem is the same with all the lists I subscribe to, they have web archives. Which means evil robots can go and harvest our email addresses. So it's not just this list it's Anytime you have an email address on a website. Even smart robots can figure out address that attempt to conceal them selves. Even lists that remove emial addresses ccompletely can still be spammed quite easily.
HTH
Dmuey
|
grrr as if i was not getting enoff already
if only work would let me become a spam cop then id get emm...
hum could we not get a nice topic prefix added to the list?
it would make it a lot easy to make mail filters that could kill all mail
going to this address, not from the list.?
humm guess i should just accept my fait at lest the spam im getting is just fraudulent
and not about prn
Ritchie
---
fnord
yes im a Concord Engineer, no it never flown!
QUOTE |
Sorry of the off topic question its just most annoying
It is annoying - we hates spam!
Ritchie
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed]
--- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.537 / Virus Database: 332 - Release Date: 06/11/2003 |