Re: Fw: off topic : frames html question

2002-02-26 Thread Jon Molin

Rahul Garg wrote:
> 
> Well, I also dont know whether its possible or not ?
> Any suggestions.
> 

I hope you won't keep replying to your own question every second hour,
saying that you don't know the answer

/jon



> - Original Message 

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




Fw: off topic : frames html question

2002-02-26 Thread Rahul Garg

Well, I also dont know whether its possible or not ?
Any suggestions.

- Original Message -
From: Rahul Garg <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 27, 2002 10:57 AM
Subject: off topic : frames html question


Well,
I have a html page which has many hyperlinks.
Now each hyperlink at present calls another html page that has two
frames(horizontally).Ist frame is same for all links.
Now second frame is also same but has many bookmarks. I want that on
clicking difft. hyperlinks they should lead to their bookmarks.

How is it possible or nany references.

I know it is offtopic but i think some people here might have some
experience in html.

Thanks,
Rahul



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




Re: arrays + split

2002-02-26 Thread Jeff 'japhy' Pinyan

On Feb 27, Stuart Clark said:

>Hi All,
>
>How do i gather an array of data from a line which has no delimiters.
>The data is put into positions relative to the start of the line.

>#string 1 will be position 1-5 on the line
>#string 2 will be position 6-15 on the line
>#string 3 will be position 16-23 on the line
>#string 4 will be position 24-28 on the line
>#string 5 will be position 29-34 on the line

Sounds like a job for unpack().

  @fields = unpack "A5 A10 A8 A5 A6", $string;

You can come up with a function to go from the list (5,15,23,28,34) to the
format string "A5 A10 A8 A5 A6" pretty easily.  (Hint: subtraction.)

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




Re: Stripping HTML

2002-02-26 Thread Jeff 'japhy' Pinyan

On Feb 27, Daniel Falkenberg said:

>$inputSite = "";
>$tree = HTML::TreeBuilder->new;
>$address = "http://"; . $inputSite;
>$request = HTTP::Request->new('GET', $address);
>$response = $ua->request($request);
>my $found = 0;
>
>$tree->parse($response->content);
>$html_string = $tree->as_HTML;
>$te = new HTML::TableExtract( headers => [qw(one two three)] );
>$te->parse($html_string);
>foreach $ts ($te->table_states) {
>  foreach $row ($ts->rows) {
>$mRow = "@$row";

You're ASSIGNING to $mRow here...

>  }
>}
>print $mRow;

 so this will only be the last row found.  Maybe you wanted to do

  $mRow .= "@$row";

but I can't be sure.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




hi all

2002-02-26 Thread Selvi Subramanian

hi group

well, i ve gotta file that doesnt ve uniform structure. i wud like 
to extract the values by using the key.

Ex
name xxx
Ed.q yyy
Add  zzz  bbb
 aaa  ccc
  bbb  ddd

in this ex, i want to extract the name and the address, if i use 
/t then i can extract only the first line in case of add
wat shud i do if i want to extract everythg thatz given against 
add column.
since i do not know the size of the array i cant use AoA as 
well!!

is there anyone who can help me in this regard?

S:)

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




Re: a simple question

2002-02-26 Thread Michael Kelly

On 2/26/02 10:27 PM, jds <[EMAIL PROTECTED]> wrote:

> #win2k system
> 
> ...
> @array=;
> ...
> 
> Q:when running,how to break the input,and not exit program?

Hi jds,

Your EOF char. On most systems, this is ^D, and on Windows I believe it is
^Z.

Hope that helps,
-- 
Michael


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




externel merge sort of numbers

2002-02-26 Thread sanilkumar


help me
I want the code of external merge sort using perl
enybody help me



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




a simple question

2002-02-26 Thread jds

#win2k system

...
@array=;
...

Q:when running,how to break the input,and not exit program?



off topic : frames html question

2002-02-26 Thread Rahul Garg

Well, 
I have a html page which has many hyperlinks.
Now each hyperlink at present calls another html page that has two  
frames(horizontally).Ist frame is same for all links.
Now second frame is also same but has many bookmarks. I want that on clicking difft. 
hyperlinks they should lead to their bookmarks.

How is it possible or nany references.

I know it is offtopic but i think some people here might have some experience in html.

Thanks,
Rahul



Stripping HTML

2002-02-26 Thread Daniel Falkenberg

Hello All,

Could some one help me with stripping out the following from the
following HTML?  


 Find this one 
 one 1 

 
 Find this two 
 two 2 

 
 Find this three 
 three 3 


Basically using HTML::TableExtract I really want to extract

one 1
two 2
three 3

So far I have the following code...

$inputSite = "";
$tree = HTML::TreeBuilder->new;
$address = "http://"; . $inputSite;
$request = HTTP::Request->new('GET', $address);
$response = $ua->request($request);
my $found = 0;

$tree->parse($response->content);
$html_string = $tree->as_HTML;
$te = new HTML::TableExtract( headers => [qw(one two three)] );
$te->parse($html_string);
foreach $ts ($te->table_states) {
  foreach $row ($ts->rows) {
$mRow = "@$row";
  }
}
print $mRow;

Is there any obvious errors in this?

Regards,

Dan

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




RE: arrays + split

2002-02-26 Thread Wagner-David

I thank you will have to use substr since you have daffygoofy and you have 
nothing to split on, so use substr to get the data.

Wags ;)

-Original Message-
From: Stuart Clark [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 26, 2002 19:57
To: perllist
Subject: arrays + split


Hi All,

How do i gather an array of data from a line which has no delimiters.
The data is put into positions relative to the start of the line.
Below is an example of the problem for this newsgroup.
The live script has far more variables.

Regards
Stuart Clark

EG:

###test file


fred barneywilmadino betty
daffygoofy taz plutodonald

#string 1 will be position 1-5 on the line
#string 2 will be position 6-15 on the line
#string 3 will be position 16-23 on the line
#string 4 will be position 24-28 on the line
#string 5 will be position 29-34 on the line



open (IN,"testfile") || die "could not open input file\n";
open (OUT,"outfile") || die "could not open output file\n";
while () {
 chomp $_;

($cartoon1,$cartoon2,$cartoon3,$cartoon4,cartoon5) = split (what goes
here??);

print OUT $cartoon2. $cartoon4. "\n";


close (IN) || die "could not close input file\n";
close (OUT) || die "could not close output file\n";


-- 
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]




arrays + split

2002-02-26 Thread Stuart Clark

Hi All,

How do i gather an array of data from a line which has no delimiters.
The data is put into positions relative to the start of the line.
Below is an example of the problem for this newsgroup.
The live script has far more variables.

Regards
Stuart Clark

EG:

###test file


fred barneywilmadino betty
daffygoofy taz plutodonald

#string 1 will be position 1-5 on the line
#string 2 will be position 6-15 on the line
#string 3 will be position 16-23 on the line
#string 4 will be position 24-28 on the line
#string 5 will be position 29-34 on the line



open (IN,"testfile") || die "could not open input file\n";
open (OUT,"outfile") || die "could not open output file\n";
while () {
 chomp $_;

($cartoon1,$cartoon2,$cartoon3,$cartoon4,cartoon5) = split (what goes
here??);

print OUT $cartoon2. $cartoon4. "\n";


close (IN) || die "could not close input file\n";
close (OUT) || die "could not close output file\n";


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




Re: net::smtp and timestamp?

2002-02-26 Thread Elaine -HFB- Ashton

Jonathan Chan [[EMAIL PROTECTED]] quoth:
*>howdy,
*>
*>when using sending an automated email using net::smtp the time stamp is not 
*>set correctly and the date line is not included in the headers.
*>
*>is there a way to include the correct time stamp in the headers?

http://www.perl.com/doc/FAQs/nt/perlwin32faq4.html#How_do_I_send_email_from_Perl_fo

should illuminate the errors in your script.

e.

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




Re: CGI-Perl list

2002-02-26 Thread Elaine -HFB- Ashton

Naika - EV1 [[EMAIL PROTECTED]] quoth:
*>Can someone direct me to the cgi-perl list for beginners? I'm trying to find
*>it but am unable. If anyone has the subscribe headers for it that will do as
*>well, thanks.

http://lists.cpan.org/showlist.cgi?name=beginners-cgi

e.

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




question output hash values

2002-02-26 Thread Keith A. Calaman


I am trying to read in a data file, sort it by a particular column and then
output the results column by column to an HTML document.  I have the below
code which is only printing out my first record.  Can someone try and point
me in the right direction where I can get it sorted and then output the
contents something like $value[1] $value[2] so I can work with each column
independantly.  If this doesn't make any sense please let me know I have
been spinning to get this accomplished and can figure out how to get it to
work.  Thanks.

__


#!/usr/bin/perl -w

use diagnostics;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;

#declare form variables
my $query = CGI->new();
my $title = $query->param('title');
my $source = $query->param('source');
my $sourceurl = $query->param('sourceurl');
my $newsurl = $query->param('newsurl');
my $year = $query->param('year');
my $action= $query->param('action');
my $month = $query->param('month');
my $day = $query->param('day');
my $date = join('/', $month,$day,$year);
my $key = $query->param('key');
$db_key = time;
$dbfile ="post.txt";




open(DB,"$dbfile") or die "can't $dbfile: $!\n";

my @entry = ;

for(@entry){my @fields=split/\|/;

my $v=$fields[0];

splice @fields,0,1;

map{$key{$v}.=" ". $_}@fields};

reverse sort keys %key;


foreach $key (reverse sort keys %key) {
$value = $key{$key};
# do something with $key and $value
}

 $see .= qq|  $value[1]\n|;


close DB;

close DB;



print <


$value
$see




EndOfHTML



-- 
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]




^] : what is this?

2002-02-26 Thread GoodleafJ

Sorting through a dump from FileMaker Pro (which, let me digress to
mention, I _hate_) trying to wedge the stuff in a little
checking/reconciliation script. I ran it through dos2unix, but still find a
character that looks like ^]  all over the place. What is this? Tried a few
subs in vi and perl and haven't hit it yet.

Thanks,
John


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




net::smtp and timestamp?

2002-02-26 Thread Jonathan Chan

howdy,

when using sending an automated email using net::smtp the time stamp is not 
set correctly and the date line is not included in the headers.

is there a way to include the correct time stamp in the headers?

here's what i get:
Return-Path: <[EMAIL PROTECTED]>
Received: from broadcast.com ([172.21.133.55]) by mailhost.broadcast.com
   (Post.Office MTA v3.1 release PO205e ID# 0-61905U600L400S0)
   with ESMTP id AAA297 for <[EMAIL PROTECTED]>;
   Mon, 25 Feb 2002 16:41:40 -0600
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: test!!

code:
 $from = '[EMAIL PROTECTED]';
 $site = 'broadcast.com';
 $smtp_host = 'mailhost.broadcast.com';
 $to = '[EMAIL PROTECTED]';
 $subject = "test!!\n";
 $smtp = Net::SMTP->new($smtp_host, Hello => 'broadcast.com');

 $smtp->mail($from);
 $smtp->to($to);
 $smtp->data();
 $smtp->datasend("From: $from\n");
 $smtp->datasend("To: $to\n");
 $smtp->datasend("Subject: $subject");
 $smtp->datasend("\n");
 $smtp->dataend();
 $smtp->quit;


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




CGI-Perl list

2002-02-26 Thread Naika - EV1

Can someone direct me to the cgi-perl list for beginners? I'm trying to find
it but am unable. If anyone has the subscribe headers for it that will do as
well, thanks.

- naika
  http://www.naikaonline.com
  http://www.triocollective.com




Re: Printing Headers

2002-02-26 Thread Robert Jimenez

Not knowing what your code looks like I will give this a stab.  Since it
is what I am currently learning (reading) .

The syntax that you can use to have your Headers show up at the top are:

# Add this line to your program:

format STDOUT_TOP =
-@||-
$%
-YOUR HEADER---
..

## Here is where you will place your format routine
format STDOUT =
FORMLIST
..


RJ

[EMAIL PROTECTED] wrote:

> I am using format to print to multiple files using a
> while loop and the body writes out to each file fine,
> however the header will not write to the top of each
> file.  The first file is fine then it will skip a few
> and write to another, but not at the top, somewhere in
> the middle and so on until the loop finishes.  How can I
> force the header to print at the top of each file just
> like the body does?
>
> Thanks for your help
>
> --
> 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]




Printing Headers

2002-02-26 Thread slhgkh5

I am using format to print to multiple files using a 
while loop and the body writes out to each file fine, 
however the header will not write to the top of each 
file.  The first file is fine then it will skip a few 
and write to another, but not at the top, somewhere in 
the middle and so on until the loop finishes.  How can I 
force the header to print at the top of each file just 
like the body does?

Thanks for your help

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




Re: Online database with DBMs??

2002-02-26 Thread Jenda Krynicky

From:   "Matt Schaft" <[EMAIL PROTECTED]>
> I am trying to make a linguistic database app. for the web.  As I am
> new to Perl and not a programmer this is proving to be quite a
> challenge.  My original idea was to use Perl's DBMs and a hash of
> arrays that looks like this :
> 
> { phrase1  =>  ["meaning1", "meaning2",..."meaningN","note1",
> "note2",..."noteN"] }
> 
> Everything seems to function fine (I'm still in the offline phase) but
> I get no output when I go to print the hash only the keys come out.

DBMs usualy do not allow storing arrays or anything like that in the 
values. You can only store a simple scalar there.

You will either have to use MLDBM or "serialize" the data yourself. 
For example you could join the "meaning"s using a character that's 
guaranteed to never appear there and store the resulting string in 
the DBM. And then you'll just split the string.

HTH, Jenda


=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
--- me

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




Re: How to declare signed char in Perl?

2002-02-26 Thread Jenda Krynicky

From:   "Philibert" <[EMAIL PROTECTED]>
> I have a problem with a program I did in Perl :
> I use the function system(@args) to launch an external command,
> and then get the exit value : $exit_value = $? >> 8.
> That runs fine, the problem is the exit value can be -1, so
> $exit_value should be a signed char. When the program returns -1, and
> I print $exit_value, I get 255...so I guess either it's an unsigned
> char, or an integer...is there a way to declare ma variable as a
> signed char? Thanks

No there is not.

But if you have a number in a Perl variable and want to treat it's 
lowest byte as a signed int you could use something like this:

sub asSignedChar {
my $x = shift() + 0;
return ( $x & 0x80 ? -(~$x & 0x7F)-1 : $x);
}   

$unsigned = 255;
$signed = asSignedChar($unsigned);

or 

$signed = unpack('c',pack('C',$unsigned));

The pack solution will most probably be quicker.

HTH, Jenda

P.S.: Explanation of code:
my $x = shift() + 0; 
= make sure we are working with a number, 
convert a string containing some numbers to actual 
number if necessary.

$x & 0x80
= If the highest bit of the lowest byte of the variable is set

~$x & 0x7F
= do binary negation of the number and forget everything
except lowest 7 bits

 -(~$x & 0x7F)-1
= change the sign and subtract one



=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
--- me

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




Re: #include or similar

2002-02-26 Thread Jenda Krynicky

> Ok, maybe I should restate the problem.  I have a bunch of scripts
> which have a couple of lines that chuck some configuration stuff into
> some variables.  I'm sick of editing the scripts each time the config
> changes. I realise that I could use a modules and do stuff like:
> 
> $path = &Config::getPath();
> 
> Is there a better way of doing this?

You could store the configuration in INI files and then use one of 
the many modules for reading INI files.

Jenda

=== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain.
I can't find it.
--- me

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




Re: regex to parse HTML files

2002-02-26 Thread Elaine -HFB- Ashton

sachin balsekar [[EMAIL PROTECTED]] quoth:
*>Hi ppl,
*>
*>I have one HTML file per News story...i got to fetch some data (first
*>few lines) out from a HTML file and display it as an abstract for the
*>said story...
*>
*>The HTML file have the following issues...
*>
*>1. There could be a HTML table at the very beginning..(can i strip out
*>the whole table..i mean  ...but may cause probs in
*>nested tables...(trying regex for the same)...
*>
*>2. I need to pick up first 1/2 lines..( i look for a '.' and pickup
*>data) but fails for acronyms/ numbers.. (Ltd. or 5.8% etc)
*>
*>These two issues solved could get the almost thru with the prob..

http://search.cpan.org/search?dist=HTML-Tree

e.

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




Re: using ssh within a perl program

2002-02-26 Thread Elaine -HFB- Ashton

Leon, Yanet I,,DMDCWEST [[EMAIL PROTECTED]] quoth:
*>
*>I have been trying to create a module to ssh among different systems and
*>edit and create different files once I log in the remote system.  I want to
*>ssh into a remote system from system A create and edit different files on
*>the remote system after a successful ssh login.  My subroutines to edit and
*>create the files work great but I cannot ssh into the remote system.  How
*>can I accomplish this (ssh to a remote system) using perl?

http://search.cpan.org/search?dist=Net-SSH

e.

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




Re: Installing Perl Help

2002-02-26 Thread Elaine -HFB- Ashton

Scott E Svendsen [[EMAIL PROTECTED]] quoth:
*>
*>I am currently running perl 5.6.0, I am trying to install 5.6.1 with the
*>-Dusethreads option enabled.  
*>
*>I have read the install file, and followed it to the letter, except using:
*>sh Configure -Dusethreads
*>
*>Then I answer all the questions it gives me and says it is installed.
*>Except there is no indication it did anything.  Doing a perl -v gives me
*>the same old version.  Doign a search doesnt turn up any new 5.6.1
*>folders.

You probably need to type 'make' to build it, 'make test' to check it and
'make install' to install it. If these don't look familiar I can guarantee
you didn't install it.

http://www.cpan.org/misc/cpan-faq.html#How_install_Perl_source

e.

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




Re: KShell / Perl

2002-02-26 Thread Paul Johnson

On Tue, Feb 26, 2002 at 12:22:52PM +0100, Patrice Boisieau wrote:
> Hi,
> I try to load KShell environment files from Perl scripts. In particular, the 
> KShell files export environment variables that the Perl script is unable to 
> get (the %ENV hash is not up to date). The loading is done during the 
> running of the Perl script (for that, I use a call system but it is surely 
> not correct). Do you have a solution to this problem ? Thanks a lot for your 
> answer.

Take a look at http://search.cpan.org/search?dist=Shell-Source

It does just what you want.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

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




RE: Writing file to Windows

2002-02-26 Thread Shaun Fryer

I know this is probably kindergarten to most of you, but if I had to
do it (I only use Unix) and strip all the HTML, I'd simply do the
following.

$url = 'http://domain/path/to/file';
$file = `lynx -dump $url`;
print $file;

===
 Shaun Fryer
===
 London Webmasters
 http://LWEB.NET
 PH:  519-858-9660
 FX:  519-858-9024
===


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




Re: ping

2002-02-26 Thread Peter Scott

At 03:28 PM 2/26/02 +, Lanceo wrote:
>Thanks Peter, that worked great!
>
>If you use http:// in the host address the server cannot be found, though...

Then it's no longer a host name, is it?

>"Peter Scott" <[EMAIL PROTECTED]> wrote in message
>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > At 09:19 AM 2/22/02 +, Lanceo wrote:
> > >Hi,
> > >
> > >I am having difficulty getting the Net::Ping module to work properly.  I
>am
> > >using ActivePerl 5.6.1.631 on a win32 platform.  I can ping a server in a
> > >dos prompt ok, but when I try to get the Perl Net::Ping to work it always
> > >returns a failure.  It seems to ponder over pinging the host for a couple
>of
> > >seconds, and then return a zero as a result, which means that it could
>not
> > >reach the host, if my interpretation of the docs is correct.
> > >
> > >Here is the snippet in question:
> > >
> > >  my ($pingThing, $host, $pingResult);
> > >  $host = 'www.google.com';
> > >   $pingThing = Net::Ping->new("tcp", 1);
> > >   $pingResult = $pingThing->ping($host);
> >
> > I've seen this sooo many times.  The answer: www.google.com responds to
> > ICMP ping packets (which are what the ping program sends) but has chosen
> > (or some router in between has chosen) not to respond to TCP ping packets
> > (which are what Net::Ping sends).  Don't need to be on DOS to find this
> > out, here's Linux:
> >
> > $ ping www.google.com
> > PING www.google.com (216.239.51.100) from 24.67.203.181 : 56(84) bytes of
>data.
> > 64 bytes from www.google.com (216.239.51.100): icmp_seq=0 ttl=52
>time=119.7 ms
> > 64 bytes from www.google.com (216.239.51.100): icmp_seq=1 ttl=52
>time=116.1 ms
> > ^C
> > $ perl -MNet::Ping -le 'print "#5 is alive" if
> > Net::Ping->new->ping("www.google.com")'
> > $
> >
> > Okay, so let's use ICMP packets.  On Unix, we have to be root:
> >
> > $ su
> > Password:
> > # perl -MNet::Ping -le 'print "#5 is alive" if
> > Net::Ping->new("icmp")->ping("www.google.com")'
> > #5 is alive
> >
> > But on DOS, you don't ("security?  what's that"):
> >
> > C:\WINDOWS\Desktop>perl -MNet::Ping -le "print qq(#5 is alive) if
> > Net::Ping->new(qq(icmp))->ping(qq(www.google.com))"
> > #5 is alive

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com


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




using ssh within a perl program

2002-02-26 Thread Leon, Yanet I,,DMDCWEST


I have been trying to create a module to ssh among different systems and
edit and create different files once I log in the remote system.  I want to
ssh into a remote system from system A create and edit different files on
the remote system after a successful ssh login.  My subroutines to edit and
create the files work great but I cannot ssh into the remote system.  How
can I accomplish this (ssh to a remote system) using perl?



-Original Message-
From:   [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
Sent:   Tuesday, February 26, 2002 10:24 AM
To: [EMAIL PROTECTED]
Subject:Minor issues with format()

I see what is happening, I think:  I am writing to a 
separate file each time through the loop and format 
doesn't know that each time through is a different page, 
I think.  Any pointers on how to tell format to print 
the header at the start of each new file would be 
greatly appreciated.

Thanks for your help.

 
> The only problem I have with the following script is it 
> does not print the header information on the first 
> page.  I must have missed something.  
> 
> I would appreciate any comments/suggestions.
> 
> Thanks
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> use constant PATH 
> => "/usr/local/scripts/security/sybase/user/";
> use constant GROUPS => "group_files.doc";
> use constant ACCESS => "user_access_all.doc";
> 
> my $user;
> 
> open F_GROUPS, PATH.GROUPSor die "Can't open:  $!";
> 
> while () {
> chomp(my @field = split /:/);
> 
> open OUT, ">$field[1]"  or die "Can't open:  $!";
> open F_ACCESS, PATH.ACCESSor die "Can't open:  
> $!";
> 
> while () {
> chomp ();
> $user = $_;
> write OUT if (/$field[0]/);
> }
> 
> format OUT_TOP =
> 
> Company Name||
> Report Title|
> 
> Security Group  First Name
> Last Name
> ..
> 
> format OUT = 
> @<<
> $user,
> ..
> 
> 
> 
> close OUT   or die "Can't close:  
> $!";
> close F_ACCESS  or die "Can't close:  
> $!";
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

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

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




Minor issues with format()

2002-02-26 Thread gkhgkh

I see what is happening, I think:  I am writing to a 
separate file each time through the loop and format 
doesn't know that each time through is a different page, 
I think.  Any pointers on how to tell format to print 
the header at the start of each new file would be 
greatly appreciated.

Thanks for your help.

 
> The only problem I have with the following script is it 
> does not print the header information on the first 
> page.  I must have missed something.  
> 
> I would appreciate any comments/suggestions.
> 
> Thanks
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> use constant PATH 
> => "/usr/local/scripts/security/sybase/user/";
> use constant GROUPS => "group_files.doc";
> use constant ACCESS => "user_access_all.doc";
> 
> my $user;
> 
> open F_GROUPS, PATH.GROUPSor die "Can't open:  $!";
> 
> while () {
> chomp(my @field = split /:/);
> 
> open OUT, ">$field[1]"  or die "Can't open:  $!";
> open F_ACCESS, PATH.ACCESSor die "Can't open:  
> $!";
> 
> while () {
> chomp ();
> $user = $_;
> write OUT if (/$field[0]/);
> }
> 
> format OUT_TOP =
> 
> Company Name||
> Report Title|
> 
> Security Group  First Name
> Last Name
> ..
> 
> format OUT = 
> @<<
> $user,
> ..
> 
> 
> 
> close OUT   or die "Can't close:  
> $!";
> close F_ACCESS  or die "Can't close:  
> $!";
> 
> -- 
> 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]




Minor issues with format()

2002-02-26 Thread gkhgkh

The only problem I have with the following script is it 
does not print the header information on the first 
page.  I must have missed something.  

I would appreciate any comments/suggestions.

Thanks

#!/usr/bin/perl -w

use strict;

use constant PATH 
=> "/usr/local/scripts/security/sybase/user/";
use constant GROUPS => "group_files.doc";
use constant ACCESS => "user_access_all.doc";

my $user;

open F_GROUPS, PATH.GROUPSor die "Can't open:  $!";

while () {
chomp(my @field = split /:/);

open OUT, ">$field[1]"  or die "Can't open:  $!";
open F_ACCESS, PATH.ACCESSor die "Can't open:  
$!";

while () {
chomp ();
$user = $_;
write OUT if (/$field[0]/);
}

format OUT_TOP =

Company Name||
Report Title|

Security Group  First Name
Last Name
..

format OUT = 
@<<
$user,
..



close OUT   or die "Can't close:  
$!";
close F_ACCESS  or die "Can't close:  
$!";

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




RE: ping

2002-02-26 Thread Timothy Johnson


I was referring to the other suggestions offered in this thread, but if the
servers are yours then you should be able to get around the ping problem I
was talking about.

-Original Message-
From: Lanceo [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 26, 2002 7:31 AM
To: [EMAIL PROTECTED]
Subject: Re: ping


What other methods?

I am trying to see if a server is alive and reachable.   Often our servers
will respond to a ping, but IIS has fallen over or there is some problem
that stops pages from being served.

So right now I have two tools to use - Ping, and fetching a page from the
server and comparing it to a previous good one stored in the database.  More
methods would be good to know...



"Timothy Johnson" <[EMAIL PROTECTED]> wrote in message
C0FD5BECE2F0C84EAA97D7300A500D5002580FB9@SMILEY">news:C0FD5BECE2F0C84EAA97D7300A500D5002580FB9@SMILEY...
>
> I had the same problem at first, but I've found that if you want the
> Net::Ping module to work on a Win32 platform, you might have better luck
> sticking to the ICMP protocol (which is what your command-line ping is
> using).  Something like this usually works for me:
>
> my $p = Net::Ping->new('icmp',2);
> foreach(@clients){
>if($p->ping($_) == 1){
>   print "$_ is alive.\n";
>}else{
>   print "$_ is not responding!\n";
>}
> }
>
> Here's the catch, though.  You should use one of the other methods to find
> out whether an Internet host is alive because many of them have their
> servers set to not respond to ping requests from the outside.
>
>
> -Original Message-
> From: Lanceo
> To: [EMAIL PROTECTED]
> Sent: 2/22/02 1:19 AM
> Subject: ping
>
> Hi,
>
> I am having difficulty getting the Net::Ping module to work properly.  I
> am
> using ActivePerl 5.6.1.631 on a win32 platform.  I can ping a server in
> a
> dos prompt ok, but when I try to get the Perl Net::Ping to work it
> always
> returns a failure.  It seems to ponder over pinging the host for a
> couple of
> seconds, and then return a zero as a result, which means that it could
> not
> reach the host, if my interpretation of the docs is correct.
>
> Here is the snippet in question:
>
>  my ($pingThing, $host, $pingResult);
>  $host = 'www.google.com';
>   $pingThing = Net::Ping->new("tcp", 1);
>   $pingResult = $pingThing->ping($host);
>
>   print "$pingResult\n";
>  if($pingResult == 1){print "$host is alive.\n";}
>  else{print "$host could not be pinged\n";}
>
>  $pingThing->close();
>
> Am I doing something wrong here, or do I need some other module that I
> am
> unaware of?  I find this sort of bizarre, as I have LWP doing a
> successful
> page fetch, so the module can obviously access the web.
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.325 / Virus Database: 182 - Release Date: 2/20/02
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> --
--
> This email may contain confidential and privileged
> material for the sole use of the intended recipient.
> If you are not the intended recipient, please contact
> the sender and delete all copies.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.325 / Virus Database: 182 - Release Date: 2/19/02



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




This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

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




Perl-CGI-script for communication via webserver Thttpd

2002-02-26 Thread Hein ten Rouwelaar

Hi,

I am a newbe in Perl. I installed the webserversoftware thttpd-2.20b-4 on a
RedHat Linux 7.1 host (hostname "linux"). Browser on client 200.1.1.5.

Now I wrote the html page below which calls the perl script printed below
again.

The query displays nice on my browser (IE5.0)and I can submit the answers.
Now one would expect the output of the perl-cgi script to be displayed by
the browser. But nothing whatsoever is send to the browser at all.

The logging from the webserver (thttpd) shows the GET . message from the
submit is received from the browser. The webscreen on the browser is blanked
and that's it.

The directory cgi-bin is a subdirectory of my homedir which is laso the
current workingdir of the webserver.
The modebits of the htmlpage are 644 and of the perl-cgi script 755. The
directory has 755.

Has anybody any guess what I am missing here ???

HTML page

Guestbook

Fill in please


Age: 
Length: 

 



Perl-CGI script

#!/usr/bin/perl

use CGI qw/:cgi/;

$Lt = param("Age");
print header();
print p("Your age is $Lt");


Thttpd logging

200.1.1.5 - - [25/Feb/2002:21:45:22 +0100] "HEAD /guest.html HTTP/1.1" 304
279 "" "Mozilla/4.0 (compatible; MSIE 5.0; Windows 95; DigExt)"
200.1.1.5 - - [25/Feb/2002:21:45:30 +0100] "GET
/cgi-bin/guest.pl?Age=55&Length=88 HTTP/1.1" 200 5
"http://linux/guest.html"; "Mozilla/4.0 (compatible; MSIE 5.0; Windows 95;
DigExt)"





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




Re: How to declare signed char in Perl?

2002-02-26 Thread Pierre Philibert

the code where I print it is :

.
.
.
elsif ($valeur_exit == -1)
{
$scripts_fatal[$#scripts_fatal + 1] = "$msgs_xml{'err_sw_sev'}.
Script : @args_sw[1], (code retour : $valeur_exit)";
}
else
{
$scripts_fatal[$#scripts_fatal + 1] = "$msgs_xml{'err_sw_sev'}.
Script : @args_sw[1], (code retour : $valeur_exit)";
}
.
.
.

when the exit value of the program is -1, $valeur_exit get the value 255 so
it allways goes in the else{} part. I thought there was a way to explicitly
declare $valeur_exit as a 1 byte signed value, but i didn't found it...I
looked
on the net, and found the function pack() which should solve my problem
but didn't get it to work...I know I could do some bit manipulation to walk
around
this problem, but thought there may be a "clean" way to do it. Or maybe
I just missed something obvious :) (It's my 2nd program in Perl)


Walter Valenti <[EMAIL PROTECTED]> a écrit dans le message :
[EMAIL PROTECTED]
> Where you print $exit_value ???
>
> >Hi,
> >I have a problem with a program I did in Perl :
> >I use the function system(@args) to launch an external command,
> >and then get the exit value : $exit_value = $? >> 8.
> >That runs fine, the problem is the exit value can be -1, so $exit_value
> >should be a signed char. When the program returns -1, and I print
> >$exit_value, I get 255...so I guess either it's an unsigned char, or an
> >integer...is there a way to declare ma variable as a signed char?
> >Thanks




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




Re: How to declare signed char in Perl?

2002-02-26 Thread walter valenti

Where you print $exit_value ???

>Hi,
>I have a problem with a program I did in Perl :
>I use the function system(@args) to launch an external command,
>and then get the exit value : $exit_value = $? >> 8.
>That runs fine, the problem is the exit value can be -1, so $exit_value
>should be a signed char. When the program returns -1, and I print
>$exit_value, I get 255...so I guess either it's an unsigned char, or an
>integer...is there a way to declare ma variable as a signed char?
>Thanks
>
>
>
>




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




RE: sort order of hash keys

2002-02-26 Thread Wagner-David

When you say, you can't use the sort routine directly, waht do you mean? You 
can sort the keys  in every color of the rainbow if necessary. Are you after the way 
they were inputted or do you have a sort sequence that you are really after?

Wags ;)

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 26, 2002 03:37
To: [EMAIL PROTECTED]
Subject: Re: sort order of hash keys


yeah, i new this was tricky.

my hash keys / values have uneven names so i cant use a sort routine directly. thats 
why i would like to get the key / values in the same order as they are in the 
hashtable file.

whats the name of that hash modules?

:o)

martin


On Tue, Feb 26, 2002 at 10:28:16AM -, John Edwards wrote:
> hash keys are stored unsorted. If you have the following hash
> 
> %test = ( one => 1,
>   two => 2,
>   three => 3);
> 
> and print out the hash key/value pairs.
> 
> foreach $key (keys %test) {
>   print "$key is $test{$key}\n";
> }
> 
> you will find they don't come out in the same order as they were stored.
> 
> You can perform a sort on the keys to arrange them in order
> 
> foreach $key (sort keys %test) {
>   print "$key is $test{$key}\n";
> }
> 
> or you can reverse the hash, making the values the keys, and sort on the new
> keys
> 
> %reversed = reverse %test;
> 
> foreach $key (keys %reversed) {
>   print "$key is $reversed{$key}\n";
> }
> 
> In doing this though, you must be aware that you will lose any data that has
> identical values. For example
> 
> %test = ( one => 1,
>   two => 2,
>   three => 3,
>   alpha => 1,
>   beta => 2,
>   gamma => 3);
> 
> %reversed = reverse %test;
> 
> foreach $key (keys %reversed) {
>   print "$key is $reversed{$key}\n";
> }
> 
> will print out
> 
> 1 is one
> 2 is two
> 3 is three
> 
> There is probably another/better way of doing this using the comparison
> operator <=>, but I don't know it. There is also a module available that
> lets you store and retrieve hashes in a fixed order.
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: 26 February 2002 09:16
> To: [EMAIL PROTECTED]
> Subject: sort order of hash keys
> 
> 
> hi
> 
> 
> i would like to know if theres a smart way to unwind a hashtable so that
> the key / value pairs comes out in the same order as they are in the table.
> 
> :o)
> 
> martin
> -- 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> --Confidentiality--.
> This E-mail is confidential.  It should not be read, copied, disclosed or
> used by any person other than the intended recipient.  Unauthorised use,
> disclosure or copying by whatever medium is strictly prohibited and may be
> unlawful.  If you have received this E-mail in error please contact the
> sender immediately and delete the E-mail from your system.
> 
> 

-- 

-- 
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: unique elements in array

2002-02-26 Thread Jeff 'japhy' Pinyan

On Feb 26, Simon K. Chan said:

>The solution to my question is probably dead easy, but the bioperl
>module I'm working on right now has sucked up all by brain juice! ;-)
>
>Let's say I have this array:
>
>@food = qw(milk ham eggs bread eggs milk);
>
>How can I write a script that sticks all UNIQUE elements (occurs only once) into 
>another array?
>So, in the above case, @another_array would receive "ham" and "bread"

You'll want to use a hash:

  $count{$_}++ for @food;
  @unique = grep $count{$_} == 1, keys %count;

Hashes are the answer to many questions.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




unique elements in array

2002-02-26 Thread Simon K. Chan

Hi All,

The solution to my question is probably dead easy, but the bioperl module I'm working 
on right now
has sucked up all by brain juice! ;-)

Let's say I have this array:

@food = qw(milk ham eggs bread eggs milk);

How can I write a script that sticks all UNIQUE elements (occurs only once) into 
another array?
So, in the above case, @another_array would receive "ham" and "bread"

Many thanks for your time, Everybody!

=
#

Warmest Regards,
Simon K. Chan - [EMAIL PROTECTED]

"Great spirits have always encountered violent opposition from mediocre minds."  - 
Albert Einstein

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

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




RE: sort order of hash keys

2002-02-26 Thread Jeff 'japhy' Pinyan

On Feb 26, Richard Smith said:

>Try the fields module.  This sounds like an ideal place to use a pseudo-hash

EWWW.  Pseudo-hashes were a blight on Perl.  They slowed things down all
over the place.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




RE: sort order of hash keys

2002-02-26 Thread Richard Smith

Try the fields module.  This sounds like an ideal place to use a pseudo-hash

Thanx,
Smiddy
..


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




Re: ping

2002-02-26 Thread Lanceo

What other methods?

I am trying to see if a server is alive and reachable.   Often our servers
will respond to a ping, but IIS has fallen over or there is some problem
that stops pages from being served.

So right now I have two tools to use - Ping, and fetching a page from the
server and comparing it to a previous good one stored in the database.  More
methods would be good to know...



"Timothy Johnson" <[EMAIL PROTECTED]> wrote in message
C0FD5BECE2F0C84EAA97D7300A500D5002580FB9@SMILEY">news:C0FD5BECE2F0C84EAA97D7300A500D5002580FB9@SMILEY...
>
> I had the same problem at first, but I've found that if you want the
> Net::Ping module to work on a Win32 platform, you might have better luck
> sticking to the ICMP protocol (which is what your command-line ping is
> using).  Something like this usually works for me:
>
> my $p = Net::Ping->new('icmp',2);
> foreach(@clients){
>if($p->ping($_) == 1){
>   print "$_ is alive.\n";
>}else{
>   print "$_ is not responding!\n";
>}
> }
>
> Here's the catch, though.  You should use one of the other methods to find
> out whether an Internet host is alive because many of them have their
> servers set to not respond to ping requests from the outside.
>
>
> -Original Message-
> From: Lanceo
> To: [EMAIL PROTECTED]
> Sent: 2/22/02 1:19 AM
> Subject: ping
>
> Hi,
>
> I am having difficulty getting the Net::Ping module to work properly.  I
> am
> using ActivePerl 5.6.1.631 on a win32 platform.  I can ping a server in
> a
> dos prompt ok, but when I try to get the Perl Net::Ping to work it
> always
> returns a failure.  It seems to ponder over pinging the host for a
> couple of
> seconds, and then return a zero as a result, which means that it could
> not
> reach the host, if my interpretation of the docs is correct.
>
> Here is the snippet in question:
>
>  my ($pingThing, $host, $pingResult);
>  $host = 'www.google.com';
>   $pingThing = Net::Ping->new("tcp", 1);
>   $pingResult = $pingThing->ping($host);
>
>   print "$pingResult\n";
>  if($pingResult == 1){print "$host is alive.\n";}
>  else{print "$host could not be pinged\n";}
>
>  $pingThing->close();
>
> Am I doing something wrong here, or do I need some other module that I
> am
> unaware of?  I find this sort of bizarre, as I have LWP doing a
> successful
> page fetch, so the module can obviously access the web.
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.325 / Virus Database: 182 - Release Date: 2/20/02
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> --
--
> This email may contain confidential and privileged
> material for the sole use of the intended recipient.
> If you are not the intended recipient, please contact
> the sender and delete all copies.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.325 / Virus Database: 182 - Release Date: 2/19/02



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




Re: ping

2002-02-26 Thread Lanceo

Thanks Peter, that worked great!

If you use http:// in the host address the server cannot be found, though...

"Peter Scott" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> At 09:19 AM 2/22/02 +, Lanceo wrote:
> >Hi,
> >
> >I am having difficulty getting the Net::Ping module to work properly.  I
am
> >using ActivePerl 5.6.1.631 on a win32 platform.  I can ping a server in a
> >dos prompt ok, but when I try to get the Perl Net::Ping to work it always
> >returns a failure.  It seems to ponder over pinging the host for a couple
of
> >seconds, and then return a zero as a result, which means that it could
not
> >reach the host, if my interpretation of the docs is correct.
> >
> >Here is the snippet in question:
> >
> >  my ($pingThing, $host, $pingResult);
> >  $host = 'www.google.com';
> >   $pingThing = Net::Ping->new("tcp", 1);
> >   $pingResult = $pingThing->ping($host);
>
> I've seen this sooo many times.  The answer: www.google.com responds to
> ICMP ping packets (which are what the ping program sends) but has chosen
> (or some router in between has chosen) not to respond to TCP ping packets
> (which are what Net::Ping sends).  Don't need to be on DOS to find this
> out, here's Linux:
>
> $ ping www.google.com
> PING www.google.com (216.239.51.100) from 24.67.203.181 : 56(84) bytes of
data.
> 64 bytes from www.google.com (216.239.51.100): icmp_seq=0 ttl=52
time=119.7 ms
> 64 bytes from www.google.com (216.239.51.100): icmp_seq=1 ttl=52
time=116.1 ms
> ^C
> $ perl -MNet::Ping -le 'print "#5 is alive" if
> Net::Ping->new->ping("www.google.com")'
> $
>
> Okay, so let's use ICMP packets.  On Unix, we have to be root:
>
> $ su
> Password:
> # perl -MNet::Ping -le 'print "#5 is alive" if
> Net::Ping->new("icmp")->ping("www.google.com")'
> #5 is alive
>
> But on DOS, you don't ("security?  what's that"):
>
> C:\WINDOWS\Desktop>perl -MNet::Ping -le "print qq(#5 is alive) if
> Net::Ping->new(qq(icmp))->ping(qq(www.google.com))"
> #5 is alive
>
>
> --
> Peter Scott
> Pacific Systems Design Technologies
> http://www.perldebugged.com
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.325 / Virus Database: 182 - Release Date: 2/19/02



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




Re: Help with | in regex...

2002-02-26 Thread Jeff 'japhy' Pinyan

On Feb 26, Paul Farley said:

>I'm trying to use a regex to match a passed value.  I'm trying to use an or
>between the patterns, and it needs to be case insensitive.
>I've tried it two ways, and it doesn't seem to work either way completely.

>if($ep =~ /^rglyc[12345] |^rglyd[235678] | ^rglyf3 | ^rglyg6 | ^rglyt5 |
>^rglyu1/i)

Uh... do you MEAN to have those spaces in there?  I have a feeling they're
killing your regex.  For example, how could / ^foo/ EVER match?  How can
you match a " " before the beginning of the string?

If you want to use whitespace in your regex for mere spacing, use the /x
modifier.

  if (/ ^foo | ^bar | ^blat /x) { ... }

Your regex can be shortened a bit, too.  No sense in matching the SAME
leading string OVER and OVER again:

  if ($ep =~ /^rgly(c[12345]|d[235678]|f3|g6|t5|u1)/i) { ... }

>{
>   $org="LYX";
>subscription($ep,$pr,$sub,$org,$plat);
>}
>   elsif ($ep =~ /^rglyv[34567] | ^rglyw[79]/i )

  elsif ($ep =~ /^rgly(v[34567]|w[79])/i) { ... }

>{
>   $org="LYP";
>subscription($ep,$pr,$sub,$org,$plat);
>}

>if($ep =~ /^rglyc[12345]/i |/^rglyd[235678]/i | /^rglyf3/i | /^rglyg6/i |
>/^rglyt5/i | /^rglyu1/i)

This method breaks because only the first regex is executed on $ep; all
the others work on $_.  And you're using BITWISE "OR", not logical "OR".

  if ($ep =~ /foo/ || $ep =~ /bar/ || ... ) { ... }

But then you have to write lots of code, and you're executing LOTS of
regexes.  Icky.

>1. How do I do an "or" in a regex if statement like this?
>2. Is there a better(more efficient) way to do this? (I know that's a loaded
>question to a perl list. )

See above.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




RE: Reg Exp help

2002-02-26 Thread Jeff 'japhy' Pinyan

On Feb 26, Daryl J. Hoyt said:

>If there is only one of the lines |GRP| this will work. Otherwise I would
>push the lines into a an array instead of a variable.
>
>@Out = `$Cmd`;
>$WhatFollowsGRP = "";
>
>foreach my $line (@Out)
>{
>   if($line =~ /|GRP|/)

You need to escape those |'s.  They're special to a regex.

>   {
>   $line =~ s/|GRP|//;

Whenever I see if (/foo/) { s/foo//; ... }, I suggest it be shortened to
if (s/foo//) { ... }  It's less work.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




Re: Reg Exp help

2002-02-26 Thread Jeff 'japhy' Pinyan

On Feb 26, Busse, Rich said:

>   $Out = `$Cmd` ;
>
>The output always looks like:
>
>List of Templates and Template Groups assigned to 'somenode.us.dnb.com':
>
>|GRP| SBS-DSM
>
>Operation successfully completed.
>
>It's always on 5 separate lines. How do I extract what follows |GRP| on the
>third line to a variable? TIA...

You could use this:

  ($text) = `$Cmd` =~ /^\|GRP\|\s*(.*)/m;

Let me expand that regex for you:

  m{
^# the start of a "line"
\|GRP\|  # the text '|GRP'
\s*  # any whitespace following it
(.*) # the rest of the line (non-newline characters)
  }m # make ^ match at the beginning of a "line"

You could also use

  `$Cmd` =~ /\n\|GRP\|\s*(.*)/;

which works almost exactly the same way.

Or, if you know it'll always be the third line...

  ($text) = (`$Cmd`)[2] =~ /\|GRP\|\s*(.*)/;

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




Help with | in regex...

2002-02-26 Thread Paul Farley

I'm trying to use a regex to match a passed value.  I'm trying to use an or
between the patterns, and it needs to be case insensitive.
I've tried it two ways, and it doesn't seem to work either way completely.

1st example:

if($ep =~ /^rglyc[12345] |^rglyd[235678] | ^rglyf3 | ^rglyg6 | ^rglyt5 |
^rglyu1/i)
{
   $org="LYX";
subscription($ep,$pr,$sub,$org,$plat);
}
   elsif ($ep =~ /^rglyv[34567] | ^rglyw[79]/i )
{
   $org="LYP";
subscription($ep,$pr,$sub,$org,$plat);
}

and:

if($ep =~ /^rglyc[12345]/i |/^rglyd[235678]/i | /^rglyf3/i | /^rglyg6/i |
/^rglyt5/i | /^rglyu1/i)
{
   $org="WRALC.LYX";
subscription($ep,$pr,$sub,$org,$plat);
}
   elsif ($ep =~ /^rglyv[34567]/i | /^rglyw[79]/i )
{
   $org="WRALC.LYP";
subscription($ep,$pr,$sub,$org,$plat);
}

Two questions:

1. How do I do an "or" in a regex if statement like this?
2. Is there a better(more efficient) way to do this? (I know that's a loaded
question to a perl list. )

-Paul



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




RE: Reg Exp help

2002-02-26 Thread Daryl J. Hoyt

If there is only one of the lines |GRP| this will work. Otherwise I would
push the lines into a an array instead of a variable.

@Out = `$Cmd`;
$WhatFollowsGRP = "";

foreach my $line (@Out)
{
if($line =~ /|GRP|/)
{
$line =~ s/|GRP|//;
$WhatFollowsGRP = $line;
}# end if
}# end foreach loop

Daryl J. Hoyt
Performance Engineer
Geodesic Systems
312-832-2010





-Original Message-
From: Busse, Rich [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 26, 2002 8:35 AM
To: Perl Beginners
Subject: Reg Exp help


I am capturing the output of a command in a string:

$Out = `$Cmd` ;

The output always looks like:

List of Templates and Template Groups assigned to 'somenode.us.dnb.com':

|GRP| SBS-DSM

Operation successfully completed.

It's always on 5 separate lines. How do I extract what follows |GRP| on the
third line to a variable? TIA...

--
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 format()

2002-02-26 Thread William.Ampeh


#!/opt/local/bin/perl

$CUR_TIME=`date "+%B-%Y"`;
$TITLE="Annual Report on Car Sales";

select ("STDOUT");

$~ = STDOUT;
for ($i = 1; $i <10; $i++) {

   $color = "Red";
   if ( $i % 2 ) { $color = "Blue"};

   $col1 = "${color}_car_col_1";
   $col2 = "${color}_car_col_2";
   $col3 = "${color}_car_col_3";
   $col4 = "${color}_car_col_4";

   write STDOUT;

   if ( $i % 5 == 0 ) {
  $~ = STDOUT_BLANK;  write STDOUT_BLANK;
  $~ = STDOUT;
   }
}

$~ = STDOUT_BOTTOM; write;

#---  OUTPUT FORMAT BEGINS HERE ---

format STDOUT =
   @<<@> @<<<
@|
$col1, $col2, $col3, $col4

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




Reg Exp help

2002-02-26 Thread Busse, Rich

I am capturing the output of a command in a string:

$Out = `$Cmd` ;

The output always looks like:

List of Templates and Template Groups assigned to 'somenode.us.dnb.com':

|GRP| SBS-DSM

Operation successfully completed.

It's always on 5 separate lines. How do I extract what follows |GRP| on the
third line to a variable? TIA...

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




Re: KShell / Perl

2002-02-26 Thread William.Ampeh


Remember, a child process inherits the variables exported by the parent,
and not the other way around.

So this what I do:

export foo="la", bar="bar", koobi="momoni"

then in your Perl script, you have read in these variables
as:

#!/opt/local/bin/perl

my $aa = $ENV{foo};
my $bb = $ENV{bar};
my $cc = $ENV{koobi};

print "\n foo = $aa, bar = $bb, koobi=$cc\n\n";


__

William Ampeh (x3939)
Federal Reserve Board


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




Re: sort order of hash keys

2002-02-26 Thread Jeff 'japhy' Pinyan

On Feb 26, Martin A. Hansen said:

>i would like to know if theres a smart way to unwind a hashtable so that
>the key / value pairs comes out in the same order as they are in the table.

What "table"?  If you'd like a hash to stay in the order you CREATED it
in, use the Tie::IxHash module.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




Re: Can you manually update @INC

2002-02-26 Thread Chas Owens

It's my fault for not being more specific.  use lib is a Perl pragma
(like use strict and use warnings).  Here is the relevant perldoc:


NAME
   lib - manipulate @INC at compile time

SYNOPSIS
   use lib LIST;

   no lib LIST;


DESCRIPTION
   This is a small simple module which simplifies the manipu­
   lation of @INC at compile time.

   It is typically used to add extra directories to perl's
   search path so that later "use" or "require" statements
   will find modules which are not located on perl's default
   search path.

   Adding directories to @INC

   The parameters to "use lib" are added to the start of the
   perl search path. Saying

   use lib LIST;

   is almost the same as saying

   BEGIN { unshift(@INC, LIST) }

   For each directory in LIST (called $dir here) the lib mod­
   ule also checks to see if a directory called $dir/$arch­
   name/auto exists.  If so the $dir/$archname directory is
   assumed to be a corresponding architecture specific direc­
   tory and is added to @INC in front of $dir.

   To avoid memory leaks, all trailing duplicate entries in
   @INC are removed.

   Deleting directories from @INC

   You should normally only add directories to @INC.  If you
   need to delete directories from @INC take care to only
   delete those which you added yourself or which you are
   certain are not needed by other modules in your script.
   Other modules may have added directories which they need
   for correct operation.

   The "no lib" statement deletes all instances of each named
   directory from @INC.

   For each directory in LIST (called $dir here) the lib mod­
   ule also checks to see if a directory called $dir/$arch­
   name/auto exists.  If so the $dir/$archname directory is
   assumed to be a corresponding architecture specific direc­
   tory and is also deleted from @INC.

   Restoring original @INC

   When the lib module is first loaded it records the current
   value of @INC in an array "@lib::ORIG_INC". To restore
   @INC to that value you can say

   @INC = @lib::ORIG_INC;


SEE ALSO
   FindBin - optional module which deals with paths relative
   to the source file.

AUTHOR
   Tim Bunce, 2nd June 1995.

On Tue, 2002-02-26 at 08:02, Dermot Paikkos wrote:
> Sorry for my ignorance but do you mean putting "use lib 
> '/usr/lib/perl5/site_perl" in my perl script? Or into the httpd.conf?
> 
> If it's that latter, where in the conf file would I put it?
> 
> Sorry to harp on.
> Dp.
> 
> 
> On 26 Feb 2002 at 7:49, Chas Owens wrote:
> 
> > use lib '/usr/lib/perl5/site_perl/'; 
> > 
> > will put it at the head of the lib search path.
> > 
> > On Tue, 2002-02-26 at 06:59, Dermot Paikkos wrote:
> > > Hi gurus,
> > > 
> > > I am trying to get mod_perl installed - yes I am about to get
> > > serious with perl - and have hit a very small snag.
> > > 
> > > Apache will not re-start because there is a missing module, AuthDBI.
> > > However the module is installed, it is located at:
> > > /usr/lib/perl5/site_perl/Apache/AuthDBI.pm
> > > 
> > > But it is looking for it in:
> > > Can't locate AuthDBI.pm in @INC (@INC contains: 
> > > /usr/lib/perl5/i386-linux /usr/lib/perl5
> > > /usr/lib/perl5/site_perl/i386- linux /usr/lib/perl5/site_perl
> > > /usr/lib/perl5/site_perl . /usr/ /usr/lib/perl) at (eval 23) line 3.
> > > 
> > > The location is not listed. How can I get the above path into @INC?
> > > 
> > > I hope that was clear.
> > > Thanx.
> > > Dp.
> > > 
> > > ~~
> > > Dermot Paikkos * [EMAIL PROTECTED]
> > > Network Administrator @ Science Photo Library
> > > Phone: 0207 432 1100 * Fax: 0207 286 8668
> > > 
> > > 
> > > -- 
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > -- 
> > Today is Boomtime the 57th day of Chaos in the YOLD 3168
> > This statement is false.
> > 
> > Missile Address: 33:48:3.521N  84:23:34.786W
> > 
> > 
> 
> 
> ~~
> Dermot Paikkos * [EMAIL PROTECTED]
> Network Administrator @ Science Photo Library
> Phone: 0207 432 1100 * Fax: 0207 286 8668
-- 
Today is Boomtime the 57th day of Chaos in the YOLD 3168
You are what you see.

Missile Address: 33:48:3.521N  84:23:34.786W


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




Re: Can you manually update @INC

2002-02-26 Thread Chas Owens

use lib '/usr/lib/perl5/site_perl/'; 

will put it at the head of the lib search path.

On Tue, 2002-02-26 at 06:59, Dermot Paikkos wrote:
> Hi gurus,
> 
> I am trying to get mod_perl installed - yes I am about to get serious 
> with perl - and have hit a very small snag.
> 
> Apache will not re-start because there is a missing module, AuthDBI. 
> However the module is installed, it is located at:
> /usr/lib/perl5/site_perl/Apache/AuthDBI.pm
> 
> But it is looking for it in:
> Can't locate AuthDBI.pm in @INC (@INC contains: 
> /usr/lib/perl5/i386-linux /usr/lib/perl5 /usr/lib/perl5/site_perl/i386-
> linux /usr/lib/perl5/site_perl /usr/lib/perl5/site_perl . /usr/ 
> /usr/lib/perl) at (eval 23) line 3.
> 
> The location is not listed. How can I get the above path into @INC?
> 
> I hope that was clear.
> Thanx.
> Dp.
> 
> ~~
> Dermot Paikkos * [EMAIL PROTECTED]
> Network Administrator @ Science Photo Library
> Phone: 0207 432 1100 * Fax: 0207 286 8668
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
-- 
Today is Boomtime the 57th day of Chaos in the YOLD 3168
This statement is false.

Missile Address: 33:48:3.521N  84:23:34.786W


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




Can you manually update @INC

2002-02-26 Thread Dermot Paikkos

Hi gurus,

I am trying to get mod_perl installed - yes I am about to get serious 
with perl - and have hit a very small snag.

Apache will not re-start because there is a missing module, AuthDBI. 
However the module is installed, it is located at:
/usr/lib/perl5/site_perl/Apache/AuthDBI.pm

But it is looking for it in:
Can't locate AuthDBI.pm in @INC (@INC contains: 
/usr/lib/perl5/i386-linux /usr/lib/perl5 /usr/lib/perl5/site_perl/i386-
linux /usr/lib/perl5/site_perl /usr/lib/perl5/site_perl . /usr/ 
/usr/lib/perl) at (eval 23) line 3.

The location is not listed. How can I get the above path into @INC?

I hope that was clear.
Thanx.
Dp.

~~
Dermot Paikkos * [EMAIL PROTECTED]
Network Administrator @ Science Photo Library
Phone: 0207 432 1100 * Fax: 0207 286 8668


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




RE: sort order of hash keys

2002-02-26 Thread John Edwards

This maybe...

Tie::LLHash.pm

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 26 February 2002 11:37
To: [EMAIL PROTECTED]
Subject: Re: sort order of hash keys


yeah, i new this was tricky.

my hash keys / values have uneven names so i cant use a sort routine
directly. thats why i would like to get the key / values in the same order
as they are in the hashtable file.

whats the name of that hash modules?

:o)

martin


On Tue, Feb 26, 2002 at 10:28:16AM -, John Edwards wrote:
> hash keys are stored unsorted. If you have the following hash
> 
> %test = ( one => 1,
>   two => 2,
>   three => 3);
> 
> and print out the hash key/value pairs.
> 
> foreach $key (keys %test) {
>   print "$key is $test{$key}\n";
> }
> 
> you will find they don't come out in the same order as they were stored.
> 
> You can perform a sort on the keys to arrange them in order
> 
> foreach $key (sort keys %test) {
>   print "$key is $test{$key}\n";
> }
> 
> or you can reverse the hash, making the values the keys, and sort on the
new
> keys
> 
> %reversed = reverse %test;
> 
> foreach $key (keys %reversed) {
>   print "$key is $reversed{$key}\n";
> }
> 
> In doing this though, you must be aware that you will lose any data that
has
> identical values. For example
> 
> %test = ( one => 1,
>   two => 2,
>   three => 3,
>   alpha => 1,
>   beta => 2,
>   gamma => 3);
> 
> %reversed = reverse %test;
> 
> foreach $key (keys %reversed) {
>   print "$key is $reversed{$key}\n";
> }
> 
> will print out
> 
> 1 is one
> 2 is two
> 3 is three
> 
> There is probably another/better way of doing this using the comparison
> operator <=>, but I don't know it. There is also a module available that
> lets you store and retrieve hashes in a fixed order.
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: 26 February 2002 09:16
> To: [EMAIL PROTECTED]
> Subject: sort order of hash keys
> 
> 
> hi
> 
> 
> i would like to know if theres a smart way to unwind a hashtable so that
> the key / value pairs comes out in the same order as they are in the
table.
> 
> :o)
> 
> martin
> -- 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> --Confidentiality--.
> This E-mail is confidential.  It should not be read, copied, disclosed or
> used by any person other than the intended recipient.  Unauthorised use,
> disclosure or copying by whatever medium is strictly prohibited and may be
> unlawful.  If you have received this E-mail in error please contact the
> sender immediately and delete the E-mail from your system.
> 
> 

-- 

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


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



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




Re: sort order of hash keys

2002-02-26 Thread Martin A. Hansen

yeah, i new this was tricky.

my hash keys / values have uneven names so i cant use a sort routine directly. thats 
why i would like to get the key / values in the same order as they are in the 
hashtable file.

whats the name of that hash modules?

:o)

martin


On Tue, Feb 26, 2002 at 10:28:16AM -, John Edwards wrote:
> hash keys are stored unsorted. If you have the following hash
> 
> %test = ( one => 1,
>   two => 2,
>   three => 3);
> 
> and print out the hash key/value pairs.
> 
> foreach $key (keys %test) {
>   print "$key is $test{$key}\n";
> }
> 
> you will find they don't come out in the same order as they were stored.
> 
> You can perform a sort on the keys to arrange them in order
> 
> foreach $key (sort keys %test) {
>   print "$key is $test{$key}\n";
> }
> 
> or you can reverse the hash, making the values the keys, and sort on the new
> keys
> 
> %reversed = reverse %test;
> 
> foreach $key (keys %reversed) {
>   print "$key is $reversed{$key}\n";
> }
> 
> In doing this though, you must be aware that you will lose any data that has
> identical values. For example
> 
> %test = ( one => 1,
>   two => 2,
>   three => 3,
>   alpha => 1,
>   beta => 2,
>   gamma => 3);
> 
> %reversed = reverse %test;
> 
> foreach $key (keys %reversed) {
>   print "$key is $reversed{$key}\n";
> }
> 
> will print out
> 
> 1 is one
> 2 is two
> 3 is three
> 
> There is probably another/better way of doing this using the comparison
> operator <=>, but I don't know it. There is also a module available that
> lets you store and retrieve hashes in a fixed order.
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: 26 February 2002 09:16
> To: [EMAIL PROTECTED]
> Subject: sort order of hash keys
> 
> 
> hi
> 
> 
> i would like to know if theres a smart way to unwind a hashtable so that
> the key / value pairs comes out in the same order as they are in the table.
> 
> :o)
> 
> martin
> -- 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> --Confidentiality--.
> This E-mail is confidential.  It should not be read, copied, disclosed or
> used by any person other than the intended recipient.  Unauthorised use,
> disclosure or copying by whatever medium is strictly prohibited and may be
> unlawful.  If you have received this E-mail in error please contact the
> sender immediately and delete the E-mail from your system.
> 
> 

-- 

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




KShell / Perl

2002-02-26 Thread Patrice Boisieau

Hi,
I try to load KShell environment files from Perl scripts. In particular, the 
KShell files export environment variables that the Perl script is unable to 
get (the %ENV hash is not up to date). The loading is done during the 
running of the Perl script (for that, I use a call system but it is surely 
not correct). Do you have a solution to this problem ? Thanks a lot for your 
answer.
Patrice


_
MSN Photos est le moyen le plus simple de partager, modifier et imprimer vos 
photos préférées. http://photos.msn.fr/Support/WorldWide.aspx


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




RE: sort order of hash keys

2002-02-26 Thread John Edwards

hash keys are stored unsorted. If you have the following hash

%test = (   one => 1,
two => 2,
three => 3);

and print out the hash key/value pairs.

foreach $key (keys %test) {
print "$key is $test{$key}\n";
}

you will find they don't come out in the same order as they were stored.

You can perform a sort on the keys to arrange them in order

foreach $key (sort keys %test) {
print "$key is $test{$key}\n";
}

or you can reverse the hash, making the values the keys, and sort on the new
keys

%reversed = reverse %test;

foreach $key (keys %reversed) {
print "$key is $reversed{$key}\n";
}

In doing this though, you must be aware that you will lose any data that has
identical values. For example

%test = (   one => 1,
two => 2,
three => 3,
alpha => 1,
beta => 2,
gamma => 3);

%reversed = reverse %test;

foreach $key (keys %reversed) {
print "$key is $reversed{$key}\n";
}

will print out

1 is one
2 is two
3 is three

There is probably another/better way of doing this using the comparison
operator <=>, but I don't know it. There is also a module available that
lets you store and retrieve hashes in a fixed order.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 26 February 2002 09:16
To: [EMAIL PROTECTED]
Subject: sort order of hash keys


hi


i would like to know if theres a smart way to unwind a hashtable so that
the key / value pairs comes out in the same order as they are in the table.

:o)

martin
-- 

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


--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



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




How to declare signed char in Perl?

2002-02-26 Thread Philibert

Hi,
I have a problem with a program I did in Perl :
I use the function system(@args) to launch an external command,
and then get the exit value : $exit_value = $? >> 8.
That runs fine, the problem is the exit value can be -1, so $exit_value
should be a signed char. When the program returns -1, and I print
$exit_value, I get 255...so I guess either it's an unsigned char, or an
integer...is there a way to declare ma variable as a signed char?
Thanks




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




Installing Perl Help

2002-02-26 Thread Scott E Svendsen


I am currently running perl 5.6.0, I am trying to install 5.6.1 with the
-Dusethreads option enabled.  

I have read the install file, and followed it to the letter, except using:
sh Configure -Dusethreads

Then I answer all the questions it gives me and says it is installed.
Except there is no indication it did anything.  Doing a perl -v gives me
the same old version.  Doign a search doesnt turn up any new 5.6.1
folders.

I need help please.

Thanks
Scott



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




Re: Book suggestion

2002-02-26 Thread Robert Jimenez

I have been reading "Learning Perl" - Schwartz (O'reilly) and it is pretty
good.  But I also borrowed the book "Perl by Example" 1st edition from my
friend.  Working with both of them seem to really be helping me.

I also have all of the other O'reilly Perl books on CD.

Robert

Anidil Rajendran-Raj wrote:

> Hi team,
>
> I am unix admin trying to learn perl. How is the book "LEARNING PERL BY
> EXAMPLE" by Ellie Quigley
> regs
>
>
> Anidil Rajendran (raj)
> Netliant,Inc
> 3600,Brigde Parkway Suite 102
> Redwood City,CA 94065-1170
> (650) 730 8271
> <>


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




sort order of hash keys

2002-02-26 Thread Martin A. Hansen

hi


i would like to know if theres a smart way to unwind a hashtable so that
the key / value pairs comes out in the same order as they are in the table.

:o)

martin
-- 

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