Ncurses for perl

2003-02-17 Thread Zysman, Roiy
Hi all,
Does anybody know of a perl _ncurses_ module ? .
I saw some _curses_ modules at cpan but not ncurses.

Thanks,Roiy

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




Re: linked lists?

2003-02-17 Thread Dave K
Jim,
Some time ago a Computer Sci student was working on Linked Lists and
posted some code she needed help with.
> How would such a thing be done with Perl?
Preuse, run, modify and complete this code (it needs a way to remove a
center link, amoung other things.
I don't take credit for this code, it was originally posted as part of a
request for help. I did take this further by extending (in another script)
the ability to link any node to a parent, left child, center child and right
child.
I don't recomend you use this to try to understand C structures (you just
might opt to abandon C altogether ;-) )

#!/usr/bin/perl -w
use strict;
#create list (1)
sub createllist   {
 my $val  = shift;
 my $node = shift;
 if (  !defined ( $node ) ) {
  die 'I need a scalar reference';
 }
 if ( defined ( $$node ) ) {
  die 'You already have a node! ';
 }
 $$node = {
  'data' => $val,
  'next' => undef,
 };
}
# References V Example Linked List (2)
sub addnode {
 my $val = shift;
 my $list  = shift;
 if ( !defined ($list ) ) {
  die 'I need a scalar reference';
 }
 if ( !defined ($$list )) {
  print "Creating list \n";
  createllist ( $val, $list);
  return;
 }
 if ( defined ($$list -> {'next'} )) {
  $list = $$list ->{'next'};
 }else {
  $$list -> {'next'} = {
'data' => $val,
  'next' => undef,
  };
  return;
 }
 while ( defined ($list -> {'next'} )) {
  $list = $list -> {'next'};
 }
 $list -> {'next'} = {
  'data' => $val,
  'next'  => undef,
 }
}

# To print the values to be used (3)sub printllist {
 my $list = shift;
while ( defined ( $list ) ) {
print $list -> {'data'}, "\n";
$list = $list -> {'next'};
}
}

#for debugging, use the  Data::Dumper module:
use Data::Dumper;
my $llist;
addnode (1,\$llist );

print "dump:";
print Dumper ($llist);
addnode (2,\$llist );
addnode (3,\$llist );
addnode (4,\$llist );
printllist ( $llist );

print "dump:";
print Dumper ($llist);




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




undefined variables

2003-02-17 Thread Bryan Harris


I'd like to concatenate two variables--

$newVar = $old1 . $old2;

-- where $old1 might be undefined.  Is there any way to set a flag so that
this just results in $old2 instead of the compiler throwing an error?

(This is a gross simplification of the problem, I'd rather not check to see
if it's undefined first...)

TIA.

- B


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




Re: linked lists?

2003-02-17 Thread Rob Dixon
Jc wrote:
> I just had a friend explain in some little detail about linked lists
> in C using structures.
>
> How would such a thing be done with Perl?  This may help me
> understand C's version a little better.
>
> If you need more information than this, I can provide it...I think :)

Yes, more information would be nice. In particular C has no built-in
linked-list capability and I would like to see what sort of
implementation you're wanting to emulate.

The most common way to implement linked lists in C is by pointers.
Something like:

struct link {
int data;
struct tag *next;
} a, b;
a.data = 1;
a.next = &b;
b.data = 2;

and so on. Perl has references, which are similar to C pointers
except that you can't do arithmetic on them (to find the address
of a given array element given its base address, say) so you could
write something equivalent like this:

my (%a, %b);

$a{data} = 1;
$a{next} = \%b;

$b{data} = 2;

But exactly how the list is implemented depends on what
functionality you need.

HTH,

Rob




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




Re: undefined variables

2003-02-17 Thread Rob Dixon
Bryan Harris wrote:
> I'd like to concatenate two variables--
>
> $newVar = $old1 . $old2;
>
> -- where $old1 might be undefined.  Is there any way to set a flag so
> that this just results in $old2 instead of the compiler throwing an
> error?

The concatenation operator will work fine with an undefined value. It's
one of the cases where the interpreter will substitute an empty string
instead of throwing an error.

Rob




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




Re: proxy server

2003-02-17 Thread Ramprasad
Mat Harris wrote:

i am trying to write a mini proxy server to authenticate and run some other
checking on http requests before they are passed to a squid server.

I have got the following program which works for very basic requests but
cannot deal with forms or anything complex.

I will detail the problems after the snip:



#!/usr/bin/perl

# Standard common-sense modules
use strict;
use warnings;

# Modules for getting http pages
use LWP::UserAgent;
use URI::URL;
use HTTP::Request;
use HTTP::Headers;

# Modules for dealing with the sockets
use IO::Socket;
use Net::hostent;

# Modules for DNS lookups and mysql connection
use Net::MySQL;
use Net::DNS;

# The port the proxy server will run on
my $PORT = 8850;

# urn on autoflushing
$| = 1;

# Get the config file
our %CONFIG;
require './proxy.conf';

# Manage correct internet line endings
my $EOL1 = "\012";
my $EOL2 = "\015";

# Do all the logging in one function
sub logmsg
{
my ($mesg) = @_;
my $date = `date`;
chomp($date);
print LOG "[$date]: $mesg\n";
print "[$date]: $mesg\n";
}

my $mysql;

# Connect to the mysql database for authentication if specified in the
# config file
if ($CONFIG{'use_auth_mysql'} eq 'true')
{
my $mysql = Net::MySQL->new(
hostname => $CONFIG{'mysql_host'},
database => $CONFIG{'mysql_name'},
user => $CONFIG{'mysql_user'},
password => $CONFIG{'mysql_pass'}
);
}

# Open the listening socket
my $server = IO::Socket::INET->new(
Proto => 'tcp',
LocalPort => $PORT,
Listen=> SOMAXCONN,
Reuse => 1
);

# Die unless the socket is ok
die "can't setup server: $!\n" unless $server;

# Open a logfile
open (LOG, ">>$CONFIG{'logfile'}") || die "couldn't open file, $!\n";

# Specify SIG INT sub
$SIG{'INT'} = 'shutdown';
sub shutdown
{
logmsg "SIGINT caught";
if ($CONFIG{'use_auth_mysql'} eq 'true')
{
logmsg "Closing connection to database...";
$mysql->close;
}
logmsg "Closing client connections...";
$server->close;
logmsg "Closing logfile...";
close LOG;
exit;
}

# Print message to show startup ok
logmsg ("Server accepting clients on $PORT");

# Fork to allow multiple connections
fork();

# For every client connection
while (my $client = $server->accept())
{
# Force autoflushing
$client->autoflush(1);

# Get the remote client ip/hostname
my $hostinfo = gethostbyaddr($client->peeraddr);
my $remote_info = $hostinfo->name || $client->peerhost;

my ($url, @headers);

# Get the request from the client...
while (my $input = <$client>)
{
if ($input =~ m/^GET /)
{
# Get the requested url from the supplied headers
$input =~ s/GET //;
$input =~ s/ HTTP\/1.1//;
$input =~ s/$EOL1//;
$input =~ s/$EOL2//;
$url = $input;
}
else
{
# Add the input to the list of headers
push (@headers, $input);
if ($input =~ m/Cookie/)
{
last;
}
print "$input";
}
}

print @headers;

	my $hdrs = new HTTP::Headers(@headers);

my $url2 = new URI::URL($url);
my $req = new HTTP::Request('GET', $url, $hdrs);
my $ua = new LWP::UserAgent;
my $resp = $ua->request($req);


if ($resp->is_success)
{
my $results = $resp->content;
print $client "$results";
chomp($url);
logmsg ("$url - $remote_info - ok");
}
else
{
chomp($url);
logmsg ("$url - $remote_info - ".$resp->message);
}
}



I believe the problem is recieving the headers. In the while() loop that
reads the headers from the browser, the browser never gives a ^D so the
while loop hangs.

Any suggestion on how to cure this or any other ideas? 

cheers

Mat Harris			OpenGPG Public Key ID: C37D57D9
[EMAIL PROTECTED]	www.genestate.com	

talk about reinventing the wheel :-O


Now when you have an excellent tool like squid why would anyone go to 
write his own proxy


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



RE: Help with printing 2 files into 1

2003-02-17 Thread Aimal Pashtoonmal
Dear folks,

I have 2 files each contain a column of data, I want to combine them
into 1 file with the 2 columns next to each other,  eg:

file_1:
12
13
14
3

file_2:
3
45
34
56

desired output:

12   3
13   45
14   34
3 56

chrs, amal.


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




Please very help...

2003-02-17 Thread Marco Giardina

Hi list,


sorry but i'am a newbie about Perl. Perl is fantastic, anything is possible 
when use Perl..
So i have a question about this language. In brief I'll modify some 
information inside a file, for example image a file test.conf.
I'll erase some character (#) before a line and then eventually, after some 
time, rewrite the same information always (#).

I must:
- Open file
- find a particular line or character
- apply a line modification
- close the file

So does anyone if exist a simple, very simple example that explain this 
approach.

Many, many thanks list

Marco


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



Re: Out Of memory

2003-02-17 Thread Bernhard van Staveren

[snip]

> Is there anything in particular in a script, that would cause this type of 
> error?? Any suggestions or areas to look at, would be greatly appreciated.

If you're seeing "out of memory" in the Apache logs, first thing to look for
is recursive loops inside the script. However if it doesn't happen all the time
it has to be in a specific area of the script.

Another good one is a script trying to slurp in a huge file and subsequently
running out of memory. 

Any which way, it's better to revert back to the old copy of the script for
the time being, Apache and the server itself will get bogged down seriously
when you get the out of memory deal, since at that point it'll already have
used up all the swap space. It makes the server very unhappy :)

-- 
Bernhard van Staveren   -   madcat(at)ghostfield.com
GhostField Internet -   http://www.ghostfield.com/
"A witty saying proves nothing, but damn it's funny!" - me, 1998 

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




Re: proxy server

2003-02-17 Thread Mat Harris
On Mon, Feb 17, 2003 at 05:34:23 +0530, Ramprasad wrote:
> talk about reinventing the wheel :-O
> 
> 
> Now when you have an excellent tool like squid why would anyone go to 
> write his own proxy
> 

I want to be able to use a php webpage to authenticate the user to make it
as transparent as possible, a method that AFAIK squid doesn't support.

also it is just something to learn from.

-- 
Mat Harris  OpenGPG Public Key ID: C37D57D9
[EMAIL PROTECTED]www.genestate.com   



msg38689/pgp0.pgp
Description: PGP signature


substitute for NTs "net use"

2003-02-17 Thread Joe Mecklin
I tried sending this last week and never saw it or any response to it on the list, 
so I'll try again:


I'm tying to write a script which will connect to all PCs in an internal
network to update select files.  I currently have it working using

system("net use ...")

but I would like to use whatever module will replicate that
connection/login/logout functionality; can anyone tell me which
module(s) will allow me to do this?  Currently I have to run this from
an NT box but would like to be able to move it to a Linux server we are
turning up so it will be available to anyone with permission to perform
this function w/o having to install Perl and this script on computers
that would not otherwise need either..

TIA,
Joe


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




Re: substitute for NTs "net use"

2003-02-17 Thread Jenda Krynicky
From: Joe Mecklin <[EMAIL PROTECTED]>

> I'm tying to write a script which will connect to all PCs in an
> internal network to update select files.  I currently have it working
> using
> 
> system("net use ...")
> 
> but I would like to use whatever module will replicate that
> connection/login/logout functionality; can anyone tell me which
> module(s) will allow me to do this?

Win32::AdminMisc, Win32::Lanman, Win32::FileOp ...

Eg:
use Win32::FileOp qw(Map);
Map 'X:' => '//server/share', 
{user => $username, passwd => $password, persistent => 1};

You may install all via PPM.
Win32::FileOp is best installed from http://Jenda.Krynicky.cz/perl

>  Currently I have to run this from
> an NT box but would like to be able to move it to a Linux server we
> are turning up so it will be available to anyone with permission to
> perform this function w/o having to install Perl and this script on
> computers that would not otherwise need either..

Well that's a totally different task. I guess you could use some 
executable that comes with samba to mount a WinNT/2k share, but I 
know next to nothing about that.

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]




1) cygwin , 2) sprite/DBM

2003-02-17 Thread Pradeep Goel
Hi All

I  have no idea of  CYGWIN  except only that almost all unix commands can be
run
on windows .

I want to know if the SAME program running on unix systems can be run on
windows without any change ( or otherwise what changes need to be made)
after installing cygwin .

in both cases ( unix & windows) - it fires from a server & take some info
from remote machines , stores in local server & updates a web page using the
info

Any suggestions/ views of how you think should it be done in an easiest way
?

& also which is better to use a DBM file or a flat file database using
sprite/jprite ?

Thanks & Regards
Pradeep



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




Re: substitute for NTs "net use"

2003-02-17 Thread Joe Mecklin
Jenda,

Thanks for the info.  I appreciate the ideas.  Seeing your response, I
obviously didn't phrase my request as well as I could have:

I'm looking for a Perl module for Linux that allows "net use"
functionality; does anyone know if such a module exists?  I believe what
is presented here is meant to be installed on a MS system.

Joe


On Mon, 2003-02-17 at 07:31, Jenda Krynicky wrote:
> From: Joe Mecklin <[EMAIL PROTECTED]>
> 
> > I'm tying to write a script which will connect to all PCs in an
> > internal network to update select files.  I currently have it working
> > using
> > 
> > system("net use ...")
> > 
> > but I would like to use whatever module will replicate that
> > connection/login/logout functionality; can anyone tell me which
> > module(s) will allow me to do this?
> 
> Win32::AdminMisc, Win32::Lanman, Win32::FileOp ...
> 
> Eg:
>   use Win32::FileOp qw(Map);
>   Map 'X:' => '//server/share', 
>   {user => $username, passwd => $password, persistent => 1};
> 
> You may install all via PPM.
> Win32::FileOp is best installed from http://Jenda.Krynicky.cz/perl
> 
> >  Currently I have to run this from
> > an NT box but would like to be able to move it to a Linux server we
> > are turning up so it will be available to anyone with permission to
> > perform this function w/o having to install Perl and this script on
> > computers that would not otherwise need either..
> 
> Well that's a totally different task. I guess you could use some 
> executable that comes with samba to mount a WinNT/2k share, but I 
> know next to nothing about that.
> 
> 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: undefined variables

2003-02-17 Thread Bryan Harris


>> I'd like to concatenate two variables--
>> 
>> $newVar = $old1 . $old2;
>> 
>> -- where $old1 might be undefined.  Is there any way to set a flag so
>> that this just results in $old2 instead of the compiler throwing an
>> error?
> 
> The concatenation operator will work fine with an undefined value. It's
> one of the cases where the interpreter will substitute an empty string
> instead of throwing an error.

That's good to know...

It looks like I've over-simplified.  I'm "concatenating" two variables into
a list:

$newTxt[$row] = [ @{$numTxt[$row]}, "\t" x ($nextCol - $#{$numTxt[$row]}),
@temp ];

I'd like result to be @temp if $numTxt[$row] is undefined, and that whole
mess if it isn't.  It seems like this should be done without an if/then, but
I can't see how.

- B


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




Re: proxy server

2003-02-17 Thread Ramprasad A Padmanabhan
Mat Harris wrote:

On Mon, Feb 17, 2003 at 05:34:23 +0530, Ramprasad wrote:


talk about reinventing the wheel :-O


Now when you have an excellent tool like squid why would anyone go to 
write his own proxy



I want to be able to use a php webpage to authenticate the user to make it
as transparent as possible, a method that AFAIK squid doesn't support.

also it is just something to learn from.



Sorry If I sounded offending, But seriously , dont you think you are 
going through too much of a bother. You may solve this problem probably 
but then there are going to hundreds of such.

  I am not discouraging you from learning, but then you can not just 
keep trouble shooting ( probably at the cost of your clients' )

  So you are trying to write a session-support proxy , good luck .

   Why dont you use a standard open source proxy and change the 
authentication program ( you can configure that in squid ) to read 
session info from a server-side session file , which you create when the 
user logs in and delete when he logs out .

Bye
Ram


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



Re: substitute for NTs "net use"

2003-02-17 Thread Felix Geerinckx
on Mon, 17 Feb 2003 13:37:57 GMT, [EMAIL PROTECTED] (Joe Mecklin)
wrote: 

> Thanks for the info.  I appreciate the ideas.  Seeing your
> response, I obviously didn't phrase my request as well as I could
> have: 
> 
> I'm looking for a Perl module for Linux that allows "net use"
> functionality; does anyone know if such a module exists?  I
> believe what is presented here is meant to be installed on a MS
> system. 

You will have to use the 'smbclient' command then.
Perhaps there are some perl modules that interface with this command.

You could try



-- 
felix

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




RE: substitute for NTs "net use"

2003-02-17 Thread Crowder, Rod
The Win32::NetResource Module will let you mount remote share


use Win32::NetResource;
use strict;
use warnings;

my$RemoteShare = {
'LocalName' => "Q:",
'RemoteName' => "server\\share",
};


my $UserName = "user";
my $Password = "password";
my $Connection = 1;
my $ErrorCode;


Win32::NetResource::AddConnection($RemoteShare,$Password,$UserName,$Connecti
on)
or die "unable to add share";

Win32::NetResource::GetError( $ErrorCode );
print $ErrorCode;




> -Original Message-
> From: Joe Mecklin [mailto:[EMAIL PROTECTED]]
> Sent: 17 February 2003 13:07
> To: [EMAIL PROTECTED]
> Subject: substitute for NTs "net use"
> 
> 
> I tried sending this last week and never saw it or any 
> response to it on the list, 
> so I'll try again:
> 
> 
> I'm tying to write a script which will connect to all PCs in 
> an internal
> network to update select files.  I currently have it working using
> 
> system("net use ...")
> 
> but I would like to use whatever module will replicate that
> connection/login/logout functionality; can anyone tell me which
> module(s) will allow me to do this?  Currently I have to run this from
> an NT box but would like to be able to move it to a Linux 
> server we are
> turning up so it will be available to anyone with permission 
> to perform
> this function w/o having to install Perl and this script on computers
> that would not otherwise need either..
> 
> TIA,
> Joe
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


The information contained in this e-mail is intended only for the individual
or entity
to whom it is addressed. Its contents (including any attachments) are
confidential
and may contain privileged information.

If you are not an intended recipient you must not use, disclose,
disseminate, copy
or print its contents. If you receive this email in error, please delete and
destroy
the message and notify the sender by reply email.



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




Re: substitute for NTs "net use"

2003-02-17 Thread Joe Mecklin
ok, thanks.


On Mon, 2003-02-17 at 07:54, Felix Geerinckx wrote:
> on Mon, 17 Feb 2003 13:37:57 GMT, [EMAIL PROTECTED] (Joe Mecklin)
> wrote: 
> 
> > Thanks for the info.  I appreciate the ideas.  Seeing your
> > response, I obviously didn't phrase my request as well as I could
> > have: 
> > 
> > I'm looking for a Perl module for Linux that allows "net use"
> > functionality; does anyone know if such a module exists?  I
> > believe what is presented here is meant to be installed on a MS
> > system. 
> 
> You will have to use the 'smbclient' command then.
> Perhaps there are some perl modules that interface with this command.
> 
> You could try
> 
> 
> 
> -- 
> felix
-- 
Joe Mecklin <[EMAIL PROTECTED]>


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




Re: 1) cygwin , 2) sprite/DBM

2003-02-17 Thread Jenda Krynicky
From: "Pradeep Goel" <[EMAIL PROTECTED]>
> I  have no idea of  CYGWIN  except only that almost all unix commands
> can be run on windows .
> 
> I want to know if the SAME program running on unix systems can be run
> on windows without any change ( or otherwise what changes need to be
> made) after installing cygwin .

It could probably be COMPILED under CYGWIN with minimal (if any) 
changes.

> & also which is better to use a DBM file or a flat file database using
> sprite/jprite ?

Depends on what do you need to do with the data.

DBM will be quicker with HASH-like access, flat file may be viewed 
and modified by hand.

I would suggest considering also DBD::SQLite, "A database in a DBD 
driver".

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: undefined variables

2003-02-17 Thread Jenda Krynicky
From: Bryan Harris <[EMAIL PROTECTED]>
> I'd like to concatenate two variables--
> 
> $newVar = $old1 . $old2;
> 
> -- where $old1 might be undefined.  Is there any way to set a flag so
> that this just results in $old2 instead of the compiler throwing an
> error?

It's not an error, but a warning.

You can temporarily turn this warning off.
Either

{
local $^W = 0;
$newVar = $old1 . $old2;
}

or

{
no warnings 'uninitialized';
$newVar = $old1 . $old2;
}

The second works only with Perl 5.6 or newer I belive.

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: Help with printing 2 files into 1

2003-02-17 Thread John W. Krahn
Aimal Pashtoonmal wrote:
> 
> Dear folks,

Hello,

> I have 2 files each contain a column of data, I want to combine them
> into 1 file with the 2 columns next to each other,  eg:
> 
> file_1:
> 12
> 13
> 14
> 3
> 
> file_2:
> 3
> 45
> 34
> 56
> 
> desired output:
> 
> 12   3
> 13   45
> 14   34
> 3 56

If you are running on a Unix like system then use paste

man paste



John
-- 
use Perl;
program
fulfillment

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




Re: Please very help...

2003-02-17 Thread John W. Krahn
Marco Giardina wrote:
> 
> Hi list,

Hello,

> sorry but i'am a newbie about Perl. Perl is fantastic, anything is possible
> when use Perl..
> So i have a question about this language.

In fact it is a Frequently Asked Question (FAQ.)

> In brief I'll modify some
> information inside a file, for example image a file test.conf.
> I'll erase some character (#) before a line and then eventually, after some
> time, rewrite the same information always (#).
> 
> I must:
> - Open file
> - find a particular line or character
> - apply a line modification
> - close the file
> 
> So does anyone if exist a simple, very simple example that explain this
> approach.

Your Perl installation should include all the standard documentation
which can be accessed by using the perldoc program.  Just enter this on
the command line:

perldoc -q "How do I change one line in a file"


For more information on how perldoc works enter this on the command
line:

perldoc perldoc


To get a list of the documents installed with Perl enter this on the
command line:

perldoc perl



John
-- 
use Perl;
program
fulfillment

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




Re: undefined variables

2003-02-17 Thread Rob Dixon
Bryan Harris wrote:
> > > I'd like to concatenate two variables--
> > >
> > > $newVar = $old1 . $old2;
> > >
> > > -- where $old1 might be undefined.  Is there any way to set a
> > > flag so that this just results in $old2 instead of the compiler
> > > throwing an error?
> >
> > The concatenation operator will work fine with an undefined value.
> > It's one of the cases where the interpreter will substitute an
> > empty string instead of throwing an error.
>
> That's good to know...
>
> It looks like I've over-simplified.  I'm "concatenating" two
> variables into a list:
>
> $newTxt[$row] = [ @{$numTxt[$row]}, "\t" x ($nextCol -
$#{$numTxt[$row]}), @temp ];
>
> I'd like result to be @temp if $numTxt[$row] is undefined, and that
> whole mess if it isn't.  It seems like this should be done without an
> if/then, but I can't see how.

Without any fancy stuff it goes like this:

if (defined my $hash = $numTxt[$row]) {
$newTxt[$row] = [
@{$numTxt[$row]},
("\t") x ($nextCol - $#{$numTxt[$row]})
];
} else {
$newTxt[$row] = [ @temp ];
}

Note the parentheses around "\t". If you leave these off you get a
single
string containing the given number of tab characters instead of an array
of single tabs.

HTH,

Rob




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




Re: undefined variables

2003-02-17 Thread Rob Dixon
Rob Dixon wrote:
> Bryan Harris wrote:
> > > > I'd like to concatenate two variables--
> > > >
> > > > $newVar = $old1 . $old2;
> > > >
> > > > -- where $old1 might be undefined.  Is there any way to set a
> > > > flag so that this just results in $old2 instead of the compiler
> > > > throwing an error?
> > >
> > > The concatenation operator will work fine with an undefined value.
> > > It's one of the cases where the interpreter will substitute an
> > > empty string instead of throwing an error.
> >
> > That's good to know...
> >
> > It looks like I've over-simplified.  I'm "concatenating" two
> > variables into a list:
> >
> > $newTxt[$row] = [ @{$numTxt[$row]}, "\t" x ($nextCol -
> > $#{$numTxt[$row]}), @temp ];
> >
> > I'd like result to be @temp if $numTxt[$row] is undefined, and that
> > whole mess if it isn't.  It seems like this should be done without
> > an if/then, but I can't see how.
>
> Without any fancy stuff it goes like this:
>
(My apologies, I posted an incorrect version before)

if (defined $numTxt[$row]) {
$newTxt[$row] = [
@{$numTxt[$row]},
"\t" x ($nextCol - $#{$numTxt[$row]})
];
} else {
$newTxt[$row] = [ @temp ];
}
>
> Note the parentheses around "\t". If you leave these off you get a
> single
> string containing the given number of tab characters instead of an
> array of single tabs.
>
> HTH,
>
> Rob





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




Re: Help with printing 2 files into 1

2003-02-17 Thread Rob Dixon
Aimal Pashtoonmal wrote:
> Dear folks,
>
> I have 2 files each contain a column of data, I want to combine them
> into 1 file with the 2 columns next to each other,  eg:
>
> file_1:
> 12
> 13
> 14
> 3
>
> file_2:
> 3
> 45
> 34
> 56
>
> desired output:
>
> 12   3
> 13   45
> 14   34
> 3 56

There was a problem identical to this just four days ago. This is
the solution that I proposed, which will handle as many files as
you want and treats each line as series of space-separated values.

use strict;
use warnings;

local @ARGV = qw( file1.txt file2.txt );

my @fds;

foreach (@ARGV) {
open (my $fd, $_) or die $!;
push (@fds, $fd);
}

my @line;

do {
undef @line;

FILE:
for (@fds){
for (scalar <$_>) {
next FILE unless defined;
push @line, split (' ', $_);
}
}

print "@line\n";

} while @line;

close foreach @ARGV;

HTH,

Rob




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




Re: linked lists?

2003-02-17 Thread Paul
> "JC(oesd)" wrote:
> I just had a friend explain in some little detail about linked
> lists in C using structures.
> How would such a thing be done with Perl?
> This may help me understand C's version a little better.

The idea is simply to have one thing tell you where the next thing is
in a preferably editably way. Perl has more and *potentially*
simplerways to do this, but it's flexibility also makes it potentially
more confusing.

Here's one example: a list of hashes, similar to a list of structs in
C:

  my %list = ( a => { value => 'first',
  next  => 'b',  },
   b => { value => 'second',
  next  => 'c',  },
   c => { value => 'other',
  next  => 'a',  },
  );

In this SIMPLISTIC case, is't a circular list; each item's "next"
points to the next item in the list, but the last one happens to point
to the first one. It could be MUCH more complex, with genuine objects
pointing to each other and back to their previous and just about
anything else you want to hang on them -- hashes are really handy that
way, lol -- but unless you explicitly break a link somewhere, be aware
that this causes a loop which prevents Perl's reference-counting
garbage-collection system from ever freeing up that space.

You could do the same thing with arrays, using cell [0] and [1] or
whever you chose as standards instead of the hash keys, and nothing
else would really change much. You could do a similar thing in C, with
an array of pointers to arrays instead of structs. Don't get hung up on
the underlying pieces -- it's the logic you need to grasp, so that you
can reimplement it efficiently for any given task in any given
language.

Of course, you'd also probably want to generate the contents
dynamically -- can I leave that as the infamous "exercise for the
reader"? :)

Paul

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




Re: eegads! File::Copy not copying

2003-02-17 Thread Paul

a small possibility -- -e just makes sure it exists. Try testing the
size if it does.

  if (-f $file and -s _) {

--- Patricia Hinman <[EMAIL PROTECTED]> wrote:
> Everything "was" perfect in my little program.  I gave
> it a test run today.  My file which copies some
> demofiles is sending blank empty files.  I've used -e
> to make sure it exists and checked the return value on
> the copy().  Both check out fine.  But the files have
> no content.
> 
> Any suggestions?
> 
> This is a snippet from one copy statement:
> 
> my$ok = "";
> $ok =
>
copy("/$htmlroot/$htmldir/demosite/$filenames[$i]","/$htmlroot/$htmldir/$files[$i]")
> || push(@messages, "Couldn't copy
> /$htmlroot/$htmldir/demosite/$filenames[$i],\n to
> /$htmlroot/$htmldir/$files[$i]\n Error: $!");
> 
> if(-e "/$htmlroot/$htmldir/$files[$i]" && $ok){
> push(@messages, "Copied
> /$htmlroot/$htmldir/demosite/$filenames[$i],\n to
> /$htmlroot/$htmldir/$files[$i]");
> }
> 
> Anybody see a mistake???
> 
> 
> __
> Do you Yahoo!?
> Yahoo! Shopping - Send Flowers for Valentine's Day
> http://shopping.yahoo.com
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




Re: linked lists? [OT]

2003-02-17 Thread Paul

--- Felix Geerinckx <[EMAIL PROTECTED]> wrote:
> on Sun, 16 Feb 2003 18:29:23 GMT, [EMAIL PROTECTED] (Jc) wrote:
> > How would such a thing be done with Perl?  This may help me
> > understand C's version a little better.
> You may want to take a look at O'Reilly's "Mastering Algorithms with 
> Perl", by Jon Orwant, Jarkko Hietaniemi and John Macdonald, which has
> a whole chapter on advanced data structures, including linked lists.
> felix

It's the one with a wolf on the cover, if you're hunting it in a
bookstore. :)

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




Re: Please very help...

2003-02-17 Thread Paul

see Tie::File

--- Marco Giardina <[EMAIL PROTECTED]> wrote:
> 
> Hi list,
> 
> 
> sorry but i'am a newbie about Perl. Perl is fantastic, anything is
> possible 
> when use Perl..
> So i have a question about this language. In brief I'll modify some 
> information inside a file, for example image a file test.conf.
> I'll erase some character (#) before a line and then eventually,
> after some 
> time, rewrite the same information always (#).
> 
> I must:
> - Open file
> - find a particular line or character
> - apply a line modification
> - close the file
> 
> So does anyone if exist a simple, very simple example that explain
> this 
> approach.
> 
> Many, many thanks list
> 
> Marco
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




Re: undefined variables

2003-02-17 Thread Paul

--- Bryan Harris <[EMAIL PROTECTED]> wrote:
> >> I'd like to concatenate two variables--
> >> $newVar = $old1 . $old2;
> >> -- where $old1 might be undefined.  Is there any way to set a flag
> >> so that this just results in $old2 instead of the compiler
throwing
> >> an error?
> >
> > The concatenation operator will work fine with an undefined value.
> 
> That's good to know...
> 
> It looks like I've over-simplified. 

lol -- looks like it! >:O]

> I'm "concatenating" two variables into a list:
> 
> $newTxt[$row] = [ @{$numTxt[$row]}, 
>   "\t" x ($nextCol - $#{$numTxt[$row]}),
>   @temp ];

Ah, but this isn't a concatentation.
You've made an implicit list out of all the contents of the [], which
then returns a reference to an unnamed array containing copies of all
those values. 

> I'd like result to be @temp if $numTxt[$row] is undefined, and that
> whole mess if it isn't.  It seems like this should be done without an
> if/then, but I can't see how.

Ok -- much easier to do if you see the problem! :)

  $newTxt[$row] = [ ( $numTxt[$row] 
? ( @{$numTxt[$row]}, 
"\t" x ($nextCol - $#{$numTxt[$row]}),
@temp
  )
: @temp
) ];

I tried to space that out to make more sense -- sorry if it didn't
work, lol

You're still doing a test, but it doesn't have to be with if/else
keywords. Is that better?



__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




Re: linked lists? [OT]

2003-02-17 Thread wiggins


On Mon, 17 Feb 2003 07:21:23 -0800 (PST), Paul <[EMAIL PROTECTED]> wrote:

> 
> --- Felix Geerinckx <[EMAIL PROTECTED]> wrote:
> > on Sun, 16 Feb 2003 18:29:23 GMT, [EMAIL PROTECTED] (Jc) wrote:
> > > How would such a thing be done with Perl?  This may help me
> > > understand C's version a little better.
> > You may want to take a look at O'Reilly's "Mastering Algorithms with 
> > Perl", by Jon Orwant, Jarkko Hietaniemi and John Macdonald, which has
> > a whole chapter on advanced data structures, including linked lists.
> > felix
> 
> It's the one with a wolf on the cover, if you're hunting it in a
> bookstore. :)
> 

Isn't that a Fox?  (Since we are a 'technical' crowd)

http://danconia.org

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




Re: linked lists? [OT]

2003-02-17 Thread Paul

--- [EMAIL PROTECTED] wrote:
> Paul <[EMAIL PROTECTED]> wrote:
> > Felix Geerinckx <[EMAIL PROTECTED]> wrote:
> > > [EMAIL PROTECTED] (Jc) wrote:
> > > > How would such a thing be done with Perl? 
> > > You may want to take a look at O'Reilly's "Mastering Algorithms
> > > with Perl", by Jon Orwant, Jarkko Hietaniemi and John Macdonald,
> > It's the one with a wolf on the cover, if you're hunting it in a
> > bookstore. :)
> 
> Isn't that a Fox?  (Since we are a 'technical' crowd)

Nope. :)
http://www.oreilly.com/catalog/maperl/colophon.html

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




Modifying the content of a request before passing to CGI?

2003-02-17 Thread Seldo
Okay, so here's what I need to do:
  1. Receive a request to a given URI, X
  
  2. Based on that URI, change certain values with the request
 (e.g. change the names or values of variables posted by the user,
 modify the "x-www-form-urlencoded" data, whatever...)
 
  3. Translate the URI to a new URI (one of a number of CGI programs)
  
  4. Execute that CGI (such that the CGI runs in an environment with
 variables and posted data modified as per step 2 )

I'm running mod_perl 2.0 with Apache 2.0.x, and the documentation of
these sorts of features:

http://perl.apache.org/docs/2.0/api/Apache/RequestUtil.html

...is sort of incomplete. Whoopsie. My fault for being all
bleeding-edge, right? Here's what I've got so far:

  1. Can do. I can write a PerlTransHandler that catches the URI

  2. Don't know how to do. The 1.0 documentation mentions the
  header_in() method which can apparently set headers in the request
  as well as get them. I can't find this method in the 2.0
  documentation, does it or an equivalent exist? And is there anything
  similar for the PUT/POST type data?
  
  3. Can do. This bit is no problem.

  4. Don't know how to do. How do you tell the server to execute a
  file using CGI protocol? Is this even possible?


The above method, assuming it's possible to do the two things I asked
about, will work fine. If it doesn't work, then I'll be forced to make
my PerlTransHandler re-implement CGI, which isn't *that* hard but
sounds like a fairly stupid idea when the server does it already. But
even in the case, I need to know how to set "environment variables"
for CGI on a per-execution basis.

Any help greatly appreciated, this project is now due in a week and
I'm beginning to feel great big stormclouds of doom closing in :-)

Seldo.

  Seldo Voss: www.seldo.com
  ICQ #1172379 or [EMAIL PROTECTED]

Bart's Blackboard: "I will not eat things for money."


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




Re: Help with printing 2 files into 1

2003-02-17 Thread Bernhard van Staveren
> file_1:
> 12
> 13
> 14
> 3
> 
> file_2:
> 3
> 45
> 34
> 56

A real quick and dirty way of doing it:

-- 8< --

use strict;

open(FONE, $ARGV[0]);
open(FTWO, $ARGV[1]);
open(FOUT, ">$ARGV[2]");

my @f1;
my @f2;
my $c=0;
chomp(@f1=);
chomp(@f2=);
close(FONE);
close(FTWO);

for($c=0;$chttp://www.ghostfield.com/
"A witty saying proves nothing, but damn it's funny!" - me, 1998 

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




RE: Ncurses for perl

2003-02-17 Thread Bob Showalter
Zysman, Roiy wrote:
> Hi all,
> Does anybody know of a perl _ncurses_ module ? .
> I saw some _curses_ modules at cpan but not ncurses.

The Curses module on CPAN will detect and use your ncurses libraries.

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




get domain only with CGI or URI modules

2003-02-17 Thread Dan Muey
Hello, 
 
Does anyone know of a quick/easy/fast way to to get the domain out of a url?
 
For instance if I do : $url = $cgi->url();
 
I'll get, say http://joe.mama.com/so/isyour.cgi?mother
 
I know I can use URI module to get the  scheme (http, https, ftp, etc) from that
What I need to grab out of that example is the domain only, ( mama.com ) just the part 
that one would register with a registrar, not any subdomains or any of that just 
whatever.com.
 
Any ideas?
Can it be done with cgi or uri or some other module instead of doing some regex on it 
that will probably let stuff get through?
 
Thanks
 
Dan



use strict and lib vars

2003-02-17 Thread Dan Muey
I guess my main question would boil down to ::

How can I use variables that get declared in a lib file in a script that uses -w and 
use strict; ?

A more complex example of what I've tried and what I'm trying to get is here ::

On the script below, when use strict is commented out ::
Name "main::dog" used only once: possible typo at ./test.pl line 11.
Content-type: text/html

Use of uninitialized value at ./test.pl line 11.
Error:  ::HI

And this when use strict; is not commented out I get ::
Global symbol "$dog" requires explicit package name at ./test.pl line 11.
Execution of ./test.pl aborted due to compilation errors.

If I uncomment the my $dog in the script then all is well. Except the lib won't change 
th value of $dog even if I take of the 'my' in the lib.

#!/usr/bin/perl -w

use strict;
#my $dog = 'bart';
eval {
use lib '/home/dmuey';
require "lib.lib";
};
print "Content-type: text/html\n\n";
print "Error: $@ :: $dog ::\n";

:: lib.lib file is ::

my $dog = 'joe';
1;

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




How to set environment variables

2003-02-17 Thread Madhu Reddy
Hi,
  I want to put MFILE=mdl_data.txt in ENV and want to
access later..

i am trying following...I am getting error...

system(`MFILE=mdl_data.txt`);
$k6 = "MFILE";
$key6 = $ENV{$k6};
print "$key6 \n";

how to do this ?

Thanx
-Madhu



__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




Re: use strict and lib vars

2003-02-17 Thread Paul

--- Dan Muey <[EMAIL PROTECTED]> wrote:
> #!/usr/bin/perl -w
> use strict;
> #my $dog = 'bart';
> eval {
> use lib '/home/dmuey';
> require "lib.lib";
> };
> print "Content-type: text/html\n\n";
> print "Error: $@ :: $dog ::\n";
> 
> :: lib.lib file is ::
> 
> my $dog = 'joe';
> 1;

First, $dog is a my() variable, and so ONLY exists in the lib file.
Don't use my() in that circumstance.

better, try this:

libfile:
=
$dog = 'spot';

progfile:
=
use warnings;
use strict;
use vars '$dog';
do 'libfile';
print "$dog\n";

output:

spot

c.f. do() in the docs. :)

perldoc -f do

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




Re: How to set environment variables

2003-02-17 Thread Paul

--- Madhu Reddy <[EMAIL PROTECTED]> wrote:
> Hi,
>   I want to put MFILE=mdl_data.txt in ENV and want to
> access later..
> i am trying following...I am getting error...
> system(`MFILE=mdl_data.txt`);
> $k6 = "MFILE";
> $key6 = $ENV{$k6};
> print "$key6 \n";
> how to do this ?

The system() call spawns a subprocess with it's own environment, in
which you set the variable. Then the process ends and it's environment
is recycles, along with your variable, before the next statement.

Just set it directly:
 $ENV{MFILE}='mdl_data.txt';

Also, there's an error there: your system call argument is in
backticks. That shells out a subprocess to do the assignment, which
gets cleaned up as before, but creates no output. The output (none) is
returned _from_the_backticks_to_the_system()_call_as an argument to be
fed to *another* subprocess.

In other words backticks and system() are each basically doing the same
thing, except that backticks return the output to their context and
system() doesn't, so DON'T use both unless you want one's output as the
arg for the other!

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




RE: use strict and lib vars

2003-02-17 Thread Dan Muey
> 
> --- Dan Muey <[EMAIL PROTECTED]> wrote:
> > #!/usr/bin/perl -w
> > use strict;
> > #my $dog = 'bart';
> > eval {
> > use lib '/home/dmuey';
> > require "lib.lib";
> > };
> > print "Content-type: text/html\n\n";
> > print "Error: $@ :: $dog ::\n";
> > 
> > :: lib.lib file is ::
> > 
> > my $dog = 'joe';
> > 1;
> 
> First, $dog is a my() variable, and so ONLY exists in the lib 
> file. Don't use my() in that circumstance.

Makes sense.
Thanks! I got it going ok and it was good to know before I 
made a whole bunch of stuff that would've needed changing!

Thanks again.!

> better, try this:
> 
> libfile:
> =
> $dog = 'spot';
> 
> progfile:
> =
> use warnings;
> use strict;
> use vars '$dog';
> do 'libfile';

Just curious...Why do, why not require ??

> print "$dog\n";
> 
> output:
> 
> spot
> 
> c.f. do() in the docs. :)
> 
> perldoc -f do
> 
> __
> Do you Yahoo!?
> Yahoo! Shopping - Send Flowers for Valentine's Day 
http://shopping.yahoo.com

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




Re: Help with printing 2 files into 1

2003-02-17 Thread R. Joseph Newton
HI Bernard,

Quick and Dirty is one thing.  Unreadable is another.  Perl allows spaces to be used 
freely.  The programmer who ishes to keep track of what his or her code is doing will 
use them.

use strict;

open (FONE, $ARGV[0]);
open (FTWO, $ARGV[1]);
open (FOUT, ">$ARGV[2]");

my @f1;
my @f2;
my $c = 0;
chomp (@f1 = );
chomp (@f2 = );
close(FONE);
close(FTWO);

for($c = 0; $c < scalar(@f1); $c++) {
  print(FOUT $f1[$c] . " " . $f2[$c] . "\n");
}

close(FOUT);



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




RE: use strict and lib vars

2003-02-17 Thread Paul
> > --- Dan Muey <[EMAIL PROTECTED]> wrote:
> > > #!/usr/bin/perl -w
> > > use strict;
> > > #my $dog = 'bart';
> > > eval {
> > > use lib '/home/dmuey';
> > > require "lib.lib";
> > > };
> > > print "Content-type: text/html\n\n";
> > > print "Error: $@ :: $dog ::\n";
> > > 
> > > :: lib.lib file is ::
> > > 
> > > my $dog = 'joe';
> > > 1;
> > 
> > First, $dog is a my() variable, and so ONLY exists in the lib 
> > file. Don't use my() in that circumstance.
> 
> Makes sense.
> Thanks! I got it going ok and it was good to know before I 
> made a whole bunch of stuff that would've needed changing!
> 
> Thanks again.!

You're very welcome.
 
> > better, try this:
> > 
> > libfile:
> > =
> > $dog = 'spot';
> > 
> > progfile:
> > =
> > use warnings;
> > use strict;
> > use vars '$dog';
> > do 'libfile';
> 
> Just curious...Why do, why not require ??
> 
> > print "$dog\n";
> > 
> > output:
> > 
> > spot
> > 
> > c.f. do() in the docs. :)
> > 
> > perldoc -f do

Personally, because I like typing 2 letters instead of 7. :)

Seriously, see the docs, which say that require() 
  "...demands that a library file be included if it hasn't 
   already been included. The file is included via the do-FILE
   mechanism, which is essentially just a variety of eval."

If it might already have been included, use require() to prevent
re-work. If not, save the extra behind-the-scenes stuff (and the typing
of 5 letters! :)

In *most* every case, however, I recommend use() and a module.
I don't think I've ever written anything that used a do() or a
require(), to be honest. I've written some things that could have been
shorter and done sooner if I *had*, but always preferred the extra work
to make it modular *once*, so that I wouldn't have that problem again.

Still, that was my situation -- yours might warrant the do(). :)

TMTOWTDI!
  

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




RE: use strict and lib vars

2003-02-17 Thread Dan Muey

Right on thanks!

> 
> > > --- Dan Muey <[EMAIL PROTECTED]> wrote:
> > > > #!/usr/bin/perl -w
> > > > use strict;
> > > > #my $dog = 'bart';
> > > > eval {
> > > > use lib '/home/dmuey';
> > > > require "lib.lib";
> > > > };
> > > > print "Content-type: text/html\n\n";
> > > > print "Error: $@ :: $dog ::\n";
> > > > 
> > > > :: lib.lib file is ::
> > > > 
> > > > my $dog = 'joe';
> > > > 1;
> > > 
> > > First, $dog is a my() variable, and so ONLY exists in the lib
> > > file. Don't use my() in that circumstance.
> > 
> > Makes sense.
> > Thanks! I got it going ok and it was good to know before I
> > made a whole bunch of stuff that would've needed changing!
> > 
> > Thanks again.!
> 
> You're very welcome.
>  
> > > better, try this:
> > > 
> > > libfile:
> > > =
> > > $dog = 'spot';
> > > 
> > > progfile:
> > > =
> > > use warnings;
> > > use strict;
> > > use vars '$dog';
> > > do 'libfile';
> > 
> > Just curious...Why do, why not require ??
> > 
> > > print "$dog\n";
> > > 
> > > output:
> > > 
> > > spot
> > > 
> > > c.f. do() in the docs. :)
> > > 
> > > perldoc -f do
> 
> Personally, because I like typing 2 letters instead of 7. :)
> 
> Seriously, see the docs, which say that require() 
>   "...demands that a library file be included if it hasn't 
>already been included. The file is included via the do-FILE
>mechanism, which is essentially just a variety of eval."
> 
> If it might already have been included, use require() to 
> prevent re-work. If not, save the extra behind-the-scenes 
> stuff (and the typing of 5 letters! :)
> 
> In *most* every case, however, I recommend use() and a 
> module. I don't think I've ever written anything that used a 
> do() or a require(), to be honest. I've written some things 
> that could have been shorter and done sooner if I *had*, but 
> always preferred the extra work to make it modular *once*, so 
> that I wouldn't have that problem again.
> 
> Still, that was my situation -- yours might warrant the do(). :)
> 
> TMTOWTDI!
>   
> 
> __
> Do you Yahoo!?
> Yahoo! Shopping - Send Flowers for Valentine's Day 
http://shopping.yahoo.com

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




RE: use strict and lib vars

2003-02-17 Thread wiggins


On Mon, 17 Feb 2003 11:45:15 -0800 (PST), Paul <[EMAIL PROTECTED]> wrote:

> > > --- Dan Muey <[EMAIL PROTECTED]> wrote:

> > > use vars '$dog';

> Personally, because I like typing 2 letters instead of 7. :)
> 

Ok then if your Perl (>5.6.0) allows it, change the above to:

our $dog;

perldoc vars
perldoc -f our

Save 7 more characters... ;-)

http://danconia.org

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




Re: Please very help...

2003-02-17 Thread R. Joseph Newton
Marco Giardina wrote:

> Hi list,
>
> sorry but i'am a newbie about Perl. Perl is fantastic, anything is possible
> when use Perl..
> So i have a question about this language. In brief I'll modify some
> information inside a file, for example image a file test.conf.
> I'll erase some character (#) before a line and then eventually, after some
> time, rewrite the same information always (#).
>
> I must:
> - Open file
> - find a particular line or character
> - apply a line modification
> - close the file
>
> So does anyone if exist a simple, very simple example that explain this
> approach.
>
> Many, many thanks list
>
> Marco

Hi Marco,

First let us note--your general description of the task does not match the steps 
listed in the algorithm that follows.  Nor is your algorithm sufficiently precise.  Do 
you want the line, or the character?  There are different solutions.  It is your job 
as a programmer to decide what you want.

I'm going to assume that you are looking for a particular string within a line, and 
use a regular expression-based substitution:

usage:
ReplaceString.pl TargetString ReplacementString SourceFile
Replaces TargetString with ReplacementString in SourceFile

#!/usr/bin/perl -w

use strict;
use warnings;

my ($TargetString, $ReplacementString, $SourceFile) = @ARGV;

ReplaceString ($TargetString, $ReplacementString, $SourceFile);

sub ReplaceString {
   my ($TargetString, $ReplacementString, $SourceFile) = @_;
   open IN, "< $SourceFile" or
die("Could not open source file.\n$!");
   open OUT, "> $SourceFile" . '.tmp' or
die("Could not open output file.\n$!");
   while () {
  $_ =~ s/$TargetString/$ReplacementString/g;
  print OUT;
   }
   close IN or die("Source file did not close properly.\n $!");
   close OUT or die("Output file did not close properly.\n $!");
   rename $SourceFile . '.tmp', $SourceFile;
}

Original Sample.txt:

Ethics warning
Plagiarism is a violation of academic ethics
This violation consists of presenting the work of another, intentionally, as ones own.
It can result in disciplinary actions, including expulsion.

Call to ReplaceString:
>ReplaceString.pl Plagiarism cheating Sample.txt

Modified Sample.txt:

Ethics warning
cheating is a violation of academic ethics
This violation consists of presenting the work of another, intentionally, as ones own.
It can result in disciplinary actions, including expulsion.

Joseph


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




Re: Help with printing 2 files into 1 [OT] -- a style discourse ;o]

2003-02-17 Thread Paul

Just for fun, a functional but BAD example

  use FileHandle;
  @_ = map { new FileHandle $_ } @ARGV;
  print while $_ = join "\t", map(scalar<$_>||'',@_), "\n"
  and s/\n(.)/\t$1/g;

Okay, that's ugly and almost completely unmaintainable for LOTS of
reasons, but it works. It will even take an arbitrary number of files,
though I'm not addressing the filesystem limit here.

First, FileHandle makes it easy to store anonymous filehandles, so you
can easily make an array of them, as I did in @_.
FileHandle is good -- it's your friend. Use it. That line isn't evil.
:)

Next, @_ is always there, as is $_ and even %_. That doesn't mean it's
a good idea to use it carelessly. It makes this code harder to read --
try rewriting it with an explicitly declared array, like this:

  my @fh = map { new FileHandle $_ } @ARGV;

Now, the *last* line is nutz. If you can read this at first pass, good
for you. I wrote it, and I have trouble. :)

  print while $_ = join "\t", map(scalar<$_>||'',@fh), "\n"
  and s/\n(.)/\t$1/g;

What's it doing? Let's break it down.

  print while .

okay, that's an implicit print of $_ in a loop. So long as the rest
evaluates to true, it will print the default variable. Obviously (I
hope), the loop must be setting $_ -- and sure enough, that's what the
next bit says!

  print while $_ = join "\t",

okay! $_ is being set with a join, which takes a list and stacks the
values into a scalar. Here, it's tab-delimited. So what's in the list?

  map(scalar<$_>||'',@_), "\n"

Okay, the "\n" on the end makes sense, if it's okay to have the final
newline always preceded with a tab. I actually like that in most of my
output. But what's that map() doing?

It's iterating over the filehandles we put into @_, and for each,
reading one line with <$_> and if it fails, returning an empty string
to pacify join. (This will run without complaint under strict pragma
with warnings on, so don't think those two things guarantee good code!
still, they darned well, help. Use 'em, both, as a habit!) 

The || operator puts <$_> into a scalar context, so it only reads one
line. But what about the poor shmuck who comes behind you in six months
trying to read your code? Is he going to know that? Are you? :)

So now we have 

  print while $_ = join "\t", map(scalar<$_>||'',@fh), "\n"

which stacks the contents of each file's read into one linedoesn't
it? Well, no, because they still have newlines on them. We didn't chomp
them. We couldn't use chomp() in the map() because it returns the
number of characters removed. The next guy is likely to add it if he
doesn't remember that, and the whole thing breaks.

What we did instead was a less-than-terrifically-efficient
substitution:

  print while $_ = join "\t", map(scalar<$_>||'',@_), "\n"
  and s/\n(.)/\t$1/g;

So, now that the join has loaded $_ with the concatenated lines from
the input files, the s/// searches for newlines (remembering the
following character) and replaces them with tabs (and the following
character). That's done before the while finishes evaluating, because
of the "and" operator. Pretty slick, eh?

Maybe, but you're making assumptions about your data. More importantly,
"slick" is almost always a euphamism for "hard to read". You'll regret
it when you come back to modify this.

Mine works, but it took me a while to work the kinks out. I could have
written the whole thing faster with more easily maintainable code.

Let's see:

  use FileHandle;
  my @fh  = map { new FileHandle $_ } @ARGV;
  # assume files have equal numbers of records
  my $driver = pop @fh;  # last entry drives
  while ( my $d_rec = <$driver> ) {  
 for my $file (@fh) {
 my $rec = <$file>;
 chomp $rec;
 print "$rec\t";
 }
 print $d_rec;   # includes newline!
  }

Now, we're still using map(), but in a reasonably clean and readable
way. We pop off one of the filehandles (the last) to use as a driver,
making the (documented) assumtion that the files have equal numbers of
records. Then we go into a basic loop reading from that driver file,
and while it has lines, we loop over all the other filehandles. In that
loop, we read records into a working space, remove the newlines, and
then print them with trailing tabs. After we've done all of those, we
print the still un-chomp()'d line from the driver file, which provides
a newline.

Is there still room for improvement? Oh, you betcha. LOTS, in many
areas. But you can read it now, practically at first glance. There are
still some gotchas -- would you have noticed that the driver still had
the newline? Maybe not, without the comment maybe it would be
better to chomp it and manually add it back on, but then that's
unnecessary work. Comments are your friend.

Ok, enough babbling -- I want to get this out there so better coders
can chop it up and comment and make real, useful suggestions. I only
post it because I got an itch to write some tight code,

RE: use strict and lib vars

2003-02-17 Thread Paul
> > > > use vars '$dog';
> 
> > Personally, because I like typing 2 letters instead of 7. :)
> 
> Ok then if your Perl (>5.6.0) allows it, change the above to:
> 
> our $dog;
> 
> perldoc vars
> perldoc -f our
> 
> Save 7 more characters... ;-)

lol -- sweet.
I'm still trying to get used to our(). ;o]

*ALWAYS* more to learn!

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




RE: get domain only with CGI or URI modules

2003-02-17 Thread Dan Muey


> Hello, 
>  
> Does anyone know of a quick/easy/fast way to to get the 
> domain out of a url?
>  
> For instance if I do : $url = $cgi->url();
>  
> I'll get, say http://joe.mama.com/so/isyour.cgi?mother
>  
Here's a partial answer to my own question ::

$uri = URI->new($cgi->url());
$domain = $uri->host();
Will set $domain to 
sub.domain.domain.com
me.domain.com
Etc...

I tried

$domain =~ m/((\w+)\.(\w+)$)/;
print "-$domain-\n";
print "-$1-\n";

And $1 did indeed only have 'domain.com'
Then I realized, what about tld's like com.uk like yahoo.com.ru google.com.uk

IF this was used at one of those you'd only get 'com.uk' or 'com.ru'
Back to the drawing board!!


Thanks


> I know I can use URI module to get the  scheme (http, https, 
> ftp, etc) from that What I need to grab out of that example 
> is the domain only, ( mama.com ) just the part that one would 
> register with a registrar, not any subdomains or any of that 
> just whatever.com.
>  
> Any ideas?
> Can it be done with cgi or uri or some other module instead 
> of doing some regex on it that will probably let stuff get through?
>  
> Thanks
>  
> Dan
> 

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




assign regex match to var all in one line

2003-02-17 Thread Dan Muey
IS there a better way to perhaps assign the value of $1 back to $var all in one 
statement?
EG

$var = 'hello.domain.com';
# Instead of this ::
$var =~ m/((\w+)\.(\w+)$)/; # $1 then becomes 'domain.com'
$var = $1; # then $var becomes 'domain.com'
# Perhaps a one liner version?

I know there's a way but it's Monday :(

Thanks

Dan

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




Re: assign regex match to var all in one line

2003-02-17 Thread Paul

--- Dan Muey <[EMAIL PROTECTED]> wrote:
> IS there a better way to perhaps assign the value of $1 back to $var
> all in one statement?
> EG
> 
> $var = 'hello.domain.com';
> # Instead of this ::
> $var =~ m/((\w+)\.(\w+)$)/; # $1 then becomes 'domain.com'
> $var = $1; # then $var becomes 'domain.com'
> # Perhaps a one liner version?
> I know there's a way but it's Monday :(

lol

The match operator returns a list of matches if your use it in a list
context. Instead of

  $str =~ /($pat)/;
  $var = $1;

do

  ($var) = $str =~ /($pat)/;

Sometimes it's the difference between 

  my $var = 

and 

  my($var) = 

that makes all the difference. The parens put it in list context.
*Learn* about context -- it will be your friend, but is fickle if you
don't understand it!

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




RE: get domain only with CGI or URI modules

2003-02-17 Thread Paul

--- Dan Muey <[EMAIL PROTECTED]> wrote:
> $domain =~ m/((\w+)\.(\w+)$)/;
> And $1 did indeed only have 'domain.com'
> Then I realized, what about tld's like com.uk like yahoo.com.ru
> google.com.uk

Try

 my($dom) = $URI =~ m{://([^/:]+)};

If $URI = "http://some.server.com.uk:1540/other/stiff.cgi?here"; it'll
work. :) 



__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




RE: assign regex match to var all in one line

2003-02-17 Thread Dan Muey

 
> 
> --- Dan Muey <[EMAIL PROTECTED]> wrote:
> > IS there a better way to perhaps assign the value of $1 
> back to $var 
> > all in one statement? EG
> > 
> > $var = 'hello.domain.com';
> > # Instead of this ::
> > $var =~ m/((\w+)\.(\w+)$)/; # $1 then becomes 'domain.com' 
> $var = $1; 
> > # then $var becomes 'domain.com' # Perhaps a one liner version?
> > I know there's a way but it's Monday :(
> 
> lol
> 
> The match operator returns a list of matches if your use it 
> in a list context. Instead of
> 
>   $str =~ /($pat)/;
>   $var = $1;
> 
> do
> 
>   ($var) = $str =~ /($pat)/;
> 
> Sometimes it's the difference between 
> 
>   my $var = 
> 
> and 
> 
>   my($var) = 
> 
> that makes all the difference. The parens put it in list context.
> *Learn* about context -- it will be your friend, but is 

Right! Duh

Like any other array assiingment my($name, $email, $food) = get_my_stuff();
Thanks for that enlightentment!

Yes I will learn, I appriciate it.

Thanks

Dan

> fickle if you don't understand it!
> 
> __
> Do you Yahoo!?
> Yahoo! Shopping - Send Flowers for Valentine's Day 
http://shopping.yahoo.com

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




Re: assign regex match to var all in one line

2003-02-17 Thread John W. Krahn
Dan Muey wrote:
> 
> IS there a better way to perhaps assign the value of $1 back to $var all in one 
>statement?

Yes.

> EG
> 
> $var = 'hello.domain.com';
> # Instead of this ::
> $var =~ m/((\w+)\.(\w+)$)/; # $1 then becomes 'domain.com'
> $var = $1; # then $var becomes 'domain.com'
> # Perhaps a one liner version?
> 
> I know there's a way but it's Monday :(


($var) = $string =~ /(\w+\.\w+)$/;

Note that you need the parenthesis around $var to force list context
because the result of a match in scalar context returns 'true' or
'false'.



John
-- 
use Perl;
program
fulfillment

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




Re: use strict and lib vars

2003-02-17 Thread R. Joseph Newton
Dan Muey wrote:

> I guess my main question would boil down to ::
>
> How can I use variables that get declared in a lib file in a script that uses -w and 
>use strict; ?
>
> A more complex example of what I've tried and what I'm trying to get is here ::
>
> On the script below, when use strict is commented out ::
> Name "main::dog" used only once: possible typo at ./test.pl line 11.
> Content-type: text/html
>
> Use of uninitialized value at ./test.pl line 11.
> Error:  ::HI
>
> And this when use strict; is not commented out I get ::
> Global symbol "$dog" requires explicit package name at ./test.pl line 11.
> Execution of ./test.pl aborted due to compilation errors.
>
> If I uncomment the my $dog in the script then all is well. Except the lib won't 
>change th value of $dog even if I take of the 'my' in the lib.
>
> #!/usr/bin/perl -w
>
> use strict;
> #my $dog = 'bart';
> eval {
> use lib '/home/dmuey';
> require "lib.lib";
> };
> print "Content-type: text/html\n\n";
> print "Error: $@ :: $dog ::\n";
>
> :: lib.lib file is ::
>
> my $dog = 'joe';
> 1;

HI Dan,

Well, we don't see what is happening in the lib file, so that leaves us largely in the 
dark.  You might also note that line 10 seems to be the last line of the script, 
unless you have dited something out.

I would suggest simply not using a lib file in this way.  I see the use and require 
statements, but no calls to functions defined therein.  It might make sense to define 
a global constant this way in a lib file, but not a raw variable. For instance, it 
probably makes more sense to use a Math module which defines PI once, than to 
hard-code the definition in each script.  It defeats the purpose of programming, by 
obscuring the source of your action, to do this with instance data..

What purpose did you mean to serve by hard-coding this data in an imported file?

Joseph


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




RE: assign regex match to var all in one line

2003-02-17 Thread Dan Muey


Thanks!
> 
> Dan Muey wrote:
> > 
> > IS there a better way to perhaps assign the value of $1 
> back to $var 
> > all in one statement?
> 
> Yes.
> 
> > EG
> > 
> > $var = 'hello.domain.com';
> > # Instead of this ::
> > $var =~ m/((\w+)\.(\w+)$)/; # $1 then becomes 'domain.com' 
> $var = $1; 
> > # then $var becomes 'domain.com' # Perhaps a one liner version?
> > 
> > I know there's a way but it's Monday :(
> 
> 
> ($var) = $string =~ /(\w+\.\w+)$/;
> 
> Note that you need the parenthesis around $var to force list 
> context because the result of a match in scalar context 
> returns 'true' or 'false'.
> 
> 
> 
> John
> -- 
> use Perl;
> program
> fulfillment
> 
> -- 
> 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: use strict and lib vars

2003-02-17 Thread Dan Muey


> 
> Dan Muey wrote:
> 
> > I guess my main question would boil down to ::
> >
> > How can I use variables that get declared in a lib file in a script 
> > that uses -w and use strict; ?
> >
> > A more complex example of what I've tried and what I'm 
> trying to get 
> > is here ::
> >
> > On the script below, when use strict is commented out ::
> > Name "main::dog" used only once: possible typo at ./test.pl line 11.
> > Content-type: text/html
> >
> > Use of uninitialized value at ./test.pl line 11.
> > Error:  ::HI
> >
> > And this when use strict; is not commented out I get :: 
> Global symbol 
> > "$dog" requires explicit package name at ./test.pl line 11. 
> Execution 
> > of ./test.pl aborted due to compilation errors.
> >
> > If I uncomment the my $dog in the script then all is well. 
> Except the 
> > lib won't change th value of $dog even if I take of the 'my' in the 
> > lib.
> >
> > #!/usr/bin/perl -w
> >
> > use strict;
> > #my $dog = 'bart';
> > eval {
> > use lib '/home/dmuey';
> > require "lib.lib";
> > };
> > print "Content-type: text/html\n\n";
> > print "Error: $@ :: $dog ::\n";
> >
> > :: lib.lib file is ::
> >
> > my $dog = 'joe';
> > 1;
> 
> HI Dan,
> 
> Well, we don't see what is happening in the lib file, so that 
> leaves us largely in the dark.  You might also note that line 
Sure you see what's going on, look above for the line -> :: lib.lib file is ::

All it has is
my $dog = 'joe';
1;

> 10 seems to be the last line of the script, unless you have 
> dited something out.

Before I created a complex bunch of scripts I wanted to have the foundation, 
basically configuration settings, set good.

> 
> I would suggest simply not using a lib file in this way.  I 
> see the use and require statements, but no calls to functions 

There will be functions later.

> defined therein.  It might make sense to define a global 
> constant this way in a lib file, but not a raw variable. For 

Well, any other ideas on how I can have a hundred scripts all use the same 
settings and make it easy to change any of them at will without having to go 
edit a hundred files would be nice.

> instance, it probably makes more sense to use a Math module 
> which defines PI once, than to hard-code the definition in 

True but pi never changes, the settings for the scripts using it will.

> each script.  It defeats the purpose of programming, by 
> obscuring the source of your action, to do this with instance data..
> 
> What purpose did you mean to serve by hard-coding this data 
> in an imported file?

To share configuration variables in one place for lots and lots of scripts to use 
instead of having to put them in each script and then on echanges and having to go 
through a hundred scripts all over the place to change them.

Someone else already helped me get it nailed down pretty well, basically the my was 
killing me and I needed to add 
use vars...

Any other insights will be welcome.

Thanks
Dan

> 
> Joseph
> 
> 

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




Re: Help with printing 2 files into 1

2003-02-17 Thread Bernhard van Staveren
I guess our definitions of unreadable differ in that case; I have my style
of writing things, you have yours - and such is life.

The extra spaces get on my tits pretty much, and it's perfectly readable
without it, IMHO.

On Mon, 17 Feb 2003, R. Joseph Newton wrote:

> HI Bernard,
>
> Quick and Dirty is one thing.  Unreadable is another.  Perl allows spaces to be used 
>freely.  The programmer who ishes to keep track of what his or her code is doing will 
>use them.
>
> use strict;
>
> open (FONE, $ARGV[0]);
> open (FTWO, $ARGV[1]);
> open (FOUT, ">$ARGV[2]");
>
> my @f1;
> my @f2;
> my $c = 0;
> chomp (@f1 = );
> chomp (@f2 = );
> close(FONE);
> close(FTWO);
>
> for($c = 0; $c < scalar(@f1); $c++) {
>   print(FOUT $f1[$c] . " " . $f2[$c] . "\n");
> }
>
> close(FOUT);
>
>
>

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




RE: get domain only with CGI or URI modules

2003-02-17 Thread Dan Muey
 
> --- Dan Muey <[EMAIL PROTECTED]> wrote:
> > $domain =~ m/((\w+)\.(\w+)$)/;
> > And $1 did indeed only have 'domain.com'
> > Then I realized, what about tld's like com.uk like yahoo.com.ru 
> > google.com.uk
> 
> Try
> 
>  my($dom) = $URI =~ m{://([^/:]+)};
> 
> If $URI = 
> "http://some.server.com.uk:1540/other/stiff.cg> i?here" it'll work. :) 

Hmm, if I'm looking at it right wouldn't that grab everything after :// and before the 
first / ie
some.server.com.uk

Which is the sam as doing 
my $dom = $uri->host();

What I was trying to get was just the domain without any subdomains, ie what you would 
register with a registrar
So what I was doing worked for a domain.com or domain.org, because it grabbed the last 
two chunks of text with a period in between. So with hello.domain.com I got domain.com 
but with domain.com.uk I'd only get com.uk which is not good.

What I was loking for was module like uri that would return just that part - 
server.com.uk

Thanks
Dan
 
> 
> 
> __
> Do you Yahoo!?
> Yahoo! Shopping - Send Flowers for Valentine's Day 
http://shopping.yahoo.com

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




Re: use strict and lib vars

2003-02-17 Thread R. Joseph Newton
Dan Muey wrote:

>
> To share configuration variables in one place for lots and lots of scripts to use 
>instead of having to put them in each script and then on echanges and having to go 
>through a hundred scripts all over the place to change them.
>
> Someone else already helped me get it nailed down pretty well, basically the my was 
>killing me and I needed to add
> use vars...
>
> Any other insights will be welcome.
>
> Thanks
> Dan

I'm wondering what would keep you from simply using a config file, and opening it to 
take these values as you would any other data used in your program?  Maybve I'm being 
simplistic.  It just seems to me that code inclusion is an extension of hard-coding.  
You seem to be describing the functionality of a system-level adapter.

I think there is a middle ground to be found here.  Your included module could provide 
functions to offer such data.  This can be done pretty easily using basic stuff we've 
all been batting around:

use DansConfig("getSetting");;

my $gatewayIP = getSetting("Gateway IP");

where, in DansConfig, you have a sub getSetting that opens a file of name=value pairs, 
one of which is the Gateway IP.  It seems to me that this would do the job.  Then, 
when those values change, you might access a simlar saveSetting function.that modifies 
the file, again using the straightforward text handling at which Perl so excels.

Joseph



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




RE: use strict and lib vars

2003-02-17 Thread Paul
> Well, any other ideas on how I can have a hundred scripts all use the
> same settings and make it easy to change any of them at will without
> having to go edit a hundred files would be nice.
> ... 
> To share configuration variables in one place for lots and lots of
> scripts to use instead of having to put them in each script and then
> on echanges and having to go through a hundred scripts all over the
> place to change them.

Sounds like you have a reasonably well-planned solution, and I think
it'll work. Still, you might consider making a proper module.
e.g.:

the configurator :)
===

package Configurator;

our %value;

sub import {
  for () {
   chomp;
   my($k,$v) = split /=/;
   $value{$k} = $v;
  }
}
1;

__DATA__
key1=value1
other=whatever


now, in your script:

use Configurator;
print "$Configurator::value{other}\n";

output:
===
whatever

It probably seems convoluted and contrived, but then every script that
uses the Configurator (or whatever you call it :) will have access to
the same data, editable and alterable in the one location after the
__DATA__ tag in the module itself.

More importantly, you can then put other tools such as utility
functions in it, and they'll be there for all scripts using them
without potentially polluting your namespace. Then you're only a couple
of steps away from writing full-blown object modules, and as your
project expands, you can completely retool the configuration system
underlying the module, maybe to use a real database and some serious
conditionals but scripts using the object interface wouldn't have
to be changed. Replacing the engine wouldn't require a new steering
wheel.

  my $conf = new Configurator @arglist or die "Can't initialize: $!";
  if ($conf->ready) { 
  do_stuff();
  } else {
  $conf->update or $conf->something_else;
  }

You get the idea. What's going on in the object? An oracle database
interface? MySQL? A DBM file? Maybe just a flatfile read, or even the
simplistic  read from stuff inside the module file itself? You
don't know without opening the module, and so the scripts coded that
way don't have to care. :)

Scalability! =o)

Could you do that with a do() or require()? Probably, but it's
nonstandard, and use() has more tools and toys built in. Use() it. :)

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




How to avoid this Warning ?

2003-02-17 Thread Madhu Reddy
Hi,
  I have following script, basically this will
ding the duplicate rows in a file...

I am getting following warnings
Use of uninitialized value at Audit_WTN.pl line 133,
 chunk 18.
Use of uninitialized value at Audit_WTN.pl line 133,
 chunk 19.

how to avoid warning at following location
133 if ( $ret >= 1 ) {



# return 1, if record is duplicate
#returns 0, if record is not duplicate
sub find_duplicates ()
{
128# get the key frim row
129 $key = substr($_,8,18);
130 $ret = $keys{$key};

132 #Record is Duplicate
133 if ( $ret >= 1 ) {
133 $keys{$key}++;
134 return 1;
} else {
$keys{$key}++;
return 0;   #not a duplicate
}
}


__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




Re: Help with printing 2 files into 1 [OT]

2003-02-17 Thread Paul

--- Bernhard van Staveren <[EMAIL PROTECTED]> wrote:
> I guess our definitions of unreadable differ in that case; I have my
> style of writing things, you have yours - and such is life.

That's pretty common. A guy in our office prefers:

  my $doc = "\n";
  $doc .= "\tThe various lines of text his program will print\n";
  $doc .= "\tif you call it with no arguments, which he types\n";
  $doc .= "\tin quotes and indiviually appends with the dot op\n";
  $doc .= "\n";

to what I personally consider more readable, which would be:

my $doc =

Re: assign regex match to var all in one line

2003-02-17 Thread R. Joseph Newton
Dan Muey wrote:

> IS there a better way to perhaps assign the value of $1 back to $var all in one 
>statement?
> EG
>
> $var = 'hello.domain.com';
> # Instead of this ::
> $var =~ m/((\w+)\.(\w+)$)/; # $1 then becomes 'domain.com'
> $var = $1; # then $var becomes 'domain.com'
> # Perhaps a one liner version?
>
> I know there's a way but it's Monday :(
>
> Thanks
>
> Dan

Wouldn't the substitution operator do what you are trying to do here?
$var =~ s/.*((\w+)\.(\w+)$)/$1/;

Joseph




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




Re: How to avoid this Warning ?

2003-02-17 Thread Paul
> Use of uninitialized value at Audit_WTN.pl line 133,
>  chunk 19.
> 
> how to avoid warning at following location
> 133   if ( $ret >= 1 ) {

Try
if ( ($ret||0) >= 1 ) {

If $ret is uninitialized, the || will pass to the 0 and return that.
Better to check your situation more carefully if you can, though.
This is just a hack to make the warning system shut up. Rather, try:

  if ($ret) {
  if ( $ret >= 1 ) {
# stuff 
  } else {
# different stuff.
  }
  } else { 
  # undefined or zero stuff
  }

It guarantees an extra check, but checking is usually better than
having bad data (or total lack of it) trip you up.

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




RE: 1) cygwin , 2) sprite/DBM

2003-02-17 Thread Tillman, James
> -Original Message-
> From: Pradeep Goel [mailto:[EMAIL PROTECTED]]
> Sent: Monday, February 17, 2003 8:34 AM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: 1) cygwin , 2) sprite/DBM 
> 
> 
> Hi All
> 
> I  have no idea of  CYGWIN  except only that almost all unix 
> commands can be
> run
> on windows .
> 
> I want to know if the SAME program running on unix systems 
> can be run on
> windows without any change ( or otherwise what changes need 
> to be made)
> after installing cygwin .

As far as I understand it, Cygwin's core is simply a *nix compatibility
layer that provides certain basic, necessary services missing from Win32.
Not all *nix programs will run under Cygwin because some require
services/libraries than Cygwin provides.  If yours is a relatively simple
program that has been properly set up to use autoconf/configure/etc. then
I'd say it's possible it might work.  If it's using some esoteric 3rd party
library, then chances for quick success are lower.

The cygwin distribution does provide a plethora of extra libraries that do
all sorts of cool stuff, however, so if your program's appetite for
libraries can be fulfilled by what cygwin offers, then I'd say install
Cygwin and give it the old "configure/make/make test" mantra and see what
happens!

jpt

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




RE: 1) cygwin , 2) sprite/DBM

2003-02-17 Thread Tillman, James
That should have been:

Not all *nix programs will run under Cygwin because some require *MORE*
services/libraries than Cygwin provides

Sorry about that...

jpt

> -Original Message-
> From: Tillman, James 
> Sent: Monday, February 17, 2003 9:53 AM
> To: 'Pradeep Goel'; [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: RE: 1) cygwin , 2) sprite/DBM 
> 
> 
> > -Original Message-
> > From: Pradeep Goel [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, February 17, 2003 8:34 AM
> > To: [EMAIL PROTECTED]
> > Cc: [EMAIL PROTECTED]
> > Subject: 1) cygwin , 2) sprite/DBM 
> > 
> > 
> > Hi All
> > 
> > I  have no idea of  CYGWIN  except only that almost all unix 
> > commands can be
> > run
> > on windows .
> > 
> > I want to know if the SAME program running on unix systems 
> > can be run on
> > windows without any change ( or otherwise what changes need 
> > to be made)
> > after installing cygwin .
> 
> As far as I understand it, Cygwin's core is simply a *nix 
> compatibility
> layer that provides certain basic, necessary services missing 
> from Win32.
> Not all *nix programs will run under Cygwin because some require
> services/libraries than Cygwin provides.  If yours is a 
> relatively simple
> program that has been properly set up to use 
> autoconf/configure/etc. then
> I'd say it's possible it might work.  If it's using some 
> esoteric 3rd party
> library, then chances for quick success are lower.
> 
> The cygwin distribution does provide a plethora of extra 
> libraries that do
> all sorts of cool stuff, however, so if your program's appetite for
> libraries can be fulfilled by what cygwin offers, then I'd say install
> Cygwin and give it the old "configure/make/make test" mantra 
> and see what
> happens!
> 
> jpt
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

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




Re: 1) cygwin , 2) sprite/DBM

2003-02-17 Thread Paul

--- Pradeep Goel <[EMAIL PROTECTED]> wrote:
> Hi All
> I  have no idea of  CYGWIN  except only that almost all unix commands
> can be run on windows .
> I want to know if the SAME program running on unix systems can be run
> on windows without any change ( or otherwise what changes need to be
> made) after installing cygwin .
 
If it's Perl, it should work unless it has UNIX-specific code in it.

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




Re: 1) cygwin , 2) sprite/DBM

2003-02-17 Thread Chris Jones
If the programs you are using are perl scripts then it is likely that you 
can run them directly on Windows without CYGWIN.  Depending on the size of 
the database file and how you want to use it, you might consider MySQL - 
open source, fast database.


Hi All

I  have no idea of  CYGWIN  except only that almost all unix commands can be
run
on windows .

I want to know if the SAME program running on unix systems can be run on
windows without any change ( or otherwise what changes need to be made)
after installing cygwin .

in both cases ( unix & windows) - it fires from a server & take some info
from remote machines , stores in local server & updates a web page using the
info

Any suggestions/ views of how you think should it be done in an easiest way
?

& also which is better to use a DBM file or a flat file database using
sprite/jprite ?

Thanks & Regards
Pradeep


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Chris Jones, P. Eng.
14 Oneida Avenue
Toronto, ON M5J 2E3
Tel. 416 203-7465
Fax. 416 203-8249




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




RE: 1) cygwin , 2) sprite/DBM

2003-02-17 Thread Dan Morrison
Does anyone know of a good resource that compares MySQL for windows to
the other popular engines?


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of
Chris Jones
Sent: Monday, February 17, 2003 11:57 AM
To: Pradeep Goel; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: 1) cygwin , 2) sprite/DBM 

If the programs you are using are perl scripts then it is likely that
you 
can run them directly on Windows without CYGWIN.  Depending on the size
of 
the database file and how you want to use it, you might consider MySQL -

open source, fast database.


>Hi All
>
>I  have no idea of  CYGWIN  except only that almost all unix commands
can be
>run
>on windows .
>
>I want to know if the SAME program running on unix systems can be run
on
>windows without any change ( or otherwise what changes need to be made)
>after installing cygwin .
>
>in both cases ( unix & windows) - it fires from a server & take some
info
>from remote machines , stores in local server & updates a web page
using the
>info
>
>Any suggestions/ views of how you think should it be done in an easiest
way
>?
>
>& also which is better to use a DBM file or a flat file database using
>sprite/jprite ?
>
>Thanks & Regards
>Pradeep
>
>
>___
>Perl-Win32-Users mailing list
>[EMAIL PROTECTED]
>To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Chris Jones, P. Eng.
14 Oneida Avenue
Toronto, ON M5J 2E3
Tel. 416 203-7465
Fax. 416 203-8249



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



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




RE: 1) cygwin , 2) sprite/DBM

2003-02-17 Thread Dan Muey
Id' try searching on  mysql.com . 
Also just from experience mysql is an extremely reliable, workhorse of a system.
In fact I found a link on  mysql's site that had an article from some big database 
conference recently that said that on the tests they ran, only Oracle and Mysql 
passed/had similar performance. That means that, free and awesome mysql had oracle 
like power, as in $50,000 to buy a house instead Oracle. ( I get the $50,000 figure 
from a company that we do work for that has a fifty thousand dollar Oracle system, 
granted that included a 2u rack server appx $3,000 if I bought it straight from a 
store. So maybe I should say $47,000 :) )
You also find great support for mysql and perl's DBI module has served me well withh 
mysql and perl. 

> -Original Message-
> From: Dan Morrison [mailto:[EMAIL PROTECTED]] 
> Sent: Monday, February 17, 2003 11:56 AM
> To: 'Chris Jones'; 'Pradeep Goel'; 
> [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: RE: 1) cygwin , 2) sprite/DBM 
> 
> 
> Does anyone know of a good resource that compares MySQL for 
> windows to the other popular engines?
> 
> 
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]] On 
> Behalf Of Chris Jones
> Sent: Monday, February 17, 2003 11:57 AM
> To: Pradeep Goel; [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: 1) cygwin , 2) sprite/DBM 
> 
> If the programs you are using are perl scripts then it is 
> likely that you 
> can run them directly on Windows without CYGWIN.  Depending 
> on the size of 
> the database file and how you want to use it, you might 
> consider MySQL -
> 
> open source, fast database.
> 
> 
> >Hi All
> >
> >I  have no idea of  CYGWIN  except only that almost all unix commands
> can be
> >run
> >on windows .
> >
> >I want to know if the SAME program running on unix systems can be run
> on
> >windows without any change ( or otherwise what changes need 
> to be made) 
> >after installing cygwin .
> >
> >in both cases ( unix & windows) - it fires from a server & take some
> info
> >from remote machines , stores in local server & updates a web page
> using the
> >info
> >
> >Any suggestions/ views of how you think should it be done in 
> an easiest
> way
> >?
> >
> >& also which is better to use a DBM file or a flat file 
> database using 
> >sprite/jprite ?
> >
> >Thanks & Regards
> >Pradeep
> >
> >
> >___
> >Perl-Win32-Users mailing list 
> [EMAIL PROTECTED]
> >To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 
> 
> Chris Jones, P. Eng.
> 14 Oneida Avenue
> Toronto, ON M5J 2E3
> Tel. 416 203-7465
> Fax. 416 203-8249
> 
> 
> 
> ___
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 
> 
> 
> -- 
> 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: assign regex match to var all in one line

2003-02-17 Thread John W. Krahn
"R. Joseph Newton" wrote:
> 
> Dan Muey wrote:
> 
> > IS there a better way to perhaps assign the value of $1 back to $var all in one 
>statement?
> > EG
> >
> > $var = 'hello.domain.com';
> > # Instead of this ::
> > $var =~ m/((\w+)\.(\w+)$)/; # $1 then becomes 'domain.com'
> > $var = $1; # then $var becomes 'domain.com'
> > # Perhaps a one liner version?
> 
> Wouldn't the substitution operator do what you are trying to do here?
> $var =~ s/.*((\w+)\.(\w+)$)/$1/;

No that won't work because the .* at the beginning is greedy.

$ perl -le' 
$string = "-=-=-=-=-abc.def";
($var) = $string =~ /(\w+\.\w+)$/;
print $var;
( $var = $string ) =~ s/.*((\w+)\.(\w+)$)/$1/;
print $var;
'
abc.def
c.def



John
-- 
use Perl;
program
fulfillment

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




RE: killing a process by window title; was: socket application

2003-02-17 Thread Timothy Johnson

How about you just force a logoff then instead of trying to find the window?

-Original Message-
From: Jangale V-S [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 17, 2003 8:15 PM
To: 'Timothy Johnson'
Subject: RE: killing a process by window title; was: socket application


No ! It's not that I did not like Win32::SetupSup !

The thing is that it does not satisfy my requirement !


The problem is in listing open windows in interactive user's login from
scheduler which is running with different user's login !!

My code is like this


use Win32::Setupsup qw(EnumWindows GetWindowText);
open (TITWIN,">c:\\system\\vsj\.log");
$status = EnumWindows(\@windows);
foreach $window (@windows) {
GetWindowText($window,\$WINTEXT);
print TITWIN "$window>\t , $WINTEXT \n\n";
}
close TITWIN;

Now let's say user AAA is loggged in interactively and has opened
application.

Scheduler is running with USER BBB and above script is running with his
login !

Now if script is run thr scheduler (user BBB login), it does not list any
open
window in user AAA's desktop !!! And since it does not list any window, I
can not close
it !

If I run the script thr user AAA's login (with user AAA logged on
interactively) ,
the logfile contains all open windows open in user AAA's login ! But this is
not
the situation !

Hope you got the problem !!


Please let me know how can I use Win32::OLE ??


Thanks in adavance !!

With Best Regards,

Vidyadhar

-Original Message-
From: Timothy Johnson [mailto:[EMAIL PROTECTED]]
Sent: 18 February 2003 09:41
To: Jangale V-S; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: RE: killing a process by window title; was: socket application



I guess that means you didn't like Win32::SetupSup?  I'm sure you could use
OLE...

-Original Message-
From: Jangale V-S [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 17, 2003 8:09 PM
To: [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: FW: killing a process by window title; was: socket application


Somebody help please !!

-Original Message-
From: Jangale V-S 
Sent: 13 February 2003 11:06
To: [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: RE: killing a process by window title; was: socket application


Further to this topic I have a slightly different requirement.

I want to kill process running on interactive desktop (with interactive
user's login) through scheduler .

The background is 

User logged on interactively on a machine are running one application
which they sometimes leave ON overnight . 

A process is running thr schduler (using different user account which is
administrator account) which has to update certain files related to above
application. For this the applcation has to be terminated/closed after
verifying
window title !

Now how can I get/enumerate windows which are open in interactive user's
desktop ?


With Best Regards,

Vidyadhar

___
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

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




Using alternatives and anchors

2003-02-17 Thread brady jacksan

I am writing a script that will read from a file named  myfiles not stdin and print 
the lines containing the following words "everywhere" or  'nowhere.

 

#!/usr/bin/perl
#use strict
while (<>) {
  chomp;
  if (/^everywhere$|^nowhere$/)
print

}

How do I invoked the file myfiles at the beginning of the script? Any help is 
appreciated.

Brady

 



-
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day


RE: Using alternatives and anchors

2003-02-17 Thread Toby Stuart


> -Original Message-
> From: brady jacksan [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, February 18, 2003 3:50 PM
> To: [EMAIL PROTECTED]
> Subject: Using alternatives and anchors
> 
> 
> 
> I am writing a script that will read from a file named  
> myfiles not stdin and print the lines containing the 
> following words "everywhere" or  'nowhere.
> 
>  
> 
> #!/usr/bin/perl
> #use strict
> while (<>) {
>   chomp;
>   if (/^everywhere$|^nowhere$/)
> print
> 
> }
> 
> How do I invoked the file myfiles at the beginning of the 
> script? Any help is appreciated.
> 
> Brady
> 
>

use strict;
use warnings;

open(F,'path\to\myfiles') || die "Cannot open: $!";
while()
{
print if /everywhere|nowhere/;
}
close(F);



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




Too may arguements Error

2003-02-17 Thread Madhu Reddy
Hi,
   i have a script with multi files...
in one file, i defined all the functions..
and from other file i am calling the functions...

suppose, following is my function defination...

sub log_msg()
{
   print LOG "@_\n";

}


i am calling this function with
log_msg("Running script\n")

here i am getting following error,
 too many arguements to log_msg at "("Running
script\n")"
--

then i changed the function defnitation.like
following 

##here i removed () in function definition
sub log_msg 
{
   print LOG "@_\n";

}


now it's workingI am curious to know,
why it is hapenning ?
in function definition we don't need to put "()" ?


Thanx
-Madhu





__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

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




Re: Gif Problem

2003-02-17 Thread Todd Wade

"Shawn Bower" <[EMAIL PROTECTED]> wrote in message
001301c2d3de$5093d020$6401a8c0@Beast">news:001301c2d3de$5093d020$6401a8c0@Beast...
> I'm trying to write a script that will open a socket connection to a
> website and return a gif.  I got it working to the point where and send
> the request and receive the response.



You dont need to work on that low of a level. Check this out:

#!/usr/bin/perl -w
use strict;
use LWP::Simple;

open(CHARTFILE, "> /home/trwww/public_html/vanessa.jpg") or die("open
failed: $!");
binmode( CHARTFILE ); # to be portable
print CHARTFILE
get('http://www.z957.net/html/concertcal/images/vanessa-carlton.jpg');
close( CHARTFILE );

The power is in get(). It fetches only document content and discards http
headers.

then I type http://localhost/~trwww/vanessa.jpg in my browser and get to
look at her beautiful face ;0)

hth,

Todd W.



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




RE: Too may arguements Error

2003-02-17 Thread Timothy Johnson

This is because you don't have to define your functions in Perl like you do
in C or some other languages.  Perl does have the ability to declare
function prototypes, but this is generally not used. If you wanted to
declare a function prototype, I believe you would have to declare it earlier
in your script as well.

-Original Message-
From: Madhu Reddy [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 17, 2003 9:07 PM
To: [EMAIL PROTECTED]
Subject: Too may arguements Error


Hi,
   i have a script with multi files...
in one file, i defined all the functions..
and from other file i am calling the functions...

suppose, following is my function defination...

sub log_msg()
{
   print LOG "@_\n";

}


i am calling this function with
log_msg("Running script\n")

here i am getting following error,
 too many arguements to log_msg at "("Running
script\n")"
--

then i changed the function defnitation.like
following 

##here i removed () in function definition
sub log_msg 
{
   print LOG "@_\n";

}


now it's workingI am curious to know,
why it is hapenning ?
in function definition we don't need to put "()" ?


Thanx
-Madhu





__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

-- 
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: Using alternatives and anchors

2003-02-17 Thread Timothy Johnson

I think this is what the OP was looking for:

if(/^(everywhere|nowhere)/){
   do something...
}

-Original Message-
From: Toby Stuart [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 17, 2003 9:01 PM
To: '[EMAIL PROTECTED]'
Cc: '[EMAIL PROTECTED]'
Subject: RE: Using alternatives and anchors

use strict;
use warnings;

open(F,'path\to\myfiles') || die "Cannot open: $!";
while()
{
print if /everywhere|nowhere/;
}
close(F);


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