Re: Control characters in file.

2002-10-21 Thread Basavaraj Bendigeri
Hi ,
   I think this should do :
   my $temp =~ s/[[:^print:]\r]+//go;
Regards
-Basavaraj

Anurag K. Singh wrote:

Yes , they are literally "^A".These characters appears in the file
when a ascii file was ftp'ed to a unix machine in binary mode.
I don't have that ascii file now , so i have to correct this 
file in unix.

-Original Message-
From: Timothy Johnson [mailto:tjohnson@;sandisk.com]
Sent: Tuesday, October 22, 2002 8:12 AM
To: 'Anurag K. Singh'; '[EMAIL PROTECTED]'
Subject: RE: Control characters in file.



This might sound like a stupid question, but are they literally "^A", etc.,
or do you mean the character created by pressing ^A?  Because if it's the
latter, then you might be able to do something like this:

	my $string =~ s/\eA//gi;

(According to 'perldoc perlre' '\e' denotes an escape)

-Original Message-
From: Anurag K. Singh [mailto:AnuragS@;Amdocs.com]
Sent: Tuesday, October 22, 2002 12:07 AM
To: '[EMAIL PROTECTED]'
Subject: Control characters in file.



hi all,

I have control characters ( like ^A , ^M ) in my ascii input file 
and I want to substitute them by space or just delete them.
 Can  anyone suggest a regex for this substitution ???


Thanks

Anurag Kumar Singh 
AMDOCS DEVELOPMENT LTD. 
Limassol , Cyprus. 
Phone: +357-25-845384(O) 




-

The information contained in this message is proprietary of Amdocs,

protected from disclosure, and may be privileged.

The information is intended to be conveyed only to the designated recipient(s)

of the message. If the reader of this message is not the intended recipient,

you are hereby notified that any dissemination, use, distribution or copying of 

this communication is strictly prohibited and may be unlawful. 

If you have received this communication in error, please notify us immediately

by replying to the message and deleting it from your computer.

Thank you.

-




--

Basavaraj Bendigeri
Software Engineer III
Andiamo Software Systems Pvt. Ltd.,
5th Floor, Sona Towers,
71, Millers Road,
Bangalore - 560 052,
India
Ph: (0) +91-80-228-9933 Ext. 5068
(R) +91-80-310-1718
Fx: +91-80-228-9955


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




RE: Control characters in file.

2002-10-21 Thread Timothy Johnson

In that case, this should work:

my $string =~ s/\^[AM]//gi;

I think you just have to escape the '^'.

-Original Message-
From: Anurag K. Singh [mailto:AnuragS@;Amdocs.com]
Sent: Tuesday, October 22, 2002 12:33 AM
To: 'Timothy Johnson'; '[EMAIL PROTECTED]'
Subject: RE: Control characters in file.


Yes , they are literally "^A".These characters appears in the file
when a ascii file was ftp'ed to a unix machine in binary mode.
I don't have that ascii file now , so i have to correct this 
file in unix.

-Original Message-
From: Timothy Johnson [mailto:tjohnson@;sandisk.com]
Sent: Tuesday, October 22, 2002 8:12 AM
To: 'Anurag K. Singh'; '[EMAIL PROTECTED]'
Subject: RE: Control characters in file.



This might sound like a stupid question, but are they literally "^A", etc.,
or do you mean the character created by pressing ^A?  Because if it's the
latter, then you might be able to do something like this:

my $string =~ s/\eA//gi;

(According to 'perldoc perlre' '\e' denotes an escape)

-Original Message-
From: Anurag K. Singh [mailto:AnuragS@;Amdocs.com]
Sent: Tuesday, October 22, 2002 12:07 AM
To: '[EMAIL PROTECTED]'
Subject: Control characters in file.



hi all,

I have control characters ( like ^A , ^M ) in my ascii input file 
and I want to substitute them by space or just delete them.
 Can  anyone suggest a regex for this substitution ???


Thanks

Anurag Kumar Singh 
AMDOCS DEVELOPMENT LTD. 
Limassol , Cyprus. 
Phone: +357-25-845384(O) 

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




RE: Control characters in file.

2002-10-21 Thread Anurag K. Singh
Yes , they are literally "^A".These characters appears in the file
when a ascii file was ftp'ed to a unix machine in binary mode.
I don't have that ascii file now , so i have to correct this 
file in unix.

-Original Message-
From: Timothy Johnson [mailto:tjohnson@;sandisk.com]
Sent: Tuesday, October 22, 2002 8:12 AM
To: 'Anurag K. Singh'; '[EMAIL PROTECTED]'
Subject: RE: Control characters in file.



This might sound like a stupid question, but are they literally "^A", etc.,
or do you mean the character created by pressing ^A?  Because if it's the
latter, then you might be able to do something like this:

my $string =~ s/\eA//gi;

(According to 'perldoc perlre' '\e' denotes an escape)

-Original Message-
From: Anurag K. Singh [mailto:AnuragS@;Amdocs.com]
Sent: Tuesday, October 22, 2002 12:07 AM
To: '[EMAIL PROTECTED]'
Subject: Control characters in file.



hi all,

I have control characters ( like ^A , ^M ) in my ascii input file 
and I want to substitute them by space or just delete them.
 Can  anyone suggest a regex for this substitution ???


Thanks

Anurag Kumar Singh 
AMDOCS DEVELOPMENT LTD. 
Limassol , Cyprus. 
Phone: +357-25-845384(O) 
-

The information contained in this message is proprietary of Amdocs,

protected from disclosure, and may be privileged.

The information is intended to be conveyed only to the designated recipient(s)

of the message. If the reader of this message is not the intended recipient,

you are hereby notified that any dissemination, use, distribution or copying of 

this communication is strictly prohibited and may be unlawful. 

If you have received this communication in error, please notify us immediately

by replying to the message and deleting it from your computer.

Thank you.

-


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


Re: Control characters in file.

2002-10-21 Thread John W. Krahn
"Anurag K. Singh" wrote:
> 
> hi all,

Hello,

> I have control characters ( like ^A , ^M ) in my ascii input file
> and I want to substitute them by space or just delete them.
>  Can  anyone suggest a regex for this substitution ???


If you want to remove all control characters:

s/[[:cntrl:]]+//g

If you want to remove all control characters except newline and tab:

s/[^\n\t[:^cntrl:]]+//g

Or using transliteration instead of substitution:

tr/\0-\037//d
tr/\0-\010\013-\037//d



John
-- 
use Perl;
program
fulfillment

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




RE: Control characters in file.

2002-10-21 Thread Timothy Johnson

This might sound like a stupid question, but are they literally "^A", etc.,
or do you mean the character created by pressing ^A?  Because if it's the
latter, then you might be able to do something like this:

my $string =~ s/\eA//gi;

(According to 'perldoc perlre' '\e' denotes an escape)

-Original Message-
From: Anurag K. Singh [mailto:AnuragS@;Amdocs.com]
Sent: Tuesday, October 22, 2002 12:07 AM
To: '[EMAIL PROTECTED]'
Subject: Control characters in file.



hi all,

I have control characters ( like ^A , ^M ) in my ascii input file 
and I want to substitute them by space or just delete them.
 Can  anyone suggest a regex for this substitution ???


Thanks

Anurag Kumar Singh 
AMDOCS DEVELOPMENT LTD. 
Limassol , Cyprus. 
Phone: +357-25-845384(O) 

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




Control characters in file.

2002-10-21 Thread Anurag K. Singh

hi all,

I have control characters ( like ^A , ^M ) in my ascii input file 
and I want to substitute them by space or just delete them.
 Can  anyone suggest a regex for this substitution ???


Thanks

Anurag Kumar Singh 
AMDOCS DEVELOPMENT LTD. 
Limassol , Cyprus. 
Phone: +357-25-845384(O) 

-

The information contained in this message is proprietary of Amdocs,

protected from disclosure, and may be privileged.

The information is intended to be conveyed only to the designated recipient(s)

of the message. If the reader of this message is not the intended recipient,

you are hereby notified that any dissemination, use, distribution or copying of 

this communication is strictly prohibited and may be unlawful. 

If you have received this communication in error, please notify us immediately

by replying to the message and deleting it from your computer.

Thank you.

-


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


Long Time Script Suddenly Failing

2002-10-21 Thread Guy Davis
Hi all,

Hopefully someone can give me a clue about a problem I'm having. I'm using the script 
below to try to retrieve the web page 
"http://inventory.overture.com/d/searchinventory/suggestion/?term="; with a term 
attached at the end of it. This script has been working for months and is all of a 
sudden returning: "500 (Internal Server Error) Can't connect to 
inventory.overture.com:80 (Timeout)"

I can connect to other sites without a problem such as yahoo.com.

Does anyone know why something like this might suddenly be taking place after such a 
long time of working flawlessly? Could it be something has been changed at the web 
site I'm trying to get?

Thanks so much in advance.

Guy Davis





#!/usr/bin/perl 

use strict;
use DBI;
use LWP::UserAgent;

# test to make sure they entered one or two arguments
if($#ARGV != 0)
{
  print "\nUsage: getraffic.pl research_run_id\n\n";
  exit();
}

# We need to subclass LWP::UserAgent in order to allow redirects on POSTS
# and fix some other problems. In other words, to make it behave like a
# 'real' web browser
@MyAgent::ISA = qw(LWP::UserAgent);
sub MyAgent::redirect_ok {
my ($self,$request)=@_;

# *
# IMPORTANT:
#
# POSTs that get redirected __MUST__ change the request
# method to GET
# *
if ($request->method eq "POST") {
$request->method("GET");
}
return 1;
}

# what client do you want to get?  first variable from the command line
my $test_phrase = "";
my $research_id = $ARGV[0];
my $VERBOSE = 1;

my $db = DB_connect();
my ($rp_id, $rp_phrase_name);
my $sql = "";
my $sth;

# Getting started - actively checking for traffic
$sql = "UPDATE research SET research_traffic_updated=1
WHERE research_id=$research_id";
$sth = $db->prepare( $sql );
$sth->execute() || die ( $DBI::errstr );

$sql = "SELECT rp_id, rp_phrase_name FROM researchphrase
WHERE rp_research_id=$research_id AND rp_status<>2 AND rp_clicks IS NULL";

$sth = $db->prepare( $sql );
$sth->execute() || die ( $DBI::errstr );
$sth->bind_columns(undef, \($rp_id, $rp_phrase_name));
while ($sth->fetch()) { # update each phrase
my $kw = $rp_phrase_name;
$kw =~ s/ /+/g;

gettraffic($rp_id, $rp_phrase_name, $kw);
}

# All done - not actively checking for traffic
$sql = "UPDATE research SET research_traffic_updated=0
WHERE research_id=$research_id";
$sth = $db->prepare( $sql );
$sth->execute() || die ( $DBI::errstr );

$sth->finish();
# now disconnect from the database
$db->disconnect();

sub gettraffic {
my ($rp_id, $rp_phrase_name, $keyword) = @_;
my $traffic=0;

my $url = 
"http://inventory.overture.com/d/searchinventory/suggestion/?term="; . $keyword;
my $ua  = new MyAgent;
my $agent   = 'Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)';

## Set some User Agent properties.
$ua->agent($agent);
$ua->timeout(15);

## Convert the URL into a url object (with a couple methods we can use).
my $u =  new URI::URL( $url );

## Fetch the web page.
my $req = HTTP::Request->new(GET=>$u->as_string);
my $res = $ua->request($req);
my $resstring = $res->as_string;

print "URL: $url\n" if ($VERBOSE);
print "$resstring\n" if ($VERBOSE);

# Check the outcome of the response
if ($res->is_success) {
my $content = $res->content;
$content =~ m/.* ([0-9]+)<\/b>.*/s;
my $traffic = $1;
if (!$traffic) {
$traffic = 0;
}

update_db($rp_id, $traffic);
} 
}

sub update_db {
my ($rphraseid, $traffic) = @_;

my $sql = "UPDATE researchphrase SET rp_clicks=$traffic WHERE 
rp_id=$rphraseid";
my $sth = $db->prepare( $sql );
$sth->execute() || die( $DBI::errstr );
$sth->finish();
}

sub DB_connect {
my $table = shift;
my $db = DBI->connect("DBI:mysql:database",  "username", "password", 
{PrintError=>0, RaiseError=>0});
return $db || "DBERROR: Could not connect to database.";
}


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




Re: Using Use:CGI to process form variables

2002-10-21 Thread Geoffrey F. Green
On 10/21/02 6:35 PM, "Johnstone, Colin" <[EMAIL PROTECTED]>
wrote:

> O'k Im willing to learn are there any instructions on using the use CGI module
> for processing form variables. please.

Official CGI.pm home page


CGI Programming with Perl (read and liked)


Writing CGI Applications with Perl (haven't read, heard good things about
it)


 - geoff


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




Re: OOP Mailing lists

2002-10-21 Thread Wiggins d'Anconia


LRMK wrote:

Can any body tell me a address of a OOP mailing list for perl



Surprisingly I didn't see one specifically for that topic. Although most 
questions on this topic could certainly be posed to the beginners list 
as it is pretty general.

There is a nice list of lists at: http://lists.perl.org/

http://danconia.org


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



Re: Using Use:CGI to process form variables

2002-10-21 Thread Wiggins d'Anconia



O'k Im willing to learn are there any instructions on using the use CGI module for processing form variables. please.


All over the place, but specifically do:

~> perldoc CGI

or check out:  http://search.cpan.org/author/JHI/perl-5.8.0/lib/CGI.pm

http://danconia.org


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




Re: Substring and Sort

2002-10-21 Thread Michael Fowler
On Mon, Oct 21, 2002 at 04:32:27PM -0500, Akens, Anthony wrote:
[snip]

It looks like you forgot -w and use strict.


> open (NAMES, $namefile)
> or print "Could not open $namefile $!";

Do you really want to continue and read the file if the open fails?

 
> while()
> {
> ($key, $value) = split /:/;

Is it possible to have colons in the display name?  If so you should limit
your split:

  ($key, $value) = split /:/, $_, 2;

> chomp $value;
> $Names{$key} = $value;
> }
> close NAMES;
> 
> %seen=();
> print "";
> 
> foreach $dirname (sort { "\L$Names{$a}" cmp "\L$Names{$b}" } keys %Names){
> $displayname = $Names{$dirname};
> if (($displayname eq "MISSING") or ($displayname eq "HIDE")){}
> else{

That empty block there looks odd.  The typical way to do this is:

  unless (($displayname eq "MISSING") or ($displayname eq "HIDE")) {

or
  if (($displayname ne "MISSING") and ($displayname ne "HIDE")) {


Though I would use:

  unless ($displayname eq 'MISSING' || $displayname eq 'HIDE') {

but only because I prefer '||' to 'or', and don't like doubling up on
parens if it can be avoided.


> 
> $item = substr($displayname, 0, 1);
> if ($seen{"\L$item"}++){}
> else {

Here's another empty block; you should avoid these.  Use:

  unless ($seen{"\L$item"}++) {

or
  if (!$seen{"\L$item"}++) {

instead.


> print "\U$item<\/a>\n";
> }
> print "";

You can avoid having to escape quotes by using different quote delimiters:

  print qq{};

If installer.pl is the name of the script this code is in you might be
better off using $ENV{SCRIPT_NAME}.


> print $displayname;
> print "<\/a>\n";

You don't need to escape forward slashes "/", just backslashes.

I'd suggest combining your print statements:

  print(
  qq{},
  qq{$displayname\n}
  );

> }
> }

Personally, I would avoid the "\L..." and "\U..." in favor of function
calls, i.e. lc(...) and uc(...).  This is a personal preference arising from
the fact that it's easy for me to overlook the \L and \U in a string.

Everything else looks fine.


Michael
--
Administrator  www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

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




Re: MIME Base64 encoding and file transfer

2002-10-21 Thread zentara
On Sun, 20 Oct 2002 08:17:01 -0400, [EMAIL PROTECTED] (Zentara)
wrote:

>Can someone please point out where my reasoning is flawed
>concerning base64 encoding.
>
>A question recently came up in the Tk newsgroup on how to
>display a jpg image with Tk, directly from a url.
>
>I could easily do it if I mirrored a temporary jpg file on the local
>harddrive, then displayed it; but to do it by displaying what is in
>memory alone, required MIME::Base64 encoding.

Nevermind, a Tk expert informed me that Tk still requires
data to be "printable characters", which seems to explain it.


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




Using Use:CGI to process form variables

2002-10-21 Thread Johnstone, Colin
Hi all,

As a Perl Newbie I just felt more comfortable processing form variables using the 
method I'm most comfortable with

As Jenda pointed out in a previous post that this is not the best method.

> #read STDIN, $PostData, $ENV{'CONTENT_LENGTH'};
> 
> #print "post data =$PostData";
> 
> #postdata will look like this
> #[EMAIL PROTECTED]&radAction=unsubscribe&rad
> #Format=html&Submit=Submit I need to extract from this string the
> #fields and their values
> my @fields = split( /\&/, $PostData);
> 
> ...
Please don't do this. The query/posted data parsing is not as simple 
as it seems. You are much safer if you 
use CGI;

O'k Im willing to learn are there any instructions on using the use CGI module for 
processing form variables. please.

Colin Johnstone 
Website Project Officer 
Corporate Website Unit 
Public Affairs Directorate
NSW Department of Education and Training
AUSTRALIA 

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




Re: Using non-standard characters...

2002-10-21 Thread Jenda Krynicky
From:   Fogle Cpl Shawn B <[EMAIL PROTECTED]>

> I'm having a little problem with some of my filenames that have ' in
> them (I would enclose it in quotes but that would probably confuse
> things).  And it never makes it beyond that point in the filename when
> running the script. I have thought of makeing a link to a temp file
> with a better name (something simple like /tmp/npntemp) using regexps.
> But, maybe I'm not thinking of all the possibilities here, but I know
> using the ' character is not a problem on the shell, as I can just
> type the command on the shell and it works fine. 

You forgot to tell us WHAT problem do you have with those files.

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]




Using non-standard characters...

2002-10-21 Thread Fogle Cpl Shawn B
I'm having a little problem with some of my filenames that have ' in them (I
would enclose it in quotes but that would probably confuse things).  And it
never makes it beyond that point in the filename when running the script. I
have thought of makeing a link to a temp file with a better name (something
simple like /tmp/npntemp) using regexps. But, maybe I'm not thinking of all
the possibilities here, but I know using the ' character is not a problem on
the shell, as I can just type the command on the shell and it works fine. 

Any suggestions?
As usual I'd like to thank everyone for their help,
shawn

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




RE: XML module

2002-10-21 Thread NYIMI Jose (BMB)
>From the README file:

XML::SAX::PurePerl
==

This is a Pure Perl XML parser, making use of PerlIO for supporting multiple
encodings (requires Perl 5.7.2 or higher), hand-written LL parsing, and a
PerlSAX2 interface, as discussed in depth on the Perl-XML mailing list.

It is far from "complete", but progressing rapidly, and is capable of parsing
most XML that doesn't contain an internal subset or make use of external
entities. These features are being worked on right now.

José.

> -Original Message-
> From: Nigel Wetters [mailto:nigel.wetters@;rivalsdm.com] 
> Sent: Monday, October 21, 2002 6:18 PM
> To: NYIMI Jose (BMB)
> Cc: Admin-Stress; perl
> Subject: RE: XML module
> 
> 
> On Mon, 2002-10-21 at 17:04, NYIMI Jose (BMB) wrote:
> > XML::Simple
> > XML::DOM
> > XML::Parser::PerlSAX
> 
> The above modules are based around the expat libraries. There 
> are also modules based around the gnome libxml2 libraries, 
> which seem to be faster, but less portable:
> 
> XML::LibXML
> XML::LibXML::SAX
> XML::LibXML::Fixup
> 
> and if speed isn't an issue, there's also a pure Perl XML parser:
> 
> XML::SAX::PurePerl
> -- 
> Nigel Wetters, Senior Programmer, Development Group
> Rivals Digital Media Ltd, 151 Freston Road, London W10 6TH
> Tel. 020 8962 1346 (direct line), Fax. 020 8962 1311 
http://www.rivalsdm.com/ <[EMAIL PROTECTED]>



 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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




Re: How do I know if a perl module is installed?

2002-10-21 Thread Peter Scott
% perl -MSome::Module -e 0

Absence of output indicates the module is installed.

-- 
Peter Scott
http://www.perldebugged.com

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




Re: lost - map { "$_:\t$h->{$_}[0]\n"} keys %$h

2002-10-21 Thread Larry Coffin
>Can anyone explain to me how map works in this code?

> print map { "$_:\t$h->{$_}[0]\n"} keys %$h ;

Essentially, this is a "cheap" way to do a foreach loop to print
out each item in the %$h (or %{$h}) hash. It is functionally equivalent to:

foreach $key (keys %$h) {
print "$key:\t$h->{$key}[0]\n";
}


The only difference being that print is called once after building
all the output lines, rather than being called for each line.

(I assume you are asking about the function of the map {} statement
and not the data structures involved)

---Larry



++
| Larry Coffin, G.P.H. Watertown, MA |
| http://www.PointInfinity.com/lcoffin/[EMAIL PROTECTED] |
++

Kirkland, Illinois, law forbids bees to fly over the village or through
any of its streets.


-



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




RE: lost - map { "$_:\t$h->{$_}[0]\n"} keys %$h

2002-10-21 Thread Nikola Janceski
# read this from bottom to top (be sure to read 'perldoc -f map' first)

print # print will print the list that is returned from map
map { # map returns the last evaluated statement
"$_" .  # this is what $_ was
":\t" . # this is a colon followed by a tab
# $h->{$_}[0] is the first element
of that array
# $h->{$_} points to an array ref
$h->{$_}[0] .   # $_ is each key from hash ref $h
"\n"# this is a new line
} keys %{ $h }; # get the keys from hash ref $h


> -Original Message-
> From: Jerry Preston [mailto:g-preston1@;ti.com]
> Sent: Monday, October 21, 2002 5:20 PM
> To: Beginners Perl
> Subject: lost - map { "$_:\t$h->{$_}[0]\n"} keys %$h 
> 
> 
> Hi!
> 
> Can anyone explain to me how map works in this code?
> 
>   for my $h (
> 
># grab the Subject and Date from every message in my 
> (fictional!) smut
> folder;
># the first argument is a reference to an array listing 
> all messages in
> the folder
># (which is what gets returned by the $imap->search("ALL") 
> method when
> called in
># scalar context) and the remaining arguments are the 
> fields to parse out
> 
># The key is the message number, which in this case we 
> don't care about:
>values %{$imap->parse_headers( 
> scalar($imap->search("ALL")) , "Subject",
> "Date")}
>   ) {
> # $h is the value of each element in the hash ref returned from
> parse_headers,
> # and $h is also a reference to a hash.
> # We'll only print the first occurance of each field 
> because we don't
> expect more
> # than one Date: or Subject: line per message.
>  print map { "$_:\t$h->{$_}[0]\n"} keys %$h ;
>   }
> 
> How can I access this and break it done to look at each line?
> 
> Thanks,
> 
> Jerry
> 
> 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




RE: Substring and Sort

2002-10-21 Thread Akens, Anthony
Thank you very much for your help, that took care of 
the issue.

The following section of code seems to work fine,
but I'd welcome any criticisms you may have, as
this is my first large perl program, and I'm sure
it could use some refining.

This section of code reads in the same file format

directory:displayname

It should print the first name of the displayname
if it's the first beginning with that character,
and should skip any displaynames that are equal
to MISSING or HIDE.  Eventually I plan on making
it possible to categorize each directory by a type,
and show/hide them based on a user's type selection.

As I said, the program is actually pretty funtional
as is, and currently is in use - but I'm always
willing to see how I can improve on what I've done.

Tony

-
open (NAMES, $namefile)
or print "Could not open $namefile $!";

while()
{
($key, $value) = split /:/;
chomp $value;
$Names{$key} = $value;
}
close NAMES;

%seen=();
print "";

foreach $dirname (sort { "\L$Names{$a}" cmp "\L$Names{$b}" } keys %Names){
$displayname = $Names{$dirname};
if (($displayname eq "MISSING") or ($displayname eq "HIDE")){}
else{

$item = substr($displayname, 0, 1);
if ($seen{"\L$item"}++){}
else {
print "\U$item<\/a>\n";
}
print "";
print $displayname;
print "<\/a>\n";
}
}
-

-Original Message-
From: Larry Coffin [mailto:lc2002@;PointInfinity.com]
Sent: Monday, October 21, 2002 2:53 PM
To: Akens, Anthony; [EMAIL PROTECTED]
Subject: Re: Substring and Sort


At 3:03 PM -0400 10/21/02, Akens, Anthony wrote:
>I'm attempting to use the following code to read a file
>in the format of:
>
>directory name:displayname
>
>I want to sort the list by the "displayname", looking
>at the first letter for each display name in the file.
>If it's unique, I want to print it.  This should result
>in an alphabetical list of the letters for the display
>names.  However, the sort is not working quite right,
>and I sometimes get letters out of order, missing, or
>some that aren't even in the list.
>
>Can anyone tell me what I've done wrong?

First of all, it looks like you are sorting based on directory
name, not on the "displayname", since you are sorting on the keys and the
keys are the first part of the 'split /:/'.

The second thing, is that you are only saving one value per
'directory name' -- if there is more than one file (assuming 'displayname'
is the name of a file) in a directory, then you will only get the last file
because your '$Names{$key} = $value;' is overwriting the previous value.

If all you want is the list of unique letters that all the files
start with, then you'd probably be better off with something much simpler,
such as:

---

while () {
($dir, $file) = split /:/;
$letter = uc(substr($file, 0, 1));
$letters{$letter} = 1; # or $letters{$letter}++; to track the number
}

print "";

foreach $letter (sort keys %letters) {
print "$letter<\/a> ";
}

---


If you want to retain the list of files and the directory they are
in and have them sorted by the displayname, then I'd do something like this
(this assumes that the file names are case sensitive so we need to retain
the case but we want the sort to be case insensitive):

---

while () {
($dir, $file) = split /:/;
$letter = uc(substr($file, 0, 1));
push(@{$files{$letter}}, [lc($file), $file, $dir])
}

#
# %files is now a hash array with keys that are the uppercase first letter
# of the file names and the values are array references
#
# Each array reference contains array references which contain
# the file name in lower case, the file name in the original case,
# and the dir name in the [0] and [1] positions
#

print "";

# print out the index
foreach $letter (sort keys %files) {
print "$letter<\/a> ";
}

# print out the file list
foreach $letter (sort keys %files) {
print "$letter\n";

foreach $file_ref (sort {$a->[0] cmp $b->[0]} @{$files{$letter}}) {
print "$file_ref->[2]:$file_ref->[1]\n";
}
}

---

Note that the conversion to upper or lower case only occurs once
when we are saving the file info. If you do the conversion in the sort
block, perl may end up doing the conversion on every comparison (unless it
caches the comparison values which it may well do). This comes at the
expense of having to save the converted filename, so if for some reason you
are tight on memory (i.e. 1000s of filenames) and have lots of CPU cycles
to spare, then you might not want to save it and do the case conversion in
the sort block.

The

RE: XML module

2002-10-21 Thread Nigel Wetters
On Mon, 2002-10-21 at 17:04, NYIMI Jose (BMB) wrote:
> XML::Simple
> XML::DOM
> XML::Parser::PerlSAX

The above modules are based around the expat libraries. There are also
modules based around the gnome libxml2 libraries, which seem to be
faster, but less portable:

XML::LibXML
XML::LibXML::SAX
XML::LibXML::Fixup

and if speed isn't an issue, there's also a pure Perl XML parser:

XML::SAX::PurePerl
-- 
Nigel Wetters, Senior Programmer, Development Group
Rivals Digital Media Ltd, 151 Freston Road, London W10 6TH
Tel. 020 8962 1346 (direct line), Fax. 020 8962 1311
http://www.rivalsdm.com/ <[EMAIL PROTECTED]>


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




lost - map { "$_:\t$h->{$_}[0]\n"} keys %$h

2002-10-21 Thread Jerry Preston
Hi!

Can anyone explain to me how map works in this code?

  for my $h (

   # grab the Subject and Date from every message in my (fictional!) smut
folder;
   # the first argument is a reference to an array listing all messages in
the folder
   # (which is what gets returned by the $imap->search("ALL") method when
called in
   # scalar context) and the remaining arguments are the fields to parse out

   # The key is the message number, which in this case we don't care about:
   values %{$imap->parse_headers( scalar($imap->search("ALL")) , "Subject",
"Date")}
  ) {
# $h is the value of each element in the hash ref returned from
parse_headers,
# and $h is also a reference to a hash.
# We'll only print the first occurance of each field because we don't
expect more
# than one Date: or Subject: line per message.
 print map { "$_:\t$h->{$_}[0]\n"} keys %$h ;
  }

How can I access this and break it done to look at each line?

Thanks,

Jerry




Mail::IMAPClient::BodyStructure::Parse error

2002-10-21 Thread Jerry Preston
Hi!

I get the following error:

Can't locate object method "new" via package
"Mail::IMAPClient::BodyStructure::Parse" at Mail/Client/BodyStructure.pm
line 15

What is wrong?

Thanks,

Jerry



OOP Mailing lists

2002-10-21 Thread LRMK
Can any body tell me a address of a OOP mailing list for perl



Re: Tidying up repeated data

2002-10-21 Thread John W. Krahn
Jonathan Musto wrote:
> 
> Hi all,

Hello,

> If i have a text file with a list of values i.e.
> 
> ght-Skem
> ght-Skem
> ght-Skem
> hjy-TOB
> hjy-TOB
> hjy-TOB
> etcetc
> 
> does anyone know of a regular expression to get rid off all the repeated
> data, so that i just have a list as follows
> 
> ght-Skem
> hjy-TOB
> 
> Any help would be much aprreciated!


perl -i~ -ne'print unless $u{$_}++' your_text_file



John
-- 
use Perl;
program
fulfillment

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




Re: Tidying up repeated data

2002-10-21 Thread Nigel Wetters
On Mon, 2002-10-21 at 16:09, [EMAIL PROTECTED] wrote:
> does anyone know of a regular expression to get rid off all the repeated
> data, so that i just have a list as follows

I don't know a regex, but you could use a hash to ensure that you only
have one instance of each item:

my %data;
while (my $line = ){
  chomp $line;
  $data{$line} = 1;
}
print keys %data;
  

-- 
Nigel Wetters, Senior Programmer, Development Group
Rivals Digital Media Ltd, 151 Freston Road, London W10 6TH
Tel. 020 8962 1346 (direct line), Fax. 020 8962 1311
http://www.rivalsdm.com/ <[EMAIL PROTECTED]>


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




Re: How do I know if a perl module is installed?

2002-10-21 Thread Nigel Wetters
On Fri, 2002-10-18 at 16:21, Jack Chen wrote:
> Thought there is some easy way bu could not find.

Use a require statement within an eval(), then check for errors:

  eval("require Foo::Bar");
  if ($@){
print "not installed";
  } else {
print "installed";
  }

-- 
Nigel Wetters, Senior Programmer, Development Group
Rivals Digital Media Ltd, 151 Freston Road, London W10 6TH
Tel. 020 8962 1346 (direct line), Fax. 020 8962 1311
http://www.rivalsdm.com/ <[EMAIL PROTECTED]>


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




Re: parsing variable that contains a regex ("/findme/")

2002-10-21 Thread K Pfeiffer
John W. Krahn writes:
> if ( $regex ) {
> # is the string true in a boolean context?

That makes sense (too bad I didn't think of it). So I guess my error message 
was complaining about my use of the three regular expression memory 
variables ($` $& $') which were then seen as being unused.

> If you want to include options like /i you will have to use an extended
> pattern like "\b(?i:the)\b" or "\b(?i)the\b".

Thanks!

-- 
Kevin Pfeiffer <[EMAIL PROTECTED]> - www.iu-bremen.de
("But WHY is it genetive?") ;-)

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




Tidying up repeated data

2002-10-21 Thread jonathan . musto
Hi all,
 
If i have a text file with a list of values i.e.
 
ght-Skem
ght-Skem
ght-Skem
hjy-TOB
hjy-TOB
hjy-TOB
etcetc
 
does anyone know of a regular expression to get rid off all the repeated
data, so that i just have a list as follows
 
ght-Skem
hjy-TOB
 
Any help would be much aprreciated!
 
cheers
 
Jonathan Musto

 

BT Ignite Solutions
Telephone - 0113 237 3277
Fax - 0113 244 1413
E-mail -   [EMAIL PROTECTED]
http://www.technet.bt.com/sit/public  


British Telecommunications plc 
Registered office: 81 Newgate Street London EC1A 7AJ 
Registered in England no. 180 
This electronic message contains information from British Telecommunications
plc which may be privileged or  confidential. The information is intended to
be for the use of the individual(s) or entity named above. If you  are not
the intended recipient be aware that any disclosure, copying, distribution
or use of the contents of  this information is prohibited. If you have
received this electronic message in error, please notify us by  telephone or
email (to the numbers or address above) immediately.




 



Re: reg shell commands

2002-10-21 Thread Mark Goland
you can also do it with a shell command

open ( RD_FH," find . -name myname |"); 
#  if you want to write to stdin of the command put the | 
#  before the command
$Result = ;

print $Result;

Mark
- Original Message - 
From: "Dharmender Rai" <[EMAIL PROTECTED]>
To: "Elanchezhian Sivanandam" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, October 21, 2002 6:21 AM
Subject: Re: reg shell commands


> Read File::Find.
> Some shell commands return 0 for success and others
> for failure or some problem. The case with 'find' is
> the same. If you are taking the return value then of
> course you will get the numerical stuff.
> 
> 
> 
>  --- Elanchezhian Sivanandam <[EMAIL PROTECTED]>
> wrote: > hi,
> > 
> >i want to find the hierarchial path of a file
> > inside a perl script.
> >the path can be found using the shell command
> >find [path] expression..
> >and assign to a variable in perl.
> >but it gives me a numerical value.
> >how to get it as a string?
> > 
> >thanks in advance.
> > 
> > cheers../elan
> > 
> > 
> > -- 
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> >  
> 
> __
> Do You Yahoo!?
> Everything you'll ever need on one web page
> from News and Sport to Email and Music Charts
> http://uk.my.yahoo.com
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


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




RE: another reg-ex question

2002-10-21 Thread Michael Hooten
If I understand you correctly, you are trying to process an array of an
array--each element of an array contains an anonymous array. Is this
correct?

Given the fact that you would like to pull out a specific user, you should
use a hash of a hash (a hash containing anonymous hashes).

Also, since you want to pull out particular info:
--user=1 --item=firstName
but user value of "1" is not contained in the data you posted. I am assuming
you mean the firstName of the first array value.

Lastly, you write that the data are "in a list format in an array" but you
include colons separate each array element which leads me to believe that
the data is really in plain text separated by colons.

I making many assumptions but here goes:

---BEGIN CODE---
#!D:\perl\bin\perl -w
use strict;

my ($id, $status, $user, $phone, $first, $last, $email) = 0 .. 6;
my @data;
my %data;

while () {
  # You can do a pattern match:
  # I did not parenthesize the field separator : below because
  # I did not want it as an element in @temp.
  # my @temp = $_ =~
  # m{ ^(\d+) # id
  #\( (\w+) \) : \s*  # status
  #(\w+) \s*   : \s*  # username
  #(\d+) \s*   : \s*  # phone
  #(\w+) \s*   : \s*  # first name
  #(\w+) \s*   : \s*  # last name
  #(.+)$  # email address
  # }x;

  # Or you can split $_
  my @temp = split /[\(\):\s]+/;
  # This is @data
  $data[ $#data+1 ] = [ @temp ];
}

# Now you can directly print the email address of the 3rd record:
print "email: $data[2][$email]\n";

# But is that really helpful?
# You might want to build a hash with the username as keys:
foreach ( @data ) {
  # This is %data
  $data{ $$_[$user] } = [ @$_[0..$user-1, $user+1..$#$_ ] ];
}
print "id: $data{idiot}[$id]\n\n";

# You now have a hash with arrays as the values.
# You can NOT safely use the global variables
# $phone, $first, $last, $email
# from above because their values should have shifted down
# by one when I removed username; therefore
foreach my $key ( keys %data ) {
  my @values = @{$data{$key}};

  # Necessary because you are replacing an array with a hash.
  # If you do not undef, a "can't coerce" error occurs.
  undef $data{$key};

  # This is a hash slice.
  # Refer to Perl Cookbook 4.7 p. 105
  @{ $data{$key} }{ qw(id status phone first last email) } = @values;
}

# Print what's in the hash.
foreach my $id ( sort keys %data ) {
  print "$id\n";
  foreach my $field ( sort keys %{$data{$id}} ) {
print "\t$field\t$data{$id}{$field}\n";
  }
}

# Or you can print oaf's last name:
print "\nlast: $data{oaf}{last}\n";

__DATA__
223344(IDLE): idiot : 1234567 : Iyam : Stupid : [EMAIL PROTECTED]
556677(IDLE): moron : 8901234 : Moe  : Ron: [EMAIL PROTECTED]
889900(IDLE): oaf   : 5678901 : Big  : Giant  : [EMAIL PROTECTED]
END CODE

-Original Message-
From: David Mamanakis [mailto:efialtis@;efialtis.com]
Sent: Friday, October 18, 2002 4:37 PM
To: [EMAIL PROTECTED]
Subject: another reg-ex question


these are common it seems...

I have a routine that returns a listing of users and all their information
in a list format in an array

1: (status):  :  : firstName :
lastName : eMail@.com
example:
1: 223344(IDLE): idiot : 1234567 : Iyam : Stupid : [EMAIL PROTECTED]

This list can be long.

The problem I am having is I need to know how to grab individual components
out of the listing...
Each list is an element in the array.
I can grab each list doing a "foreach" but I need a reg-ex to grab only the
username or only the phone number...

Earlier reg-ex's I have written I have split lists on commons like the ":"
but can I split this list into 7 parts then re-split # 2 again to have a
total of all 8 list parts?
This is not exactly what I am looking for...I would much rather like to
"plug in" what I am looking for and be able to grab it out..

i.e.  I would like to input which user and which item I want and have it
output only those items...

--user=1 --item=firstName

User1-firstName=Iyam

I just need the reg-ex...I can work out the rest of the programming...


Thanks for any help...


--Dave Mamanakis
--Monroe, WA






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




Perl inside .NET

2002-10-21 Thread Yevgeny Menaker
Hi all!
As you probably know, Microsoft has released its new .NET environment, which 
allows to create .NET components (similar to Java classes) in different 
languages. The good news is that Perl language has joined the family of .NET 
languages after ActiveState (http://www.ActiveState.com) introduced its new 
product, PerlNET, as part of Perl Development Kit (PDK).
There is a new book "Programming Perl in the .NET environment" that is quite 
self-containing - it includes Core Perl tutorial in the first part and the 
second part is dedicated to programming inside .NET including database 
access using ADO.NET, ASP.NET Web Applications in Perl, Creating Perl .NET 
components and other cool stuff. Here is the Amazon link to the book:
http://www.amazon.com/exec/obidos/ASIN/0130652067/ref%3Dnosim/fc-20/102-6136429-4446555

Enjoy the reading and happy bugs-free programming!


_
Get faster connections -- switch to MSN Internet Access! 
http://resourcecenter.msn.com/access/plans/default.asp


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



GD Problem

2002-10-21 Thread Andreas Pflug
Hi,

I am quite new to perl and I am starting with a big problem.
I just compiled Perl 5.8.0 from the source -> Works fine.
I added several module -> Works fine.
I added GD 2.0.1 -> Problem starts:

If I execute this script on the shell as root, it bworks fine and
prints out height and width of the picture.

If I try the same as normal user, I get a "Segmentation fault".
I am running SuSE Linux 7.3 with new kernel 2.4.18

#!/usr/bin/perl

use GD;
use CGI;
my $q = CGI->new();
print $q->header;
my $image = GD::Image->newFromJpeg("../../html/bilder/0020.jpg");
my ($breite, $hoehe) = $image->getBounds();
print $breite."   ".$hoehe;

A little help might help me :-)
Thanks,

Andreas



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




Re: print @$lines

2002-10-21 Thread John W. Krahn
Jerry Preston wrote:
> 
> Hi!

Hello,

> How would you write a foreach loop to go through @$lines on line at a time?

foreach ( @$lines ) {



John
-- 
use Perl;
program
fulfillment

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




Re: print @$lines

2002-10-21 Thread Yevgeny Menaker
Hi, Jerry!
Is this what you mean:

# lines.pl
use strict;

my @lines = ("Line 1", "Line 2", "Line 3");
foreach my $line (@lines)
{
  print $line, "\n";
}
#

Will output:
Line 1
Line 2
Line 3

Yevgeny.






From: "Jerry Preston" <[EMAIL PROTECTED]>
Reply-To: <[EMAIL PROTECTED]>
To: "Beginners Perl" <[EMAIL PROTECTED]>
Subject: print @$lines
Date: Mon, 21 Oct 2002 15:31:20 -0500

Hi!

How would you write a foreach loop to go through @$lines on line at a time?

Thanks,

Jerry



_
Surf the Web without missing calls! Get MSN Broadband.  
http://resourcecenter.msn.com/access/plans/freeactivation.asp


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



Re: upgrade to perl 5.8.0

2002-10-21 Thread zentara
On Fri, 18 Oct 2002 00:12:16 -0500, [EMAIL PROTECTED] (Randy
Perkins) wrote:

>i would like to upgrade perl to 5.8.0
>i currently have 5.6.1
>
>i use redhat and perl was originally installed as a precompiled binary
>(.rpm)
>
>i started out with 5.6.0
>and somehow it got updated to 5.6.1
>
>i am worried that if i compile it the redhat version will not be removed.
>or i will have other problems
>
>what is the best way to proceed?


You can have multiple versions of Perl coexisting side by side.
Each perl executable knows where it's libraries are, do a "perl -V".

So your easiest option is to find your current perl version 561
binary and rename it to perl56.
Then go and install 5.8, and it will become plain perl.
If you want to use your old 5.61 version of perl:
#!/usr/bin/perl56

If you want to manually remove the perl56, do perl -V
and remove the directories listed.
Some distros put the perl libs in /usr/lib/perl and
the binary in /usr/bin/perl.
The default 58 install will put them in /usr/local/bin/perl
and the libs in /usr/local/lib/perl.









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




sourcing CSH scripts from PERL and retaining variables

2002-10-21 Thread Zielfelder, Robert
Greetings,

Is there a way that I can source a CSH script from PERL that sets a bunch of
variables and import those variables into the PERL script without resorting
to having the CSH script write a temp file that sets the variables in PERL
syntax?

Robert Zielfelder

..-.  --..

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




print @$lines

2002-10-21 Thread Jerry Preston
Hi!

How would you write a foreach loop to go through @$lines on line at a time?

Thanks,

Jerry


RE: XML module

2002-10-21 Thread NYIMI Jose (BMB)
It depends on how big,complex,validation required(via DTD) or not... is your XML.
Start looking from following modules:

XML::Simple
XML::DOM
XML::Parser::PerlSAX

José.


> -Original Message-
> From: Admin-Stress [mailto:meerkapot@;yahoo.com] 
> Sent: Monday, October 21, 2002 5:49 PM
> To: perl
> Subject: XML module
> 
> 
> Hi,
> 
> anyone can suggest me XML module for 
> reading/parsing/modifying an XML file?
> 
> Thanks,
> kapot
> 
> __
> Do you Yahoo!?
> Y! Web Hosting - Let the expert host your web site 
http://webhosting.yahoo.com/

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



 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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




Re: Digest::MD5 -> U32 /usr/bin/ld -> cannot find -ldb

2002-10-21 Thread zentara
On Mon, 21 Oct 2002 00:17:53 -0400, [EMAIL PROTECTED] wrote:

>I am trying to install Digest::MD5 on a linux box (perl 5.6.1, yes i know i
>should,). i have gzip'd and tar'd the package, moved into the directory
>and tried to 'perl Makefile.PL' and i get the following error message:
>Testing alignment requiremnets for U32... /usr/bin/ld: cannot find -ldb

You need to install the Berkeley Database from Sleepycat Software.
Either your distro has an rpm for this, or get it from Sleepycat.




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




Re: parsing variable that contains a regex ("/findme/")

2002-10-21 Thread John W. Krahn
K Pfeiffer wrote:
> 
> This worked (see below), but $`, $&, and $' are still empty. (Would they
> need to go inside eval block? Guess I need to read perldoc -f eval a couple
> more times... (or move on to the next problem?) ;-)

perldoc perlvar
[snip]
   $&  The string matched by the last successful pattern
   match (not counting any matches hidden within a
   BLOCK or eval() enclosed by the current BLOCK).
   (Mnemonic: like & in some editors.)  This variable
   is read-only and dynamically scoped to the current
   BLOCK.



John
-- 
use Perl;
program
fulfillment

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




RE: Tidying up repeated data

2002-10-21 Thread Kipp, James
if your just looking to remove dup lines from a file, this should work:
open (F, "yourfile") or die "...";
my %uniq;
$uniq{$_}++ while ;
print for keys %uniq;


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:jonathan.musto@;bt.com]
> Sent: Monday, October 21, 2002 11:09 AM
> To: [EMAIL PROTECTED]
> Subject: Tidying up repeated data
> 
> 
> Hi all,
>  
> If i have a text file with a list of values i.e.
>  
> ght-Skem
> ght-Skem
> ght-Skem
> hjy-TOB
> hjy-TOB
> hjy-TOB
> etcetc
>  
> does anyone know of a regular expression to get rid off all 
> the repeated
> data, so that i just have a list as follows
>  
> ght-Skem
> hjy-TOB
>  
> Any help would be much aprreciated!
>  
> cheers
>  
> Jonathan Musto
> 
>  
> 
> BT Ignite Solutions
> Telephone - 0113 237 3277
> Fax - 0113 244 1413
> E-mail -   [EMAIL PROTECTED]
> http://www.technet.bt.com/sit/public 
>  
> 
> 
> British Telecommunications plc 
> Registered office: 81 Newgate Street London EC1A 7AJ 
> Registered in England no. 180 
> This electronic message contains information from British 
> Telecommunications
> plc which may be privileged or  confidential. The information 
> is intended to
> be for the use of the individual(s) or entity named above. If 
> you  are not
> the intended recipient be aware that any disclosure, copying, 
> distribution
> or use of the contents of  this information is prohibited. If you have
> received this electronic message in error, please notify us 
> by  telephone or
> email (to the numbers or address above) immediately.
> 
> 
> 
> 
>  
> 


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




Re: Substring and Sort

2002-10-21 Thread Larry Coffin
At 3:03 PM -0400 10/21/02, Akens, Anthony wrote:
>I'm attempting to use the following code to read a file
>in the format of:
>
>directory name:displayname
>
>I want to sort the list by the "displayname", looking
>at the first letter for each display name in the file.
>If it's unique, I want to print it.  This should result
>in an alphabetical list of the letters for the display
>names.  However, the sort is not working quite right,
>and I sometimes get letters out of order, missing, or
>some that aren't even in the list.
>
>Can anyone tell me what I've done wrong?

First of all, it looks like you are sorting based on directory
name, not on the "displayname", since you are sorting on the keys and the
keys are the first part of the 'split /:/'.

The second thing, is that you are only saving one value per
'directory name' -- if there is more than one file (assuming 'displayname'
is the name of a file) in a directory, then you will only get the last file
because your '$Names{$key} = $value;' is overwriting the previous value.

If all you want is the list of unique letters that all the files
start with, then you'd probably be better off with something much simpler,
such as:

---

while () {
($dir, $file) = split /:/;
$letter = uc(substr($file, 0, 1));
$letters{$letter} = 1; # or $letters{$letter}++; to track the number
}

print "";

foreach $letter (sort keys %letters) {
print "$letter<\/a> ";
}

---


If you want to retain the list of files and the directory they are
in and have them sorted by the displayname, then I'd do something like this
(this assumes that the file names are case sensitive so we need to retain
the case but we want the sort to be case insensitive):

---

while () {
($dir, $file) = split /:/;
$letter = uc(substr($file, 0, 1));
push(@{$files{$letter}}, [lc($file), $file, $dir])
}

#
# %files is now a hash array with keys that are the uppercase first letter
# of the file names and the values are array references
#
# Each array reference contains array references which contain
# the file name in lower case, the file name in the original case,
# and the dir name in the [0] and [1] positions
#

print "";

# print out the index
foreach $letter (sort keys %files) {
print "$letter<\/a> ";
}

# print out the file list
foreach $letter (sort keys %files) {
print "$letter\n";

foreach $file_ref (sort {$a->[0] cmp $b->[0]} @{$files{$letter}}) {
print "$file_ref->[2]:$file_ref->[1]\n";
}
}

---

Note that the conversion to upper or lower case only occurs once
when we are saving the file info. If you do the conversion in the sort
block, perl may end up doing the conversion on every comparison (unless it
caches the comparison values which it may well do). This comes at the
expense of having to save the converted filename, so if for some reason you
are tight on memory (i.e. 1000s of filenames) and have lots of CPU cycles
to spare, then you might not want to save it and do the case conversion in
the sort block.

There are, of course, lots of variations on this that will work
just as well!

---Larry




++
| Larry Coffin, G.P.H. Watertown, MA |
| http://www.PointInfinity.com/lcoffin/[EMAIL PROTECTED] |
++

Demographic polls show that you have lost credibility across the
board.  Especially with  those 14 year-old Valley girls.


-



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




reg shell commands

2002-10-21 Thread Elanchezhian Sivanandam
hi,

  i want to find the hierarchial path of a file inside a perl script.
  the path can be found using the shell command
  find [path] expression..
  and assign to a variable in perl.
  but it gives me a numerical value.
  how to get it as a string?

  thanks in advance.

cheers../elan


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




RE: XML module

2002-10-21 Thread NYIMI Jose (BMB)
> The above modules are based around the expat libraries. There 
> are also modules based around the gnome libxml2 libraries, 
> which seem to be faster, but less portable:

It seems that you must be root to install libxml2 libraries, right ?
while expat libraries offer more flexibility with the option --prefix:
../configure --prefix=/home/my/install/dir

José.


 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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




Re: A better way to handle array index?

2002-10-21 Thread Jenda Krynicky
From: chris <[EMAIL PROTECTED]>
> I am looking for a less cryptic way to handle array index.
> 
> most cryptic
> $array[0]
> 
> better
> use constant NAME => 0;
> $array[NAME]

This all depends on what do you want to do with the data structure.
But most probably you do want to use a hash.

$hash{NAME}

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


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




RE: sourcing CSH scripts from PERL and retaining variables

2002-10-21 Thread NYIMI Jose (BMB)
Yes !

use Shell::Source module

http://search.cpan.org/author/PJCJ/Shell-Source-0.01/Source.pm#SYNOPSIS


José.

> -Original Message-
> From: Zielfelder, Robert 
> [mailto:robert.zielfelder@;tycoelectronics.com] 
> Sent: Monday, October 21, 2002 4:51 PM
> To: Perl Beginners List (E-mail)
> Subject: sourcing CSH scripts from PERL and retaining variables
> 
> 
> Greetings,
> 
> Is there a way that I can source a CSH script from PERL that 
> sets a bunch of variables and import those variables into the 
> PERL script without resorting to having the CSH script write 
> a temp file that sets the variables in PERL syntax?
> 
> Robert Zielfelder
> 
> ..-.  --..
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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




Re: Substring and Sort

2002-10-21 Thread david
Anthony Akens wrote:

> I'm attempting to use the following code to read a file
> in the format of:
> 
> directory name:displayname
> 
> I want to sort the list by the "displayname", looking
> at the first letter for each display name in the file.
> If it's unique, I want to print it.  This should result
> in an alphabetical list of the letters for the display
> names.  However, the sort is not working quite right,
> and I sometimes get letters out of order, missing, or
> some that aren't even in the list.
> 
> Can anyone tell me what I've done wrong?
> 
> Tony
> 
> ---
> open (NAMES, $namefile)
> or die "Could not open $namefile $!";
> 
> while()
> {
> ($key, $value) = split /:/;
> chomp $value;
> $Names{$key} = $value;
> }
> close NAMES;
> 
> foreach $dirname (sort { "\L$a" cmp "\L$b" } keys %Names){
> $displayname = $Names{$dirname};
> $item = substr($displayname, 0, 1);
> push (@alpha, "\U$item") unless $seen{"\L$item"}++;
> }
> 
> print "";
> 
> foreach $letter(@alpha) {
> print "$letter<\/a> ";
> }
> 

if you want to sort by displayname, those are the values of the hash, not 
the keys. you might want to try something like:

#!/usr/bin/perl -w
use strict;

my %Names;
my %Seen;

open(NAMES,$nameFile) || die $!;
while(){
chmop;
my($key,$value) = split(/:/);
$Names{$key} = $value;
}
close(NAMES);

foreach my $value (sort {lc $a cmp lc $b} values %Names){
next unless($value =~ /(.)/ && !$seen{lc $1}++);
print "$1\n";
}

__END__

untested. see if the above works better.

david

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




RE: A better way to handle array index?

2002-10-21 Thread Jenda Krynicky
From: "Johnstone, Colin" <[EMAIL PROTECTED]>

> for example I read my form variables into a hash for processing. 
> 
> I then reference them by the form fieldname.
> 
> #read STDIN, $PostData, $ENV{'CONTENT_LENGTH'};
> 
> #print "post data =$PostData";
> 
> #postdata will look like this
> #[EMAIL PROTECTED]&radAction=unsubscribe&rad
> #Format=html&Submit=Submit I need to extract from this string the
> #fields and their values
> my @fields = split( /\&/, $PostData);
> 
> ...

Please don't do this. The query/posted data parsing is not as simple 
as it seems. You are much safer if you 
use CGI;

Or maybe
use CGI::Deurl;

Both available from CPAN, CGI.pm should already be installed.

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


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




Re: reg shell commands

2002-10-21 Thread Dharmender Rai
Read File::Find.
Some shell commands return 0 for success and others
for failure or some problem. The case with 'find' is
the same. If you are taking the return value then of
course you will get the numerical stuff.



 --- Elanchezhian Sivanandam <[EMAIL PROTECTED]>
wrote: > hi,
> 
>i want to find the hierarchial path of a file
> inside a perl script.
>the path can be found using the shell command
>find [path] expression..
>and assign to a variable in perl.
>but it gives me a numerical value.
>how to get it as a string?
> 
>thanks in advance.
> 
> cheers../elan
> 
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
>  

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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




problem using array of hashes and hash of hashes

2002-10-21 Thread naveen prabhakar

Hi experts,help!!

I am reading data from a text file and storing the data in an array of hashes and hash 
of hashes.I dont know how and where I need to pass the reference into the array and 
hash and dereference it.

The purpose of the code is to read data by column names and compare each record with a 
record from another text file.Could someone help me .Thank you. Naveen

I am sorry about the amount,style  of code I am enclosing.

 

 

# File to do the compare

sub compare {

my ($record_type,$raima_file,$db2_file) =@_;

print "raima file :$raima_file\n";

# my $raima_file =  "raima_profile.txt";
# my $db2_file = "db2profile.txt";

my @db2array;
my %hashb_outer;
my %hasha_outer;

open (RAIMA,$raima_file)
 or die "Cannot open file $raima_file\n";


print "Comparing raima and db2 profile files\n";

while( my $raimadata = ) {

 my @line_a;
 my %hash_a;
 
 chop $raimadata;
 $raimadata =~ s/\"//g;
 
 @line_a = split(/\|/,$raimadata);
  
 my @raimafields = &get_raima_field_names($record_type);
 
 
 while (@raimafields){
  
  my $raimafieldname = shift @raimafields;
 # print "raima field name is $raimafieldname \n";
  $hash_a{$raimafieldname} = shift @line_a;
 # print "raima hash value is  $hash_a{$raimafieldname} \n";
  
#push(@raimaarray,\%hash_a);
  
 } #end while of raimafields

 my $raimaid = "profile"." ".$hash_a{"profile_user_id"}." ".$hash_a{"profile_country"};
 $hasha_outer{$raimaid} = \%hash_a;
 
}

open (DB2,$db2_file)
 or die "Cannot open file $db2_file\n";

 while( my $db2data = ) {
  
  my @line_b;
  my %hash_b;
  chop $db2data;
  $db2data =~ s/\"//g;
  @line_b = split(/\|/,$db2data);
  my @db2fields = &get_db2_field_names($record_type);
  
  while (@db2fields){
  
  my $db2fieldname = shift @db2fields;
   # print "db2 field name is $db2fieldname \n";
  $hash_b{$db2fieldname}= shift @line_b;
#  print "db2 hash value is  $hash_b{$db2fieldname} \n";
 

  
  }
 
  my $db2id = "profile"." ".$hash_b{"profile_user_id"}." ".$hash_b{"profile_country"};
 
  $hashb_outer{$db2id} = \%hash_b;
  
 }
&printRecDiffs(\@db2array,\%hasha_outer,$record_type);


} #end of compare


sub printRecDiffs {


 my ($db2array,$hashRaima,$record_type) =@_;
 
 my %ignored_fields = &get_ignored_fields($record_type);
 
 my %char_fields = &get_char_fields($record_type);
 

  
 for $i (0..$#{$db2array})
 {
 
 my %db2hash1 = %{$$db2array[$i]};
 my $id;
 
   #  if($record_type eq "profile"){
  
  $id= "profile"." ".$db2hash1{"profile_user_id"}." ".$db2hash1{"profile_country"};
  
 # print "inside profile id value is $id\n";
# }
 
# print "check after char fields \n";
 
 if (exists $$hashRaima{$id})
 {
  
  my %raimahash = %{$$hashRaima{$id}};
 
  
  
  foreach $db2key (keys %db2hash1)
  {
  # print "the value for the key $db2key is $db2hash1{$db2key}\n";
  
  if ($ignored_fields{$db2key}) 
  {
   print "ignored fieldname is $db2key :$ignored_fields{$db2key}\n";
   next;
  }
  if ($char_fields{$db2key}) {
   
   print "char field name is $db2key :$char_fields{$db2key} \n";
   $raimahash{$db2key} = chr($raimahash{$db2key});
   
  }

  if( $db2hash1{$db2key} ne $raimahash{$db2key})
  {
   # print the differences
   if($db2hash1{$db2key} =~ /[+-]?\d+\.?\d*$/ )
   {
   if($db2hash1{$db2key} != $raimahash{$db2key})
   {
print "numeric \n";
print "the key is $db2key\n";
print " db2 value is $db2hash1{$db2key}\n";
print " raima value is $raimahash{$db2key}\n";
   }
   }
   else
   {
   print "the key is $db2key\n";
   print " db2 value is $db2hash1{$db2key}\n";
   print " raima value is $raimahash{$db2key}\n";
   }
   
  } #if
  
  } #foreach
  
  
 } #if
 else {
  print "The record doesnt exist in Raima\n";
 }
 
 } #for
 
}

end of code


 

 



-
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site


Weekly posting statistics - 42/2002

2002-10-21 Thread Felix Geerinckx
Weekly posting statistics for perl.beginners - week 42 of 2002.

>From Monday 2002-10-14 to Sunday 2002-10-20 there were 
373 articles posted (18397 lines) by 114 authors, giving an average 
3.27 articles per author, and an average article length of 49 lpa.
The average number of articles per day was 53.

There were 103 (28%) original articles, and 270 (72%) replies
(articles that started with 'RE:' in their subject line).

53 (46%) authors posted only one article.

The authors top-10 by number of articles is as follows:

 All/Ori Lines  lpa  Author

  23/0 970   42  [EMAIL PROTECTED] (John W. Krahn)
  23/0 762   33  [EMAIL PROTECTED] (Jeff 'Japhy' Pinyan)
  18/51082   60  [EMAIL PROTECTED] (James Edward Gray ...
  16/0 475   29  [EMAIL PROTECTED] (Michael Fowler)
  13/01036   79  [EMAIL PROTECTED] (Rob)
  12/0 443   36  [EMAIL PROTECTED] (Jenda Krynicky)
  11/1 794   72  [EMAIL PROTECTED] (Timothy Johnson)
  11/0 659   59  [EMAIL PROTECTED] (Beau E. Cox)
   7/2 557   79  [EMAIL PROTECTED] (Rakhitha M...
   7/3 474   67  [EMAIL PROTECTED] (Folschette)

-- 
felix

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




XML module

2002-10-21 Thread Admin-Stress
Hi,

anyone can suggest me XML module for reading/parsing/modifying an XML file?

Thanks,
kapot

__
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/

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




Digest::MD5 -> U32 /usr/bin/ld -> cannot find -ldb

2002-10-21 Thread cmustard
I am trying to install Digest::MD5 on a linux box (perl 5.6.1, yes i know i
should,). i have gzip'd and tar'd the package, moved into the directory
and tried to 'perl Makefile.PL' and i get the following error message:
Testing alignment requiremnets for U32... /usr/bin/ld: cannot find -ldb
collect2: ld returned 1 exit status
Can't compile test program
Writing Makefile for Digest::MD5

from what i understand this means that the linker (/usr/bin/ld) program 
can't find the 'db' lib(?) but neither can i,... i went to gnu.org and
could not find anything relevent.  ( the reason i came to this conclusion
is originally the error read 'cannot find -lgdbm', which i did find at
gnu.org and installed,...)

I do know about the auto CPAN module and am in the process of installing it 
but that (CPAN) stated that it wanted LWP, LWP stated that it needed Digest::MD5
, Digest, told me the above.

Any insight is very much appreciated
thank you. 
( i don't always check this list, please 'cc' me if you respond )

-mustard


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