Re: finding syntax errors

2003-10-27 Thread Motherofperls
I use editpadpro,  (there is a lite free version of it).  You can download 
syntax color schemes for perl code.   It will give you the matching brace or 
parenthesis.  
http://www.editpadpro.com/cscs.html


RE: how to pass multi array as args

2003-10-27 Thread perl
It took a while, but I got the reference syntax down with the referencing
calls like $$x[int] and @$x.

thanks


> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> :
> : > sub mysub {
> : > my( $x, $y, $z ) = @_;
> :
> : Can I have three arrays instead?
> :
> : I know I can use $x->[0], $x->[1], etc. But can I make
> : it a @x, @y, @z?
>
> 
>  Question: If this is all that is relevant to your
>  question, why continue to quote the rest of the email?
>  The idea is to save bandwidth and quote only the
>  relevant part, then stop!
> 
>
>
> Read perlref.
>
> $x, $y, and $z are references to arrays. you can
> use them as arrays with caution. If you use them as
> @$x, @$y, and @$z any changes you make will affect
> the original arrays.
>
> You can copy them if you need to temporarily
> change their values:
>
> sub mysub {
> my( $x, $y, $z ) = @_;
>
> my @dup_x = @$x;
>
> # change @dup_x
>
> I can't really help you more than that without
> knowing what you are trying to do in the sub.
>
> HTH,
>
> Charles K. Clarkson
> --
> Head Bottle Washer,
> Clarkson Energy Homes, Inc.
> Mobile Home Specialists
> 254 968-8328
>
>
>
> BTW, I used @x, @y, @z because $a and $b are special.
>
>
>
>
>
>
>
>
>
>



-
eMail solutions by 
http://www.swanmail.com

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



Re: how to pass multi array as args

2003-10-27 Thread perl
> If you prototype your subroutine as
>
>   sub mysub ([EMAIL PROTECTED]@\@)

I saw that prototying in the docs. Does perl programmer use prototyping?

thanks




-
eMail solutions by 
http://www.swanmail.com

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



Re: trouble backup with perl.

2003-10-27 Thread Goffredo Saffioti
Wiggins d'Anconia ha scritto:

Goffredo Saffioti wrote:



Ok your script work fine, but my problem still persist, because the 
work directory is too big so i need to do backup on more little 
portion of dir , i attempt to process i wish to process $backup_dir/2 
or /4 how can do it?


Which part of the process is failing because the directory is to big? 
The find should be able to handle it, so is it the other part?  
Because I am not familar with the utility you are running I can't tell 
where your size limitation is...

http://danconia.org


Good mornin
the problem is bound to the dimension of the file on the filesystem .
On ext3fs the size of a file is maximum 2.50 .
So that is the limitation if my dir contain a number of dir that is 
greater than that size, and my backup don't contain all files of the 
directory, so i need to devide the dorectory content and backup this 
before and backup later a next part .
the 3 modules that are in the script allow me to execute this script 
with multi process for to speed up the backup time, but this another 
story :-)
How can handle a portion more light of my big dir ?? .
Thanks in advance .

Goffredo Saffioti .



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


pattern matching

2003-10-27 Thread Christiane Nerz
Hi everybody!

Two questions:
I've got a test-file and want to add something to some lines, while 
reading it out.
I tried the following code:

while () {
 if (/pattern/) {
#$line = $_ . $something;
#push (@new_array, $line);
 }
 else {
#$line = $_;
#push (@new_array, $line);
 }
}
But @new_array didn't get the lines!

The textfile look like

>SA texttexttext...\n
texttexttext\n
texttexttext\n
texttexttext\n
>SA texttexttext...\n
texttexttext\n
texttexttext\n
texttexttext\n
>SA texttexttext...\n
texttexttext\n
texttexttext\n
texttexttext\n
I tried to get the >SA..-lines by

if (/^SA[.]*\n/) {
do...
but the pattern was not be found.
Whats wrong with it?
Or does anyone knows a simple method to read the lines in a hash - 
every-SA-line should be the key, the following lines until the next >SA 
the value. That'll be much more simple to handle..

Jane



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


RE: pattern matching

2003-10-27 Thread Stephen Hardisty
> Two questions:
> I've got a test-file and want to add something to some lines, while 
> reading it out.
> I tried the following code:
> 
> while () {
>   if (/pattern/) {
>  #$line = $_ . $something;
>  #push (@new_array, $line);
>   }
>   else {
>   #$line = $_;
>   #push (@new_array, $line);
>   }
> }

The code that appends the array is commented out.. if I assume that you have tried 
it without the comments, try putting a print statement inside the 'if' block, this 
will atleast let you know if your regexp is correct.


This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com


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



Re: working on time

2003-10-27 Thread [EMAIL PROTECTED]
Hi,

thanks, it working very well.

Damien

-- Initial Header ---

From  : news <[EMAIL PROTECTED]>
To  : [EMAIL PROTECTED]
Cc  : 
Date  : Fri, 10 Oct 2003 19:17:39 +0200
Subject : Re: working on time

On Fri, 10 Oct 2003 12:13:45 -0400, Bill Akins wrote:
> Try this:
> #!/usr/bin/perl -w
>  
> my @now = localtime;
> my $sec = ( $now[0] );
> my $min = ( $now[1] );
> my $hr  = ( $now[2] );
> my $day = ( $now[3] );
> my $mth = ( $now[4] + 1 );
> my $yr  = ( $now[5] + 1900 );
>  
> $day = ($day -1);

No!  Do _not_ try this!  What happens when you're using this code on the
1st of a month?

I recently fallen in love (...) with Time::Piece (and Time::Seconds),
which let me do this in a nifty way;

  #!/usr/bin/perl
  #
  use strict;
  use warnings;
  use Time::Seconds;
  use Time::Piece;

  my $today = localtime;
  my $yesterday = $today - ONE_DAY;
  my $tomorrow  = $today + ONE_DAY;

Install Time::Piece and do a 'perldoc Time::Piece' for more information.


-- 
Tore Aursand <[EMAIL PROTECTED]>


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



** L'ADSL A 20 EUR/MOIS** 
Avec Tiscali, l'ADSL est à 20 EUR/mois. Vous pourrez chercher longtemps avant de 
trouver moins cher ! 
Pour profiter de cette offre exceptionnelle, cliquez ici : 
http://register.tiscali.fr/adsl/
Offre soumise à conditions.



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



Re: pattern matching

2003-10-27 Thread Christiane Nerz
SORRY! copy-and-paste-error...I tried it without the ###  ;-)
and tried too the print-statement-thing.
Seems the regex is wrong, but why?
Jane




Stephen Hardisty wrote:

Two questions:
I've got a test-file and want to add something to some lines, while 
reading it out.
I tried the following code:

while () {
 if (/pattern/) {
#$line = $_ . $something;
#push (@new_array, $line);
 }
 else {
#$line = $_;
#push (@new_array, $line);
 }
}
The code that appends the array is commented out.. if I assume that you have tried it without the comments, try putting a print statement inside the 'if' block, this will atleast let you know if your regexp is correct.


This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com






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


RE: pattern matching

2003-10-27 Thread Stephen Hardisty
> SORRY! copy-and-paste-error...I tried it without the ###  ;-)
> and tried too the print-statement-thing.
> Seems the regex is wrong, but why?
> Jane

Try:
/^SA.+\n/


This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com


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



Re: pattern matching

2003-10-27 Thread Ramprasad A Padmanabhan
Christiane Nerz wrote:
Hi everybody!

Two questions:
I've got a test-file and want to add something to some lines, while 
reading it out.
I tried the following code:

while () {
 if (/pattern/) {
#$line = $_ . $something;
#push (@new_array, $line);
 }
 else {
 #$line = $_;
 #push (@new_array, $line);
 }
}
But @new_array didn't get the lines!

The textfile look like

 >SA texttexttext...\n
texttexttext\n
texttexttext\n
texttexttext\n
 >SA texttexttext...\n
texttexttext\n
texttexttext\n
texttexttext\n
 >SA texttexttext...\n
texttexttext\n
texttexttext\n
texttexttext\n
I tried to get the >SA..-lines by

if (/^SA[.]*\n/) {
do...
but the pattern was not be found.
Whats wrong with it?
Or does anyone knows a simple method to read the lines in a hash - 
every-SA-line should be the key, the following lines until the next >SA 
the value. That'll be much more simple to handle..

Jane



Read about push
perldoc -f push
Maybe this will help

.
while() {
if(/pattern/){
   $line = $_ . $something;
} else {
   $line = $_;
}
push @newarray , $line
.




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


Re: RE : SQL Syntax quickie

2003-10-27 Thread dan
Thanks I'll try your suggestion about the LIMIT portion, that's what I want,
to minimize the amount of data the program gets from the SQL server, making
processing faster.

The program isn't a script as such that's executed from the web, it's a
program that opens a socket, connects to IRC chat and acts as a network
service. There's only ever one copy running, since it can't bind to the same
socket on the same port more than once, it'll simply just die with a socket
error. This program is always the one that accesses the database, and
nothing else. So that I'm sure that nothing will happen between the INSERT
and SELECT.

I'll also give the mysql_insertid a go, that generally looks like what I
want to happen, so that may be my best option all around.

Many thanks for all of your help,

Dan

"Tore Aursand" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Sun, 26 Oct 2003 13:40:20 +, dan wrote:
> > The MAX(id) didn't return anything [...]
>
> Are you sure about that?  Generally, MAX(id) _always_ returns something,
> ie:
>
>   SELECT MAX(user_id) FROM user
>
> This one will return the highest 'user_id' value, _or_ 0 if there are no
> records in the 'user' table.
>
> > SELECT id FROM memodata ORDER BY id DESC
>
> Then you should also limit the expression, thus offloading the SQL server
> a bit;
>
>   SELECT id FROM memodata ORDER BY id DESC LIMIT 1
>
> > then take the first line value and ignore the rest.
>
> With 'LIMIT' you don't need to worry about ignoring anything.  Just ignore
> ignoring. :-)
>
> > Ideally though i want the last line with the highest id number.
>
> If you want the last auto_increment value, you could always use the MySQL
> proprietary 'mysql_insertid';
>
>   my $stInsert = $dbh->prepare( ... );
>   $stInsert->execute();
>   $stInsert->finish();
>   my $last_insert_id = $stInsert->{ 'mysql_insertid' };
>
> > I know for a fact that another INSERT won't happen before the SELECT
> > because they happen immediately one after the other.
>
> Do yuo really?  Is there _always_ only one user using the script?
>
>
> -- 
> Tore Aursand <[EMAIL PROTECTED]>
>



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



Can't Compile BerkeleyDB on OS X with Perl 5.8.1

2003-10-27 Thread Aaron Davies
I'm trying to install BerkeleyDB via CPAN on my OS X 10.2.6 box, but 
the make phase bombs almost immediately. I've put the error log at 
, since it's a little 
larger than I like to mail people. Can anyone give me a hand here?
--
____
   /  )  /  )
  /--/ __.  __  /  / __. , __o  _  _
 /  (_(_/|_/ (_(_) / / <_  /__/_(_/|_\/ <__

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


RE: RE : SQL Syntax quickie

2003-10-27 Thread EUROSPACE SZARINDAR
Hi Dan, 

To be sure to collect something, you could use the "nvl(VALUE_ORI,
replacement_value_if_VALUE_ORI_is_null)" function which will return
something if the entry value is null otherwise return the entry value.

select nvl( max(id), 0 ) from table_id ;


The "nvl" is an Oracle function but sure that there is something similar on
Mysql 

==
SQL> create table table_id ( id integer );

Table created.

SQL> select max(id) from table_id;

   MAX(ID)
--


SQL> select nvl(max(id), 0) from table_id;

NVL(MAX(ID),0)
--
 0

SQL> insert into table_id(id) values (1);

1 row created.

SQL> select nvl(max(id), 0) from table_id;

NVL(MAX(ID),0)
--
 1

==


Michel

-Message d'origine-
De: dan [mailto:[EMAIL PROTECTED]
Date: dimanche 26 octobre 2003 14:40
À: [EMAIL PROTECTED]
Objet: Re: RE : SQL Syntax quickie


The MAX(id) didn't return anything, i eventually settled for an idea posted
to
SELECT id FROM memodata ORDER BY id DESC
then take the first line value and ignore the rest. Ideally though i want
the last line with the highest id number. I know for a fact that another
INSERT won't happen before the SELECT because they happen immediately one
after the other.
FYI, i'm using MySQL and DBD::mysql if that's any more help.

Many thanks

Dan

"Tore Aursand" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Sun, 26 Oct 2003 06:30:11 +0100, SIMON Cedric wrote:
> > For your  query, try "SELECT MAX(id) FROM table"
> > That works with mysql.
>
> That should "work" with most databases, but what happens if there's a new
> insert between the original insert and the SELECT statement above?
>
> This _could_ be solved by locking the table before the insert, and then
> unlocking it again after you've select the maximum id from the same table.
>
>
> -- 
> Tore Aursand <[EMAIL PROTECTED]>
>



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

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



Re: initializing a closure variable

2003-10-27 Thread Rob Dixon
Kevin Pfeiffer wrote:
>
> I would have thought that this would initialize my $indent variable to 2
> (like setting an initial state for an object), but if I call "indent()" I
> get nothing back. :-(
>
>
> {  # static local variable
>my $indent = 2;
>
>sub indent {
>   my $increment = shift;
>   $indent += $increment if $increment;
>   return $indent;
>}
> }

By the way, that's not a closure! It's just a subroutine
with a non-volatile local variable.

Rob



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



Re: how to pass multi array as args

2003-10-27 Thread Rob Dixon
[EMAIL PROTECTED] wrote:
>
> > If you prototype your subroutine as
> >
> >   sub mysub ([EMAIL PROTECTED]@\@)
>
> I saw that prototying in the docs. Does perl programmer use prototyping?

I'm not sure what you mean here?

Rob



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



RE: Custom rmodule with use strict;

2003-10-27 Thread Bob Showalter
Dan Muey wrote:
> Howdy all!.
> 
> I'm using a simpewlmmodule to get vars an dfunctions into one place.

Dan, I think you need a new keyboard :~)

> 
> It works dandy except I can't have use strict in the module.
> 
>  I think it has todo with not doing my or our with teh @EXPORT and
> friends: 

Use "our" with those.

> 
> So what am I missing, what do I need to do to be able to add
> use stirct; to
> my module below and also therefore in my scripts thatuse it?
> 
> package TestMod;
> 
> require Exporter;
> @ISA = qw(Exporter);
> @EXPORT = qw(TestMod);

I think you mean 'TestModSub'

> @EXPORT_OK = qw($testvar);
> 
> our $testvar = 'Howdy Module';
> sub TestModSub { return "Content-type: text/html\n\n$testvar\n"; }
> 
> ###
> perl -e 'use TestMod;print TestModSub();'
> 
> TIA
> 
> Dan


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



how to optimize a string search

2003-10-27 Thread Ramprasad A Padmanabhan
I know this is more of an algorithm question but please bear with me.

In my program I am checking wether a emailid exists in a list
I have in the complete_list a string like
$complete_string="<[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> ... <[EMAIL 
PROTECTED]>";
#  that is a string of emailids sorted

Now I want to find out if another ID  "<[EMAIL PROTECTED]>" exists in this list

How is it possible to optimize the search  given that the complete list 
string is sorted in order

The alternative I am considering is
  1) Create a hash array with each of the ids as keys and just use the 
exits function

like
my %hash=();
while($complete_list=~/(\<.*?\>)/g){ $hash{$1}=1 };

if(exists($hash{$emailid})) {
# FOUND id in string
}
Is this the best way

Is there no way directly to use the string
Thanks
Ram
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: how to optimize a string search

2003-10-27 Thread Rob Dixon
Ramprasad A Padmanabhan wrote:
>
> I know this is more of an algorithm question but please bear with me.
>
>
> In my program I am checking wether a emailid exists in a list
> I have in the complete_list a string like
> $complete_string="<[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> ... 
> <[EMAIL PROTECTED]>";
>
> #  that is a string of emailids sorted
>
> Now I want to find out if another ID  "<[EMAIL PROTECTED]>" exists in this list
>
> How is it possible to optimize the search  given that the complete list
> string is sorted in order
>
> The alternative I am considering is
>1) Create a hash array with each of the ids as keys and just use the
> exits function
>
> like
> my %hash=();
> while($complete_list=~/(\<.*?\>)/g){ $hash{$1}=1 };
> 
> if(exists($hash{$emailid})) {
> # FOUND id in string
> }
>
> Is this the best way
>
> Is there no way directly to use the string

Hi Ram.

If you want to check many different mail addresses against the list then it
will be best to build a hash. You could assign a slice, like this:

  my %hash;
  @hash{ $complete_string =~ /(\<.*?\>)/g } = ();

  if (exists $hash{$emailid}) {
:
  }

but beware that the values for each element will be
'undef' if you do this, so that you have to use 'exists'
instead of 'defined'.

If you're just testing a single mail address then you'd probably
be better off doing

  if (index($complete_string, $emailid) >= 0) {
:
  }

HTH,

Rob



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



cat zipped files

2003-10-27 Thread lobach
I was hoping someone would have an idea of how to cat zipped files.. gzcat
is NOT available to me, however, cat and zcat are.. But is there a module or
sample perl script to cat zipped files?  Thanks, Steve.



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



RE: cat zipped files

2003-10-27 Thread Bakken, Luke
> -Original Message-
> I was hoping someone would have an idea of how to cat zipped 
> files.. gzcat
> is NOT available to me, however, cat and zcat are.. But is 
> there a module or
> sample perl script to cat zipped files?  Thanks, Steve.

If you have gzip, look at gzip -d -c

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



RE: Can't Compile BerkeleyDB on OS X with Perl 5.8.1

2003-10-27 Thread Bakken, Luke
> -Original Message-
> From: Aaron Davies [mailto:[EMAIL PROTECTED] 
> 
> I'm trying to install BerkeleyDB via CPAN on my OS X 10.2.6 box, but 
> the make phase bombs almost immediately. I've put the error log at 
> , since 
> it's a little 
> larger than I like to mail people. Can anyone give me a hand here?

BerkeleyDB.xs:74:2: #error db.h is from Berkeley DB 1.x - need at least
Berkeley DB 2.6.4

I'd go looking for that old db.h laying around somewhere.

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



Re: cat zipped files

2003-10-27 Thread Rob Dixon
[EMAIL PROTECTED] wrote:
>
> I was hoping someone would have an idea of how to cat zipped files.. gzcat
> is NOT available to me, however, cat and zcat are.. But is there a module or
> sample perl script to cat zipped files?

Hi Steve.

Archive::Zip is what you need.

  use strict;
  use warnings;
  use Archive::Zip;

  my $zip = Archive::Zip->new('archive.zip')

To list the files in the archive:

  print "$_\n" foreach $zip->memberNames

to cat a given member:

  print $zip->contents('member.txt')

Clearly a combination of the two will let you cat
all members of the archive. Read the module's POD
if you need any more.

HTH,

Rob



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



RE: cat zipped files

2003-10-27 Thread Steve Lobach
Thank you, for some reason I had it in my mind that command would only decompress the 
file, I tried it in my perl script and it worked fine.. 

>>> "Bakken, Luke" <[EMAIL PROTECTED]> 10/27/03 09:41AM >>>
> -Original Message-
> I was hoping someone would have an idea of how to cat zipped 
> files.. gzcat
> is NOT available to me, however, cat and zcat are.. But is 
> there a module or
> sample perl script to cat zipped files?  Thanks, Steve.

If you have gzip, look at gzip -d -c




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



Re: Parse and Compare Text Files

2003-10-27 Thread Mike M
I've found this script on another message board that is close, but still
doesn't work with my data.  Any ideas on modifications?  I think my biggest
problem is the regex in the split function, because what this does is match
ONLY against the first column in the line, when I need it to match anything
in the fourth column.  Thanks for your help, and I'll see what I can do
about allowing playboy.com (although since I work at a public school
district, it might not be a good idea!)   The script follows:

#!/bin/perl -w
use strict;

my %domains;
open FILE1, '< domains.txt or
die $!;
while()
{
chomp;
$domains{$_}=1;
}
close FILE1;

open OUT, '>> access.out' or
die $!;
open FILE2, '< access.log' or
die $!;
while(my $line=)
{
my($num);
($num, undef)=split /\s+/,$line, 2;
if(defined $domains{$num})
{
print OUT $line;
}
else
{
print OUT "$line not found";
}

}
close FILE2;
close OUT;


"Wiggins D'Anconia" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Mike M wrote:
> > Hi,
> >
> > I'm new to Perl and have what I hope is a simple question:  I have a
Perl
> > script that parses a log file from our proxy server and reformats it to
a
> > more easily readable space-delimited text file.  I also have another
file
> > that has a categorized list of internet domains, also space-delimited.
A
> > snippet of both text files is below:
> >
> > Proxy Log
> > snip
> > 10/23/2003 4:18:32 192.168.0.100 http://www.squid-cache.org OK
> > 10/23/2003 4:18:33 192.168.1.150 http://msn.com OK
> > 10/23/2003 4:18:33 192.168.1.150 http://www.playboy.com DENIED
> > snip
> >
> > Categorized Domains List
> > snip
> > msn.com news
> > playboy.com porn
> > squid-cache.com software
> > snip
> >
> > What I would like to do is write a script that compares the URL in the
proxy
> > log with the categorized domains list file and creates a new file that
looks
> > something like this:
> >
> > New File
> > snip
> > 10/23/2003 4:18:32 192.168.0.100 http://www.squid-cache.org software OK
> > 10/23/2003 4:18:33 192.168.1.150 http://msn.com news OK
> > 10/23/2003 4:18:33 192.168.1.150 http://www.playboy.com porn DENIED
> > snip
> >
> > Is this possible with Perl??  I've been trying to do this by importing
the
> > log files into SQL and then running queries, but it's so much slower
than
> > Perl (the proxy logs are roughly 1 million lines).  Any ideas?
> >
>
> What have you tried, where have you failed?  Just about anything is
> possible with Perl, and there are hints that will make this more
> bearable, but this isn't a one stop shopping place, so give it a try
> yourself first
>
> You seem to have a good grasp of what is needed, break it down into
> parts and see what you come up with...
>
> 1. We need a list of domains to match against and what category they are
in,
> 2. We need a line from the log to get the domain,
> 3. We need to look up into the list of domains to see if the domain is
> there,
> 4. If it is we need to add the category to the end of the domain,
> 5. We need a place to store the information back to.
>
> So you need at the very least:
>
> perldoc -f open
> perldoc -f print
>
> And you are probably going to want,
>
> perldoc -f exists
> perldoc -f keys
> perldoc -f values
> perldoc -f grep
>
> And then probably a while loopSo some pseudo code might look like:
>
> open file of categorized domains
> store categorized domains into an easily accessible data structure
> close file
>
> open file for writing to store updated log to
> open file that has log lines in it
> while we read the file, do some stuff, where:
> if the line has a domain name
> pull the domain name
> compare it to the data structure
> if it is in teh data structure update the line
> print the line to the new location
> repeat
>
> close the read file
> close the write file
>
> Have a beer.  By the way you should deny msn.com instead of playboy.com
> ;-)
>
> http://danconia.org
>



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



RE: Finding the current path

2003-10-27 Thread Bob Showalter
Octavian Rasnita wrote:
> Does anyone know if it is possible to find out the path in
> which a perl
> program is launched?
>
> For example, I am in /var/www and I run the following command:
>
> perl /home/script.pl
>
> And I want it to give me the result:
>
> /var/www

Use the standard Cwd module. 

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



help with perl

2003-10-27 Thread Rufus Fleary
I need to convert times in a piece of text to dfifferent formats

The formats are

24 hour clock as hh:mm 09:35 17:05
24 hour clock as hhmmhrs 0935hrs 1705hrs
12 hour clock hh.mm am or pm 9.35am 5.05pm
The application is to have a web form with a large text area for the text to 
be processed an other suitable input fields to select the format required 
and trigger the change.
For examples you can
choose to change 24 hour clock to change to  12 hour clock

or 12 hour clock to 24 hour clock as hhmmhrs

so all the times in the text area will be change to there respected choise

I am new to perl but like it very much I think I have to use subtiution 
expressions

Please can I get some advice from someone as soon as posible

Thanks

Regards Flare

_
Use MSN Messenger to send music and pics to your friends 
http://www.msn.co.uk/messenger

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


Re: RE : SQL Syntax quickie

2003-10-27 Thread Chuck Fox
Yet another solution
SET ROWCOUNT 1
SELECT id FROM table ORDER BY id DESC
Only works if there is an index on id and the RDBMS support backward scans
Chuck

[EMAIL PROTECTED] wrote:

Another solution :
For your  query, try "SELECT MAX(id) FROM table"
That works with mysql.
-Message d'origine-
De : dan [mailto:[EMAIL PROTECTED] 
Envoyé : samedi 25 octobre 2003 11:44
À : [EMAIL PROTECTED]
Objet : SQL Syntax quickie

Hi,

I've looked around to not much avail, what I'm looking for is a SELECT
query that selects the last record in a database. Each table has the
primary field "id", to which auto increments on each input. I don't want
to have to load the entire db, cycle through it until I find the last
one, the program needs to react fast, not being slowed down by having to
cycle through database records.
Basically what happens is the program enters information using INSERT,
and then it needs to re-read the data it's just sent to verify it, and
get the id number that auto_increment assigned it.
Is this possible? Does this make sense? *laugh*

Many thanks,
Dan


 



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


downloading a mp3 file using LWP::simple

2003-10-27 Thread [EMAIL PROTECTED]
using the following code I get a distorted file , I used the sockets and 
the result is the same here is the LWP code i used
use strict;
use LWP::Simple;
my $url ="http://xxx.xxx.com/Amazing_Grace.mp3"; ;
my $html = get($url) ;
print $html;
exit(0);

I think that the tranfer was made in ascii .
any help would be greatly appreciated .
thks n rgds
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Issue

2003-10-27 Thread Bruce_Phillip
Hi,

 

  I'm trying to accomplish some task using perl. So let

  me describe what I have.

 

  I have several systems of the following: 

 

  Unix:

Sun - Solaris

HP - HPUX

 

  Windows:

Dell - Windows 2k

 

 

 Each of these OS's have specific commands that are specific

 not only to the OS but to the hardware as well. Wouldn't it be

 better if I created a header file that contains these commands

 and assigned them to a common variable?

 

 Example:



$memory = 'prtconf | grep Memory | awk '{print $3}'

 

 That would be the command that would be executed only if OS

 is Solaris.

 

 Here is my thinking on this:

 

 In one file I will have a list of the commands:

 

Example:

 

os_commands.pl

 

with in that file have the following:



# memory command for Solaris

$memory = 'prtconf | grep Memory | awk '{print $3}'

 

  

# memory command for HPUX

$memory = 'adb -k /stand/vmunix /dev/mem'

 

list of other commands for other OS's.

 

Then have the main perl program call those memory variables based

on that setting into the main perl code. 

 

So what you end up having is:

 

1 file called command_header.pl which only list all the possible commands

2. file will be the main perl code that just call or displaces the command
within

the perl   

 

I'd appreciate the feedback if any.



 

 

  

 



 

Phillip Bruce
ISC Consultant, System Architect
Location: Dublin, CA
* Cell: 408-476-8658
* Office: 925-560-7853 
AIM: OkieUnix 

 



Re: Can't Compile BerkeleyDB on OS X with Perl 5.8.1

2003-10-27 Thread Aaron Davies
On Monday, October 27, 2003, at 09:43 AM, Bakken, Luke wrote:

-Original Message-
From: Aaron Davies [mailto:[EMAIL PROTECTED]
I'm trying to install BerkeleyDB via CPAN on my OS X 10.2.6 box, but
the make phase bombs almost immediately. I've put the error log at
, since
it's a little
larger than I like to mail people. Can anyone give me a hand here?
BerkeleyDB.xs:74:2: #error db.h is from Berkeley DB 1.x - need at least
Berkeley DB 2.6.4
I'd go looking for that old db.h laying around somewhere.
I tried hacking the Makefile to replace /usr/include/db.h, the version 
from Apple's perl install, with /sw/include/db4/db.h, the version 
installed by Fink, which is presumably more up to date, but it hasn't 
helped much. Make now succeeds, but make test fails as shown below. 
Furthermore, the script I'm installing BerkeleyDB in order to run 
doesn't find it at all, as also shown.

***make test output***

12-220-219-110~/.cpan/build/BerkeleyDB-0.24% make test
PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e" 
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/btreedyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/btreedubious
Test returned status 0 (wstat 5, 0x5)
t/db-3.0...dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/db-3.0...dubious
Test returned status 0 (wstat 5, 0x5)
t/db-3.1...dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/db-3.1...dubious
Test returned status 0 (wstat 5, 0x5)
t/db-3.2...dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/db-3.2...dubious
Test returned status 0 (wstat 5, 0x5)
t/db-3.3...dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/db-3.3...dubious
Test returned status 0 (wstat 5, 0x5)
t/destroy..dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/destroy..dubious
Test returned status 0 (wstat 5, 0x5)
t/encrypt..dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/encrypt..dubious
Test returned status 0 (wstat 5, 0x5)
t/env..dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/env..dubious
Test returned status 0 (wstat 5, 0x5)
t/examples.dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/examples.dubious
Test returned status 0 (wstat 5, 0x5)
t/examples3dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/examples3dubious
Test returned status 0 (wstat 5, 0x5)
t/filter...dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/filter...dubious
Test returned status 0 (wstat 5, 0x5)
t/hash.dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/hash.dubious
Test returned status 0 (wstat 5, 0x5)
t/join.dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/join.dubious
Test returned status 0 (wstat 5, 0x5)
t/mldbmskipped
all skipped: MLDBM is not installed on this system.
t/queuedyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/queuedubious
Test returned status 0 (wstat 5, 0x5)
t/recnodyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/recnodubious
Test returned status 0 (wstat 5, 0x5)
t/strict...dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/strict...dubious
Test returned status 0 (wstat 5, 0x5)
t/subdbdyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/subdbdubious
Test returned status 0 (wstat 5, 0x5)
t/txn..dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/txn..dubious
Test returned status 0 (wstat 5, 0x5)
t/unknown..dyld: /usr/local/bin/perl Undefined symbols:
_db_create
_db_env_create
_db_strerror
_db_version
t/unknown..dubious
Test returned status 0 (wstat 5, 0x5)
FAILED--20 test scripts could be run, alas--no output ever seen
make: *** [test_dynamic] Error 2

***attempt to run POPFile***

POPFile Engine loading

Loading...
 {core: config logger mq}
Can't locate BerkeleyDB.pm in @INC (@INC contains: 
/sw/lib/perl5/5.6.0/darwin /sw/lib/perl5/5.6.0 /sw/lib/perl5/darwin 
/sw/lib/perl5 /System/Library/Pe

RE: Issue

2003-10-27 Thread Bob Showalter
[EMAIL PROTECTED] wrote:
> Hi,
> 
> 
> 
>   I'm trying to accomplish some task using perl. So let
> 
>   me describe what I have.
> 
> 
> 
>   I have several systems of the following:
> 
> 
> 
>   Unix:
> 
> Sun - Solaris
> 
> HP - HPUX
> 
> 
> 
>   Windows:
> 
> Dell - Windows 2k
> 
> 
> 
> 
> 
>  Each of these OS's have specific commands that are specific
> 
>  not only to the OS but to the hardware as well. Wouldn't it be
> 
>  better if I created a header file that contains these commands
> 
>  and assigned them to a common variable?
> 
> 
> 
>  Example:
> 
> 
> 
> $memory = 'prtconf | grep Memory | awk '{print $3}'
> 
> 
> 
>  That would be the command that would be executed only if OS
> 
>  is Solaris.
> 
> 
> 
>  Here is my thinking on this:
> 
> 
> 
>  In one file I will have a list of the commands:
> 
> 
> 
> Example:
> 
> 
> 
> os_commands.pl
> 
> 
> 
> with in that file have the following:
> 
> 
> 
> # memory command for Solaris
> 
> $memory = 'prtconf | grep Memory | awk '{print $3}'
> 
> 
> 
> 
> 
> # memory command for HPUX
> 
> $memory = 'adb -k /stand/vmunix /dev/mem'
> 
> 
> 
> list of other commands for other OS's.
> 
> 
> 
> Then have the main perl program call those memory variables based
> 
> on that setting into the main perl code.
> 
> 
> 
> So what you end up having is:
> 
> 
> 
> 1 file called command_header.pl which only list all the
> possible commands
> 
> 2. file will be the main perl code that just call or
> displaces the command
> within
> 
> the perl
> 
> 
> 
> I'd appreciate the feedback if any.

This sounds fine in principle. Many of the standard Perl modules do this
kind of thing. You use the built-in $^O variable to detect the operating
system. If you want to see an example, do 'perldoc -m Cwd' to browse the
source code of the Cwd module.

Instead of command_header.pl, consider making a full-fledged module. It
isn't hard. Start by reading 'perldoc perlmod'.

Also, read 'perldoc perlport' for general info on writing cross-platform
perl.

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



using modules only when available

2003-10-27 Thread Phil Schaechter
I have a program that has an optional GUI which makes use of Tk.  On machines 
without Tk, the program errors out looking for the Tk modules.  Currently, I 
am just saying

use Tk;

Is there some method I can use that will prevent it from dying in the event Tk 
is not on the current machine?  Or, is there a way that I can make it not 
load the Tk modules until I actually need them within the program?

Thanks,

Phil

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



RE: using modules only when available

2003-10-27 Thread Bob Showalter
Phil Schaechter wrote:
> I have a program that has an optional GUI which makes use of
> Tk.  On machines
> without Tk, the program errors out looking for the Tk
> modules.  Currently, I
> am just saying
> 
> use Tk;
> 
> Is there some method I can use that will prevent it from
> dying in the event Tk
> is not on the current machine?  Or, is there a way that I can make it
> not load the Tk modules until I actually need them within the program?

The general solution is to wrap the "use" in an eval():

   eval "use Some::Module";
   if ($@) {
  # module not found or some other problem
   }

I'm not sure if there are any caveats with this approach WRT the Tk
module...

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



Re: using modules only when available

2003-10-27 Thread Phil Schaechter
This is what I tried:

eval "use Tk";
   if ($@) {
  $notk = 1;
   }

Now, on machines where Tk doesn't exist, it works fine.  On machines where Tk 
does exist, the program exits silently when I begin to use Tk.

Perhaps there is a caveat with using this with Tkany ideas, anyone?

-Phil

>eval "use Some::Module";
>if ($@) {
>   # module not found or some other problem
>}
>
> I'm not sure if there are any caveats with this approach WRT the Tk
> module...

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



Re: using modules only when available

2003-10-27 Thread Wiggins d Anconia
> This is what I tried:
> 
> eval "use Tk";
>if ($@) {
>   $notk = 1;
>}
> 
> Now, on machines where Tk doesn't exist, it works fine.  On machines
where Tk 
> does exist, the program exits silently when I begin to use Tk.
> 
> Perhaps there is a caveat with using this with Tkany ideas, anyone?
> 
> -Phil
> 
> >eval "use Some::Module";
> >if ($@) {
> >   # module not found or some other problem
> >}
> >
> > I'm not sure if there are any caveats with this approach WRT the Tk
> > module...
> 

I would have thought in this case you would want the BLOCK form of
'eval' rather than the EXPR form?  Or does it matter?  Gurus can you
expound on the differences in this case?

Give:

eval { use Tk };
if ($@) {
  # module not ok, etc.
}

A try. perldoc -f eval

http://danconia.org

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



RE: using modules only when available

2003-10-27 Thread Bakken, Luke
> I would have thought in this case you would want the BLOCK form of
> 'eval' rather than the EXPR form?  Or does it matter?  Gurus can you
> expound on the differences in this case?
> 
> Give:
> 
> eval { use Tk };
> if ($@) {
>   # module not ok, etc.
> }
> 
> A try. perldoc -f eval
> 
> http://danconia.org
> 

"use" is done at compile time ( i.e. in a BEGIN {} if I remember correctly ). In order 
to check for a module, you have to use require() in an eval block { } to check for the 
presence of a module. If you have to import symbols, use import().

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



Re: using modules only when available

2003-10-27 Thread Steve Grazzini
On Mon, Oct 27, 2003 at 03:21:50PM -0700, Wiggins d Anconia wrote:
> > This is what I tried:
> > 
> > eval "use Tk";
> 
> I would have thought in this case you would want the BLOCK form of
> 'eval' rather than the EXPR form?  Or does it matter?  Gurus can you
> expound on the differences in this case?

Since use() happens at compile-time, this doesn't work the way it
ought to:

> eval { use Tk };
> if ($@) {
>   # module not ok, etc.
> }

Try it with a different module (one you don't have) and you'll
see the problem...  

You can see the same thing with BEGIN blocks:

  eval q{ BEGIN{ die 'Whoops!' }};   # string eval() catches error
  eval  { BEGIN{ die 'Whoops!' }};   # block eval() doesn't

String eval works here because the string is compiled (and executed)
at runtime, when eval() is called.  This means that compilation errors
will be protected by the eval().

Block eval doesn't work because the block is compiled (although it's
not executed) *before* eval() is called.  This means that compilation
errors aren't protected.

Since require() happens at run-time, the OP could do something like
this as well:

BEGIN{ eval{ require Tk }};  # and optionally: Tk->import

-- 
Steve

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



RE: Issue

2003-10-27 Thread Bruce_Phillip
Bob,

 Thanks for the feedback, The only thing is that $O^ will only
 work if the scripts are going to be invoke on that system.

 My plans are to run the perl script from one location and go
 and discover the systems and their configuration. I'll be using
 Net::Telnet module to do this with to connect to systems in
 order to get those configs. 

 Any other suggestions is welcomed.

  

Phillip

-Original Message-
From: Bob Showalter [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 27, 2003 12:25 PM
To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED]
Subject: RE: Issue

[EMAIL PROTECTED] wrote:
> Hi,
> 
> 
> 
>   I'm trying to accomplish some task using perl. So let
> 
>   me describe what I have.
> 
> 
> 
>   I have several systems of the following:
> 
> 
> 
>   Unix:
> 
> Sun - Solaris
> 
> HP - HPUX
> 
> 
> 
>   Windows:
> 
> Dell - Windows 2k
> 
> 
> 
> 
> 
>  Each of these OS's have specific commands that are specific
> 
>  not only to the OS but to the hardware as well. Wouldn't it be
> 
>  better if I created a header file that contains these commands
> 
>  and assigned them to a common variable?
> 
> 
> 
>  Example:
> 
> 
> 
> $memory = 'prtconf | grep Memory | awk '{print $3}'
> 
> 
> 
>  That would be the command that would be executed only if OS
> 
>  is Solaris.
> 
> 
> 
>  Here is my thinking on this:
> 
> 
> 
>  In one file I will have a list of the commands:
> 
> 
> 
> Example:
> 
> 
> 
> os_commands.pl
> 
> 
> 
> with in that file have the following:
> 
> 
> 
> # memory command for Solaris
> 
> $memory = 'prtconf | grep Memory | awk '{print $3}'
> 
> 
> 
> 
> 
> # memory command for HPUX
> 
> $memory = 'adb -k /stand/vmunix /dev/mem'
> 
> 
> 
> list of other commands for other OS's.
> 
> 
> 
> Then have the main perl program call those memory variables based
> 
> on that setting into the main perl code.
> 
> 
> 
> So what you end up having is:
> 
> 
> 
> 1 file called command_header.pl which only list all the
> possible commands
> 
> 2. file will be the main perl code that just call or
> displaces the command
> within
> 
> the perl
> 
> 
> 
> I'd appreciate the feedback if any.

This sounds fine in principle. Many of the standard Perl modules do this
kind of thing. You use the built-in $^O variable to detect the operating
system. If you want to see an example, do 'perldoc -m Cwd' to browse the
source code of the Cwd module.

Instead of command_header.pl, consider making a full-fledged module. It
isn't hard. Start by reading 'perldoc perlmod'.

Also, read 'perldoc perlport' for general info on writing cross-platform
perl.

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



Opening a new shell

2003-10-27 Thread Anthony J Segelhorst
I am strapped for time on the run time on a perl script I have been 
working on. 

I was wondering if it is possible to open another shell within a perl 
script that will call another script that uses another processes.

If I call script B from script A, script A will not complete until script 
B is done running.  Is there a way to run script B within another shell or 
process?

`c:\temp\scripta.pl`;


Anthony J Segelhorst
Enterprise Systems Management Team
Phone: 937-495-1876
Email: [EMAIL PROTECTED]


This email has been scanned for all viruses by the MessageLabs SkyScan
service.___

Note:  Please update your email address for this user to reflect the
new MeadWestvaco Corporation.  MeadWestvaco employee email addresses
are in the format of [EMAIL PROTECTED] 

This electronic message contains information from MeadWestvaco
Corporation or subsidiary companies, which may be confidential,
privileged or otherwise protected from disclosure.  The
information is intended to be used solely by the recipient(s)
named.  If you are not an intended recipient, be aware that
any review, disclosure, copying, distribution or use of this
transmission or its contents is prohibited.  If you have
received this transmission in error, please notify MeadWestvaco
immediately at [EMAIL PROTECTED]
___

RE: Opening a new shell

2003-10-27 Thread LoBue, Mark
> -Original Message-
> From: Anthony J Segelhorst [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 27, 2003 5:50 PM
> To: [EMAIL PROTECTED]
> Subject: Opening a new shell
> 
> 
> I am strapped for time on the run time on a perl script I have been 
> working on. 
> 
> I was wondering if it is possible to open another shell within a perl 
> script that will call another script that uses another processes.
> 
> If I call script B from script A, script A will not complete 
> until script 
> B is done running.  Is there a way to run script B within 
> another shell or 
> process?
> 
> `c:\temp\scripta.pl`;

unix?  Guess not, since you are using backslashes in your file name.  try:
system('c:/temp/scripta.pl &');

The backticks imply you want to wait for the script to return some output,
system may make more sense here.  Also, it is ok to use forward slashes in
your perl script, even in Windows.

Mark

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



Re: Opening a new shell

2003-10-27 Thread simran
% perldoc -f fork 


On Tue, 2003-10-28 at 12:50, Anthony J Segelhorst wrote:
> I am strapped for time on the run time on a perl script I have been 
> working on. 
> 
> I was wondering if it is possible to open another shell within a perl 
> script that will call another script that uses another processes.
> 
> If I call script B from script A, script A will not complete until script 
> B is done running.  Is there a way to run script B within another shell or 
> process?
> 
> `c:\temp\scripta.pl`;
> 
> 
> Anthony J Segelhorst
> Enterprise Systems Management Team
> Phone: 937-495-1876
> Email: [EMAIL PROTECTED]
> 
> 
> This email has been scanned for all viruses by the MessageLabs SkyScan
> service.___
> 
> Note:  Please update your email address for this user to reflect the
> new MeadWestvaco Corporation.  MeadWestvaco employee email addresses
> are in the format of [EMAIL PROTECTED] 
> 
> This electronic message contains information from MeadWestvaco
> Corporation or subsidiary companies, which may be confidential,
> privileged or otherwise protected from disclosure.  The
> information is intended to be used solely by the recipient(s)
> named.  If you are not an intended recipient, be aware that
> any review, disclosure, copying, distribution or use of this
> transmission or its contents is prohibited.  If you have
> received this transmission in error, please notify MeadWestvaco
> immediately at [EMAIL PROTECTED]
> ___


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



creating a hash list from arrays

2003-10-27 Thread radhika sambamurti
Hi,
As per the code below, I am trying to read from the database and put the values into a 
hash list, so that I can retrieve the values later.
I have managed to put the values into arrays, but am not able to put them into a hash.
Any ideas how this can be done/improved?

###code below##

while (my $res = $sth->fetchrow_hashref()) {
push(@menu_id, $res->{"menu_item_number"});
push(@menu_desc, $res->{"description"});
my $results_hash = ($res->{"menu_item_number"}, $res->{"description"});
}

Thanks,
radhika

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



Re: creating a hash list from arrays

2003-10-27 Thread Daniel Staal
--On Monday, October 27, 2003 21:51 -0500 radhika sambamurti 
<[EMAIL PROTECTED]> wrote:

Hi,
As per the code below, I am trying to read from the database and
put the values into a hash list, so that I can retrieve the values
later. I have managed to put the values into arrays, but am not
able to put them into a hash. Any ideas how this can be
done/improved?
### code below##

while (my $res = $sth->fetchrow_hashref()) {
push(@menu_id, $res->{"menu_item_number"});
push(@menu_desc, $res->{"description"});
my $results_hash = ($res->{"menu_item_number"},
$res->{"description"}); }
Not too bad.  Though, by 'retrieve the values later' I assume you 
mean after the while loop, yes?  If so, it would be a good idea to 
change the scope of the hash to reflect that...

Try:

my $results_hash;
while (my $res = $sth->fetchrow_hashref()) {
  push(@menu_id, $res->{"menu_item_number"});
  push(@menu_desc, $res->{"description"});
  $results_hash = ($res->{"menu_item_number"},
   $res->{"description"});
}
Then the hash won't expire at the end of the loop.

Daniel T. Staal

---
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: creating a hash list from arrays

2003-10-27 Thread Daniel Staal
--On Monday, October 27, 2003 21:22 -0600 Daniel Staal 
<[EMAIL PROTECTED]> wrote:

my $results_hash;
Sorry, correction.  That should be:

my %results_hash;

while (my $res = $sth->fetchrow_hashref()) {
   push(@menu_id, $res->{"menu_item_number"});
   push(@menu_desc, $res->{"description"});
   $results_hash = ($res->{"menu_item_number"},
$res->{"description"});
}
Then the hash won't expire at the end of the loop.
Daniel T. Staal

---
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: creating a hash list from arrays

2003-10-27 Thread radhika sambamurti
Hmmm, This did not work.
my $count = keys %results_hash; gives me 0
And perl also complained that $results_hash had to be explicitly defined, so I had my 
$results_hash AND my %results_hash.
This is not working. my hash is empty.

Radhika


On Mon, 27 Oct 2003 21:24:28 -0600
Daniel Staal <[EMAIL PROTECTED]> wrote:

> --On Monday, October 27, 2003 21:22 -0600 Daniel Staal 
> <[EMAIL PROTECTED]> wrote:
> 
> >
> > my $results_hash;
> 
> Sorry, correction.  That should be:
> 
> my %results_hash;
> 
> > while (my $res = $sth->fetchrow_hashref()) {
> >push(@menu_id, $res->{"menu_item_number"});
> >push(@menu_desc, $res->{"description"});
> >$results_hash = ($res->{"menu_item_number"},
> > $res->{"description"});
> > }
> >
> > Then the hash won't expire at the end of the loop.
> 
> Daniel T. Staal
> 
> ---
> This email copyright the author.  Unless otherwise noted, you
> are expressly allowed to retransmit, quote, or otherwise use
> the contents for non-commercial purposes.  This copyright will
> expire 5 years after the author's death, or in 30 years,
> whichever is longer, unless such a period is in excess of
> local copyright law.
> ---
> 
> -- 
> 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: creating a hash list from arrays

2003-10-27 Thread Jeff 'japhy' Pinyan
On Oct 27, radhika sambamurti said:

>As per the code below, I am trying to read from the database and put the
>values into a hash list, so that I can retrieve the values later. I have
>managed to put the values into arrays, but am not able to put them into a
>hash. Any ideas how this can be done/improved?

>while (my $res = $sth->fetchrow_hashref()) {
>  push(@menu_id, $res->{"menu_item_number"});
>  push(@menu_desc, $res->{"description"});
>  my $results_hash = ($res->{"menu_item_number"}, $res->{"description"});
>}

First, you don't want $results_hash to be my().  It'll lose its value each
time.  Second, you want a hash.  $foo = (1,2) ends up setting $foo to 2.
Third, doing %hash = (key, value) clears the entire hash each time.  You
want to do:

  my %results_hash;
  while (my $res = ...) {
# two push()s
$results_hash{$res->{menu_item_number}} = $res->{description};
  }

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


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



array of elements

2003-10-27 Thread Andrew Gaffney
I have an array of keywords that I need to generate. I have 2 separate input files. The 
first one contains the defaults. The second input file contains additions and overrides. 
For example, first input:

key1 key2 key3 key4 key5 key6 key7

second input:

-key3 -key5 key8 key9

end result:

key1 key2 key4 key6 key7 key8 key9

What is the easiest/fastest way to do this?

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


Re: array of elements

2003-10-27 Thread Andrew Gaffney
How would I go about this?

simran wrote:
a way i can think of is:

* read first file and put keys in hash (%h)
* read second file and add/delete from hash (%h) as needed
* print keys of %h
 
On Tue, 2003-10-28 at 14:52, Andrew Gaffney wrote:

I have an array of keywords that I need to generate. I have 2 separate input files. The 
first one contains the defaults. The second input file contains additions and overrides. 
For example, first input:

key1 key2 key3 key4 key5 key6 key7

second input:

-key3 -key5 key8 key9

end result:

key1 key2 key4 key6 key7 key8 key9

What is the easiest/fastest way to do this?

--
Andrew Gaffney




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


Re: array of elements

2003-10-27 Thread Steve Grazzini
On Mon, Oct 27, 2003 at 09:52:20PM -0600, Andrew Gaffney wrote:
> I have an array of keywords that I need to generate. I have 2 separate 
> input files. The first one contains the defaults. The second input file 
> contains additions and overrides. For example, first input:
> 
> key1 key2 key3 key4 key5 key6 key7
> 
> second input:
> 
> -key3 -key5 key8 key9
> 
> end result:
> 
> key1 key2 key4 key6 key7 key8 key9
> 
> What is the easiest/fastest way to do this?

my @array = do { 
local @ARGV = qw(default.txt override.txt);
local $^I;

my %params;
while (<>) {
foreach (split) {
if (s/^-//) {
delete $params{$_};
}
else {
$params{$_}++
}
}
}
sort keys %params;
};

-- 
Steve

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