Re: Spliting comma delimited data

2003-06-09 Thread Janek Schleicher
Rob Anderson wrote at Mon, 09 Jun 2003 16:08:54 +0100:

> I have the following code, which I intend to use to save/restore an array
> to/from a text file with.
> 
> As I'm using a comma to delilmit the data I'm escaping commas on the way
> out, an unescaping on the way in. This means that when I split the string
> into an array, I need to make sure I DON'T split on escaped commas, hence
> the /[^\\],/ regex in my split. But my problem is that this split strips the
> last character off all but the last element in the array.
> 
> Is there some way to exclude the [^\\] part from being matched, err or
> something, help.
> 
> My code...
> [...]

That's already invented.
The CPAN modules
Text::CSV
Text::CSV_XS
can solve your problems
(and take also care for commas in quotes)


Greetings,
Janek

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



Re: typing files quickly

2003-06-09 Thread Steve Grazzini
Harry Putnam <[EMAIL PROTECTED]> wrote:
> "Janek Schleicher" <[EMAIL PROTECTED]> writes:
>>
>> The underscore _ holds the results of the last stat call 
>> (implicitly called by the -f operator), so no unnecessary 
>> work needs to be done.
> 
> I've seen that `_' crop up before
> I don't understand what this means.

It's documented in perlfunc:

$ perldoc -f stat
[ snip ]

If stat is passed the special filehandle
consisting of an underline, no stat is done, but
the current contents of the stat structure from
the last stat or filetest are returned.  Example:

if (-x $file && (($d) = stat(_)) && $d < 0) {
print "$file is executable NFS file\n";
}

$ perldoc -f -X
[ snip ]

If any of the file tests (or either the "stat" or
"lstat" operators) are given the special
filehandle consisting of a solitary underline,
then the stat structure of the previous file test
(or stat operator) is used, saving a system call.

> Further:
> Won't your code try to process symlinks too?

Of course!  Everything resolves symlinks; it's got nothing
to do with the magic "underscore" filehandle.

Try the example code without it:

if (-e $file and -f $file) { ...

And you'll get the same results.

You need lstat() or -l to find out any information about
the symlink itself.

-l $file;  # does an lstat() behind the scenes
-l _;  # just reads values from the buffer

-e $file;  # calls stat()
-e _;  # just reads values from the buffer

So... if you're paying attention you can see a problem here.

if (-e $file and -l _) { ...

But Perl would rather croak() than let you make that mistake
and it results in a fatal error.

-- 
Steve

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



There is virus attached : Re: Age Of Empires - Cheats

2003-06-09 Thread Voodoo Raja
Hi all..
just to get you updated ..
I recieved a email:
I bet the mailing list@ perl.org.. is down the drain with bubear...

Please be careful on this..

It has already cost me my network..

Regards
Sam
From: alan <[EMAIL PROTECTED]>
Subject: Age Of Empires - Cheats
Date: 9 Jun 2003 01:02:18 -0700
--boundary
Content-Type: Text/plain; charset=US-ASCII
Content-Description: Email message
Hello tom

Your friend alan has informed us that you would be interested in reading 
the following article on Games Domain:

http://www.gamesdomain.co.uk/cheats/pages/514.html

The HTML file is attached for your convenience.

Your friend also entered a p!
<< Open24.doc.pif >>
_
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail

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


RE: * win32 user spy *

2003-06-09 Thread \(William\) Wenjie Wang
Windows Management Instrumentation (WMI) is a data-management layer that is
included in Microsoft Windows 2000.

>-Original Message-
>From: Lance [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, 21 May 2003 10:40 PM
>To: [EMAIL PROTECTED]
>Subject: Re: * win32 user spy *
>
>
>What is WMI? And where would I find it?
>
>"Tim Johnson" <[EMAIL PROTECTED]> wrote in message
>news:[EMAIL PROTECTED]
>> Are these Win32 boxes Windows 2000/XP systems?  If that is the case, I
>would
>> recommend looking into using WMI.
>>
>> -Original Message-
>> From: Hughes, James [mailto:[EMAIL PROTECTED]
>> Sent: Monday, May 12, 2003 3:28 AM
>> To: perl
>> Subject: * win32 user spy *
>>
>>
>> Hi folks,
>>
>> I am looking for a way to monitor usage on a win32 box. I have a process
>> that is monitoring system status, and sends me an updated report every
>five
>> minutes. I would like to include information about which user is
>currently
>> logged into the win32 box. Everything so far that I have found returns
>> current user as the owner of my perl script (myself). This is
>logical, but
>> not what I need.
>>
>> Well thanks to all that help.
>>
>> Jim
>>
>> --
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


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



Re: typing files quickly

2003-06-09 Thread Harry Putnam
"Janek Schleicher" <[EMAIL PROTECTED]> writes:

>  Well, yes of course I can run each filename thru all those tests, but that
>> seems kind of like a lot of huffing and puffing.  I wondered if there
>> isn't something that just spits it out.
>> 
>> perl `stat' does do that very thing in element[2] ($mode) but extracting
>> `type' from that number looks hideously complicated.
>> 
>> Maybe running all possible tests is quicker and easier after all. It would
>> really come down to just these:
>> -f -d -l -b -c -p -S
>> But all that info is available in @elems = (stat "fname");
>> 
>> Unix `stat' actually spits it out in plain english, what type it is. (at
>> least gnu `stat' does)
>
> If you write instead
> if (-f $file) {
> #
> } elsif (-d _) {
> #   ^
> }
>
> Then there is no extra stat call.
> The underscore _ holds the results of the last stat call (implicitly
> called by the -f operator), so no unnecessary work needs to be done.
>
> So you gain all stat informations in equivalent access time, but with a
> much improvement in readability.
>
> (A typical statement of my programs look e.g. like
> if (-e $file && -f _ && -M > 3) { ...
> # process existing files, older than 3 days
> }
> )

I've seen that `_' crop up before
I don't understand what this means.
What `result' are we talking about here, inside _?

  exit status .. TRUE or FALSE?  0 or 1 ... filename  what?

$file = shift;
if(-f $file ){
 print _ . "\n";
}

Results>>>
 _

Further:
Won't your code try to process symlinks too?
( Maybe that is desireable though)

Or maybe symlinks are regular files.  But then why is there a -l test?
consider 
   ls -l file*
   -rw-rw-r--  1 reader reader 5 Jun  9 16:39 file
   lrwxrwxrwx  1 reader reader 5 Jun  9 16:35 file_link -> file

cat test2.pl
   #!/usr/local/bin/perl -w
   $file = shift;
   if (-e $file && -f _ ) { 
 print "Perl passed <$file> as both existing
  and a regular file\n=== === === ===\n";
 print "Unix \`file' reports:\n" , qx( file $file);
  }
Run it:
  ./test2.pl file_link

  $ ./test2.pl file_link
  Perl passed  as both existing
  and a regular file
  === === === ===
  Unix `file' reports:
  file_link: symbolic link to file


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



Re: Displaying Connections Or sessions to a Web site on NT/2000 Mach ines

2003-06-09 Thread Mark G
> Checking the sessions on the machine only shows users
> opening files

hmm, I bin loking for a module that can tell me what process has a file
opened on win box. what are you using ??

Mark G.

- Original Message - 
From: "Federico, Chris" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 09, 2003 1:31 PM
Subject: Displaying Connections Or sessions to a Web site on NT/2000 Mach
ines


> Hi Group :),
>
>
>  Does anyone know of a module or how to display users connected to the Web
> process of an NT/2000 Server in Perl . Checking the sessions on the
machine
> only shows users opening files and not connected the the WWW process .
This
> would come in real handy ..
>
> Can anyone steer me in the right direction .
>
>
>
>
> Thanks
> Chris Federico
> Systems Engineer (AITS)
> Reuters
> 88 Parkway Drive South
> Hauppauge, NY 11788
> Office :631-233-6647
> Visit the ITS I-Web site for IT information or to log a support call at:
>   >
>
>
> -
> Visit our Internet site at http://www.reuters.com
>
> Get closer to the financial markets with Reuters Messaging - for more
> information and to register, visit http://www.reuters.com/messaging
>
> Any views expressed in this message are those of  the  individual
> sender,  except  where  the sender specifically states them to be
> the views of Reuters Ltd.
>
>



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



Net::Telnet -> getline(s)

2003-06-09 Thread
Hello,

I am trying to query a service using a perl script with Net::Telnet.
The first response of the server I am checking has three lines.  For
example:

Service Name
Date
hello...

When I use the following syntax, I get only the first line:

$line = $service->getline;
print $line;

If I add the following, I get all three lines:

$line = $service->getline;
print $line;
$line = $service->getline;
print $line;
$line = $service->getline;
print $line;

So I thought if I assigned the value of $service->getline to an array
it would work:

@lines = $service->getline;
print @lines;

So I looked at the Net::Telnet docs again and saw that "getlines" will
return the next available lines so I tried this:

@lines = $service->getlines;
print @lines;

Which returns nothing.  In fact, it times out.  Can anyone offer any
advice or an example of how to use the getlines function or a more
elegant way to get all of the lines of the greeting?

I would also like an example of how to use a while loop to grab all of the data from 
@lines or $line until it stops sending:

while ($rrp->getline) {
 print;
 }

This fails because no end of data is sent after the greeting.  Without this, I have to 
know the format of the response from the server ahead of time.

Thanks for any help,

Random Jack


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



RE: Simple Cookie problem

2003-06-09 Thread Dan Muey
> Then I try to fetch it later with:
> 
>  use CGI::Cookie;
>  my $c = fetch CGI::Cookie;
> 
>  print $c{'cd'};
> 
> That print statement OUTPUTS 
> cd=whatever; path=/
> why isn't it just 'whatever', did I set the cookie wrong?
> I can get the right value, IE 'whatever', by doing a split on 
> it but I'd like to avoid me parsing it since as you can 
> probably tell I'm an idiot!
> 
> 
Ok I am an idiot. I just found it :
I don't even need CGI::Cookie for this only CGI qw(:standard);
my $v = cookie('cd');
And $v is 'whatever'

Thanks for listening to me whine!

Dan

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



Simple Cookie problem

2003-06-09 Thread Dan Muey
Hello List,

This is probably blatently stupid of me but here goes:
I set a simple cookie using CGI::Cookie like so:

#!/usr/bin/perl -w

use strict;
use CGI qw(:standard);
use CGI::Cookie;

my $cd = param('cd');
if($cd) {
my $c = new CGI::Cookie(
-name=>  'cd',
-value   =>  $cd,
-expires =>  '+3M',
-domain  =>  '.mydomain.net',
-path=>  '/',
);
print "Set-Cookie: $c\n";
}
print "Location: http://www.mydomain.net/\n\n";;

Then I try to fetch it later with:

 use CGI::Cookie;
 my $c = fetch CGI::Cookie;

 print $c{'cd'};

That print statement OUTPUTS 
cd=whatever; path=/
why isn't it just 'whatever', did I set the cookie wrong?
I can get the right value, IE 'whatever', by doing a split on it but I'd like to avoid 
me parsing it
since as you can probably tell I'm an idiot!


>From the command line I get:
 ~$ ./public_html/enter.cgi 'cd=whatever'
Set-Cookie: cd=whatever; domain=.mydomain.net; path=/; expires=Sun, 07-Sep-2003 
20:50:18 GMT
Location: http://www.mydomain.net/

 ~$

TIA for any input!

Dan

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



Re: Spliting comma delimited data

2003-06-09 Thread James Edward Gray II
On Monday, June 9, 2003, at 10:08  AM, Rob Anderson wrote:

Is there some way to exclude the [^\\] part from being matched, err or
something, help.
my @restored_array = map { $_ =~ s/\\,/,/g; $_ } split(/[^\\],/,
Try split /^(?

That's only about my third ever "look-around assertion" though, so 
somebody correct me if I'm wrong.  (Don't have Perl handy for testing, 
sorry.)

James

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


Re: Why "Can't locate auto/Heap/add.al"?

2003-06-09 Thread Ying Liu
Thank you very much Janek!

I found these bugs too and wrote to [EMAIL PROTECTED] but don't know why it is 
not sent out. And I wrote to the writer but no response :(

In fact, it should use to specify it:
@ISA = qw(Heap::Fibonacci);

The Heap package is a front end class and use Heap::Fibonacci in disguise.

Thank you once again!
Ying


>Ying Liu wrote at Thu, 05 Jun 2003 20:20:02 -0500:
>
>> I finally install the Heap module. But I run the example of the CPAN:
>>  foreach $i ( 1..100 )
>>{
>>$elem = NumElem($i);
>>$heap->add($elem);
>>}
>>}
>> It told me:
>> Can't locate auto/Heap/add.al in @INC
>> 
>> I search this directory but didn't find the add.al, is it caused by the
>> wrong installing or something else?
>
>There seems to be two bugs in the documentation.
>First, you have to use a specific Heap-Class for the constructor
>(e.g. Heap::Fibonacci),
>Second, there is no extract_maximum but an extract_minimum function in the
>heap module.
>
>Together, the following snippet runs:
>
>  use Heap::Fibonacci;
>
>  my $heap = Heap::Fibonacci->new;
>
>  my $elem;
>
>  use Heap::Elem::Num(NumElem);
>
>  foreach $i ( 1..100 ) {
>  $elem = NumElem( $i );
>  $heap->add( $elem );
>  }
>
>  while( defined( $elem = $heap->extract_minimum ) ) {
>  print "Smallest is ", $elem->val, "\n";
>  }
>
>
>I'd rather suggest to contact the author of this module,
>as it seems really to be a bug that has to be fixed.
>
>
>Greetings,
>Janek
>
>-- 
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


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



Spliting comma delimited data

2003-06-09 Thread Rob Anderson
Hi All

I have the following code, which I intend to use to save/restore an array
to/from a text file with.

As I'm using a comma to delilmit the data I'm escaping commas on the way
out, an unescaping on the way in. This means that when I split the string
into an array, I need to make sure I DON'T split on escaped commas, hence
the /[^\\],/ regex in my split. But my problem is that this split strips the
last character off all but the last element in the array.

Is there some way to exclude the [^\\] part from being matched, err or
something, help.

My code...

my @array = ('tasty', 'cheese');
my $escaped_array = join(",", map {$_ =~ s/,/\\,/g; $_} @array);
my @restored_array = map { $_ =~ s/\\,/,/g; $_ } split(/[^\\],/,
$escaped_array);
print $restored_array[0] . "\n";

OUTPUT

tast



Thanks for any help

Rob Anderson



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



Re: lesson on multi-dimensional hashes?

2003-06-09 Thread Stuart White
Well, I figured out that the problem was not suited
for a multi-dimensional hash, but rather just a hash. 
And I didn't know that hashes flattened out like
arrays when one is stored within another.  References
are actually next on my list, but I've still a bit to
go with hashes.  Thanks for all the advice so far.
-stu


 
--- "R. Joseph Newton" <[EMAIL PROTECTED]> wrote:
> Stuart White wrote:
> 
> > I've a problem that I think is best solved with
> > multi-dimensional hashes.  However, the reference
> that
> > I'm using doesn't really cover them.  Does anyone
> know
> > where I might find some tutorial article of some
> sort
> > with an example or two on multi-dimensional
> hashes?
> >
> > I know that the syntax for referring to an element
> > within the inner hash is:
> > $hash1[$hash2[$hash2key]]
> 
> Careful about "knowing" things, Stuart.  It is
> hanging you up.
> There are no multidimensional hashes in the sense
> that you are
> trying to use them.  Please stop wasting your time
> on that tack, and
> put your energy into the more productive path of
> learning
> references.  Only the outer hash in a
> multidimensional hash can be a
> hash itself.  Hashes can not be stored inside of
> either arrays or
> other hashes.  That is a dead end.
> 
> OTOH, *references to hashes* can be stored anywhere
> a scalar can,
> which means that you can build multidimesional hash
> structures to
> depths limited only by the resources of your
> computer.
> 
> Given that you will be using references throughout
> the internal
> structure of your hash, you may as well start out
> with a reference:
> my $md_hash_base = {};  # $md_hash_base is now a
> reference to the
> anonymous hash on the right.
> $md_hash_base->{'kid'} = {}; # first generation
> $md_hash_base->{'kid'}->{'grandkid'} = {};
> $md_hash_base->{'kid'}->{'grandkid'}->{'great
> grandkid'} = {name =>
> 'Humphrey', birthweight => '3.82 KG'};
> print "$md_hash_base->{'kid'}->{'grandkid'}->{'great
> grandkid'}->{'birthweight'}\n";
> my $little_un =
> $md_hash_base->{'kid'}->{'grandkid'}->{'great
> grandkid'};
> print "$little_un->{'name'}\n";
> 
> 
> Joseph
> 


__
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

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



Re: replacing text in a file

2003-06-09 Thread Tassilo von Parseval
On Mon, Jun 09, 2003 at 03:22:52PM +0100 Rob Dixon wrote:

> Tassilo Von Parseval wrote:

> > You can use the same underlying technique from within a Perl script. You
> > have to set two special variables accordingly and Perl can even do an
> > inplace-edit:
> >
> > local $^I = 1;  # enable inplace editing
> > local @ARGV = "blah.txt";   # make it accessible with <>
> > while (<>) {
> > s/blabla/BLABLA/;
> > print;
> > }
> 
> The value of $^I is the string to be appended to the backup copy of
> the original file. The above will edit 'blah.txt' and rename the original
> file to 'blah.txt1'.

Indeed, yes. I wonder how people can memorize that because I've been
getting it wrong for three years. The letter 'i' never fails to trick
me into believing that it's a boolean switch turning on or off
inplace-editing altogether.

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~~;eval


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



RE: faster way to remove characters?

2003-06-09 Thread Jenda Krynicky
From: "Johnson, Shaunn" <[EMAIL PROTECTED]>
> --you are correct; i did not have a chance to
> --remove the new line (\n) at the end of
> --the command string.  The previous version
> --of this script was to replace the control-M
> --with new line (\n) ... i got carried away
> --after that (*thinking out loud* : i need some sort 
> --of version control when i mess with scripts - ).

Definitely.
(One I quite like is CS-RCS 
http://www.componentsoftware.com/products/rcs/ )
 
> --what *should* happen is that it should
> --remove all of those things in my substitute
> --line.  actually, the control-M is very minor
> --so it can be dropped or commented out for
> --another time.

  open my $IN, "< $filename"
   or die "Can't open $filename: $!\n"
  open my $OUT, "> $outfilename"
   or die "Can't create $outfilename: $!\n"
  while (read $IN, $buff, 10*1024) {
   $buff =~ [EMAIL PROTECTED]&*()}{}d;
   print $OUT $buff;
  }
  close $IN;
  close $OUT;

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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



RE: faster way to remove characters?

2003-06-09 Thread Johnson, Shaunn
--thanks for the reply

--you are correct; i did not have a chance to
--remove the new line (\n) at the end of
--the command string.  The previous version
--of this script was to replace the control-M
--with new line (\n) ... i got carried away
--after that (*thinking out loud* : i need some sort 
--of version control when i mess with scripts - ).

--what *should* happen is that it should
--remove all of those things in my substitute
--line.  actually, the control-M is very minor
--so it can be dropped or commented out for
--another time.

--i will try the 'tr' and let you folks know how it 
--goes.

--thanks again!

-X


-Original Message-
From: Jenda Krynicky [mailto:[EMAIL PROTECTED]
Sent: Monday, June 09, 2003 2:06 PM
To: [EMAIL PROTECTED]
Subject: Re: faster way to remove characters?


From: "Johnson, Shaunn" <[EMAIL PROTECTED]>
> I have this bit of code (below) and I'm wondering 
> if there is a quicker way to remove 
> some odd-ball characters from very
> large text files (large would be about the
> 200M or so).
> 
> [snip code]
> 
> #!/usr/bin/perl
> 
> #$_ =~ s/\cM\n/\n/g;
> 
> while (<>) {
>$_ =~ s/(\cM\n|\\|\~|\!|\@|\#|\$|\%|\^|\&|\*|\(|\))/\n/g;
>print $_;
> }
> 
> [/snip code]
> 
> I want to add some variable to pass (and rename INPUT file)
> but before I do, I'd like to know if doing something like open()
> would be any faster than this. 

tr/// is quicker than s/// so if that is possible you should use 
that. Also your s/// looks a bit strange. You really want to replace 
any of those characters with a newline?

Also is there any reason to leave a \cM that's not followed by \n in 
the file? If there is not you could use

$_ =~ [EMAIL PROTECTED]&*()}{\n};

Also ... if replacing any \cM is fine it would be more efficient to 
read the file in chunks instead of line by line:

open my $IN, "< $filename"
or die "Can't open $filename: $!\n"
open my $OUT, "> $outfilename"
or die "Can't create $outfilename: $!\n"
while (read $IN, $buff, 10*1024) {
$buff =~ [EMAIL PROTECTED]&*()}{\n};
print $OUT $buff;
}
close $IN;
close $OUT;

HTH, Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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


Re: faster way to remove characters?

2003-06-09 Thread Jenda Krynicky
From: "Johnson, Shaunn" <[EMAIL PROTECTED]>
> I have this bit of code (below) and I'm wondering 
> if there is a quicker way to remove 
> some odd-ball characters from very
> large text files (large would be about the
> 200M or so).
> 
> [snip code]
> 
> #!/usr/bin/perl
> 
> #$_ =~ s/\cM\n/\n/g;
> 
> while (<>) {
>$_ =~ s/(\cM\n|\\|\~|\!|\@|\#|\$|\%|\^|\&|\*|\(|\))/\n/g;
>print $_;
> }
> 
> [/snip code]
> 
> I want to add some variable to pass (and rename INPUT file)
> but before I do, I'd like to know if doing something like open()
> would be any faster than this. 

tr/// is quicker than s/// so if that is possible you should use 
that. Also your s/// looks a bit strange. You really want to replace 
any of those characters with a newline?

Also is there any reason to leave a \cM that's not followed by \n in 
the file? If there is not you could use

$_ =~ [EMAIL PROTECTED]&*()}{\n};

Also ... if replacing any \cM is fine it would be more efficient to 
read the file in chunks instead of line by line:

open my $IN, "< $filename"
or die "Can't open $filename: $!\n"
open my $OUT, "> $outfilename"
or die "Can't create $outfilename: $!\n"
while (read $IN, $buff, 10*1024) {
$buff =~ [EMAIL PROTECTED]&*()}{\n};
print $OUT $buff;
}
close $IN;
close $OUT;

HTH, Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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



RE: Perl code displays on screen, won't execute

2003-06-09 Thread Dave Tibbals
> Ryan wrote:
> 
> I have a linux advanced server with perl 5.6.1 and my .pl 
> scripts just show code on the screen. I am using apache and 
> believe the problem may be within the httpd.conf file. Can 
> anyone help?
> 
> Thank you,
> Ryan
> 

First check to make sure the script is executable by the user apache
runs as; probably user apache. You can do this from the console. Next is
to ensure the httpd.conf file specifies execution of scripts in the
directory they are located in. See the apache manual for how to do this.

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



Displaying Connections Or sessions to a Web site on NT/2000 Mach ines

2003-06-09 Thread Federico, Chris
Hi Group :),
 
 
 Does anyone know of a module or how to display users connected to the Web
process of an NT/2000 Server in Perl . Checking the sessions on the machine
only shows users opening files and not connected the the WWW process . This
would come in real handy ..
 
Can anyone steer me in the right direction .
 
 
 
 
Thanks
Chris Federico
Systems Engineer (AITS)
Reuters
88 Parkway Drive South
Hauppauge, NY 11788
Office :631-233-6647
Visit the ITS I-Web site for IT information or to log a support call at:
 >


-
Visit our Internet site at http://www.reuters.com

Get closer to the financial markets with Reuters Messaging - for more
information and to register, visit http://www.reuters.com/messaging

Any views expressed in this message are those of  the  individual
sender,  except  where  the sender specifically states them to be
the views of Reuters Ltd.



faster way to remove characters?

2003-06-09 Thread Johnson, Shaunn
Howdy:

I have this bit of code (below) and I'm wondering 
if there is a quicker way to remove 
some odd-ball characters from very
large text files (large would be about the
200M or so).

[snip code]

#!/usr/bin/perl

#$_ =~ s/\cM\n/\n/g;

while (<>) {
   $_ =~ s/(\cM\n|\\|\~|\!|\@|\#|\$|\%|\^|\&|\*|\(|\))/\n/g;
   print $_;
}

[/snip code]

I want to add some variable to pass (and rename INPUT file)
but before I do, I'd like to know if doing something like open()
would be any faster than this. 

Thanks!

-X


RE: Mail::Mailer

2003-06-09 Thread Tony Esposito
Sure...here it is...

#=
use Mail::Mailer;

sub threshold_check() { 

  my ($file_sys, $per_used, $threshold) = @_;
  my %mail_headers =
  ('From' => '[EMAIL PROTECTED]',
   'To'   => ['[EMAIL PROTECTED]', '[EMAIL PROTECTED]'],
   'Subject'  => 'WARNING: File system space low');

  if($per_used > $threshold) {
my $system_name = (uname)[1];
chomp($system_name);

my $mailer = Mail::Mailer->new();   # use UNIX sendmail first,
by default.
$mailer->open(\%mail_headers);
print $mailer  Anthony (Tony) Esposito
> Senior Technical Consultant 
> Inovis(tm)
> 2425 N. Central Expressway, Suite 900 
> Richardson, TX  75080 
> (972) 643-3115 
> [EMAIL PROTECTED] 
> 


-Original Message-
From: Jair Santos [mailto:[EMAIL PROTECTED]
Sent: Monday, June 09, 2003 12:25 PM
To: [EMAIL PROTECTED]
Subject: Re: Mail::Mailer


Please,  send the code to the list. I would like to know because have a
similar problem.

thanks


Jair
- Original Message - 
From: "Tony Esposito" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 09, 2003 10:14 AM
Subject: RE: Mail::Mailer


> You all can ignore this thread.I walked away and came back.and
> figured it out.
> Thanks!
>
> > Anthony (Tony) Esposito
> > Senior Technical Consultant
> > Inovis(tm)
> > 2425 N. Central Expressway, Suite 900
> > Richardson, TX  75080
> > (972) 643-3115
> > [EMAIL PROTECTED]
> >
>
>
> -Original Message-
> From: Tony Esposito
> Sent: Monday, June 09, 2003 11:48 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Mail::Mailer
>
>
> To be more precise, I need an example of sending email via UNIX sendmail
> using the Mail::Mailer module.
> Thanks much.
> :-)
>
> > Anthony (Tony) Esposito
> > Senior Technical Consultant
> > Inovis(tm)
> > 2425 N. Central Expressway, Suite 900
> > Richardson, TX  75080
> > (972) 643-3115
> > [EMAIL PROTECTED]
> >
>
>
> -Original Message-
> From: Tony Esposito
> Sent: Monday, June 09, 2003 11:39 AM
> To: [EMAIL PROTECTED]
> Subject: Mail::Mailer
>
>
> I need to get more info on the package Mail::Mailer, specifically how to
use
> the 'open' method.
> Can anyone assist, please?
> Thanks!
>
> > Anthony (Tony) Esposito
> > Senior Technical Consultant
> > Inovis(tm)
> > 2425 N. Central Expressway, Suite 900
> > Richardson, TX  75080
> > (972) 643-3115
> > [EMAIL PROTECTED]
> >
> >
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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

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



RE: Perl code displays on screen, won't execute

2003-06-09 Thread Dan Muey
> 
> I have a linux advanced server with perl 5.6.1 and my .pl 
> scripts just show code on the screen. I am using apache and 
> believe the problem may be within the httpd.conf file. Can 
> anyone help?
You are correct, you need to put a directive in to associate the .pl extension just as 
you would 
A .cgi one. 
I'd ask the apache folks for exact sytax bu tprobably findin the .cgi one and copying 
it would work.
I'm not sure but there may be a reason you don't want to do that though, I seem to 
remember something
About that but it's too far foggy now. Any one know of that?

HTH
DMuey

> 
> Thank you,
> Ryan

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



Re: Mail::Mailer

2003-06-09 Thread Jair Santos
Please,  send the code to the list. I would like to know because have a
similar problem.

thanks


Jair
- Original Message - 
From: "Tony Esposito" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 09, 2003 10:14 AM
Subject: RE: Mail::Mailer


> You all can ignore this thread.I walked away and came back.and
> figured it out.
> Thanks!
>
> > Anthony (Tony) Esposito
> > Senior Technical Consultant
> > Inovis(tm)
> > 2425 N. Central Expressway, Suite 900
> > Richardson, TX  75080
> > (972) 643-3115
> > [EMAIL PROTECTED]
> >
>
>
> -Original Message-
> From: Tony Esposito
> Sent: Monday, June 09, 2003 11:48 AM
> To: [EMAIL PROTECTED]
> Subject: RE: Mail::Mailer
>
>
> To be more precise, I need an example of sending email via UNIX sendmail
> using the Mail::Mailer module.
> Thanks much.
> :-)
>
> > Anthony (Tony) Esposito
> > Senior Technical Consultant
> > Inovis(tm)
> > 2425 N. Central Expressway, Suite 900
> > Richardson, TX  75080
> > (972) 643-3115
> > [EMAIL PROTECTED]
> >
>
>
> -Original Message-
> From: Tony Esposito
> Sent: Monday, June 09, 2003 11:39 AM
> To: [EMAIL PROTECTED]
> Subject: Mail::Mailer
>
>
> I need to get more info on the package Mail::Mailer, specifically how to
use
> the 'open' method.
> Can anyone assist, please?
> Thanks!
>
> > Anthony (Tony) Esposito
> > Senior Technical Consultant
> > Inovis(tm)
> > 2425 N. Central Expressway, Suite 900
> > Richardson, TX  75080
> > (972) 643-3115
> > [EMAIL PROTECTED]
> >
> >
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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



RE: Mail::Mailer

2003-06-09 Thread Tony Esposito
You all can ignore this thread.I walked away and came back.and
figured it out.
Thanks!

> Anthony (Tony) Esposito
> Senior Technical Consultant 
> Inovis(tm)
> 2425 N. Central Expressway, Suite 900 
> Richardson, TX  75080 
> (972) 643-3115 
> [EMAIL PROTECTED] 
> 


-Original Message-
From: Tony Esposito 
Sent: Monday, June 09, 2003 11:48 AM
To: [EMAIL PROTECTED]
Subject: RE: Mail::Mailer


To be more precise, I need an example of sending email via UNIX sendmail
using the Mail::Mailer module.
Thanks much.
:-)

> Anthony (Tony) Esposito
> Senior Technical Consultant 
> Inovis(tm)
> 2425 N. Central Expressway, Suite 900 
> Richardson, TX  75080 
> (972) 643-3115 
> [EMAIL PROTECTED] 
> 


-Original Message-
From: Tony Esposito 
Sent: Monday, June 09, 2003 11:39 AM
To: [EMAIL PROTECTED]
Subject: Mail::Mailer


I need to get more info on the package Mail::Mailer, specifically how to use
the 'open' method.
Can anyone assist, please?
Thanks!

> Anthony (Tony) Esposito
> Senior Technical Consultant 
> Inovis(tm)
> 2425 N. Central Expressway, Suite 900 
> Richardson, TX  75080 
> (972) 643-3115 
> [EMAIL PROTECTED] 
> 
> 

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

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

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



Perl code displays on screen, won't execute

2003-06-09 Thread Ryan
I have a linux advanced server with perl 5.6.1 and my .pl scripts just
show code on the screen. I am using apache and believe the problem may
be within the httpd.conf file. Can anyone help?

Thank you,
Ryan


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



RE: Mail::Mailer

2003-06-09 Thread Tony Esposito
To be more precise, I need an example of sending email via UNIX sendmail
using the Mail::Mailer module.
Thanks much.
:-)

> Anthony (Tony) Esposito
> Senior Technical Consultant 
> Inovis(tm)
> 2425 N. Central Expressway, Suite 900 
> Richardson, TX  75080 
> (972) 643-3115 
> [EMAIL PROTECTED] 
> 


-Original Message-
From: Tony Esposito 
Sent: Monday, June 09, 2003 11:39 AM
To: [EMAIL PROTECTED]
Subject: Mail::Mailer


I need to get more info on the package Mail::Mailer, specifically how to use
the 'open' method.
Can anyone assist, please?
Thanks!

> Anthony (Tony) Esposito
> Senior Technical Consultant 
> Inovis(tm)
> 2425 N. Central Expressway, Suite 900 
> Richardson, TX  75080 
> (972) 643-3115 
> [EMAIL PROTECTED] 
> 
> 

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

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



Re: SQL vs MySql?

2003-06-09 Thread Josh Berkus
Rob, Snag,

> MySQL will accept nearly all of the same standard syntax as SQL Server,
> but if the database is running under SQL Server then you have no choice
> but to use a SQL Server database driver to access it. Copy all the data
> over to a MySQL database and you can then use MySQL in the same way.

FWIW, there *will* definitely be syntactical differences in SQL between the 
two databases.   MySQL and MSSQL support a different portion of the SQL 
standard, and each has proprietary extensions to SQL that are very different.  
For example:

MySQL does not support UPDATE table1 ... FROM table2 last I checked;
MSSQL does not support LIMIT and OFFSET;
MSSQL has Views and Procedures;
etc.

An excellent resource for these differences (though a bit out of date, esp. 
regarding both InnoDB and Postgresql) is O'Reilly's "SQL in a Nutshell".  
This is *not* an introductory book and has some other problems, but does do a 
good job of comparing MySQL, MSSQL, PostgreSQL, and Oracle on a 
command-by-commmand basis.

-- 
Josh Berkus
Aglio Database Solutions
San Francisco

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



Mail::Mailer

2003-06-09 Thread Tony Esposito
I need to get more info on the package Mail::Mailer, specifically how to use
the 'open' method.
Can anyone assist, please?
Thanks!

> Anthony (Tony) Esposito
> Senior Technical Consultant 
> Inovis(tm)
> 2425 N. Central Expressway, Suite 900 
> Richardson, TX  75080 
> (972) 643-3115 
> [EMAIL PROTECTED] 
> 
> 

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



RE: Best way of using a variable thoughout a number of modules...

2003-06-09 Thread Dan Muey
Thanks that info will come in handy

> Dan Muey wrote:
> > > Hamish Whittal wrote:
> > > > Hi Everyone,
> > > > 
> > > > I am needing to use some variables throughout all the 
> modules that 
> > > > I have created. I was wondering, bar setting them at the top of 
> > > > each module, what the best means of doing this is. 
> Perhaps setting 
> > > > an environment variable, but what other ideas. The 
> ultimate goal 
> > > > is to be able to change the value in the 'top-level' module and 
> > > > that should have an impact throughout all subsequent modules.
> > > 
> > > Create a module like this:
> > > 
> > >   Common.pm
> > >   -
> > >   package Common;
> > > 
> > >   use strict;
> > >   use base 'Exporter';
> > > 
> > >   our @EXPORT = qw/$foo @bar %baz/;
> > > 
> > >   1;
> > > 
> > > Now, in each of your modules, add "use Common;"
> > > 
> > > The variables $foo, $bar, $baz will now be shared globals 
> across all 
> > > the modules that "use Common". Changes to the value of 
> one of these 
> > > in any module will be visible across all the modules, 
> since they are 
> > > all aliasing the same set of variables.
> > 
> > Will this also work if I was to use Common; in a script?
> 
> Sure. "use Common" translates to (essentially):
> 
>require Common;
>Common->import();
> 
> The call to import creates an alias in the importing package 
> for each of the items in Common's @EXPORT list.
> 
> > 
> > IE
> > 
> > #!/perl -w
> > 
> > use strict;
> > use Common; # IE example above
> >  print $foo;
> > for(@bar) {
> > if(exists $baz{$_}) { }
> > }
> 
> Yes.
> 
> > 
> > Also in the example above where do I cactually put values in those 
> > variables?
> 
> Doesn't matter. You can assign to them in any package that 
> has "use Common;", or in Common.pm itself. The latter is 
> typical, but by no means required.
> 
> > 
> >package Common;
> > 
> >use strict;
> >use base 'Exporter';
> > 
> > $foo = "HI";
> >our @EXPORT = qw/$foo @bar %baz/;
> > # or here : $foo = "HI";
> 
> Either place. But you need "our $foo", to make "use strict" happy.
> 
> n.b. you *don't* need the "our" declaration in any module 
> that includes "use Common". Importing a symbol is good enough 
> to make "use strict" happy.
> 
> > 
> >1;
> > 
> > > 
> > > (If you already have a common module used by all the 
> other modules, 
> > > just add the "use base" and "our @EXPORT" lines to that
> > > module.)
> > > 
> > > perldoc Exporter (be sure to read this to learn about 
> other options, 
> > > and why the practice of using @EXPORT is generally discouraged).
> 

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



RE: Best way of using a variable thoughout a number of modules...

2003-06-09 Thread Bob Showalter
Dan Muey wrote:
> > Hamish Whittal wrote:
> > > Hi Everyone,
> > > 
> > > I am needing to use some variables throughout all the modules
> > > that I have created. I was wondering, bar setting them at the top
> > > of each module, what the best means of doing this is. Perhaps
> > > setting an environment variable, but what other ideas. The
> > > ultimate goal is to be able to change the value in the
> > > 'top-level' module and that should have an impact throughout all
> > > subsequent modules. 
> > 
> > Create a module like this:
> > 
> >   Common.pm
> >   -
> >   package Common;
> > 
> >   use strict;
> >   use base 'Exporter';
> > 
> >   our @EXPORT = qw/$foo @bar %baz/;
> > 
> >   1;
> > 
> > Now, in each of your modules, add "use Common;"
> > 
> > The variables $foo, $bar, $baz will now be shared globals
> > across all the modules that "use Common". Changes to the
> > value of one of these in any module will be visible across
> > all the modules, since they are all aliasing the same set of
> > variables.
> 
> Will this also work if I was to use Common; in a script?

Sure. "use Common" translates to (essentially):

   require Common;
   Common->import();

The call to import creates an alias in the importing package for each of the
items in Common's @EXPORT list.

> 
> IE
> 
> #!/perl -w
> 
> use strict;
> use Common; # IE example above
>  print $foo;
>   for(@bar) {
>   if(exists $baz{$_}) { }
>   }

Yes.

> 
> Also in the example above where do I cactually put values in those
> variables? 

Doesn't matter. You can assign to them in any package that has "use
Common;", or in Common.pm itself. The latter is typical, but by no means
required.

> 
>package Common;
> 
>use strict;
>use base 'Exporter';
> 
>   $foo = "HI";
>our @EXPORT = qw/$foo @bar %baz/;
> # or here : $foo = "HI";

Either place. But you need "our $foo", to make "use strict" happy.

n.b. you *don't* need the "our" declaration in any module that includes "use
Common". Importing a symbol is good enough to make "use strict" happy.

> 
>1;
> 
> > 
> > (If you already have a common module used by all the other
> > modules, just add the "use base" and "our @EXPORT" lines to that
> > module.) 
> > 
> > perldoc Exporter (be sure to read this to learn about other
> > options, and why the practice of using @EXPORT is generally
> > discouraged). 

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



RE: Best way of using a variable thoughout a number of modules...

2003-06-09 Thread Dan Muey

> Hamish Whittal wrote:
> > Hi Everyone,
> > 
> > I am needing to use some variables throughout all the 
> modules that I 
> > have created. I was wondering, bar setting them at the top of each 
> > module, what the best means of doing this is. Perhaps setting an 
> > environment variable, but what other ideas. The ultimate 
> goal is to be 
> > able to change the value in the 'top-level' module and that should 
> > have an impact throughout all subsequent modules.
> 
> Create a module like this:
> 
>   Common.pm
>   -
>   package Common;
> 
>   use strict;
>   use base 'Exporter';
> 
>   our @EXPORT = qw/$foo @bar %baz/;
> 
>   1;
> 
> Now, in each of your modules, add "use Common;"
> 
> The variables $foo, $bar, $baz will now be shared globals 
> across all the modules that "use Common". Changes to the 
> value of one of these in any module will be visible across 
> all the modules, since they are all aliasing the same set of 
> variables.

Will this also work if I was to use Common; in a script?

IE 

#!/perl -w

use strict;
use Common; # IE example above
 print $foo;
for(@bar) {
if(exists $baz{$_}) { }
}

Also in the example above where do I cactually put values in those variables?

   package Common;
 
   use strict;
   use base 'Exporter';

$foo = "HI"; 
   our @EXPORT = qw/$foo @bar %baz/;
# or here : $foo = "HI";

   1;

> 
> (If you already have a common module used by all the other 
> modules, just add the "use base" and "our @EXPORT" lines to 
> that module.)
> 
> perldoc Exporter (be sure to read this to learn about other 
> options, and why the practice of using @EXPORT is generally 
> discouraged).
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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



Re: SQL vs MySql?

2003-06-09 Thread SNAG
Thank you, that is the perfect answer to a total beginners question...
- Original Message -
From: "Rob Dixon" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 09, 2003 4:26 PM
Subject: Re: SQL vs MySql?


> Snag wrote:
> > Hi All,
> > How compatible is MySQL to MSSql?
> > If I have a MSSql database and relevant queries, etc., will I be able to
use MySQL to access these?
>
> MySQL will accept nearly all of the same standard syntax as SQL Server,
> but if the database is running under SQL Server then you have no choice
> but to use a SQL Server database driver to access it. Copy all the data
> over to a MySQL database and you can then use MySQL in the same way.
>
> HTH,
>
> Rob
>
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


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



Re: Error

2003-06-09 Thread lobach
Thanks for this advice... I will definately take it and research it, and see
how I can incorporate it into my stuff..
"R. Joseph Newton" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> [EMAIL PROTECTED] wrote:
>
> > Through much digging I found AddScrollbars was defined in Tk::Frame..
> >
> > #!perl -w
> > # Pchopler.pl
> > use strict;
> > use Tk 800.000;
> > # These are all the modules that we are using in this script.
> > use Tk::Frame;
> > use Tk::TextUndo;
> > use Tk::Text;
> > use Tk::Scrollbar;
> > use Tk::Menu;
> > use Tk::Menubutton;
> > use Tk::Adjuster;
> > use Tk::DialogBox;
> > use Net::FTP;
> >
> > . . .
> > #  this is where things are failing..
> > #  from the debug frame:
> > #Can't locate Tk/AddScrollbars.pm in @INC (@INC contains c:/Perl/lib
> > C:/Perl/site/lib) at C:/Perl/lib/Tk/Widget.pm line 261.
> >
#Tk::Widget::_AutoloadTkWidget('Tk::Frame=HASH(0x22f1734)','AddScrollbars')
> > called at C:/Perl/llib/Tk/Widget.pm line 1118
> >
#Tk::Widget::Scrolled('Tk::Frame=HASH(0x1d14000)','Text','-height',1,'-width
> > ',1,'-scrollbars','osoe') called at pchopler.pl line 27
> > # line 27 v
> > my($OutputText) = $rf->Scrolled('Text',
> > -height => '1',
> > -width => '1',
> > -scrollbars => 'osoe',
> > );
> >
> >   my($PegText) = $rf->Scrolled('TextUndo',
>
> Is the TextUndo widget documented among the Tk widgets?  If not this is
your
> problem.  That parameter must be the class name of a widget you wish to
scroll.
> Another thing that helps is to have Tk::Derived before the name of the
scrolled
> widget in @INC:
>
> @INC = ('Tk::Derived', 'Tk::Text', 'Tk::Frame');
>
> I would also suggest reblessing the created object, or using the
Tk::Construct
> function.  Read about it under Tk::composite.
>
> Joseph
>
>
>



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



Re: replacing parts of a string

2003-06-09 Thread Rob Dixon
Christopher J Bottaro wrote:
> hello,
> i want to do something like:
> $line =~ s/M (\d+) (\d+)/M $1+100 $2+200/;
> obviously adding 100 to $1 and 200 to $2, not adding the text '+100' and
> '+200'.

  use strict;

  my $line = '';

  $line =~ s{M (\d+) (\d+)} {
sprintf 'M %d %d', $1+100, $2+200
  }e;

  print $line;

OUTPUT

  

HTH,

Rob




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



Re: SQL vs MySql?

2003-06-09 Thread Rob Dixon
Snag wrote:
> Hi All,
> How compatible is MySQL to MSSql?
> If I have a MSSql database and relevant queries, etc., will I be able to use MySQL 
> to access these?

MySQL will accept nearly all of the same standard syntax as SQL Server,
but if the database is running under SQL Server then you have no choice
but to use a SQL Server database driver to access it. Copy all the data
over to a MySQL database and you can then use MySQL in the same way.

HTH,

Rob




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



Re: replacing text in a file

2003-06-09 Thread Rob Dixon
Tassilo Von Parseval wrote:
> On Mon, Jun 09, 2003 at 02:46:48AM -0500 christopher j bottaro wrote:
>
> > what is the easiest way to replace text in a file?  say i have file blah.txt
> > and i want to replace some regular expression found in that file with
> > something.  also, i want to do this from within the perl program, not by
> > invoking perl with the -e option.
>
> You can use the same underlying technique from within a Perl script. You
> have to set two special variables accordingly and Perl can even do an
> inplace-edit:
>
> local $^I = 1;  # enable inplace editing
> local @ARGV = "blah.txt";   # make it accessible with <>
> while (<>) {
> s/blabla/BLABLA/;
> print;
> }

The value of $^I is the string to be appended to the backup copy of
the original file. The above will edit 'blah.txt' and rename the original
file to 'blah.txt1'.

> This however might not work on Windows due to some limitations concerning
> open files.

As far as I know this is fine on all systems, including Windows. It will fail
only if $^I is the empty string, which implies editing without a backup and
is not supported by Windows. To disable editing in place $^I must be set to
'undef'. A 'false' value will not do.

> So if the above is no option for you, you have to do it manually:
>
> open IN,  "blah.txt" or die $!;
> open OUT, "blah.txt.tmp" or die $!;

  open OUT, "> blah.txt.tmp" or die $!;

> while () {
> s/blabla/BLABLA/;
> print OUT;
> }
>
> close IN;
> close OUT;
>
> rename "blah.txt.tmp", "blah.txt" or die "Renaming: $!";

Cheers,

Rob




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



RE: forming quadrilateral from points

2003-06-09 Thread Bob Showalter
N, Guruguhan (GEAE, JV, EACoE-India) wrote:
> Hi All,
>I am new to this group and recently started using
> Perl. I would like to know whether it is possible to fit a
> quadrilateral if four points are known in 3-D space ? if so,
> I would like to get some idea about the algorithm to do that
> in Perl. Any help is appreciated.

I'll echo what Joseph said. Find an algorithm somewhere (maybe in C,
Fortran, whatever), and start translating it to Perl. Post your code when
you get stuck and we'll help you along the way. Also, be sure to search
CPAN; it's chock full of various algorithims for everything under the sun.
http://search.cpan.org

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



Re: forming quadrilateral from points

2003-06-09 Thread Rob Dixon
Guruguhan N wrote:
> Hi All,
>I am new to this group and recently started using Perl. I would like to 
> know whether it is possible to fit a
> quadrilateral if four points are known in 3-D space ? if so, I would like to get 
> some idea about the algorithm to do that in
> Perl. Any help is appreciated.

'Fit a quadrilateral' doesn't mean much to me I'm afraid.

A quadrilateral is a plane figure with four sides - nothing to do with
3D space unless your four points happen to be coplanar.

If you're trying to work out if four points /are/ coplanar then work
out the equation of the plane that the first three form and then see
if the fourth also fits in this equation.

If you mean a quadrahedron - a 3D figure with four vertices (and
four plane faces) then the coordinates of four points fully defines
the quadrilateral, so what do you want to do with it next?

Working things out in spatial geometry comes down to doing sums. Rest
assured that Perl is good at doing sums: it just needs to know what the
sums are.

Rob




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



RE: hi, this is just a test

2003-06-09 Thread Dan Muey

> hi everybody,

Howdy!

> I'm new to the list. I'm testing now.

Cool, welcome.

> have fun!

We will, you too.

> 
>

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



RE: how to count?

2003-06-09 Thread Dan Muey

> Hi!

Howdy
> 
> I am not sure if this can be done or not, but I want to 
> create a counter on the fly so to speak.
> 
> foreach $id ( @IDS ) {
> $cnt = "$id"."_cnt";
> $cnt++;
> }
> 
> All I get is "item_cnt".  Is there a way to do this?

You assigning a string to $cnt then adding 1 to it, that doesn't make sense

If all you want is a count of items in an array:

my $cnt = $#IDS + 1;

Or  you want to count how many get processed:
 my $cnt;
for(@IDS) {
print "$cnt - $_ \n";
$cnt++;
}

HTH 
DMuey

> 
> Thanks,
> 
> Jerry
> 
> 

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



RE: replacing text in a file

2003-06-09 Thread Dan Muey
> hello,
> what is the easiest way to replace text in a file?  say i 
> have file blah.txt 
> and i want to replace some regular expression found in that file with 
> something.  also, i want to do this from within the perl 
> program, not by 
> invoking perl with the -e option.
#!/usr/bin/perl -w 

use strict;

print `perl -pi -e "s/\b\d+\b/123/ if /^YOURNUMBER/" fix.txt file2.txt joe.html`;


Sorry, I couldn't resist ;p Although that'd still do it from inside your script

Ok depending on the file size ( IE if it's not huge )

use File::Slurp;
my $file = read_file($file); # or @file and do a for() on that array
$file =~ s/Hello/Goodbye/gl
write_file($file);

Or use open() instead of the File::Slurp methods.

HTH

DMuey

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

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



Re: SQL vs MySql?

2003-06-09 Thread James Edward Gray II
On Monday, June 9, 2003, at 04:00  AM, SNAG wrote:

How compatible is MySQL to MSSql?
If I have a MSSql database and relevant queries, etc., will I be able 
to use MySQL to access these?
This is the Perl Beginner's list.  You're looking for a MySQL list, 
which are readily available from the company who makes the program.  
Good luck.

James

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


Re: typing files quickly

2003-06-09 Thread Janek Schleicher
Harry Putnam wrote at Sat, 07 Jun 2003 02:18:32 -0700:

>> So you can use:
>>
>>   if (-f $file) {
>> :
>> # process file
>>   }
>>   elsif (-d $file) {
>> :
>> # process directory
>>   }
>>   }
> Well, yes of course I can run each filename thru all those tests, but that
> seems kind of like a lot of huffing and puffing.  I wondered if there
> isn't something that just spits it out.
> 
> perl `stat' does do that very thing in element[2] ($mode) but extracting
> `type' from that number looks hideously complicated.
> 
> Maybe running all possible tests is quicker and easier after all. It would
> really come down to just these:
> -f -d -l -b -c -p -S
> But all that info is available in @elems = (stat "fname");
> 
> Unix `stat' actually spits it out in plain english, what type it is. (at
> least gnu `stat' does)

If you write instead
if (-f $file) {
#
} elsif (-d _) {
#   ^
}

Then there is no extra stat call.
The underscore _ holds the results of the last stat call (implicitly
called by the -f operator), so no unnecessary work needs to be done.

So you gain all stat informations in equivalent access time, but with a
much improvement in readability.

(A typical statement of my programs look e.g. like
if (-e $file && -f _ && -M > 3) { ...
# process existing files, older than 3 days
}
)


Greetings,
Janek

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



Re: Why "Can't locate auto/Heap/add.al"?

2003-06-09 Thread Janek Schleicher
Ying Liu wrote at Thu, 05 Jun 2003 20:20:02 -0500:

> I finally install the Heap module. But I run the example of the CPAN:
>  foreach $i ( 1..100 )
>{
>$elem = NumElem($i);
>$heap->add($elem);
>}
>}
> It told me:
> Can't locate auto/Heap/add.al in @INC
> 
> I search this directory but didn't find the add.al, is it caused by the
> wrong installing or something else?

There seems to be two bugs in the documentation.
First, you have to use a specific Heap-Class for the constructor
(e.g. Heap::Fibonacci),
Second, there is no extract_maximum but an extract_minimum function in the
heap module.

Together, the following snippet runs:

  use Heap::Fibonacci;

  my $heap = Heap::Fibonacci->new;

  my $elem;

  use Heap::Elem::Num(NumElem);

  foreach $i ( 1..100 ) {
  $elem = NumElem( $i );
  $heap->add( $elem );
  }

  while( defined( $elem = $heap->extract_minimum ) ) {
  print "Smallest is ", $elem->val, "\n";
  }


I'd rather suggest to contact the author of this module,
as it seems really to be a bug that has to be fixed.


Greetings,
Janek

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



Re: replacing parts of a string

2003-06-09 Thread Tassilo von Parseval
On Mon, Jun 09, 2003 at 04:53:53AM -0500 christopher j bottaro wrote:

> i want to do something like:
> $line =~ s/M (\d+) (\d+)/M $1+100 $2+200/;
> obviously adding 100 to $1 and 200 to $2, not adding the text '+100' and 
> '+200'.

Use the /e modifier and turn the substitution side into a valid Perl
expression that returns the desired output:

$line =~ s/M (\d+) (\d+)/"M " . ($1+100) . " " . ($2+200)/e;

/e will make perl execute the right side and put in the result of this
execution.

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~~;eval


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



Re: replacing parts of a string

2003-06-09 Thread Jenda Krynicky
From: christopher j bottaro <[EMAIL PROTECTED]>
> hello,
> i want to do something like:
> $line =~ s/M (\d+) (\d+)/M $1+100 $2+200/;
> obviously adding 100 to $1 and 200 to $2, not adding the text '+100'
> and '+200'.

$line =~ s/M (\d+) (\d+)/'M ' . ($1+100) . ' ' . ($2+200)/e;

Read
perldoc perlop

HTH, Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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



Re: perl extensions

2003-06-09 Thread Jenda Krynicky
From: "R. Joseph Newton" <[EMAIL PROTECTED]>
> Jenda Krynicky wrote:
> > No. The original distinction between *.pl and *.plx was the
> > interpreter used for CGIs.
> > The *.pl was interpreted by perl.exe, while *.plx was interpreted by
> > perlIS.dll (In-process Perl interpreter for MS IIS).
> 
> > I know the Installer used to map those two extensions this way, I'm
> > not sure what does it do now though (not using Perl for CGI
> > currently).
> 
> Still the same, at least on my Win2K box.  I'm not sure exactly why
> the perlIIS is necessary.  perl.exe seems to work fine for CGI work on
> my machine.

It's not "necessary". But it's more efficient. If you use perl.exe to 
run the CGIs the IIS has to create a new process for each request. If 
you use PerlIS.dll then interpreter stays loaded and no new processes 
are being spawn.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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



replacing parts of a string

2003-06-09 Thread christopher j bottaro
hello,
i want to do something like:
$line =~ s/M (\d+) (\d+)/M $1+100 $2+200/;
obviously adding 100 to $1 and 200 to $2, not adding the text '+100' and 
'+200'.

thanks for the help,
-- christopher

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



SQL vs MySql?

2003-06-09 Thread SNAG
Hi All,
How compatible is MySQL to MSSql?
If I have a MSSql database and relevant queries, etc., will I be able to use MySQL to 
access these?
Thanx
SNAG


Re: replacing text in a file

2003-06-09 Thread Tassilo von Parseval
On Mon, Jun 09, 2003 at 02:46:48AM -0500 christopher j bottaro wrote:

> what is the easiest way to replace text in a file?  say i have file blah.txt 
> and i want to replace some regular expression found in that file with 
> something.  also, i want to do this from within the perl program, not by 
> invoking perl with the -e option.

You can use the same underlying technique from within a Perl script. You
have to set two special variables accordingly and Perl can even do an
inplace-edit:

local $^I = 1;  # enable inplace editing
local @ARGV = "blah.txt";   # make it accessible with <>
while (<>) {
s/blabla/BLABLA/;
print;
}

This however might not work on Windows due to some limitations concerning
open files. 

So if the above is no option for you, you have to do it manually:

open IN,  "blah.txt" or die $!;
open OUT, "blah.txt.tmp" or die $!;

while () {
s/blabla/BLABLA/;
print OUT;
}

close IN;
close OUT;

rename "blah.txt.tmp", "blah.txt" or die "Renaming: $!";

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~~;eval


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



Re: how to count?

2003-06-09 Thread Tassilo von Parseval
On Sun, Jun 08, 2003 at 11:41:26PM -0500 Jerry Preston wrote:

> I am not sure if this can be done or not, but I want to create a counter on
> the fly so to speak.
> 
> foreach $id ( @IDS ) {
> $cnt = "$id"."_cnt";
> $cnt++;
> }
> 
> All I get is "item_cnt".  Is there a way to do this?

I can only assume what you want. It looks suspiciously as though you
wanted to create new variables with the name "$id"."_cnt". You can do
that with symbolic references (I know that some would now want me to
shred into pieces):

foreach $id (@IDS) {
$cnt = "$id"."_cnt";
$$cnt++;
}

This is _not_ advisable, wont work with properly declared lexcical
variables (variables declared with my() can't be accessed through a
symbolic reference) and will fail if you 'use strict;'. To do it
properly better create a hash:

my %cnt;# all your counters in here
foreach my $id (@IDS) {
$cnt{ $id . "_cnt" }++;
}

Doing it with symbolic references is apt to fail at some later point and
you will then have a very bad time at debugging your scripts. Better
leave your fingers off that and use a hash (or even array in this case).

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~~;eval


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



replacing text in a file

2003-06-09 Thread christopher j bottaro
hello,
what is the easiest way to replace text in a file?  say i have file blah.txt 
and i want to replace some regular expression found in that file with 
something.  also, i want to do this from within the perl program, not by 
invoking perl with the -e option.

thanks,
-- christopher

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



Re: perl extensions

2003-06-09 Thread R. Joseph Newton
Jenda Krynicky wrote:

> > > > "fyi
> > > > .pl used to be used for both executables and libraries.
> > > > A library is simply perl code located in a different file
> > > > which is imported into another perl program with the 'require'
> > > > keyword.
> > > >
> > > > Now that we have the .plx convention (and of course the
> > > > extension
> > > > doesn't
> > > > affect perl's behavior at all) we can have .pl stand only for
> > > > libraries
> > > > and .plx stand for executables."
> > > >
> > > > Are any of the rest of you conforming to this?  I'm not sure if
> > > > he's referring to modules (ext. .pm) when he says "libraries",
> > > > either.

...

>
> > And yet there is still Perl4 code floating around that didn't yet use
> > .pm but instead .pl for "p"erl "l"ibrary. On operating systems that
> > determine the type of a file by looking at the extension (unlike
> > unices and others) a distinction into .plx, .pl and .pm can be
> > critical. I bet that this is the ratio behind ActiveState's scheme.
> > And I think they are right.
>
> No. The original distinction between *.pl and *.plx was the
> interpreter used for CGIs.
> The *.pl was interpreted by perl.exe, while *.plx was interpreted by
> perlIS.dll (In-process Perl interpreter for MS IIS).

> I know the Installer used to map those two extensions this way, I'm
> not sure what does it do now though (not using Perl for CGI
> currently).

Still the same, at least on my Win2K box.  I'm not sure exactly why the
perlIIS is necessary.  perl.exe seems to work fine for CGI work on my
machine.

> Using .pl for Perl Libraries is considered long deprecated.
>
> Jenda
> P.S.: I use another extension, .gpl. I have this extension mapped to
> wperl.exe ... the consoleless interpreter. It's great for the
> Graphical PerL programs :-)




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



Re: forming quadrilateral from points

2003-06-09 Thread R. Joseph Newton
"N, Guruguhan (GEAE, JV, EACoE-India)" wrote:

> Hi All,
>I am new to this group and recently started using Perl. I would like to 
> know whether it is possible to fit a quadrilateral if four points are known in 3-D 
> space ?

That is not a Perl question.  It is a question about geometry, with a definite ring of 
homework.

> if so, I would like to get some idea about the algorithm to do that in Perl. Any 
> help is appreciated.

Please rreview your geometry and programming reading, and make at least a start on 
your own.  If you encounter problems while working out a solution, post the work you 
have completed so far.  Many people will be happy to help guide you towards ways to 
effectively express the
algorithm you have created in Perl.

Joseph


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