RE: Cookies

2003-09-18 Thread Wiggins d'Anconia


On Wed, 17 Sep 2003 20:33:00 -0800, Alejandro Chavarria - CyPage [EMAIL PROTECTED] 
wrote:

 Hey,
 
 I have a script and I want to allow an administrator log on to it.  Once
 logged in they can change things... etc.  Basically stuff I don't want other
 people to be able to do.  I have decided that cookies is the best way to go.
 I've been looking and looking on the internet for a way to add a logout
 button in the script that will delete the cookie that has the username and
 password so they are essentially logged out.  I have read that you can fill
 in the expires field in with 1. a date in the past (ie. -1d) or 2. the
 word now.  I have heard about problems with both these methods.
 
 What do you suggest?
 

In general I would reset the cookie to the empty string with no expiration date, and 
then on the other end your check should be that the cookie exists *and* has a correct 
value.  Then make the correct value very hard (because nothing is 100% secure) to 
figure out how to generate. In other words hash it with a secret key or some such that 
only the server has.  So the cookie exists but the check fails, and as soon as the 
session ends the cookie is no longer stored.

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: list-parsing problem

2003-09-18 Thread Stephen Hardisty
Two dimensional hash perhaps? Where the first column is the first dimension and the 
second is, well, the second.

E.g.

while(FH)
{
($col1, $col2) = split(/$delimeter/, chomp($_));
$blah{$col1}{$col2} = 1;
}

Hope this helps.


This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: problems with DBD::mysql

2003-09-18 Thread Ramprasad A Padmanabhan
Erwin Van Kouteren wrote:
Hi there,

I'm having problems with th einstallation of the module DBD::mysql. When
giving the command:
perl Makefile.PL the script gives error messages about de mysql_config
file. (no such file).
Can anyone help me any further on this matter?

Thanks,

Erwin

This is a common problem. If you can install mysql from the source then 
this problem will not occur Since the the mysql header files will be 
installed by the source.
Or else, You can just untar the source in some temporary area find 
mysql.h ( I dont remember exactly but must be the same file ) in the 
directory and change the Makefile of DBD::mysql  to include that directory

Hope that helps
Ram


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: list-parsing problem

2003-09-18 Thread Marcus Claesson
Thanks Michel, I found it! 

But I just have one question before trying it out. Isn't the key order
in a hash randomised, which in this case means I wouldn't get first
column in numerical order as I wanted?

Marcus


On Thu, 2003-09-18 at 10:31, EUROSPACE SZARINDAR wrote:
 Hi Marcus
 
 Just look at the perldoc perlreftut. What you are looking for is the exact
 exemple of the paper.
 
 Michel
 
 
 -Message d'origine-
 De: Marcus Claesson [mailto:[EMAIL PROTECTED]
 Date: jeudi 18 septembre 2003 11:26
 : [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Objet: list-parsing problem
 
 
 Hi People,
 
 I have a silly little list-parsing problem that I can't get my head
 around, and I'm sure some of you have come across it before.
 
 I have a list like this:
 
 1 a
 2 b
 2 c
 3 a
 4 d
 4 d
 4 e
 4 f
 5 g
 
 and I want to make the first column non-redundant and collect the second
 column values on the same line, like this:
 
 1 a
 2 b,c
 3 a
 4 d,e,f
 5 g
 
 Please note that line 4 only has one 'd'.
 
 I've tried with both hashes and arrays (don't want to confuse you so I
 won't display them here), but nothing really works...
 
 I would really appreciate any help!
 
 Marcus
 
 
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: list-parsing problem

2003-09-18 Thread Charles K. Clarkson
Marcus Claesson [EMAIL PROTECTED] wrote
: 
: I have a silly little list-parsing problem that I can't get
: my head around, and I'm sure some of you have come across
: it before.
: 
: I have a list like this:
: 
: 1 a
: 2 b
: 2 c
: 3 a
: 4 d
: 4 d
: 4 e
: 4 f
: 5 g
: 
: and I want to make the first column non-redundant and
: collect the second column values on the same line, like
: this:
: 
: 1 a
: 2 b,c
: 3 a
: 4 d,e,f
: 5 g
: 
: Please note that line 4 only has one 'd'.

What order should each column be in? The input order
or some kind of sort order? Or does order matter?



HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: list-parsing problem

2003-09-18 Thread Marcus Claesson
Homework's sorted ;)! Thanks a lot Thomas, it worked fine!
Marcus

On Thu, 2003-09-18 at 10:41, Thomas Btzler wrote:
 Marcus Claesson [mailto:[EMAIL PROTECTED] asked:
  I have a silly little list-parsing problem that I can't get my head
  around, and I'm sure some of you have come across it before.
 
 Sure. Looks like homework ;-)
 
 HTH,
 Thomas
 
 #!/usr/bin/perl -w
 
 use strict;
 
 my %unique;
 
 while( DATA ){
   my( $key, $value ) = split;
   
   $unique{$key}-{$value}++
 }
 
 foreach my $key ( sort keys %unique ){
   print $key:  . join( , , sort keys %{$unique{$key}} ) . \n;
 }
 
 __DATA__
 1 a
 2 b
 2 c
 3 a
 4 d
 4 d
 4 e
 4 f
 5 g


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: list-parsing problem

2003-09-18 Thread Charles K. Clarkson
Marcus Claesson [EMAIL PROTECTED]
: 
: But I just have one question before trying it out.
: Isn't the key order in a hash randomised, which in
: this case means I wouldn't get first column in
: numerical order as I wanted?

You didn't state what order in the problem not did
you say that the first column would always be numeric.
You didn't state it for the second column either.



Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: list-parsing problem

2003-09-18 Thread Gary Stainburn
On Thursday 18 Sep 2003 10:26 am, Marcus Claesson wrote:
 Hi People,

 I have a silly little list-parsing problem that I can't get my head
 around, and I'm sure some of you have come across it before.

 I have a list like this:

 1 a
 2 b
 2 c
 3 a
 4 d
 4 d
 4 e
 4 f
 5 g

 and I want to make the first column non-redundant and collect the second
 column values on the same line, like this:

 1 a
 2 b,c
 3 a
 4 d,e,f
 5 g

 Please note that line 4 only has one 'd'.

 I've tried with both hashes and arrays (don't want to confuse you so I
 won't display them here), but nothing really works...

 I would really appreciate any help!

 Marcus

Hi Marcus,

Hows about something like:

my @f=(1   a,2   b,2   c,
   3   a,4   d,4   d,
   4   e,4   f,5   g);

my %cols=();
foreach(@f) {
  my ($col1,$col2)=split(/ */,$_);
  $cols{$col1}.=$col2;
}
foreach (sort keys %cols) {
  print join(,,split('',$cols{$_})),\n;
}

If you actually want the commas in the scripts, you'll need to do it either 
inside the first loop, or have a seperate loop just after.

Gary
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Recursively scanning a directory on Mac OS X for size Timestap

2003-09-18 Thread Shishir Saxena
Hi, 

I'm doing the following and the purpose is to genrate a HTML log file. But
the script says Can not apply stat : No such file or directory found
Can someone plz tell me where I'm going wrong ?

use File::Find;
use File::stat;


open (OUT,./out.html);

$Root = $ARGV[0];
print $Root;

my $var;

print OUT 'html

head
meta http-equiv=Content-Language content=en-us
meta http-equiv=Content-Type content=text/html; charset=windows-1252
meta name=GENERATOR content=Microsoft FrontPage 4.0
meta name=ProgId content=FrontPage.Editor.Document
titlePath of File/title
/head

body

table border=1 width=106%
  tr
td width=20% align=center bgcolor=#00bPath of
File/b/td
td width=20% align=center bgcolor=#00bFile
Version/b/td
td width=20% align=center bgcolor=#00bBuild
Number/b/td
td width=20% align=center bgcolor=#00bSize on
Disk/b/td
td width=20% align=center bgcolor=#00bTimestamp/b/td
  /tr';

find (\wanted,$Root);
  
print OUT '  /table
pnbsp;/p

/body

/html';

sub wanted()
{
   if (-d $File::Find::name)
   {
return;
}
   $file = $File::Find::name;
   $file =~ s/\//\\/g;
   $st = stat($file);
   $size = $st-size;
   $size = ($size/1024).KB ($size bytes);
   $time = scalar localtime $st-mtime;
   
   

print OUT '
  tr
td width=20% align=center bgcolor=#CC'.$file.'/td
td width=20% align=center bgcolor=#CCNot Available/td
td width=20% align=center bgcolor=#CCNot Available/td
td width=20% align=center bgcolor=#CC'.$size.'/td
td width=20% align=center bgcolor=#CC'.$time.'/td
/tr';

Regards,
Shishir Saxena




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



recursively finding file size/timestamp on a Mac / Solaris

2003-09-18 Thread Shishir Saxena
Hi,

This is wat I'm doing... but its not working :-(

find (\wanted,$Root);
  
print OUT '  /table
pnbsp;/p

/body

/html';

sub wanted()
{
   if (-d $File::Find::name)
   {
return;
}
   $file = $File::Find::name;
   $file =~ s/\//\\/g;
   $st = stat($file);
   $size = $st-size;
   $size = ($size/1024).KB ($size bytes);
   $time = scalar localtime $st-mtime;
   

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



assign new letter to drive in Win32?

2003-09-18 Thread Chris McMahon

Hi...
I was hoping to use Perl to invoke the MS utility diskpart to
script some disk management, especially in order to rename drives and
partitions.   
Unfortunately, diskpart is an XP utility-- on Win2K, I can use
diskpart to strip the letter from the drive, but attempting to assign a new
letter yields an error msg. that this operation is not supported on your
version of Windows.
Does anyone know if Perl is capable of stripping/assigning drive
letters on Windows 2000?   And if so, how? Or where I could read more?
-Chris 
PS Any other pointers to Perl-on-Windows would be helpful-- I have
Learning Perl on Win32 Systems, but I'm a Windows newbie and further
information is always helpful...

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



DBD:Pg place holder errors

2003-09-18 Thread Johnson, Shaunn
Howdy:

I have a script where I connect from Oracle 9 to
PostgreSQL 7.2.x and insert new records.  It seems
to work for about 200 or so records, but, fails
(I was able to capture this message)

[error]
Uncaught exception from user code:
Placeholder :0 invalid, placeholders must be = 1 at
/usr/lib/perl5/site_p
erl/5.6.0/i386-linux/DBD/Pg.pm line 129.
DBD::Pg::db::prepare('DBI::db=HASH(0x83d88a0)', 'insert into
sys_ed_inp (^
JMBR_ID,^JCODE,^JPROC_1,^JPROC_2,^JPROC_3,^JD...', undef) called at
/usr/lib/perl5
/site_perl/5.6.0/i386-linux/DBI.pm line 1212
DBD::_::db::do('DBI::db=HASH(0x83d88a0)', 'insert into sys_ed_inp
(^JMBR_I
D,^JCODE,^JPROC_1,^JPROC_2,^JPROC_3,^JD...') called at
./insert_sys_ed_inp.pl line
 95
Database handle destroyed without explicit disconnect at
/usr/lib/perl5/site_perl/
5.6.0/i386-linux/DBD/Pg.pm line 129.

[/error]

What is this talking about?  I'm not sure I understand why it
failed after so many records.  I *thought* it could be a record
was off or a column had some odd character or whatever, but
perhaps I don't see that?  The table should accept NULLs by
default and the table structure on both DBs are the same.

This is the code

[snip code]
#!/usr/bin/perl -w

# created 17 Sep 03
# script to connect from Oracle via DBI to
# PostgreSQL and insert records into a table
#

use POSIX 'strftime';
use strict;
use warnings;
use diagnostics;
use DBI;

my $host='local';
my $sid='jessupic';
my $dbname='o_testdb';
my $username='joe';
my $password='joe_passwd';
my $datestr=strftime '%d%m%Y',localtime;

# connection options either works

my $dbh = DBI-connect(dbi:Oracle:host=$host;sid=$sid, $username,
$password, { R
aiseError = 1 }) or die Can not connect: $!;

if (!defined($dbh)) {exit;}

# test the SQL
# don't use semi-colons?  wonder why ...
#

print \nthis is for SYS_ED_INP table\n\n;

my $sql = 
SELECT
MBR_ID,
CODE,
PROC_1,
PROC_2,
PROC_3,
DIAG_1,
DIAG_2,
DIAG_3,
DIAG_4,
DIAG_5,
FROM_DT,
THRU_DT,
BILLINGPROVIDERNUM,
BILLINGPROVIDERNAME,
DIAGNOSISDESCRIPTION,
ADDED,
ID,
PRODUCT
from
SYS_ED_INP
 ;

# test the sql and prepare to use
# for Oracle

my $sth = $dbh-prepare($sql) or die Error = , DBI::errstr;

unless ($sth-execute) {
print\n\tExecute failed for stmt:\n\t$sql\nError = , DBI::errstr;
$sth-finish;
$dbh-disconnect;
die \n\t\tClean up finished\n;
}

print \nThis is to be inserted into PostgreSQL  ...\n\n;
print \nThis is the build time $datestr ...\n\n;

while (my (
$MBR_ID,
$CODE,
$PROC_1,
$PROC_2,
$PROC_3,
$DIAG_1,
$DIAG_2,
$DIAG_3,
$DIAG_4,
$DIAG_5,
$FROM_DT,
$THRU_DT,
$BILLINGPROVIDERNUM,
$BILLINGPROVIDERNAME,
$DIAGNOSISDESCRIPTION,
$ADDED,
$ID,
$PRODUCT
) =$sth-fetchrow) {
my $dbh_p=DBI-connect('dbi:Pg:dbname=test_db', 'joe')
or die Can not connect: $!;
$dbh_p-do(insert into sys_ed_inp (
MBR_ID,
CODE,
PROC_1,
PROC_2,
PROC_3,
DIAG_1,
DIAG_2,
DIAG_3,
DIAG_4,
DIAG_5,
FROM_DT,
THRU_DT, 
BILLINGPROVIDERNUM,
BILLINGPROVIDERNAME,
DIAGNOSISDESCRIPTION,
ADDED,
ID,
PRODUCT
) values (
'$MBR_ID',
'$CODE',
'$PROC_1',
'$PROC_2',
'$PROC_3',
'$DIAG_1',
'$DIAG_2',
'$DIAG_3',
'$DIAG_4',
'$DIAG_5',
'$FROM_DT',
'$THRU_DT',
'$BILLINGPROVIDERNUM',
'$BILLINGPROVIDERNAME',
'$DIAGNOSISDESCRIPTION',
'$ADDED',
'$ID',
'$PRODUCT') );

$dbh_p-disconnect;

}

print done with the sys_ed_inp  program.\n\n;

$dbh-disconnect;

[/snip code]

Suggestions?  TIA!

-X


instance variables?

2003-09-18 Thread Kevin Pfeiffer
Hi all,

I stumbled across something called BlueJ which provides a user-friendly
graphical environment in which to learn OO-programming, Java-style. I think
this is a great parallel universe to go along with the Perl Objects book.

I started re-writing one of the first exercises as a Perl package:
[question follows below]

package TicketMachine;
# etc.

=head1 DESCRIPTION
TicketMachine models a naive ticket machine that issues
flat-fare tickets.

The price of a ticket is specified via the constructor.

[Based on an exercise from Objects First With Java:
A Practical Introduction Using BlueJ.]
=cut

# my $price;# Price of a ticket from this machine.
# my $balance;  # Amount of money entered by customer
# my $total;# Total amount of money collected by machine


# Create a machine that issues tickets of the given price.
# Price must be greater than zero (but no checks done).
sub new {
my $class = shift;

# In the BlueJ environment instances are automatically
# named behind the scenes (so far)...
my $instance = tm . int(rand(25));

my $self = { Name = $instance, Price = shift };
bless $self, $class;
}

sub getPrice {
my $self = shift;
return $self-{Price};
}

# more methods to come...

1;

__END__

In the Java version, the three variables are declared in the class first:
private int price;
private int balance;
private int total;

So in Perl I tried declaring these in the package using my, but they seemed
to remain class variables, so if I would do something like:

for (@ticket_machines) {
  print A ticket costs , $_-getPrice(),  cents.\n;
} 

I would then get (for two machines):

A ticket costs 100 cents.
A ticket costs 100 cents.


Then I tried this with Perl...

In the new constructor:

   my $class = shift;
   my $price = shift;
   my $self = $instance;
   bless \$self, $class, $price;

...I was told too many arguments to bless. The Perl Objects book says the
easiest way to use more data with an instance is with a blessed hash
reference, and that did work fine (and maybe that's the best way).

But I'm wondering if there is another way (like the Java private variable)
to say all class variables declared here are unique to each instance? 

It occurs to me that perhaps the difference is that in Perl you can call
methods on a class (i.e. the an unnamed horse from the Perl Objects book)
but not in Java (other than the contructor method)?

(If anyone is interested in BlueJ - www.bluej.org)

-K

-- 
Kevin Pfeiffer
International University Bremen



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Split based on length

2003-09-18 Thread Bob Showalter
NYIMI Jose (BMB) wrote:
 ...
 I was thinking about unpack function but how to make it dynamic ?
 
 I mean writing :
 my @items = unpack('A2 A2', $str);
 Will work for $str='abdc';
 Not for $str='abcdef';

How about something like:

   my $s = 'abcdefghij';
   my @x;
   ([EMAIL PROTECTED],$s) = unpack('a2 a*', $s) while length $s;
   print @x\n;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Split based on length

2003-09-18 Thread Bob Showalter
Stephen Hardisty wrote:
  for(split(/(..)/, $string)) { print *$_ if $_; }
 
 Gorgeous :o)

or,

@parts = grep length, split /(..)/, $string;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Net::SSH::Perl

2003-09-18 Thread Gupta, Sharad

Hi All,

I remember i read somewhere about some limitations of Net::SSH::Perl on
windows systems particularly something about 5.8 
but can't find the link now. 

Can anybody point me to it without much effort.??


Thanx,
-Sharad

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: instance variables?

2003-09-18 Thread Hanson, Rob
 But I'm wondering if there is another way
 (like the Java private variable) to say
 all class variables declared here are unique
 to each instance? 

It sounds like you are trying to link how OO-Perl works with OO-Java... and
that is only going to make your head spin.  What you really need to do is
understand what bless really does, and that OO-Perl isn't really OO in the
usual sense (but it works like it is).

In Perl an object is really just a scalar variable that has been blessed.
Blessing adds an attribute to the scalar variable which is supposed to
represent the type of scalar.  The only requirement is that the bless
scalar must be a reference.

my $x = foo;
my $y = bless \$x, bar;
print $y;
# PRINTS: bar=SCALAR(0xa01ed1c)

Here $y is a reference to a scalar (hence the SCALAR(0xa01ed1c)), and it
has been tagged as type bar.

That is all bless does.

Now the next part is the magic that Perl does...

$x-do_stuff;

Here $x does what looks like a method call.  Perl will look at the type of
$x, which is foo, then try to execute do_stuff() in the foo package.
The first argument of this call will always be $x, like this:

foo:do_stuff($x);

This call does exactly the same thing as above.

Now when you talk about instance variables, realize that there is no true
object instance in Perl.  It is just a reference tagged with a type... the
rest is all smoke and mirrors.

So to emmulate instance variables you can use a hash reference instead of a
scalar reference, like this:

my %x = (field1 = 'val1', field2 = 'val2');
my $y = bless \%x, bar;

Now $y is just a hash reference, so this stuff still works:

print $y-{field1};
print $y-{field2};

...And $y is also blessed, meaning you can emulate calling methods like I
did earlier.

Now you can still emulate private variables, but again, it's more smoke and
mirrors.  Without getting into the details (look at 'tie' for more info) you
can just use the Tie::SecureHash module.  It emulated public, protected, and
private variables.

http://search.cpan.org/author/DCONWAY/Tie-SecureHash-1.03/SecureHash.pm

I hope that helps a little.

Rob



-Original Message-
From: Kevin Pfeiffer [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 18, 2003 1:32 PM
To: [EMAIL PROTECTED]
Subject: instance variables?


Hi all,

I stumbled across something called BlueJ which provides a user-friendly
graphical environment in which to learn OO-programming, Java-style. I think
this is a great parallel universe to go along with the Perl Objects book.

I started re-writing one of the first exercises as a Perl package:
[question follows below]

package TicketMachine;
# etc.

=head1 DESCRIPTION
TicketMachine models a naive ticket machine that issues
flat-fare tickets.

The price of a ticket is specified via the constructor.

[Based on an exercise from Objects First With Java:
A Practical Introduction Using BlueJ.]
=cut

# my $price;# Price of a ticket from this machine.
# my $balance;  # Amount of money entered by customer
# my $total;# Total amount of money collected by machine


# Create a machine that issues tickets of the given price.
# Price must be greater than zero (but no checks done).
sub new {
my $class = shift;

# In the BlueJ environment instances are automatically
# named behind the scenes (so far)...
my $instance = tm . int(rand(25));

my $self = { Name = $instance, Price = shift };
bless $self, $class;
}

sub getPrice {
my $self = shift;
return $self-{Price};
}

# more methods to come...

1;

__END__

In the Java version, the three variables are declared in the class first:
private int price;
private int balance;
private int total;

So in Perl I tried declaring these in the package using my, but they seemed
to remain class variables, so if I would do something like:

for (@ticket_machines) {
  print A ticket costs , $_-getPrice(),  cents.\n;
} 

I would then get (for two machines):

A ticket costs 100 cents.
A ticket costs 100 cents.


Then I tried this with Perl...

In the new constructor:

   my $class = shift;
   my $price = shift;
   my $self = $instance;
   bless \$self, $class, $price;

...I was told too many arguments to bless. The Perl Objects book says the
easiest way to use more data with an instance is with a blessed hash
reference, and that did work fine (and maybe that's the best way).

But I'm wondering if there is another way (like the Java private variable)
to say all class variables declared here are unique to each instance? 

It occurs to me that perhaps the difference is that in Perl you can call
methods on a class (i.e. the an unnamed horse from the Perl Objects book)
but not in Java (other than the contructor method)?

(If anyone is interested in BlueJ - www.bluej.org)

-K

-- 
Kevin Pfeiffer
International University Bremen



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, 

RE: Problems with CPAN

2003-09-18 Thread Bob Showalter
John Birkhead wrote:
 Hi,
   I'm a perl newbie and I'm having problems getting CPAN connecting
 and downloading on SuSE 8.2. I start with 'perl -MCPAN -e shell' but
 the urlist is undefined. The default of 'ftp.perl.org' doesn't work.
 
 If I 'o conf urlist push
 ftp://cpan.nas.nasa.gov/pub/perl/CPAN' (or other
 mirror sites I've tried) when I download this url appears to
 be ignored and
 the downloads are attempted from the default.

push will add to the end of the urllist. You can use unshift to add to
the beginning.

 
 It also appears that when I exit and restart CPAN it has forgotten
 the url I added.

use o conf commit to save changes

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: instance variables?

2003-09-18 Thread Kevin Pfeiffer
In article
[EMAIL PROTECTED], Rob
Hanson wrote:

 But I'm wondering if there is another way
 (like the Java private variable) to say
 all class variables declared here are unique
 to each instance?
 
 It sounds like you are trying to link how OO-Perl works with OO-Java...
 and
 that is only going to make your head spin.  What you really need to do is
 understand what bless really does, and that OO-Perl isn't really OO in the
 usual sense (but it works like it is).
[...]

 Now when you talk about instance variables, realize that there is no true
 object instance in Perl.  It is just a reference tagged with a type...
 the rest is all smoke and mirrors.
 
 So to emulate instance variables you can use a hash reference instead of
 a scalar reference, like this:

And this actually works quite fine I think...

 I hope that helps a little.
 
 Rob

Thanks, that helped a lot! (Thank you also to others who responded.)

Meanwhile my naive ticketMachine is chugging along. And I like doing the
Perl version of something else; it's good practice for me (though I'm
getting tired of typing my $self = shift;).  ;-)

-K

-- 
Kevin Pfeiffer
International University Bremen


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: instance variables?

2003-09-18 Thread Rob Dixon
Not quite right Rob :)

Rob Hanson wrote:

  But I'm wondering if there is another way
  (like the Java private variable) to say
  all class variables declared here are unique
  to each instance?

 It sounds like you are trying to link how OO-Perl works with OO-Java... and
 that is only going to make your head spin.  What you really need to do is
 understand what bless really does, and that OO-Perl isn't really OO in the
 usual sense (but it works like it is).

 In Perl an object is really just a scalar variable that has been blessed.
 Blessing adds an attribute to the scalar variable which is supposed to
 represent the type of scalar.  The only requirement is that the bless
 scalar must be a reference.

 my $x = foo;
 my $y = bless \$x, bar;
 print $y;
 # PRINTS: bar=SCALAR(0xa01ed1c)

 Here $y is a reference to a scalar (hence the SCALAR(0xa01ed1c)), and it
 has been tagged as type bar.

 That is all bless does.

 Now the next part is the magic that Perl does...

 $x-do_stuff;

 Here $x does what looks like a method call.  Perl will look at the type of
 $x, which is foo, then try to execute do_stuff() in the foo package.

The type of $x is 'bar' - you just said so above. Its value is
'foo', but usually you will want a lot more than just a single
scalar value in your object, so they are more usually hashes
as you say below.

 The first argument of this call will always be $x, like this:

 foo:do_stuff($x);

THis should be

  bar::do_stuff($x)

 This call does exactly the same thing as above.

 Now when you talk about instance variables, realize that there is no true
 object instance in Perl.  It is just a reference tagged with a type... the
 rest is all smoke and mirrors.

 So to emmulate instance variables you can use a hash reference instead of a
 scalar reference, like this:

 my %x = (field1 = 'val1', field2 = 'val2');
 my $y = bless \%x, bar;

 Now $y is just a hash reference, so this stuff still works:

 print $y-{field1};
 print $y-{field2};

 ...And $y is also blessed, meaning you can emulate calling methods like I
 did earlier.

 Now you can still emulate private variables, but again, it's more smoke and
 mirrors.  Without getting into the details (look at 'tie' for more info) you
 can just use the Tie::SecureHash module.  It emulated public, protected, and
 private variables.

 http://search.cpan.org/author/DCONWAY/Tie-SecureHash-1.03/SecureHash.pm

It would be a Good Idea to get simple objects working before considering
private variables.

Cheers,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Split based on length

2003-09-18 Thread Jeff 'japhy' Pinyan
On Sep 18, Bob Showalter said:

Stephen Hardisty wrote:
  for(split(/(..)/, $string)) { print *$_ if $_; }

 Gorgeous :o)

@parts = grep length, split /(..)/, $string;

WHY are we using split() for this?  Why are we using a method that returns
a list twice the size that we want, that we then have to filter through?

  @parts = $string =~ /.{1,$len}/sg;

and you're done.

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  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.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Single and Double quotes in SQL

2003-09-18 Thread Pablo Fischer
Hi!

I need to save some HTML text in a DataBase (MySql, using DBI). However
some HTML text will have single and double quotes, so.. how can I save
them?, for example:

align=centerIt's so funny/align

Thanks!
Pablo
-- 
Pablo Fischer Sandoval (pablo -arroba- pablo.com.mx)
http://www.pablo.com.mx
http://www.debianmexico.org
GPG FingerTip: 3D49 4CB8 8951 F2CA 8131 AF7C D1B9 1FB9 6B11 810C
Firma URL: http://www.pablo.com.mx/firmagpg.txt


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Single and Double quotes in SQL

2003-09-18 Thread Oliver Schnarchendorf
On Sat, 20 Sep 2003 21:34:58 +, Pablo Fischer wrote:
 I need to save some HTML text in a DataBase (MySql, using DBI). However
 some HTML text will have single and double quotes, so.. how can I save
 them?, for example:
 align=centerIt's so funny/align
$html_text =~ s/'/''/g;
$html_text =~ s///g;

Use the help of regular expressions to double the number of each quote and mysql won't 
have any problems.

thanks
/oliver/


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



perl modules in java

2003-09-18 Thread Hari Fajri
Hi All,

Is it possible to use module perl modules (let say DBD::Xbase) in java?
i'm sorry posting this java question to this perl forum,
because no body (able to) answer this question in java forum.