RE: Creating a word document

2004-09-29 Thread Raymond Raj
hi
use Win::OLE module
some examples availbe at
http://perlmonks.thepen.com/198045.html


-Original Message-
From: paul beckett (JIC) [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 29, 2004 6:58 PM
To: [EMAIL PROTECTED]
Subject: Creating a word document


I've been trying to find a perl module that can create microsoft word
documents and failed. Does anyone know of one?

Cheers,

Paul

-- 
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: (when) is the ; required?

2004-09-29 Thread Gunnar Hjalmarsson
Chris Devers wrote:
Gunnar Hjalmarsson wrote:
The ';' character separates statements within a block.
Accordingly, it's not needed after the last statement.
That said, it's a good habit to include it. If you ever come back
to edit that file later, the original last statment might not
always be the last statement, and if you forget to add it -- which
would be all too easy to do -- then things will break.
Agreed. (I confined myself to give a plausible explanation to the OP's
observation.)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: (when) is the ; required?

2004-09-29 Thread Chris Devers
On Thu, 30 Sep 2004, Gunnar Hjalmarsson wrote:

> The ';' character separates statements within a block. Accordingly, 
> it's not needed after the last statement.

That said, it's a good habit to include it. If you ever come back to 
edit that file later, the original last statment might not always be the 
last statement, and if you forget to add it -- which would be all too 
easy to do -- then things will break. 

My impression is that the missing semi-colon is allowed to make it so 
that statements like this --

  sub ack { print "Ack! Ack! Mars will rule!" }

-- work as one-liners without having to fuss over another semi-colon. 
For anything longer than a single-statement one-liner, it's a bad habit.

IMO.

 

-- 
Chris Devers

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




Perl and Postgres

2004-09-29 Thread Eduardo Vázquez Rodríguez
Hello everybody out there using postgres and perl
I am writing Perl scripts with the purpouse of parsing text and 
inserting the text parsed into a database, which I choose Postgresql.

My scripts are many, exactly 7, if I ran each one of them sequencially, 
my processing speed is about 200 lines per second, but if I ran 
concurrently the 7 scripts my processing speed downs to 1 line per 
second, which is not acceptable.

My strategy of connecting to the database is the following
$mbd = DBI->connect("dbi:Pg:dbname=$database", "$username", "$password")
or die "Error opening database: $DBI::errstr \n";
$sth1 = $mbd->prepare
("
  INSERT INTO public.table ( date, time, time_taken, c_ip, 
sc_status,
s_action, sc_bytes, cs_bytes, 
cs_method,
cs_uri_scheme, cs_host, 
cs_uri_stem,
cs_username, s_hierarchy, 
s_supplier_name,
cs_content_type, cs_user_agent, 
sc_filter_result,
sc_filter_category, xvirus_id, 
s_ip, s_sitename)

VALUES  (?::varchar(10),  ?::varchar(8) , ?::float4 , 
?::varchar(15),
 ?::varchar(5) ,  ?::varchar(30), ?::float4, ?::float4,
 ?::varchar(10),  ?::varchar(10), ?::varchar(50), 
?::varchar(800),
 ?::varchar(30),  ?::varchar(20), ?::varchar(30), 
?::varchar(30),
 ?::varchar(200), ?::varchar(30), ?::varchar(30), 
?::varchar(30),
 ?::varchar(15),  ?::varchar(30))
 ");

And when I insert
 $sth1->execute ($normal[0],  $normal[1],  $normal[2],  $normal[3], 
 $normal[4],
$normal[5],  $normal[6],  $normal[7], 
$normal[8],  $normal[9],
$normal[10], $normal[11], $normal[12], 
$normal[13], $normal[14],
$normal[15], $normal[16], $normal[17], 
$normal[18], $normal[19],
$normal[20], $normal[21])

or die "Can't insert $DBI::errstr\n"

Every script use 3 database handlers of the "same size", I mean using 
the same numbers of fields.

My question is
How can I improve the database performance?
Is there anything wrong on my database handlers that degrade the 
performance, from 200 lines per second to 1 line per second?


Thanks in advanced.

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



Re: (when) is the ; required?

2004-09-29 Thread Gunnar Hjalmarsson
John wrote:
I was just updating some old script and found a big switch full of 
one-liners.  In one of the cases there is no ";".  Why doesn't the 
interpreter flag that as a syntax error?
The ';' character separates statements within a block. Accordingly, 
it's not needed after the last statement.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Open a text file

2004-09-29 Thread Eduardo Vázquez Rodríguez
Thanks Chris I try this and works
  $. = 0;
do
{
$_ = 
}
until $. == 5;
WHILE 
{
Do_whatever_you_like_begining_after_line_5();  :-)
}
Chris Devers wrote:
On Wed, 29 Sep 2004, Eduardo Vázquez Rodríguez wrote:

I have a question, how do I open a file in a specific line number, for example
I want to open a text file exactly on line number 5,

What have you tried so far?
What problems did you have?
Show us what you've tried and we can make suggestions.


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



(when) is the ; required?

2004-09-29 Thread John
I was just updating some old script and found a big switch full of 
one-liners.  In one of the cases there is no ";".  Why doesn't the 
interpreter flag that as a syntax error?

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



Re: Open a text file

2004-09-29 Thread Chris Devers
On Wed, 29 Sep 2004, Eduardo Vázquez Rodríguez wrote:

> I have a question, how do I open a file in a specific line number, for example
> I want to open a text file exactly on line number 5,

What have you tried so far?

What problems did you have?

Show us what you've tried and we can make suggestions.




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


Open a text file

2004-09-29 Thread Eduardo Vázquez Rodríguez
Hello everyone
I have a question, how do I open a file in a specific line number, for 
example I want to open a text file exactly on line number 5,

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



Re: UNIX Process List (U)

2004-09-29 Thread Owen
On Wed, 29 Sep 2004 07:52:53 -0400
"Meidling, Keith, CTR, ISD" <[EMAIL PROTECTED]> wrote:

> Is there a module to get a list of processes on a UNIX/Linux machine, or
> would I just do a `ps` and save it to an array?





There is a program in the Perl Cookbook called 'psgrep' which may meet your need.



-- 
Owen



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




Re: how to open a file with 666 permission

2004-09-29 Thread Gunnar Hjalmarsson
Bob Showalter wrote:
Chris Devers wrote:
Maybe the program is a code generator that produces other files
which should be executable (I can't remember anyone doing this,
but there's no reason why it couldn't be reasonably be done).
Fine, use creation bits of 0777.
Are you saying that
open FH, "> $file";
chmod 0777, $file;
is fine, while
umask 0;
sysopen FH, $file, O_CREAT|O_RDWR, 0777;
is not? In that case, I'm really confused by now. ;-)
Neither of these require fooling with umask.
If you want to set permission 777 via e.g. sysopen() or mkdir(), you
do need to set umask, unless it happens to be 0 to start with.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: connect through socks

2004-09-29 Thread William Melanson
On Sun, 26 Sep 2004, Ing. Branislav Gerzo wrote:

> Hi perlers,
> 
> anyone knows how to connect to a website and download it through socks
> (ver 4,5) ? I tried IO::Socket::Socks and Net::SOCKS, but I can't get
> them to work.

I know it can be done via 'LWP::UserAgent'. Not sure via a socket though.

-- 


Regards,

Bill

==
William Melanson: WebUnited Systems Administration
Phone: 954-418-8884 Ext: 287
==



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




RFC on script

2004-09-29 Thread RichT
   Hello knowledgeable perl type people

 im still very new to perl and, iv got my script "working",  what
is does in searches  through a large data file finds the segments i
need and outputs
 the data in a more use-full format. As i said id does work but im
no to convinced the structure is very clean
 so i  thort maybe some one could give me some pointers.

yours
most gratefully RichT


scanPoller.cfg.pl==

#!/usr/local/bin/perl

use strict;
use warnings;
use Getopt::Long;

my($inFile,$USAGE,$showKey,$site,$found,$foundKeys,@dataFile,@foundSegments,$value);

my($opt_inFile, $opt_showAll, $opt_help ) = (0,0,0);

my $feildName = "agentAddress";
my $showFields = "segment,agentAddress,community";

$USAGE = < \$feildName,
"showFeilds=s"  => \$showFields,
"showAll",
"help|h|H|?|HELP"
);

if ($opt_help == 1) {print $USAGE; exit; } # print out help and exit 

# start finding results
if ($inFile){  # find  results if we have in -inFile
open DFILE, "$opt_inFile"  # open $inFile and read in  or die
or die " could not open $opt_inFile";
@dataFile = ;
close DFILE;

foreach $value (@dataFile) {  # loop  for each line/site in dataFile
chomp $value ;
@foundSegments=findVars($feildName,$value); 
}
} elsif ($ARGV[0]) { # read in value from comandline

foreach $value ($ARGV[0]) {  # loop  for each line/site in dataFile
@foundSegments=findVars($feildName,$value);
}
} else {print $USAGE; exit; }   #quit if no values are supplyed...


# start show results
if ($opt_showAll) { # if show all option then print out every thing
 for $found ( @foundSegments ) {
print "\n" ;
for $foundKeys (keys %$found) {
print "$foundKeys,$found->{$foundKeys}\n";
}
 }
} else {# show chosen fields
 for $found ( @foundSegments ) {
foreach $showKey (split /,/, $showFields) {
print "$found->{$showKey},";
}
print "\n";
 }
}

sub findVars {

# Function Check Discover Results
#



my($findKey, $findValue, $segmentFieldKey, $segmentFieldValue,
%segmentFields, $nullVar, @foundSegments);

# read in Search Key and Value  from parent NOTE make a check for this
$findKey=$_[0] || die "Missing Args $findKey $!" ;
$findValue=$_[1] || die "Missing Args $findValue $!" ;
chomp $findValue;
chomp $findKey;
#my $NH_HOME= $ENV[NH_HOME];  # point to the poller CFG file
my $NH_HOME= ".";  # point to the poller CFG file NOTE this is temp
for testing use above line in live


local $/ = "}\n";   # set delimiter


open(POLLER, "$NH_HOME/poller.cfg") || die "can not open : $!";

while() {
next unless /^\s+segment/;
s/\n\s+\}\n//g;
s/["{]//g;
foreach (split(/\n/)) {
($nullVar,$segmentFieldKey,$segmentFieldValue) = split(/\s+/,$_,3);
$segmentFields{ $segmentFieldKey } = $segmentFieldValue ;
}
if ( $segmentFields{$findKey} eq $findValue ) {

push @foundSegments, {%segmentFields } ; 
}
undef %segmentFields;
my %segmentFields;
}
close POLLER;

return (@foundSegments);  # return the data
}; 

/scanPoller.cfg.pl==


exampleExtract form poller.cfg==

segment "customer-site-Bend" {
agentAddress "x.x.x.x"
uniqueDeviceId   "dfofdkskhjkldsf"
mibTranslationFile "cisco-frameRelay-cir.mtf"
index"2"
index2   "400"
deviceSpeed  "64000.0"
deviceSpeed2 "64000.0"
discoverMtf  "cisco-frameRelay-cir.mtf"
index3   "7"
community"public"
sysDescr "Cisco Internetwork Operating System Software
IOS (tm) C1700 Software (C1700-Y-M), Version 12.1 blar blar..."
sysName  "routerName"
sysLoc   "siteLocation"
ifDescr  "Serial0"
ifType   "frame-relay"
aliasName"PVCreffNumber"
nmsKey   "routerName Serial0 400"
enterpriseId "9"
possibleLatencySources "concord, ciscoPing"
fullDuplex   "1"
mediaSpeed   "64000.0"
mediaSpeed1  "64000.0"
statistics   "1"
}


exampleExtract form poller.cfg==

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




Re: Need help with script

2004-09-29 Thread JupiterHost.Net
I would like the output in the following format
object1<...tab>Description1
object2<...tab>Description2
object3<...tab>Description3

perl -lne 'BEGIN{$/="\n\n";}s/\n/\t/;print' FILENAME

perl -l -00pe's/\n/\t/' FILENAME
That's pretty slick you guys, he's sure to get an A+ ;)
If your teacher requires the quotes to be removed:
 perl -l -00pe's/\n/\t/;s/\"//g;' FILENAME
:)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Need help with script

2004-09-29 Thread John W. Krahn
Ramprasad A Padmanabhan wrote:
On Wed, 2004-09-29 at 18:55, PerlDiscuss - Perl Newsgroups and mailing
lists wrote:
I have a file with the following format
Object1
"Description1"
Object2
"Description"
Object3
"Description"
I would like the output in the following format
object1<...tab>Description1
object2<...tab>Description2
object3<...tab>Description3
perl -lne 'BEGIN{$/="\n\n";}s/\n/\t/;print' FILENAME

perl -l -00pe's/\n/\t/' FILENAME

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



subroutines and modules

2004-09-29 Thread DBSMITH
Perl'ers

I am reading Object Oriented Perl pages 52 and 53 for setting up a module. 
 It is telling me in order to use a routine from a different file you have 
to

1) choose a lib directory
2) export PERL5LIB=.../.../.../
use lib /usr/local/perl/my.pl
3) created nested subdirs for each component of the module name
4) create a text file in the last directory
5) Insert you code.
6) add 1; at then end of the perl program file.


NOTE:  is says in the footer that I can use h2xs to combine steps 3 and 4. 
 

My quesiton is can't I just use step 2 and then in my program where I want 
to use this code, make a routine call?
My goal is to set up a module for a routine that I can pass a data file 
to,  from a different file  so it can read this file in then execute.
an example would be :  &routine(datafile);

I then looked into Perl Cookbook ch 12_02 and it discussed :



In module file YourModule.pm, place the following code. Fill in the ellipses as 
explained in the 
Discussion section.
package YourModule;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);

use Exporter;
$VERSION = 1.00;  # Or higher
@ISA = qw(Exporter);

@EXPORT  = qw(...);   # Symbols to autoexport (:DEFAULT tag)
@EXPORT_OK   = qw(...);   # Symbols to export on request
%EXPORT_TAGS = (  # Define names for sets of symbols
TAG1 => [...],
TAG2 => [...],
...
);


# your code goes here


1;# this should be your last line 



Is one autoloader and self loader?  It seems to me I am getting 
conflicting info of just that I am not understanding?

thanks, derek

RE: how to open a file with 666 permission

2004-09-29 Thread Chris Devers
On Wed, 29 Sep 2004, Bob Showalter wrote:

> Chris Devers wrote:
> 
> > Maybe the program is a code generator that produces other
> > files which should be executable (I can't remember anyone doing this,
> > but there's no reason why it couldn't be reasonably be done).
> 
> Fine, use creation bits of 0777.
> 
> Neither of these require fooling with umask.

Did I say umask was required? If so, that wasn't what I meant. 

I'm not getting into the mechanism of how permissions get set; I'm 
saying that there are clear, justifiable cases where a program can have 
a legitmate need to set permissions in any way the programmer sees fit. 
The user of such a program may choose to override these settings, but 
that may or may not invalidate the reasons for originally setting them.
 
> My gripe is with a program that decides a file _needs_ to be created 
> as 666, for example.

Everything has a place. Sometimes it can make sense. 


-- 
Chris Devers

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




RE: how to open a file with 666 permission

2004-09-29 Thread Bob Showalter
Chris Devers wrote:
> On Wed, 29 Sep 2004, Bob Showalter wrote:
> 
> > Gunnar Hjalmarsson wrote:
> > > 
> > > If the program, for some reason, requires that a file it creates
> > > has certain permissions, isn't it better to have the program set
> > > those permissions?
> > 
> > Why would the program itself require this? Perhaps the way I'm
> > _using_ the program requires this, but then let me control the
> > environment. 
> 
> There's nothing wrong with enforcing file permissions
> programmatically. 
> 
> Maybe the program creates a log file that shouldn't be readable by
> anyone. 

Anyone? Maybe you mean owner only? Fine, use creation bits of 0600.

> Maybe the program is a code generator that produces other
> files which should be executable (I can't remember anyone doing this,
> but there's no reason why it couldn't be reasonably be done).

Fine, use creation bits of 0777.

Neither of these require fooling with umask.

My gripe is with a program that decides a file _needs_ to be created as 666,
for example.

> 
> Messing with the general umask isn't polite, but it's okay to manage
> the permissions of files a program governs, if the problem it was
> written to solve has such a requirement.

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




RE: how to open a file with 666 permission

2004-09-29 Thread Chris Devers
On Wed, 29 Sep 2004, Bob Showalter wrote:

> Gunnar Hjalmarsson wrote:
> > 
> > If the program, for some reason, requires that a file it creates has 
> > certain permissions, isn't it better to have the program set those 
> > permissions?
> 
> Why would the program itself require this? Perhaps the way I'm _using_ 
> the program requires this, but then let me control the environment.

There's nothing wrong with enforcing file permissions programmatically. 

Maybe the program creates a log file that shouldn't be readable by 
anyone. Maybe the program is a code generator that produces other files 
which should be executable (I can't remember anyone doing this, but 
there's no reason why it couldn't be reasonably be done). 

Messing with the general umask isn't polite, but it's okay to manage the 
permissions of files a program governs, if the problem it was written to 
solve has such a requirement.


-- 
Chris Devers

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




Re: Create hash from MySQL field headers

2004-09-29 Thread JupiterHost.Net
perldoc DBI
look for selectrow_hashref

Mucho gracias... I'll look it up, but the name certainly implies that
it is what I am after.
Glad I could help :)
HTH :)
 
I'm certain it will.

Thanks again!
Steve
Lee.M - JupiterHost.Net

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



Re: Converting special characters?

2004-09-29 Thread KEVIN ZEMBOWER
>>> Wiggins d Anconia <[EMAIL PROTECTED]> 09/29/04 12:08PM >>>
If possible you should consider using a CSV formatting module, this will
translate best into Access (which you should avoid completely if
possible).  Text::CSV or even DBI/D::CSV are excellent.  These modules
will allow you to setup your delimiters however you wish, and Access
should support importing from them.

helps?

http://danconia.org

===
Helps very much. Thank you, Wiggins.

-Kevin


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




RE: how to open a file with 666 permission

2004-09-29 Thread Chris Devers
On Wed, 29 Sep 2004 [EMAIL PROTECTED] wrote:

> Thanks for the support .the following is the code I have written.
> Working fine.

Still not right though -- it was suggested to you that you use the $! 
variable in your die statement so that you get the error message, hence:

  do_stuff( $arg) or die "Can't do stuff!"; # bad!
  do_stuff( $arg) or die "Can't do stuff!" $!;  # good!

Also, as another person noted, chown() and chmod() are built in to Perl, 
so there's no need to make a system call to do these operations.

Also, why are you prefixing your variables with $main:: ? There can be 
good reasons to do this, but they're esoteric -- most of the time you 
can safely leave out the 'main::' part.  



-- 
Chris Devers

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




Re: Create hash from MySQL field headers

2004-09-29 Thread Steve Bertrand
> Steve Bertrand wrote:
>
>> Hi all,
>
> Hello,
>
>> I've been developing a module for our accounting system and am
>> trying
>> to create a hash with the names equal to the fieldnames of the
>> database table.
>>
>> It seems as though 'ListFields' is not functioning, and am wondering
>> if there is another way.
>>
>> I simply want to SELECT a single line from the table, have it stored
>> in a hash, with the name as the fieldname and the value as the
>> actual
>> data.
>>
>> Any help would be greatly appreciated, and I am not afraid to go
>> R'ingAFM if someone could supply decent links.
>
> perldoc DBI
> look for selectrow_hashref

Mucho gracias... I'll look it up, but the name certainly implies that
it is what I am after.

> HTH :)

I'm certain it will.

Thanks again!

Steve

>
> Lee.M - JupiterHost.Net
>



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




Re: Converting special characters?

2004-09-29 Thread Wiggins d Anconia
> I've been given the job of writing a CGI script to receive the data
from a form and append it to a text file. Later, the text file will be
analyzed using MS Access. My problem is escaping characters which are
often used as delimiters in text-based importing formats, such as ' or "
or \t or \n. Any of these could be legitimately entered by a user into
the text fields of the form. I'd like to capture these, and not just
discard them, and in such as way that they can be easily converted back
into the original characters after importing into Access.
> 
> Is there a standardized or commonly accepted way of doing this?
> 
> I first looked at HTML::Entities, but it doesn't look as if it
converts \t or \n. Otherwise, this would be a good choice. I also looked
at Unicode::Strings, but it seemed as if this would convert the entire
string to Unicode, which I don't  know if Access accepts, or if this
would even solve my problem.
> 
> The form is an Adobe .pdf form with editable fields, which returns the
data as an .fdf file. Don't think this is important, but you can learn
more about it at http://www.adobe.com/support/techdocs/27f9a.htm.
> 
> I tried searching CPAN on 'encoding' but that didn't seem to be the
right term.
> 
> Thanks for your help and advice.
> 
> -Kevin
> 

If possible you should consider using a CSV formatting module, this will
translate best into Access (which you should avoid completely if
possible).  Text::CSV or even DBI/D::CSV are excellent.  These modules
will allow you to setup your delimiters however you wish, and Access
should support importing from them.

helps?

http://danconia.org

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




Re: POSIX module

2004-09-29 Thread Errin Larsen
On Wed, 29 Sep 2004 12:27:03 -0400, Bob Showalter
<[EMAIL PROTECTED]> wrote:
> Errin Larsen wrote:
> > When I use the following in my code, it runs and
> > works fine:
> >
> >   use POSIX 'setsid';
> >   use POSIX 'errno_h';
> >   use POSIX ':sys_wait_h';
> >
> > However, when I try to combine those into one line:
> >
> >   use POSIX qw/setsid errno_h :sys_wait_h/;
> >
> > Then I get the following error:
> >
> > # ismon.pl
> > ":errno_h" is not exported by the POSIX module at
> > /usr/perl5/5.6.1/lib/sun4-solaris-64int/POSIX.pm line 19
> >
> > ":sys_wait_h" is not exported by the POSIX module at
> > /usr/perl5/5.6.1/lib/sun4-solaris-64int/POSIX.pm line 19
> >
> > Can't continue after import errors at
> > /usr/perl5/5.6.1/lib/sun4-solaris-64int/POSIX.pm line 19
> > BEGIN failed--compilation aborted at ./ismon.pl line 3.

<< SNIP >>

> 
> Exporter only does the special :tag processing if the *first* entry in the
> import list starts with one of the following characters
> 
>: ! /
> 
> So move :sys_wait_h to the front and it will work.
> 

Thanks Bob, that did it.

I wonder why that is about Exporter?  It seems rather counter-intuitive to me.

--Errin

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




Re: Create hash from MySQL field headers

2004-09-29 Thread JupiterHost.Net
Steve Bertrand wrote:
Hi all,
Hello,
I've been developing a module for our accounting system and am trying
to create a hash with the names equal to the fieldnames of the
database table.
It seems as though 'ListFields' is not functioning, and am wondering
if there is another way.
I simply want to SELECT a single line from the table, have it stored
in a hash, with the name as the fieldname and the value as the actual
data.
Any help would be greatly appreciated, and I am not afraid to go
R'ingAFM if someone could supply decent links.
perldoc DBI
look for selectrow_hashref
HTH :)
Lee.M - JupiterHost.Net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: POSIX module

2004-09-29 Thread Bob Showalter
Errin Larsen wrote:
> When I use the following in my code, it runs and
> works fine: 
> 
>   use POSIX 'setsid';
>   use POSIX 'errno_h';
>   use POSIX ':sys_wait_h';
> 
> However, when I try to combine those into one line:
> 
>   use POSIX qw/setsid errno_h :sys_wait_h/;
> 
> Then I get the following error:
> 
> # ismon.pl
> ":errno_h" is not exported by the POSIX module at
> /usr/perl5/5.6.1/lib/sun4-solaris-64int/POSIX.pm line 19
> 
> ":sys_wait_h" is not exported by the POSIX module at
> /usr/perl5/5.6.1/lib/sun4-solaris-64int/POSIX.pm line 19
> 
> Can't continue after import errors at
> /usr/perl5/5.6.1/lib/sun4-solaris-64int/POSIX.pm line 19
> BEGIN failed--compilation aborted at ./ismon.pl line 3.
> 
> First of all, I'm not putting a ':' in front of 'errno_h' in my code,
> but Perl seems to assume it's there ... why?

POSIX fixes up foo_h as :foo_h for some reason

> Is there a difference
> between the two implementations above that I'm not seeing?

Exporter only does the special :tag processing if the *first* entry in the
import list starts with one of the following characters

   : ! /

So move :sys_wait_h to the front and it will work.

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




Create hash from MySQL field headers

2004-09-29 Thread Steve Bertrand
Hi all,

I've been developing a module for our accounting system and am trying
to create a hash with the names equal to the fieldnames of the
database table.

It seems as though 'ListFields' is not functioning, and am wondering
if there is another way.

I simply want to SELECT a single line from the table, have it stored
in a hash, with the name as the fieldname and the value as the actual
data.

Any help would be greatly appreciated, and I am not afraid to go
R'ingAFM if someone could supply decent links.

TIA,

Steve


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




Re: POSIX module

2004-09-29 Thread Errin Larsen
On Wed, 29 Sep 2004 11:32:58 -0400, Jim <[EMAIL PROTECTED]> wrote:
> 
> 
> 
> > Hi Perlers,
> >
> > I've seen a lot of tutorial or example code dealing with the
> > POSIX module that does something like this:
> >
> >   use POSIX ':sys_wait_h';
> >
> > What does the ':' mean/do in the above line?
> >
> 
> Besides googling for it, try reading:
> perldoc perlipc
> perldoc perldoc -f waitpid
> perldoc POSIX
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.770 / Virus Database: 517 - Release Date: 9/27/2004
> 
> 

Thank you Bob, and Jim

I have read about this.  My question is more about the 'use' code then
about the POSIX module.  It's just a really big module that has a lot
of these tags in it, it seems.

Here's my problem:  When I use the following in my code, it runs and works fine:

  use POSIX 'setsid';
  use POSIX 'errno_h';
  use POSIX ':sys_wait_h';

However, when I try to combine those into one line:

  use POSIX qw/setsid errno_h :sys_wait_h/;

Then I get the following error:

# ismon.pl
":errno_h" is not exported by the POSIX module at
/usr/perl5/5.6.1/lib/sun4-solaris-64int/POSIX.pm line 19

":sys_wait_h" is not exported by the POSIX module at
/usr/perl5/5.6.1/lib/sun4-solaris-64int/POSIX.pm line 19

Can't continue after import errors at
/usr/perl5/5.6.1/lib/sun4-solaris-64int/POSIX.pm line 19
BEGIN failed--compilation aborted at ./ismon.pl line 3.

First of all, I'm not putting a ':' in front of 'errno_h' in my code,
but Perl seems to assume it's there ... why?  Is there a difference
between the two implementations above that I'm not seeing?

--Errin

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




RE: How to access first key of "Hash of Hash"

2004-09-29 Thread Bob Showalter
Edward Wijaya wrote:
> I thought 'keys' are only for simple hash.

All hashes are simple hashes, if you think about it. Each entry is a string
key and a scalar value. There is no other kind of hash.

Now that scalar value can be a *reference* to something else, and you get a
bit of syntactic sugar for dereferencing it. But it's still just a scalar.

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




RE: POSIX module

2004-09-29 Thread Jim
 
> Hi Perlers,
> 
> I've seen a lot of tutorial or example code dealing with the 
> POSIX module that does something like this:
> 
>   use POSIX ':sys_wait_h';
> 
> What does the ':' mean/do in the above line?
>

Besides googling for it, try reading:
perldoc perlipc
perldoc perldoc -f waitpid
perldoc POSIX  

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.770 / Virus Database: 517 - Release Date: 9/27/2004
 


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




Converting special characters?

2004-09-29 Thread KEVIN ZEMBOWER
I've been given the job of writing a CGI script to receive the data from a form and 
append it to a text file. Later, the text file will be analyzed using MS Access. My 
problem is escaping characters which are often used as delimiters in text-based 
importing formats, such as ' or " or \t or \n. Any of these could be legitimately 
entered by a user into the text fields of the form. I'd like to capture these, and not 
just discard them, and in such as way that they can be easily converted back into the 
original characters after importing into Access.

Is there a standardized or commonly accepted way of doing this?

I first looked at HTML::Entities, but it doesn't look as if it converts \t or \n. 
Otherwise, this would be a good choice. I also looked at Unicode::Strings, but it 
seemed as if this would convert the entire string to Unicode, which I don't  know if 
Access accepts, or if this would even solve my problem.

The form is an Adobe .pdf form with editable fields, which returns the data as an .fdf 
file. Don't think this is important, but you can learn more about it at 
http://www.adobe.com/support/techdocs/27f9a.htm.

I tried searching CPAN on 'encoding' but that didn't seem to be the right term.

Thanks for your help and advice.

-Kevin


-
E. Kevin Zembower
Internet Systems Group manager
Johns Hopkins University
Bloomberg School of Public Health
Center for Communications Programs
111 Market Place, Suite 310
Baltimore, MD  21202
410-659-6139


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




RE: POSIX module

2004-09-29 Thread Bob Showalter
Errin Larsen wrote:
> Hi Perlers,
> 
> I've seen a lot of tutorial or example code dealing with the POSIX
> module that does something like this:
> 
>   use POSIX ':sys_wait_h';
> 
> What does the ':' mean/do in the above line?

It's called a "tag" and is typically used to import a "basket" of symbols.

See "perldoc Exporter", under the heading "Specialised Import Lists"

For some reason this isn't documented in my copy of POSIX. But you can see
the symbols exported by running:

  $ perl -MPOSIX -le 'print for @{$POSIX::EXPORT_TAGS{sys_wait_h}}'
  WEXITSTATUS
  WIFEXITED
  WIFSIGNALED
  WIFSTOPPED
  WNOHANG
  WSTOPSIG
  WTERMSIG
  WUNTRACED

(your system may show different values)

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




Help with ARP scan/reverse DNS script

2004-09-29 Thread Jason Noble
this script is supposed to take an input like 10.0.1.0/24
and output something like this
HOSTNAME MACADDRESS
node-1 00:30:48:28:E9:7E
node-2 00:30:48:29:12:1A

but it is only returning very few if any results.
anyone have any ideas, or maybe a better way to do this?


#!/usr/bin/perl
use strict;

use Getopt::Std;
use Net::DNS;
use IO::Select;
use Net::Netmask;

my $timeout = 5;
my $nameserver = "10.0.1.240";
my $subnet;
my %host;
my %opts;
getopts('n:', \%opts);

die "Usage: arp-scan_lookup.pl -n 10.0.0.0/24\n"
   unless $opts{n};

use Net::Pkt::DescL2;
Net::Pkt::DescL2->new;

use Net::Pkt::Quick;

$subnet = Net::Netmask->new2($opts{n});

my @frames;
for ($subnet->enumerate) {
   my $frame = Net::Pkt::Quick->arpRequest(
  whoHas  => "$_",
  tell=> $Net::Pkt::Ip,
  tellMac => $Net::Pkt::Mac,
  toMac   => 'broadcast',
   );
   push @frames, $frame;
}

use Net::Pkt::Dump;
my $dump = Net::Pkt::Dump->new(
   filter => "arp",
   unlinkAfterAnalyze => 1,
);

$dump->start;

$frames[$_ - 1]->send for $subnet->enumerate;

$dump->stop;

$dump->analyze;
my @replies;
for ($subnet->enumerate) {
   my $reply = $frames[$_ - 1]->recv;
   next unless $reply;
   push @replies, $reply;
}

sub lookup {
my $ip_address = shift;
my $result;
my $res = new Net::DNS::Resolver;
$res->nameservers( $nameserver );
my $bgsock = $res->bgsend( $ip_address );
my $sel = new IO::Select($bgsock);
my @ready = $sel->can_read($timeout);
if (@ready) {
foreach my $sock (@ready) {
if ($sock == $bgsock) {
my $packet = $res->bgread($bgsock);
if ($packet) {
foreach my $rr ($packet->answer) {
my $hostname = $rr->rdatastr;
$hostname =~ s/\.pz.local.//g;
$result = $hostname;
}
}
else { 
$result = $ip_address;
}
$bgsock = undef;
}
$sel->remove($sock);
$sock = undef;
}
}
else {
$result = $ip_address;
}
if ( $result eq "" ) { $result = $ip_address; }
return $result;
}

print lookup($_->arpSrcIp), "   ", $_->arpSrc, "\n" for @replies;

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




Re: How to access first key of "Hash of Hash"

2004-09-29 Thread Jose Alves de Castro
On Wed, 2004-09-29 at 15:32, Edward Wijaya wrote:
> On 29 Sep 2004 15:20:39 +0100, Jose Alves de Castro  
> <[EMAIL PROTECTED]> wrote:
> 
> 
> >
> > for (keys %HoH) {
> >   print "$_\n";
> > }
> >
> 
> It seems so. Thanks a lot.

Glad to be of help :-)

> I thought 'keys' are only for simple hash.
>
> Regards,
> Edward WIJAYA
> SINGAPORE
-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


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




POSIX module

2004-09-29 Thread Errin Larsen
Hi Perlers,

I've seen a lot of tutorial or example code dealing with the POSIX
module that does something like this:

  use POSIX ':sys_wait_h';

What does the ':' mean/do in the above line?

--Errin

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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-29 Thread JupiterHost.Net

Wiggins d Anconia wrote:

I like this thread, lots of opinions + not too many flames = productive 
learning
U ignorant piece of uh sorry

hehe good one :)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: how to open a file with 666 permission

2004-09-29 Thread Bob Showalter
Gunnar Hjalmarsson wrote:
> Bob Showalter wrote:
> > You need to set umask to 0 before creating the file.
> > 
> > But don't do that. It's inadvisable to mess with the umask in a
> > program, IMO.
> 
> Why would that be inadvisable?

The spirit of umask is to allow the user/sysadmin to control the "policy"
for permissions. It's desinged to be under the user's control. If you change
the umask in the program, you force me to chmod the file after I run the
program if I don't like the bits.

> 
> > If the user wants to create files as 666, let him set the umask
> > before running your program.
> 
> If the program, for some reason, requires that a file it creates has
> certain permissions, isn't it better to have the program set those
> permissions?

Why would the program itself require this? Perhaps the way I'm _using_ the
program requires this, but then let me control the environment.

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




RE: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-29 Thread NYIMI Jose \(BMB\)


> -Original Message-
> From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, September 29, 2004 4:38 PM
> To: JupiterHost.Net; [EMAIL PROTECTED]
> Subject: Re: Becoming Disenheartened - Everyone talks about 
> Python and says Perl is old news.
> 
> 
> > My what long lines you have :)
> > 
> > > It may not be commercial grade but, who of us writes commerical
> applications all the time. 
> > 
> > I do mostly, private corporate backends mostly among other 
> things :) I 
> > use it for the quick tasks and simple scripts also of course. (the 
> > projects never end the same as durability and ability)
> > 
> > And cPanel (http://cpanel.net) is mostly perl for instance. I'd say 
> > that's pretty commercial seeing as how many webhosts use it.
> > 
> > An associate of mine worked for/does consulting for a nationwide
> > communications provider that uses all perl for the website, 
> and backend 
> > employee/customer/support/work order/materials handling/etc etc.
> > 
> > Apple's website uses perl last I heard (the .adp extension is their
> > special build of it)
> > 
> > That's just 4 that I knew off off the top of my head.
> 
>http://perl.oreilly.com/pub/a/oreilly/perl/news/success_stories.html
>http://poe.perl.org/?Organizations_Using_POE
>
>Those are just a few more...

Indeed !
http://masonhq.com/?MasonPoweredSites

Plus more ...



 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 to open a file with 666 permission

2004-09-29 Thread Gunnar Hjalmarsson
Bob Showalter wrote:
You need to set umask to 0 before creating the file.
But don't do that. It's inadvisable to mess with the umask in a
program, IMO.
Why would that be inadvisable?
If the user wants to create files as 666, let him set the umask
before running your program.
If the program, for some reason, requires that a file it creates has
certain permissions, isn't it better to have the program set those
permissions?
One way may be to have umask and/or the permissions set as
configuration variables.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: How to access first key of "Hash of Hash"

2004-09-29 Thread Errin Larsen
On Wed, 29 Sep 2004 22:18:49 +0800, Edward Wijaya
<[EMAIL PROTECTED]> wrote:
> On 29 Sep 2004 14:58:00 +0100, Jose Alves de Castro
> <[EMAIL PROTECTED]> wrote:
> > If I understood this correctly, you want to do this:
> >
> 
> So sorry for being not clear.
> I will extend just a bit.
> 
> Suppose I have:
> 
> my %HoH = (
> firstkey => { A => 'blabla',
>   B => 'dadada',
>   C => 'tititi',}
> secondkey => { D => 'blabla',
>E => 'dadada',
>F => 'tititi',}
> 
> );
> 
> and I generated that HoH with this:
> 
> $HoH{$fkey}{$alpha}=$text;
> 
> namely:
> 
> "firstkey, secondkey" from $fkey
> "A, B, C, etc"from $alpha
> "blabla etc"  from $text
> 
> my question is how can I print output like:
> 
> firstkey
> secondkey
> 
> given the construction variables as mention before.
> 
> Thanks
> 
> Regards,
> Edward WIJAYA
> SINGAPORE
> 
> 
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 
> 

Jose was correct.  You need to read:

  perldoc -f keys

try this:

print "$_\n" foreach( keys %HoH );

--Errin

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




Re: How to access first key of "Hash of Hash"

2004-09-29 Thread Jose Alves de Castro
On Wed, 2004-09-29 at 15:18, Edward Wijaya wrote:
> On 29 Sep 2004 14:58:00 +0100, Jose Alves de Castro  
> <[EMAIL PROTECTED]> wrote:
> > If I understood this correctly, you want to do this:
> >
> 
> So sorry for being not clear.
> I will extend just a bit.
> 
> Suppose I have:
> 
> my %HoH = (
> firstkey => { A => 'blabla',
>   B => 'dadada',
>   C => 'tititi',}
> secondkey => { D => 'blabla',
>E => 'dadada',
>F => 'tititi',}
> 
> );
> 
> and I generated that HoH with this:
> 
> $HoH{$fkey}{$alpha}=$text;
> 
> namely:
> 
> "firstkey, secondkey" from $fkey
> "A, B, C, etc"from $alpha
> "blabla etc"  from $text
> 
> my question is how can I print output like:
> 
> firstkey
> secondkey

for (keys %HoH) {
  print "$_\n";
}

Was that it?

> given the construction variables as mention before.
> 
> Thanks
> 
> Regards,
> Edward WIJAYA
> SINGAPORE
-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-29 Thread Wiggins d Anconia
> My what long lines you have :)
> 
> > It may not be commercial grade but, who of us writes commerical
applications all the time. 
> 
> I do mostly, private corporate backends mostly among other things :)
> I use it for the quick tasks and simple scripts also of course. (the 
> projects never end the same as durability and ability)
> 
> And cPanel (http://cpanel.net) is mostly perl for instance.
> I'd say that's pretty commercial seeing as how many webhosts use it.
> 
> An associate of mine worked for/does consulting for a nationwide 
> communications provider that uses all perl for the website, and backend 
> employee/customer/support/work order/materials handling/etc etc.
> 
> Apple's website uses perl last I heard (the .adp extension is their 
> special build of it)
> 
> That's just 4 that I knew off off the top of my head.

http://perl.oreilly.com/pub/a/oreilly/perl/news/success_stories.html
http://poe.perl.org/?Organizations_Using_POE

Those are just a few more...

> 
> Perhaps you meant commercial grade as in you don't have to spend 
> thousands of dollars on a devleopment suite (hint hint Microsoft) and 
> hire a team of engineers to keep it running (hint hint PHP), in that 
> case I'd agree ;p
> 
> One thing my associate says that I agree with that may help with the 
> language blues is be proud of perl! When you do web apps in perl, use 
> .pl instead of .cgi. Show some pride man!! If you're host can't add one 
> line to apache conf to be able to serve .pl files then get a new host.
> 

I say drop the extension completely, no one needs to know what your
implementation is, as long as it works.

> [shameless plug] go to jupiterhost.net we *love* Perl [/shameless plug]
> 
> I like this thread, lots of opinions + not too many flames = productive 
> learning
>

U ignorant piece of uh sorry
 
> Just my .02
> 
> Lee.M - JupiterHost.Net
> 

http://danconia.org

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




Re: How to access first key of "Hash of Hash"

2004-09-29 Thread Flemming Greve Skovengaard
Edward Wijaya wrote:
On 29 Sep 2004 14:58:00 +0100, Jose Alves de Castro  
<[EMAIL PROTECTED]> wrote:

If I understood this correctly, you want to do this:
So sorry for being not clear.
I will extend just a bit.
Suppose I have:
my %HoH = (
   firstkey => { A => 'blabla',
 B => 'dadada',
 C => 'tititi',}
   secondkey => { D => 'blabla',
  E => 'dadada',
  F => 'tititi',}
   );
and I generated that HoH with this:
$HoH{$fkey}{$alpha}=$text;
namely:
"firstkey, secondkey" from $fkey
"A, B, C, etc"from $alpha
"blabla etc"  from $text
my question is how can I print output like:
firstkey
secondkey
How about:
print "$_\n" foreach( keys( %HoH ) );
or
map{ print "$_\n" } keys( %HoH );
Remember that a hash stores its keys/values in random order, so you will get
your keys in random order.
given the construction variables as mention before.

--
Flemming Greve SkovengaardThe prophecy of the holy Norns
a.k.a Greven, TuxPowerA tale of death and doom
<[EMAIL PROTECTED]>   Odin saw the final sign
4112.38 BogoMIPS  The end is coming soon
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Problem iterating over diamond (while)

2004-09-29 Thread Edward Wijaya
On 29 Sep 2004 14:06:33 -, Peter Scott <[EMAIL PROTECTED]> wrote:
Nitpick - the "diamond operator" is <>.  
would be use of the "readline operator".
Thanks for making it precise Peter.
Glad that I learnt that.
Forgive me for my limited Perl vocabulary.
Regards,
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-29 Thread Gavin Henry
JupiterHost.Net said:
> My what long lines you have :)
>
>> It may not be commercial grade but, who of us writes commerical
>> applications all the time.
>
> I do mostly, private corporate backends mostly among other things :)
> I use it for the quick tasks and simple scripts also of course. (the
> projects never end the same as durability and ability)
>
> And cPanel (http://cpanel.net) is mostly perl for instance.
> I'd say that's pretty commercial seeing as how many webhosts use it.
>
> An associate of mine worked for/does consulting for a nationwide
> communications provider that uses all perl for the website, and backend
> employee/customer/support/work order/materials handling/etc etc.
>
> Apple's website uses perl last I heard (the .adp extension is their
> special build of it)
>
> That's just 4 that I knew off off the top of my head.
>
> Perhaps you meant commercial grade as in you don't have to spend
> thousands of dollars on a devleopment suite (hint hint Microsoft) and
> hire a team of engineers to keep it running (hint hint PHP), in that
> case I'd agree ;p
>
> One thing my associate says that I agree with that may help with the
> language blues is be proud of perl! When you do web apps in perl, use
> .pl instead of .cgi. Show some pride man!! If you're host can't add one
> line to apache conf to be able to serve .pl files then get a new host.

I agree.

>
> [shameless plug] go to jupiterhost.net we *love* Perl [/shameless plug]
>
> I like this thread, lots of opinions + not too many flames = productive
> learning

Again, I agree.


More examples please

>
> Just my .02
>
> Lee.M - JupiterHost.Net
>
>
>
> --
> 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: How to access first key of "Hash of Hash"

2004-09-29 Thread Edward Wijaya
On 29 Sep 2004 15:20:39 +0100, Jose Alves de Castro  
<[EMAIL PROTECTED]> wrote:


for (keys %HoH) {
  print "$_\n";
}
It seems so. Thanks a lot.
I thought 'keys' are only for simple hash.
Regards,
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Problem iterating over diamond (while)

2004-09-29 Thread Peter Scott
Nitpick - the "diamond operator" is <>.  
would be use of the "readline operator".

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/

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




Re: How to access first key of "Hash of Hash"

2004-09-29 Thread Edward Wijaya
On 29 Sep 2004 14:58:00 +0100, Jose Alves de Castro  
<[EMAIL PROTECTED]> wrote:
If I understood this correctly, you want to do this:
So sorry for being not clear.
I will extend just a bit.
Suppose I have:
my %HoH = (
   firstkey => { A => 'blabla',
 B => 'dadada',
 C => 'tititi',}
   secondkey => { D => 'blabla',
  E => 'dadada',
  F => 'tititi',}
   );
and I generated that HoH with this:
$HoH{$fkey}{$alpha}=$text;
namely:
"firstkey, secondkey" from $fkey
"A, B, C, etc"from $alpha
"blabla etc"  from $text
my question is how can I print output like:
firstkey
secondkey
given the construction variables as mention before.
Thanks
Regards,
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Need help with script

2004-09-29 Thread Ramprasad A Padmanabhan
On Wed, 2004-09-29 at 18:55, PerlDiscuss - Perl Newsgroups and mailing
lists wrote:
> I have a file with the following format
> 
> Object1
> "Description1"
> 
> Object2
> "Description"
> 
> Object3
> "Description"
> 
> I would like the output in the following format
> object1<...tab>Description1
> object2<...tab>Description2
> object3<...tab>Description3
> 
> Thanks
> 

perl -lne 'BEGIN{$/="\n\n";}s/\n/\t/;print' FILENAME

HTH
Ram



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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-29 Thread JupiterHost.Net
My what long lines you have :)
It may not be commercial grade but, who of us writes commerical applications all the time. 
I do mostly, private corporate backends mostly among other things :)
I use it for the quick tasks and simple scripts also of course. (the 
projects never end the same as durability and ability)

And cPanel (http://cpanel.net) is mostly perl for instance.
I'd say that's pretty commercial seeing as how many webhosts use it.
An associate of mine worked for/does consulting for a nationwide 
communications provider that uses all perl for the website, and backend 
employee/customer/support/work order/materials handling/etc etc.

Apple's website uses perl last I heard (the .adp extension is their 
special build of it)

That's just 4 that I knew off off the top of my head.
Perhaps you meant commercial grade as in you don't have to spend 
thousands of dollars on a devleopment suite (hint hint Microsoft) and 
hire a team of engineers to keep it running (hint hint PHP), in that 
case I'd agree ;p

One thing my associate says that I agree with that may help with the 
language blues is be proud of perl! When you do web apps in perl, use 
.pl instead of .cgi. Show some pride man!! If you're host can't add one 
line to apache conf to be able to serve .pl files then get a new host.

[shameless plug] go to jupiterhost.net we *love* Perl [/shameless plug]
I like this thread, lots of opinions + not too many flames = productive 
learning

Just my .02
Lee.M - JupiterHost.Net

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



Re: How to access first key of "Hash of Hash"

2004-09-29 Thread Jose Alves de Castro
On Wed, 2004-09-29 at 14:37, Edward Wijaya wrote:
> Hi,

Hi.

> I have this HoH:
> my %HoH = (
> firstkey => { A => 'blabla',
>   B => 'dadada',
>   C => 'tititi',}
> );
> 
> generated with
> 
> $HoH{$fkey}{$alpha}=$text;
> 
> how can I access the value
> of the first key, so that it gives: "firstkey"

If I understood this correctly, you want to do this:

print $fkey;

HTH, :-)

jac

> I tried this with no avail:
> 
> print "$HoH{$fkey}\n"
> 
> 
> 
> Regards,
> Edward WIJAYA
> SINGAPORE
-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-29 Thread Gavin Henry
John W. Krahn said:
> Gavin Henry wrote:
>> Randal L. Schwartz said:
>>>
>>>Remember "new coke", and how long we had that. (If you're old enough
>>>to remember that fiasco.)
>>
>> Again, thanks for this. My morale is now completely topped up, so I am
>> going to shell out for Programming Perl, although I do have the CD
>> Bookshelf 3.0 (better than 4.0)
>
> You might hurt his feelings, he didn't contribute to the third edition of
> Programming Perl.  Better to buy his latest book _Learning Perl Objects,
> References & Modules_  ;-)

Quick, where's my Mastercard...

>
>
> John
> --
> use Perl;
> program
> fulfillment
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
>
>
>


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




Re: How to access first key of "Hash of Hash"

2004-09-29 Thread Wiggins d Anconia
> Hi,
> 
> I have this HoH:
> my %HoH = (
> firstkey => { A => 'blabla',
>   B => 'dadada',
>   C => 'tititi',}
> );
> 
> generated with
> 
> $HoH{$fkey}{$alpha}=$text;
> 
> how can I access the value
> of the first key, so that it gives: "firstkey"
>

This is confusing, the value of the first key is a hash, so it will not
give 'firstkey'.  
 
> I tried this with no avail:
> 
> print "$HoH{$fkey}\n"
> 

RIght, that will print info about the HASH (aka the reference
stringified).  Looks like you are walking into the world of references,
have you read:

perldoc perllol
perldoc perldsc
perldoc perlreftut
perldoc perlref

They should get you going. Of course it might be sufficient to start with,

perldoc -f keys
perldoc -f values
perldoc -f each

But if not, try to provide more specifics of what you are up to.

> 
> 
> Regards,
> Edward WIJAYA
> SINGAPORE
> 

http://danconia.org

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




Re: Need help with script

2004-09-29 Thread Wiggins d Anconia
Please use a more descriptive subject line

> I have a file with the following format
> 
> Object1
> "Description1"
> 
> Object2
> "Description"
> 
> Object3
> "Description"
> 
> I would like the output in the following format
> object1<...tab>Description1
> object2<...tab>Description2
> object3<...tab>Description3
> 
> Thanks
> 

What have you tried, what have you researched, where did you fail?  This
is not a free script writing service, and your question looks like homework.

http://www.catb.org/~esr/faqs/smart-questions.html

http://danconia.org

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




Re: fork/exec/pipe

2004-09-29 Thread Wiggins d Anconia
> Hi
> 
> I am trying to control to start an octave process where I can write
> to it read the output back into perl. 
> 
> For example I would like to :
> 
> 1 - Start octave
> 2 - Write a=1 b=2. Read output into perl
> 3 - Write a+b. Read output into perl and so on.
> 
> Could someone please help me do this.
> 
> Thanks
> 

Have a look at the following docs, 

perldoc perlipc
perldoc IPC::Open3
perldoc IPC::Open2
perldoc perlopentut

See if they help. In general the above will allow you to avoid messing
with setting up your own pipes, etc. but still allow you to read/write
to a process.  If they don't work you can get lower level but start
there first.

http://danconia.org

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




Re: Using variables to store statements/formulae in perl

2004-09-29 Thread Wiggins d Anconia
> Hello Perl Beginners,
> 
> I'm writing a program in perl that collects data about calls into a
> telephone system and presents some statistics based on it.  There could
> come a time in the future where different data needs to be used and
> different statistics need to be reported on so I'm trying to keep the
> entire thing as generic as possible.  I have a conf file telling me what
> data represents what statistics and what formula needs to be used to get
> that data.
> 
> Then I began to wonder if I store the formulae in variables then how do
> I get them out again and get perl to use them as statements?
> 
> Here is some example code I wrote while trying to figure this out, any
> help would be appreciated.  Is this even a good way to do this? 
> 
> -- Code Starts --
> 
> use strict;
> use diagnostics;
> 
> # Data and Formula will eventually be read from a conf file and there
> may be multiple 
> # instances of them that need to stay grouped and indexed so they're in
> a hash.
> 
> my (%data, %formula);
> 
> # Dummy Test Data
> 
> $data{"ext1"} = 12;
> $data{"ext2"} = 9;
> $data{"ext3"} = 10;
> 
> # Dummy Test Formula
> 
> $formula{"Addition"} = "ext1 + ext2";
> $formula{"Subtraction"} = "ext3 - ext2";
> $formula{"Brackets"} = "(ext2 + ext3) - ext1";
> 
> # I can quite easily print these out and I could put the $data{"extX"}
> in with a 
> # regular expression but how do I get it to evaluate the variable as if
> it 
> # were an expression?
>

perldoc -f eval 

Depending on where your data is coming from it might be advisable to
read through

perldoc perlsec

 
> print $formula{"Addition"} . "\n";
> print $formula{"Subtraction"} . "\n";
> print $formula{"Brackets"} . "\n";
> 
> -- Code Ends --
> 
> Thanks,
> 
> Anthony Murphy

HTH,

http://danconia.org

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




How to access first key of "Hash of Hash"

2004-09-29 Thread Edward Wijaya
Hi,
I have this HoH:
my %HoH = (
   firstkey => { A => 'blabla',
 B => 'dadada',
 C => 'tititi',}
   );
generated with
$HoH{$fkey}{$alpha}=$text;
how can I access the value
of the first key, so that it gives: "firstkey"
I tried this with no avail:
print "$HoH{$fkey}\n"

Regards,
Edward WIJAYA
SINGAPORE
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Need help with script

2004-09-29 Thread PerlDiscuss - Perl Newsgroups and mailing lists
I have a file with the following format

Object1
"Description1"

Object2
"Description"

Object3
"Description"

I would like the output in the following format
object1<...tab>Description1
object2<...tab>Description2
object3<...tab>Description3

Thanks


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




Re: current directory

2004-09-29 Thread John W. Krahn
Urs Wagner wrote:
Hello
Hello,
How can I find out the current directory? I call chdir, afterwards I 
should switch back to the old one.
perldoc Cwd
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: current directory

2004-09-29 Thread Errin Larsen
Hi Urs,

You should look at Cwd:

  perldoc Cwd

That capital "C" in "Cwd" is relevant.

--Errin


On Wed, 29 Sep 2004 15:24:06 +0200, Urs Wagner <[EMAIL PROTECTED]> wrote:
> Hello
> 
> How can I find out the current directory? I call chdir, afterwards I
> should switch back to the old one.
> 
> Thanks
> 
> Urs
> 
> --
> 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]
 




Creating a word document

2004-09-29 Thread paul beckett (JIC)
I've been trying to find a perl module that can create microsoft word
documents and failed. Does anyone know of one?

Cheers,

Paul

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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-29 Thread John W. Krahn
Gavin Henry wrote:
Randal L. Schwartz said:
Remember "new coke", and how long we had that. (If you're old enough
to remember that fiasco.)
Again, thanks for this. My morale is now completely topped up, so I am
going to shell out for Programming Perl, although I do have the CD
Bookshelf 3.0 (better than 4.0)
You might hurt his feelings, he didn't contribute to the third edition of 
Programming Perl.  Better to buy his latest book _Learning Perl Objects, 
References & Modules_  ;-)

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



current directory

2004-09-29 Thread Urs Wagner
Hello
How can I find out the current directory? I call chdir, afterwards I 
should switch back to the old one.

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



Fwd: UNIX Process List (U)

2004-09-29 Thread Errin Larsen
On Wed, 29 Sep 2004 07:52:53 -0400, Meidling, Keith, CTR, ISD
<[EMAIL PROTECTED]> wrote:
> UNCLASSIFIED
>
> Is there a module to get a list of processes on a UNIX/Linux machine, or
> would I just do a `ps` and save it to an array?
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
>
>

Hi Keith,

Check out Proc::ProcessTable on CPAN.  That might be what you're looking for.

--Errin

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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-29 Thread Gavin Henry
Randal L. Schwartz said:
>> "Gavin" == Gavin Henry <[EMAIL PROTECTED]> writes:


Wow I didn't know that you read this list. I am learning from your
book and I am catching up with all the columns you have ever published on
your site.


I am actually getting paid to learn Python now, and frankly it looks
really ugly, I like the way Perl flows and I can *read* it, unlike what
many people say.

>
> Gavin> I really like Perl, but lately everywhere I seem to go and talk
> Gavin> to say I shouldn't be learning Perl as it's old and Python is
> Gavin> better.
>
> Perl is more powerful.  Python is simpler.  Python is for people
> who don't want to master a language -- just use it casually.

I have that feeling now, one person (the one paying me to learn Python)
said they tried Perl about 10 years ago and couldn't really it and
understand RE. Well, your comment kind of sums him up. I have just bought
"Mastering RE from O'reilly", so I don't get scared of them :-)

The only reason I might find Python interesting is that Fedora uses it for
all the sys-admin utils, so I can help with those. (I am
http://FedoraNEWS.ORG/ghenry so I have an interest in Fedora)

>
> However, if you're gonna spend two or more hours a day hacking code,
> Perl is definitely the right place to be.  Still.

I'm almost at that level, but I should be doing other jobs, but I can't
seem to pull myself out if Vi to do technical documentations etc ;-)

>
> Those Python weenies are all just casual programmers complaining
> that for Perl, "with great power comes great responsibility".  Let'em.

Ha. That was a very politically correct response ;-)

>
> Perl's support only grows.  I used to be able to follow the CPAN "new
> modules list" by examining the daily run at search.cpan.org/recent.
> But no more.  Look at all the new modules just in the past *seven*
> days.  (It's typically a full web page for each day!) If that doesn't
> show you an intense activity in the Perl community, I really don't
> know what else I could show you.

The fact you replied is enough.

>
> Ask your Python friends where such a similar list exists. :)

He tried to show me a page on Zope's site for modules etc., but no way
does it beat CPAN or:

perl -MCPAN -e shell

>
> Python may be newer, but Perl is more mature, and here to stay.

Yes.

>
> Remember "new coke", and how long we had that. (If you're old enough
> to remember that fiasco.)


Again, thanks for this. My morale is now completely topped up, so I am
going to shell out for Programming Perl, although I do have the CD
Bookshelf 3.0 (better than 4.0)


Lastly, I just want to say that these kind of responses are what I love
about the open source etc. communities. Everyone is friendly (give or
take) and as long as you ask sensible questions, people will chat. After
all, we are all people.

If fact, this gives me the excuse to say why I am hooked to Linux and OSS.
When I setup my Linux company: http://www.suretecsystems.com I e-mailed
Linus to ask if Tux was registered to him, as the original company name
was going to be Inventux Solutions Ltd. Lo and behold he replied, with a
kind, "Nope, go ahead".

Well, from that day I have been hooked. Would Bill Gates answer a personal
e-mail? Would he f**k...

Thanks,

Gavin.

>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
> 0095
> <[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
> training!
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
>
>
>


-- 
Just getting into the best language ever...
Fancy a [EMAIL PROTECTED] Just ask!!!

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




Re: how to open a file with 666 permission

2004-09-29 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
Hey guys !
Thanks for the support .the following is the code I have written.
Working fine.
===
open(LOG,">$main::TRACELOGFILE") or die "Can't open trace file
$main::TRACELOGFILE";
 system("chown XXX:Y  $main::TRACELOGFILE");
 system("chmod 0666 $main::TRACELOGFILE");

perl has the functions chown() and chmod() built in to the language so there 
is no need to run external programs with system()

perldoc -f chown
perldoc -f chmod

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: how to open a file with 666 permission

2004-09-29 Thread arjun.mallik

Hey guys !
Thanks for the support .the following is the code I have written.
Working fine.

===
open(LOG,">$main::TRACELOGFILE") or die "Can't open trace file
$main::TRACELOGFILE";
 system("chown XXX:Y  $main::TRACELOGFILE");
 system("chmod 0666 $main::TRACELOGFILE");


Arjun


-Original Message-
From: John W. Krahn [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 29, 2004 6:16 PM
To: Perl Beginners
Subject: Re: how to open a file with 666 permission


Bob Showalter wrote:
> [EMAIL PROTECTED] wrote:
>
>>My requirement is to open file with 666 permissions.
>
> You need to set umask to 0 before creating the file.
>
> But don't do that. It's inadvisable to mess with the umask in a
> program, IMO. If the user wants to create files as 666, let him set
> the umask before running your program.

Or use chmod() on the file to set whatever permissions you desire.


John
--
use Perl;
program
fulfillment

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




Confidentiality Notice

The information contained in this electronic message and any attachments to this 
message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged 
information. If
you are not the intended recipient, please notify the sender at Wipro or [EMAIL 
PROTECTED] immediately
and destroy all copies of this message and any attachments.

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




Re: how to open a file with 666 permission

2004-09-29 Thread John W. Krahn
Bob Showalter wrote:
[EMAIL PROTECTED] wrote:
My requirement is to open file with 666 permissions.
You need to set umask to 0 before creating the file.
But don't do that. It's inadvisable to mess with the umask in a program,
IMO. If the user wants to create files as 666, let him set the umask before
running your program.
Or use chmod() on the file to set whatever permissions you desire.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: how to open a file with 666 permission

2004-09-29 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
Hai!
Hello,
My requirement is to open file with 666 permissions.[If fine doesn't
exists it should get created ].Iam doing as below,is this ok.
===
sysopen(LOG,"$main::TRACELOGFILE",O_CREATE,0666) or die "Can't open
trace file $main::TRACELOGFILE";

ami doing any thing wrong ,if yes correct me.If file is created once it
is working fine.For the first time it is giving below error
===
Can't open trace file /var/opt/X/log/X08013.log
==
You should include the $! variable in your error message so you know *why* it 
failed.  The third argument to sysopen must include *one* of either O_RDONLY 
or O_WRONLY or O_RDWR (read only OR write only OR read and write.)

Read the section "Open A la C" in perlopentut for more details on sysopen.
perldoc perlopentut

John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: how to open a file with 666 permission

2004-09-29 Thread Bob Showalter
[EMAIL PROTECTED] wrote:
> Hai!
> My requirement is to open file with 666 permissions.

You need to set umask to 0 before creating the file.

But don't do that. It's inadvisable to mess with the umask in a program,
IMO. If the user wants to create files as 666, let him set the umask before
running your program.

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




Re: How to find if a key exist in hash?

2004-09-29 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
%a = (
   "a" => 1,
   "b" => 2,
   "c" => 3
);
$searchKey = "a";
print "Found $searchKey" if defined($a{$searchKey});
Try that with this hash:
my %a = (
a => undef,
b => undef,
c => undef,
);
defined() does not tell you if a key exists.
perldoc -f exists
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



fork/exec/pipe

2004-09-29 Thread Zafer Leylek
Hi

I am trying to control to start an octave process where I can write
to it read the output back into perl. 

For example I would like to :

1 - Start octave
2 - Write a=1 b=2. Read output into perl
3 - Write a+b. Read output into perl and so on.

Could someone please help me do this.

Thanks

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




Re: How to find if a key exist in hash?

2004-09-29 Thread max4o

%a = (
   "a" => 1,
   "b" => 2,
   "c" => 3
);

$searchKey = "a";

print "Found $searchKey" if defined($a{$searchKey});

-
This mail is from: <[EMAIL PROTECTED]>
-


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




Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news.

2004-09-29 Thread Randal L. Schwartz
> "Gavin" == Gavin Henry <[EMAIL PROTECTED]> writes:

Gavin> I really like Perl, but lately everywhere I seem to go and talk
Gavin> to say I shouldn't be learning Perl as it's old and Python is
Gavin> better.

Perl is more powerful.  Python is simpler.  Python is for people
who don't want to master a language -- just use it casually.

However, if you're gonna spend two or more hours a day hacking code,
Perl is definitely the right place to be.  Still.

Those Python weenies are all just casual programmers complaining
that for Perl, "with great power comes great responsibility".  Let'em.

Perl's support only grows.  I used to be able to follow the CPAN "new
modules list" by examining the daily run at search.cpan.org/recent.
But no more.  Look at all the new modules just in the past *seven*
days.  (It's typically a full web page for each day!) If that doesn't
show you an intense activity in the Perl community, I really don't
know what else I could show you.

Ask your Python friends where such a similar list exists. :)

Python may be newer, but Perl is more mature, and here to stay.

Remember "new coke", and how long we had that. (If you're old enough
to remember that fiasco.)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

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




Re: directory copy command

2004-09-29 Thread Jenda Krynicky
From: Urs Wagner <[EMAIL PROTECTED]>
> Is there a similar perl command for directory copy like the File:Copy?
>  I thinks this one does not work for directories.

If you did not mind it's Windows only then Win32::FileOp::Copy.
Comes with optional progress and confirmation dialogs and other 
goodies.

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]
 




UNIX Process List (U)

2004-09-29 Thread Meidling, Keith, CTR, ISD
UNCLASSIFIED

Is there a module to get a list of processes on a UNIX/Linux machine, or
would I just do a `ps` and save it to an array?

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




RE: How to find if a key exist in hash?

2004-09-29 Thread NYIMI Jose \(BMB\)


> -Original Message-
> From: Edward Wijaya [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, September 29, 2004 12:17 PM
> To: [EMAIL PROTECTED]
> Subject: How to find if a key exist in hash?
> 
> 
> Hi,
> 
> I have the following code,
> and I know it is HORRIBLE.
> 
> I wonder if I can do it in more
> efficient and elegant way?
> 
> Thanks so much
> and
> 
> Regards,
> Edward WIJAYA
> SINGAPORE
> 
> 
> __BEGIN__
> use strict;
> use warnings;
> use Getopt::Std;
> use Data::Dumper;
> 
> my %hash = (
>A => 'blabla',
>B => 'dadada',
>C => 'tititi',
> );
> 
> my $s = 'A';
> my $get = check_ifHash_key_exist(\%hash, $s);
> print "Got it: $get\n";
> 
> #--- this is how I do it (don't laugh) --
> 
>   sub check_ifHash_key_exist {
> 
>   my ($hash, $str) = @_;
>   my $found_str;
>   my @array = keys %{$hash};
>   for (my $i= 0; $i < keys %{$hash}; $i++) {
> if ($array[$i] eq $str) {
>  $found_str = $array[$i];
> last;
> }
>  }
>   return $found_str;
>   }
> __END__


perldoc -f exists

See Also:
http://search.cpan.org/~bpowers/Hash-NoVivify-0.01/NoVivify.pm

HTH,

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: How to find if a key exist in hash?

2004-09-29 Thread Gunnar Hjalmarsson
Edward Wijaya wrote:
Subject: How to find if a key exist in hash?
There is a builtin Perl function for the purpose.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



How to find if a key exist in hash?

2004-09-29 Thread Edward Wijaya
Hi,
I have the following code,
and I know it is HORRIBLE.
I wonder if I can do it in more
efficient and elegant way?
Thanks so much
and
Regards,
Edward WIJAYA
SINGAPORE
__BEGIN__
use strict;
use warnings;
use Getopt::Std;
use Data::Dumper;
my %hash = (
  A => 'blabla',
  B => 'dadada',
  C => 'tititi',
   );
my $s = 'A';
my $get = check_ifHash_key_exist(\%hash, $s);
print "Got it: $get\n";
#--- this is how I do it (don't laugh) --
 sub check_ifHash_key_exist {
 my ($hash, $str) = @_;
 my $found_str;
 my @array = keys %{$hash};
 for (my $i= 0; $i < keys %{$hash}; $i++) {
   if ($array[$i] eq $str) {
   $found_str = $array[$i];
   last;
   }
}
 return $found_str;
 }
__END__
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: How to track the success of insert

2004-09-29 Thread NYIMI Jose \(BMB\)


> -Original Message-
> From: Anish Kumar K. [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, September 29, 2004 9:28 AM
> To: beginners perl
> Subject: How to track the success of insert
> 
> 
> Hi
> 
> I was trying out some practice examples with DBI and CGI and
> kind of stuck while doing a comparison
> 
> That is if I  could insert successfully into a databse a
> script window shld come "Success". but when the insert fails 
> a window shld come saying "Can;t insert "..
> 
> How will I track if the insertion is success or not? Below is
> the program...
> 
> 
> use strict;
> use warnings;
> use CGI;
> use DBI;
> my $cgi = new CGI;
> print $cgi->header( "text/html" );
> print $cgi->start_html( "Welcome" );
> my $dbh =
> DBI->connect("DBI:Pg:dbname=testdb;host=localhost",'postgres',
> 'postgres',{RaiseError=>1,PrintErr
> or=>1})
> or die "Cannot connect to testdb\n";
> 
> my $sth=$dbh->prepare("insert into userinfo
> values('$fvalue','$lvalue','$email')");
> $sth->execute();
>if($sth)
> {
>print $cgi->p( " 
> alert('Execution Done') " );
> }
>  else
>{
>print $cgi->p(" 
> alert('Execution Not Done') " );
>}

Suggestion:
Put your instert inside a transaction like this:

[snip]

#begin transaction
$dbh->begin_work;
eval{   
#you can decide to combine prepare() and execute() into do()
$dbh->do( "insert into userinfo values ('$fvalue','$lvalue','$email')" );
$dbh->commit;
};
#check if the transaction went ok
if($@){ 
$dbh->rollback;
print $cgi->p(" alert('Execution Not Done') 
" );
}
else{
print $cgi->p( " alert('Execution Done') 
" );  
}


Tim Bunce (the Author of DBI) gave a nice presentation
about "DBI transactions" that you can find from this link:
http://search.cpan.org/src/TIMB/DBI_AdvancedTalk_2004/sld054.htm

Or from
http://dbi.perl.org (Online Documentation)

HTH,

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]  




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




RE: How to track the success of insert

2004-09-29 Thread NYIMI Jose \(BMB\)


> -Original Message-
> From: Anish Kumar K. [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, September 29, 2004 9:28 AM
> To: beginners perl
> Subject: How to track the success of insert
> 
> 
> Hi
> 
> I was trying out some practice examples with DBI and CGI and 
> kind of stuck while doing a comparison
> 
> That is if I  could insert successfully into a databse a 
> script window shld come "Success". but when the insert fails 
> a window shld come saying "Can;t insert "..
> 
> How will I track if the insertion is success or not? Below is 
> the program...
> 
> 
> use strict;
> use warnings;
> use CGI;
> use DBI;
> my $cgi = new CGI;
> print $cgi->header( "text/html" );
> print $cgi->start_html( "Welcome" );
> my $dbh = 
> DBI->connect("DBI:Pg:dbname=testdb;host=localhost",'postgres',
> 'postgres',{RaiseError=>1,PrintErr
> or=>1})
> or die "Cannot connect to testdb\n";
> 
> my $sth=$dbh->prepare("insert into userinfo 
> values('$fvalue','$lvalue','$email')");
> $sth->execute();
>if($sth)
> {
>print $cgi->p( " 
> alert('Execution Done') " );
> }
>  else
>{
>print $cgi->p(" 
> alert('Execution Not Done') " );
>}

Suggestion:
Put your instert inside a transaction like this:

[snip]

#begin transaction
$dbh->begin_work;
eval{   
#you can decide to combine prepare() and execute() into do()
$dbh->do( "insert into userinfo values ('$fvalue','$lvalue','$email')" );
};
#check if the transaction went ok
if($@){ 
$dbh->rollback;
print $cgi->p(" alert('Execution Not Done') 
" );
}
else{
$dbh->commit;
print $cgi->p( " alert('Execution Done') 
" );  
}


Tim Bunce (the Auteur of DBI) gave a nice presentation about
"DBI transactions" that you can find from this link:
http://search.cpan.org/src/TIMB/DBI_AdvancedTalk_2004/sld054.htm

Or from
http://dbi.perl.org (Online Documentation)

HTH,

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]
 




How to track the success of insert

2004-09-29 Thread Anish Kumar K.
Hi

I was trying out some practice examples with DBI and CGI and kind of stuck while doing 
a comparison

That is if I  could insert successfully into a databse a script window shld come 
"Success". but when the insert fails 
a window shld come saying "Can;t insert "..

How will I track if the insertion is success or not? Below is the program...


use strict;
use warnings;
use CGI;
use DBI;
my $cgi = new CGI;
print $cgi->header( "text/html" );
print $cgi->start_html( "Welcome" );
my $dbh = 
DBI->connect("DBI:Pg:dbname=testdb;host=localhost",'postgres','postgres',{RaiseError=>1,PrintErr
or=>1})
or die "Cannot connect to testdb\n";

my $sth=$dbh->prepare("insert into userinfo values('$fvalue','$lvalue','$email')");
$sth->execute();
   if($sth)
{
   print $cgi->p( " alert('Execution Done') " 
);
}
 else
   {
   print $cgi->p(" alert('Execution Not Done') 
" );
   }


how to open a file with 666 permission

2004-09-29 Thread arjun.mallik

Hai!
My requirement is to open file with 666 permissions.[If fine doesn't
exists it should get created ].Iam doing as below,is this ok.

===
sysopen(LOG,"$main::TRACELOGFILE",O_CREATE,0666) or die "Can't open
trace file $main::TRACELOGFILE";


ami doing any thing wrong ,if yes correct me.If file is created once it
is working fine.For the first time it is giving below error
===
Can't open trace file /var/opt/X/log/X08013.log
==


Arjun






Confidentiality Notice

The information contained in this electronic message and any attachments to this 
message are intended
for the exclusive use of the addressee(s) and may contain confidential or privileged 
information. If
you are not the intended recipient, please notify the sender at Wipro or [EMAIL 
PROTECTED] immediately
and destroy all copies of this message and any attachments.