Re: Downloadable and Online Perl Documentation

2007-12-18 Thread Chas. Owens
On Dec 19, 2007 12:46 AM, AndrewMcHorney <[EMAIL PROTECTED]> wrote:
> How does one gunzip on a windows pc?
snip

If you are on Win32 you are most likely using ActiveState Perl.  If
so, you don't need to download anything more.  All of those docs are
included in the distribution.  Look in the start menu.  If you are
using Cygwin instead, you can get the perldocs by just typing perldoc
perl.  You can get individual function descriptions by typing perldoc
-f funcname.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Downloadable and Online Perl Documentation

2007-12-18 Thread Chas. Owens
On Dec 18, 2007 4:16 PM, Ankur Gupta <[EMAIL PROTECTED]> wrote:
snip
> If you have a unix/linux box then no need to download/install any manual.
> Just type perldoc perl to get started.
snip

Not all Linux distributions include the Perl docs by default.  On
Ubuntu you need to install the perldocs with

sudo apt-get install perl-doc

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Downloadable and Online Perl Documentation

2007-12-18 Thread yitzle
On 12/19/07, AndrewMcHorney <[EMAIL PROTECTED]> wrote:
> How does one gunzip on a windows pc?

I believe Firefox has a built in gzip and will be able to read a .tar.gz
Barring that, WinRar, 7Zip or 7ZipPortable should all be up to the task.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Downloadable and Online Perl Documentation

2007-12-18 Thread AndrewMcHorney

How does one gunzip on a windows pc?

At 13:16 2007-12-18, Ankur Gupta wrote:

On Dec 19, 2007 2:40 AM,  <[EMAIL PROTECTED]> wrote:
> Hello
>
> i am looking for perl documenation that would aid in the 
determining what code to write and how to determine how one made a 
syntax error and also available functions.

>
> I need the documentation 2 formats. The first would be something 
that can be retrieved online for when I am online ( a link to the 
documentation). The second will be something i can download.  will 
be gone for a week and working on a few scripts. However, I will 
not be able to look up information online so I need something that 
can be read from disk in perhaps pdf format.


If you have a unix/linux box then no need to download/install any manual.
Just type perldoc perl to get started.

But if you want to go online or view the documentation in a web browser,
then I think http://perldoc.perl.org is the best.

You can also download it for off line viewing(has both html and pdf formats).

http://perldoc.perl.org/perldoc.tar.gz

--
Ankur

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.17.4/1188 - Release Date: 
2007-12-17 14:13



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp for two quotes

2007-12-18 Thread Rob Dixon

Dr.Ruud wrote:

Rob Dixon schreef:

scooter:



Can someone help me with the regexp that will match exactly two
quotes(') or no quotes in the string.
If a single quote exists, then will break out.

eg:
aabbcc -  Should Match
aa''bb''c''c - Should Match
a''b - Should Match
ab'' - Should Match


aa'bbcc - Should not Match
aa''bb'cc - Should not Match (since there is a single quote)
'aabcc - Should not Match

This does what you have described. It looks for a single quote,
preceded by a character other than a single quote or the start of the
string, and followed by a character other than a single quote or the
end of the string.

if (not /(?:\A|[^'])'(?:\Z|[^'])/) {
   print "matches\n"
}


That would fail q{ab}.


What do you mean by fail?

use strict;
use warnings;

for (q{ab}) {

  if (not /(?:\A|[^'])'(?:\Z|[^'])/) {
print "matches\n"
  }

}
__END__

prints 'matches'.

I understand this to be correct as the string doesn't contain a solitary
single quote.

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp for two quotes

2007-12-18 Thread Corin Lawson

Hi ab,

Can you not simply count the number of quotes mod 2?

Cheers,
Corin.

On 19/12/2007, at 6:23 AM, scooter wrote:


Can someone help me with the regexp that will match exactly two
quotes(') or no quotes in the string.
If a single quote exists, then will break out.

eg:
aabbcc -  Should Match
aa''bb''c''c - Should Match
a''b - Should Match
ab'' - Should Match


aa'bbcc - Should not Match
aa''bb'cc - Should not Match (since there is a single quote)
'aabcc - Should not Match


Thanks.
-ab.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: how to increment to records using SEEK

2007-12-18 Thread Jenda Krynicky
From: "minky arora" <[EMAIL PROTECTED]>
> Here is my code:
> !/usr/bin/perl
> 
> use strict;
> open FILE, "/users/meenaksharora/db.txt" or die"cnt open $!";
> my($fname,$lname,$address,$lline,$line,@db);
> foreach my $line(){
> $fname=substr($line,0,10);
> $lname=substr($line,10,15);
>   $address=substr($line,16,25);
> 
>   $lline=substr($line,59,13);

  my ($fname,$lname,$address,$lline) = ($line =~ 
/^(.{10})(.{15})(.{25})(.{13})/);


> $fname=~s/\s+/ /;
> $lname=~s/\s+/ /;
> $address=~s/\s+/ /;
> $lline=~s/\s+/ /;

for ($fname,$lname,$address,$lline) {
  s/\s+/ /; 
  # you sure? Replace the first group of spaces by a single one?
}

> print "$fname $lname\n";
> print "$address\n";
> print"$lline\n";
> }
> 
> Now each record as I calculated is of a fixed lenght of 75 chars.I
> need some idea as to how to run the Loop to print all such
> records.Right now I am only able to print the first record,

If the file doesn't contain lines, but fixed length records you 
should either use read() or set 

  $/ = \75;

see
 perldoc -f read
and
 perldoc perlvar

If you modify $/ you should do so for the smallest part of the code 
possible ... I would rather use read() myself.

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]
http://learn.perl.org/




Re: Date::manip query

2007-12-18 Thread Gunnar Hjalmarsson

pauld wrote:

im using Date::Manip to convert dates  and times eg  2007:08:02 12:23
to allow me to sort them,


Why are you doing that?

C:\home>type test.pl
@dates = ( '2007:08:02 12:23', '2007:10:21 04:40',
  '2007:06:05 16:08', '2007:09:11 22:20', );
print "$_\n" for sort @dates;

C:\home>test.pl
2007:06:05 16:08
2007:08:02 12:23
2007:09:11 22:20
2007:10:21 04:40

C:\home>

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp for two quotes

2007-12-18 Thread Dr.Ruud
Rob Dixon schreef:
> scooter:

>> Can someone help me with the regexp that will match exactly two
>> quotes(') or no quotes in the string.
>> If a single quote exists, then will break out.
>> 
>> eg:
>> aabbcc -  Should Match
>> aa''bb''c''c - Should Match
>> a''b - Should Match
>> ab'' - Should Match
>> 
>> 
>> aa'bbcc - Should not Match
>> aa''bb'cc - Should not Match (since there is a single quote)
>> 'aabcc - Should not Match
> 
> This does what you have described. It looks for a single quote,
> preceded by a character other than a single quote or the start of the
> string, and followed by a character other than a single quote or the
> end of the string.
> 
> if (not /(?:\A|[^'])'(?:\Z|[^'])/) {
>print "matches\n"
> }

That would fail q{ab}.

So maybe something like:  do{ local $_ = $str; s/''//g; !/'/; } 

-- 
Affijn, Ruud

"Gewoon is een tijger."

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: how to increment to records using SEEK

2007-12-18 Thread John W . Krahn
On Tuesday 18 December 2007 13:48, minky arora wrote:
>
> Hi Gurus,

Hello,

>  I am parsing through a file and need to print the records in the
> following order:
>
> Minky Arora
> 235 River Drive,
> Newton,PA 19073
>
> Here is my code:
> !/usr/bin/perl
>
> use strict;
> open FILE, "/users/meenaksharora/db.txt" or die"cnt open $!";
> my($fname,$lname,$address,$lline,$line,@db);
> foreach my $line(){
> $fname=substr($line,0,10);
> $lname=substr($line,10,15);
>   $address=substr($line,16,25);
>
>   $lline=substr($line,59,13);
> $fname=~s/\s+/ /;
> $lname=~s/\s+/ /;
> $address=~s/\s+/ /;
> $lline=~s/\s+/ /;
> print "$fname $lname\n";
>
>
> print "$address\n";
> print"$lline\n";
> }
>
> Now each record as I calculated is of a fixed lenght of 75 chars.I
> need some idea as to how to run the Loop to print all such
> records.Right now I am only able to print the first record,

You could try something like this:

#!/usr/bin/perl
use warnings;
use strict;

my $file = '/users/meenaksharora/db.txt';

open my $fh, '<', $file or die "Cannot open '$file' $!";

while ( my $line = <$fh> ) {
my ( $fname, $lname, $address, $lline ) = unpack 'A10 A15 A25 A13', 
$line;

print "$fname $lname\n$address\n$lline\n";
}

__END__



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: how to increment to records using SEEK

2007-12-18 Thread Tom Phoenix
On Dec 18, 2007 1:48 PM, minky arora <[EMAIL PROTECTED]> wrote:

> !/usr/bin/perl

I think you meant for that to begin with #!, not to nitpick

> foreach my $line(){

That should run your loop once for each line in the file. But I prefer
this line:

  while (my $line = ) {

That should also run the loop once for each line in the file. But
because it uses  in scalar context, it will read one line, run
the loop, then go back to read another line. Using  in list
context (as foreach does) means to read the entire file at once, but
there's no need to bring what may be a large file into memory if
you'll be processing it a line at a time. (To be sure, perl may
optimize this code; but it's safer in general to use while.)

> $fname=substr($line,0,10);
> $lname=substr($line,10,15);
>   $address=substr($line,16,25);
>
>   $lline=substr($line,59,13);

That doesn't add up right, unless you're not using substr() correctly.

http://perldoc.perl.org/functions/substr.html

For the kind of thing you're looking to do, unless you really do want
overlapping fields, I think you want unpack().

http://perldoc.perl.org/functions/unpack.html
http://perldoc.perl.org/functions/pack.html

> Now each record as I calculated is of a fixed lenght of 75 chars.I
> need some idea as to how to run the Loop to print all such
> records.Right now I am only able to print the first record,

Perhaps your data file isn't organized in lines? The readline operator
(angle brackets around a filename, like ) reads a text file a
line at a time, but it's not usually appropriate for non-text files.
You probably want the read() operator.

http://perldoc.perl.org/functions/read.html

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Downloadable and Online Perl Documentation

2007-12-18 Thread yitzle
On 12/18/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello
>
> i am looking for perl documenation that would aid in the determining what 
> code to write and
> how to determine how one made a syntax error and also available functions.
--snip--

In addition to what Gupta said, I'd advise always including the
following two lines at the top of your code:

use warnings;
use strict;

This way, Perl will tell you if you got something suspicious or wrong.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: testing for a file type

2007-12-18 Thread Rob Dixon

goldtech wrote:

Hi,

If I have:

...
foreach (@ARGV) {
print "do something only to .mdb files";
}

I could use File::Basename's fileparse and test for the file extension
and put a big if statement around or in the foreach loop. So if a user
puts a non .mdb file argument on the cmd line it won't process and
prints a usage.

But I suspect in perl theres a more compact way of doing that?


use strict;
use warnings;

if (grep { not /\.mdb\z/ } @ARGV) {
  print "All parameters must be MDB files\n";
  exit;
}

foreach (@ARGV) {
  print "do something only to .mdb files";
}

HTH,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




how to increment to records using SEEK

2007-12-18 Thread minky arora
Hi Gurus,

 I am parsing through a file and need to print the records in the
following order:

Minky Arora
235 River Drive,
Newton,PA 19073

Here is my code:
!/usr/bin/perl

use strict;
open FILE, "/users/meenaksharora/db.txt" or die"cnt open $!";
my($fname,$lname,$address,$lline,$line,@db);
foreach my $line(){
$fname=substr($line,0,10);
$lname=substr($line,10,15);
  $address=substr($line,16,25);

  $lline=substr($line,59,13);
$fname=~s/\s+/ /;
$lname=~s/\s+/ /;
$address=~s/\s+/ /;
$lline=~s/\s+/ /;
print "$fname $lname\n";


print "$address\n";
print"$lline\n";
}

Now each record as I calculated is of a fixed lenght of 75 chars.I
need some idea as to how to run the Loop to print all such
records.Right now I am only able to print the first record,

Thanks in advance,
Min

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp for two quotes

2007-12-18 Thread Rob Dixon

Dr.Ruud wrote:

scooter schreef:


Can someone help me with the regexp that will match exactly two
quotes(') or no quotes in the string.
If a single quote exists, then will break out.

eg:
aabbcc -  Should Match
aa''bb''c''c - Should Match
a''b - Should Match
ab'' - Should Match


aa'bbcc - Should not Match
aa''bb'cc - Should not Match (since there is a single quote)
'aabcc - Should not Match


Why use a regex?
You can just test the evenness of the quotescount, see `perldoc -f tr`.

A regex-way:

   m/\A(?:[^']*'[^']*')*[^']*\z/


The OP's examples fit this interpretation, but I assumed him to mean
that "aa'bb'cc" would fail the match. We need to find out :)

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Downloadable and Online Perl Documentation

2007-12-18 Thread Ankur Gupta
On Dec 19, 2007 2:40 AM,  <[EMAIL PROTECTED]> wrote:
> Hello
>
> i am looking for perl documenation that would aid in the determining what 
> code to write and how to determine how one made a syntax error and also 
> available functions.
>
> I need the documentation 2 formats. The first would be something that can be 
> retrieved online for when I am online ( a link to the documentation). The 
> second will be something i can download.  will be gone for a week and working 
> on a few scripts. However, I will not be able to look up information online 
> so I need something that can be read from disk in perhaps pdf format.

If you have a unix/linux box then no need to download/install any manual.
Just type perldoc perl to get started.

But if you want to go online or view the documentation in a web browser,
then I think http://perldoc.perl.org is the best.

You can also download it for off line viewing(has both html and pdf formats).

http://perldoc.perl.org/perldoc.tar.gz

-- 
Ankur

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: testing for a file type

2007-12-18 Thread Ankur Gupta
On Dec 18, 2007 10:08 PM, goldtech <[EMAIL PROTECTED]> wrote:

> Hi,
>
> If I have:
>
> ...
> foreach (@ARGV) {
>print "do something only to .mdb files";
> }
>
> I could use File::Basename's fileparse and test for the file extension
> and put a big if statement around or in the foreach loop. So if a user
> puts a non .mdb file argument on the cmd line it won't process and
> prints a usage.
>
> But I suspect in perl theres a more compact way of doing that?

I don't think you need to use File::Basename.

You can simply do this.

foreach my $file (@ARGV) {
if ( $file !~ /\.mdb$/ ) {
print "$file is not a mdb file. Ignoring...\n";
next;
}

# code to pocess .mdb file
...
...
}

-- 
Ankur

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Date::manip query

2007-12-18 Thread pauld
the END_DS field is the date  field that I want  - but as I couldnt
get it back from the seconds  since epoch field I included it.
IMHO it would be tideir to just use the (numerical) date-seconds and
convert it back as necessary . i used the Date::Manip function
Date_SecsSince1970($m,$d,$y,$h,$mn,$s); to get the date& time  into a
format  I can sort it by. i was wanting to use Date::manip to extract
the bits i want ( HH:MM) for the final display. i can do it by
splitting the text formatted  value (START_DS)  but i thought it would
be neater ( and i'd learnt something ) by doing it using the module


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Downloadable and Online Perl Documentation

2007-12-18 Thread andrewmchorney
Hello

i am looking for perl documenation that would aid in the determining what code 
to write and how to determine how one made a syntax error and also available 
functions.

I need the documentation 2 formats. The first would be something that can be 
retrieved online for when I am online ( a link to the documentation). The 
second will be something i can download.  will be gone for a week and working 
on a few scripts. However, I will not be able to look up information online so 
I need something that can be read from disk in perhaps pdf format.

Thanks,
Andrew

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




testing for a file type

2007-12-18 Thread goldtech
Hi,

If I have:

...
foreach (@ARGV) {
print "do something only to .mdb files";
}

I could use File::Basename's fileparse and test for the file extension
and put a big if statement around or in the foreach loop. So if a user
puts a non .mdb file argument on the cmd line it won't process and
prints a usage.

But I suspect in perl theres a more compact way of doing that?

Thanks.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp for two quotes

2007-12-18 Thread Rob Dixon

scooter wrote:

Can someone help me with the regexp that will match exactly two
quotes(') or no quotes in the string.
If a single quote exists, then will break out.

eg:
aabbcc -  Should Match
aa''bb''c''c - Should Match
a''b - Should Match
ab'' - Should Match


aa'bbcc - Should not Match
aa''bb'cc - Should not Match (since there is a single quote)
'aabcc - Should not Match


This does what you have described. It looks for a single quote, preceded
by a character other than a single quote or the start of the string, and
followed by a character other than a single quote or the end of the
string.

if (not /(?:\A|[^'])'(?:\Z|[^'])/) {
  print "matches\n"
}

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp for two quotes

2007-12-18 Thread Tom Phoenix
On 12/18/07, yitzle <[EMAIL PROTECTED]> wrote:

> I tried to do something like the following, but it didn't work. It
> fails on a zero-quote line. No idea why.
> /^([^']*'[^']*'[^']*)*$/

No idea? Here's one: If it is to match a non-trivial string, your
pattern needs to find at least two apostrophes.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp for two quotes

2007-12-18 Thread Dr.Ruud
scooter schreef:

> Can someone help me with the regexp that will match exactly two
> quotes(') or no quotes in the string.
> If a single quote exists, then will break out.
>
> eg:
> aabbcc -  Should Match
> aa''bb''c''c - Should Match
> a''b - Should Match
> ab'' - Should Match
>
>
> aa'bbcc - Should not Match
> aa''bb'cc - Should not Match (since there is a single quote)
> 'aabcc - Should not Match

Why use a regex?
You can just test the evenness of the quotescount, see `perldoc -f tr`.

A regex-way:

   m/\A(?:[^']*'[^']*')*[^']*\z/

-- 
Affijn, Ruud

"Gewoon is een tijger."


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp for two quotes

2007-12-18 Thread Tom Phoenix
On 12/18/07, scooter <[EMAIL PROTECTED]> wrote:

> Can someone help me with the regexp that will match exactly two
> quotes(') or no quotes in the string.
> If a single quote exists, then will break out.

You are saying what you want for the cases of zero, one, or two single
quote marks in the string. What would you like to cause to happen in
other cases?

If you're interested in counting the number of times that a particular
character occurs in a string, the tr/// operator is probably what you
want.

  my $some_string = q{This isn't a 'test'.};
  my $count = ($some_string =~ tr/'/'/);

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regexp for two quotes

2007-12-18 Thread yitzle
Nasty piece of code, but works:
__CODE__
while (<>) {
print;
my @a = /\'/g ;
print "MATCH\n" if not scalar (@a) % 2;
}
__END__

Matches blank lines as well.

I tried to do something like the following, but it didn't work. It
fails on a zero-quote line. No idea why.
/^([^']*'[^']*'[^']*)*$/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




regexp for two quotes

2007-12-18 Thread scooter
Can someone help me with the regexp that will match exactly two
quotes(') or no quotes in the string.
If a single quote exists, then will break out.

eg:
aabbcc -  Should Match
aa''bb''c''c - Should Match
a''b - Should Match
ab'' - Should Match


aa'bbcc - Should not Match
aa''bb'cc - Should not Match (since there is a single quote)
'aabcc - Should not Match


Thanks.
-ab.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: out to keyboard

2007-12-18 Thread Tom Phoenix
On 12/18/07, Ryan <[EMAIL PROTECTED]> wrote:

> I want to control a terminal program that is proprietary and Curses
> and such won't work.  So instead I'd like to have my perl program
> output chars to the keyboard or mouse port on my UNIX machine, which
> will be plugged into a Windows machine with the terminal.  Will this
> work?  How can I do it?

It sounds as if you want to have a Windows machine that's running some
proprietary program, and another machine that is the "user" of that
program, typing on the keyboard and maybe even clicking the mouse from
time to time. Is that it?

It almost certainly _possible_ to do something like this. But it's not
a small project, and it requires more than a little clever hardware
and software. Furthermore, unless your program can always predict
what's going to happen, you'll need some way to interpret whatever the
proprietary program puts on the screen, and that's a bit of a big
project all by itself.

What proprietary program are you trying to control? A setup like this
could be used for many purposes, not all of them honorable. For
example, you could try to discover a product registration code by
brute force, or try to cheat in an online game. If you're doing
something that should be permitted, there may be an easier way to do
it.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




out to keyboard

2007-12-18 Thread Ryan

Here's something I've never done before and I need some help.

I want to control a terminal program that is proprietary and Curses  
and such won't work.  So instead I'd like to have my perl program  
output chars to the keyboard or mouse port on my UNIX machine, which  
will be plugged into a Windows machine with the terminal.  Will this  
work?  How can I do it?


Thanks!

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Date::manip query

2007-12-18 Thread Rob Dixon

pauld wrote:
>

im importing data from an excel spreadsheet into an array of hashes.
the date is initially converted using Date::Format::Excel.

for this bit

{START} = unix start time .{START_DS} = string that I use to convert
to unixtime with

my $var=0;my [EMAIL PROTECTED];
while ($var<$va_length)
{
print "${$daylistsorted[$var]}{TH} ";
print   'from ';
print ${$daylistsorted[$var]}{START};
print ' to '.${$daylistsorted[$var]}{END_DS};
print "   duration  ";print   int((${$daylistsorted[$var]}{END}-$
{$daylistsorted[$var]}{START})/60);

if (exists(  ${$daylistsorted[$var+1]}{TH}  )   )
 {
print "\tinterval to next start "; print int ((${$daylistsorted[$var
+1]}{START}-${$daylistsorted[$var]}{END})/60);print " \n";
 }
$var++;
}}

Sat  04-08-2007
=
1 from 1186220100 to 2007:08:04 10:33   duration  58 interval to next
start 34
4 from 1186225620 to 2007:08:04 13:29   duration  142  interval to
next start 26

and when i change it to
#print ${$daylistsorted[$var]}{START};
print UnixDate(${$daylistsorted[$var]}{START}, '%Y:%m:%d %H:%M');

 I get this

Sat  04-08-2007
=
 1 from  to 2007:08:04 10:33   duration  58   interval to next start
34
 4 from  to 2007:08:04 13:29   duration  142  interval to next start
26


with both dates as strings


Sat  04-08-2007
=
1 from 2007:08:04 09:35 to 2007:08:04 10:33   duration  58   interval
to next start 34
4 from 2007:08:04 11:07 to 2007:08:04 13:29   duration  142  interval
to next start 26


Your START and END fields appear to be seconds since epoch, whereas the
END_DS field is in the form '%Y:%m:%d %H:%M' as you described in your
earlier post. Neither of these are anything to do with the Date::Manip
module and consequently the answers you have had were irrelevant.

To display a time value such as this in a custom format you can use the
strftime() function from the POSIX module. The program below exemplifies
this.

However, unless I am misunderstanding you you already have the START
time as a string in START_DS. Isn't this sufficient?

HTH,

Rob



use strict;
use warnings;

use POSIX qw(strftime);

my $date_time = 1186220100;

print strftime('%Y:%m:%d %H:%M', localtime($date_time));

**OUTPUT**

2007:08:04 10:35

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/