RE: how to remove a ^M charaters from a variable

2003-12-19 Thread Tom Kinzer
tr/015//;

-Tom Kinzer

-Original Message-
From: Randy W. Sims [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 18, 2003 8:05 PM
To: David Inglis
Cc: [EMAIL PROTECTED]
Subject: Re: how to remove a ^M charaters from a variable


On 12/20/2003 8:21 AM, David Inglis wrote:

> I am reading in a csv file and it has a control character ^M at the end
> of each line how can I remove these charaters, I have tried the following
> and had no success.
> 
> $a=~s/\^M//;
> $a=~s/^M//;
> 
> 
> Any help appreciated thanks.
> 
> 

^M is the carriage return. Try s/\x0D//;

Regards,
Randy.


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




Calling another perl file

2003-12-19 Thread Tushar Gokhale
How do I call another perl script from my current perl script? I'm working
on one perl testing harness, currently my "bin/run.pl" has a control and
now I want to call script files one by one from "tests/" folder. I also
want to pass an argument to the test script file. Once the file is executed
from "tests" folder i want the control to come back to my run.pl file.

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




Timing an operation

2003-12-19 Thread HENRY,MARK (HP-Roseville,ex1)
Dear All,

Merry Christmas!! 

Wondering if someone can recommend the best way to time an operation within
a script.

I'm using Net:FTP to check transmission times on files to various computers
for later comparison.  
I see the benchmark module, but I'm thinking take a timestamp, running the
ftp transfer, then running again when complete and diffing the two..

Any other recommendations?

Cheers,

Mark

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




Re: mysql cgi admin and client

2003-12-19 Thread George Georgalis

On Tue, Dec 16, 2003 at 09:19:01AM -0800, R. Joseph Newton wrote:
>George Georgalis wrote:
>
>> After I wrote that, I made some good progress... notably:
>> http://www.thedumbterminal.co.uk/software/webmysql.shtml
>>
>> This might be good too, haven't tried
>> http://sourceforge.net/projects/mysqltool/
>>
>> // George
>
>That sounds good.  You didn't say what myphpadmin does, though, so I'm not
>really sure what functionality you are looking for.  The standard tool in Perl
>for basic DB access is the DBI [database independent] interface, coulple
>withDBD:: as the driver for specific engine .  You will
>want to get familiar with these, though it sounds like yur immediate issue has
>more to do with database administration.  I'm not sure what DBI's capabilities
>are for design tasks.  It does have methods for querying metadata.  My guess is
>that it will also pass DDL statements as well as SQL.

Hi Joseph,

the tool I had in mind was http://www.phpmyadmin.net/

it does a lot, with php. I'm looking for a perl based cgi program
I can drop in to allow remote users to design a db and enter data.
template/css based would be good.

I'd expect it to use DBI::mysql and would hopefully be a good project
for me to use to get better experience with perl. Presently I create
mysql scripts for database generation and bash interfaces for input and
queries.

webmysql doesn't seem to support INSERT so...

the idea is to get something simple in place quickly, for remote clients
to admin/insert on databases (and web based not client), then work on
developing a more specialized custom application.

// George

-- 
GEORGE GEORGALIS, System Admin/Architectcell: 646-331-2027<
Security Services, Web, Mail,mailto:[EMAIL PROTECTED] 
Multimedia, DB, DNS and Metrics.   http://www.galis.org/george 


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




Re: Term:ANSIColor and negative numbers

2003-12-19 Thread Andrew Gaffney
Wagner, David --- Senior Programmer Analyst --- WGO wrote:
Andrew Gaffney wrote:

(William) Wenjie Wang wrote:

-Original Message-
From: Wagner, David --- Senior Programmer Analyst --- WGO
[mailto:[EMAIL PROTECTED]
Sent: Thursday, 18 December 2003 4:41 AM
To: James Edward Gray II; Steve Massey
Cc: [EMAIL PROTECTED]
Subject: RE: Term:ANSIColor and negative numbers
James Edward Gray II wrote:


On Dec 17, 2003, at 11:25 AM, Steve Massey wrote:



Hi All

using Term:ANSIColor - does anyone know if it's possible ( or
maybe I mean practical) to print out negative numbers in say RED,
at the same time ensuring the original value is retained.
so if value is -16 the it should print 16 in RED text otherwise
leave it alone.
How do you get it to actually do the color? I use both std
command( w2k) and older version os MKS Korn shell and all I get is
numbers. Never understood how one actually gets the colors etc.
	What does one need to do?


I'm using perl5.08 on Win2k box, and have faced the same problem in
my DOS prompt window.  There is no color changes, but some escape
sequence was displayed instead.  If I execute the sample code
provided by James, I got "?[31m16?[0m" displayed instead of "16" in
red color. 

But I do have red colored 16 displayed properly, if execute it from
cgywin's bash shell. 

I'm presuming it got something to do with the configuration?
I believe that you need to load ANSI.SYS in your CONFIG.SYS in order
to have the escape sequences interpreted in a DOS session.
	Sorry, but when you say load, what do you mean? Sorry but unsure what is necessary and I would like to see this work.

	Thanks for any input.
Well, in Windows 98 and below, you could add the line:

DEVICE=ANSI.SYS

to your C:\CONFIG.SYS and it would allow the command prompt to interpret ANSI escape 
sequences. Unfortunately, I do not know the equivelant for Windows NT/2K/XP.

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



Re: mysql cgi admin and client

2003-12-19 Thread George Georgalis
yeah, that looks right. Thanks Jose.

// George


On Tue, Dec 16, 2003 at 03:30:10PM +0100, NYIMI Jose (BMB) wrote:
>Try
>http://www.gossamer-threads.com/scripts/mysqlman/index.htm
>
>Jos?.
>
>-Original Message-
>From: George Georgalis [mailto:[EMAIL PROTECTED] 
>Sent: Tuesday, December 16, 2003 6:14 AM
>To: [EMAIL PROTECTED]
>Subject: Re: mysql cgi admin and client
>
>
>After I wrote that, I made some good progress... notably: 
>http://www.thedumbterminal.co.uk/software/webmysql.shtml
>
>This might be good too, haven't tried http://sourceforge.net/projects/mysqltool/
>
>// George
>
>On 12/15/03, George Georgalis wrote:
>>Hi,
>>
>>I thought there was something like myphpadmin (for mysql) in perl but 
>>I'm not finding it.
>>
>>I'm looking for a perl or mod_perl cgi, to create (as admin) mysql 
>>database and tables, data entry interface and access client. Ideally 
>>template / css based. Lots of companies sell this sort og thing for 
>>under $40, but I suspect there is a GNU one out there?
>>
>>// George
>>

-- 
GEORGE GEORGALIS, System Admin/Architectcell: 646-331-2027<
Security Services, Web, Mail,mailto:[EMAIL PROTECTED] 
Multimedia, DB, DNS and Metrics.   http://www.galis.org/george 


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




RE: how to remove a ^M charaters from a variable

2003-12-19 Thread Jaffer
Hai David,

I don't where you tried this 
have you tried this in NT or in UNIX?

$a="jaffer^";
$a=~s/\^M//; This works in NT
print $a;

But it wont works in Unix.

Try this way in Unix $a=~s/\015//g; 

Let me know if any

Thank you
jaffer


-Original Message-
From: David Inglis [mailto:[EMAIL PROTECTED]
Sent: Saturday, December 20, 2003 6:51 PM
To: [EMAIL PROTECTED]
Subject: how to remove a ^M charaters from a variable



I am reading in a csv file and it has a control character ^M at the end
of each line how can I remove these charaters, I have tried the following
and had no success.

$a=~s/\^M//;
$a=~s/^M//;


Any help appreciated thanks.


-- 
Regards



David Inglis
0408502342


-- 
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: Term:ANSIColor and negative numbers

2003-12-19 Thread Randy W. Sims
On 12/18/2003 9:15 PM, Andrew Gaffney wrote:

Wagner, David --- Senior Programmer Analyst --- WGO wrote:

Andrew Gaffney wrote:

(William) Wenjie Wang wrote:

I believe that you need to load ANSI.SYS in your CONFIG.SYS in order
to have the escape sequences interpreted in a DOS session.


Sorry, but when you say load, what do you mean? Sorry but unsure 
what is necessary and I would like to see this work.

Thanks for any input.


Well, in Windows 98 and below, you could add the line:

DEVICE=ANSI.SYS

to your C:\CONFIG.SYS and it would allow the command prompt to interpret 
ANSI escape sequences. Unfortunately, I do not know the equivelant for 
Windows NT/2K/XP.

There is no equivelant for 2K/XP.  I think there is way in NT, but don't 
recall the specifics.

Randy.



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



Re: foreach

2003-12-19 Thread Rob Dixon
Eric Walker wrote:
>
> perlknucklehead
> >
> > On Thu, 2003-12-18 at 17:07, Paul Johnson wrote:
> > On Thu, Dec 18, 2003 at 04:57:26PM -0700, Eric Walker wrote:
> >
> > > > Hello all
> > > > While traversing a loop across and array, how can I access array
> > > > positions further down the array, like say if I am on a loop looking at
> > > > position 23, how can I check the value of say position 24 or 32 while my
> > > > loop counter is on position 23.
> >
> > Hmmm?  Add 1 or 9 to your loop counter?
> >
> > Or have you not actually got a loop counter?  If that is the case the
> > easiest solution is probably to get one.
> >
> > Or have I completely misunderstood?  Showing the code is usually more
> > productive than simply describing the problem.
> >
> > I got it so I need a counter which sends me to a for loop instead of a
> > foreach.  Thanks..

You may want to use 'foreach' and just keep track of the current index. That
gives you the extra speed and clarity of 'foreach' but still gives you an
index to work with. Like this:

  my $i = 0;

  foreach (@array) {
:
$i++;
  }

HTH,

Rob



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




Re: how to remove a ^M charaters from a variable

2003-12-19 Thread Rob Dixon
Tom Kinzer wrote:
>
> tr/015//;

This will do nothing to the string. It will just return the
number of zero, one and five characters it finds.

Control-M is

  "\cM"
or
  "\x0D"
or
  "\015"
or
  "\r"

To get 'tr' to delete the characters it finds you need the /d
modifier.

  tr/\015//d

will do the trick.

Cheers,

Rob



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




REGEX: matching AFTER a specific character

2003-12-19 Thread Ben Crane
Hi all,

Here is a code snippet, and yes I am going to use
File::Basename to strip the file path/filename once
I've stripped the entire path from a string.

The string $_ is a line in a text file. I want to use
File::Basename to pull apart the file path and
filename, but first I need to extract the string from
the entire string...

$_="Open Table \"Q:\\OSMAPS\\mapinfo\\gazos_rd\" As
Gazos_Rd Interactive ReadOnly";

($path) = /(".*")/i;

print "$path\n";

Now my problem is: when I run this code (yep, I know
strict isn't on) I get "Q:\OSMAPS\mapinfo\gazos_rd",
 but I just want what's between the quotation
marks...how do I match a value in a string but exclude
the Quotation marks. The quotation marks delineate the
file path so they're very useful, but I can't have
them in my $path when it gets put into File::Basename.

Any ideas? If I match on \w or \w+ I get the Open
Table part (not wanted). The file paths will vary
greatly so sometimes they'll be a large complex file
path and otherwise (if in the same folder as the txt
file, it'll just be "gazos_rd".

Ben

__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

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




Re: REGEX: matching AFTER a specific character

2003-12-19 Thread Rob Dixon
Ben Crane wrote:
>
> Here is a code snippet, and yes I am going to use
> File::Basename to strip the file path/filename once
> I've stripped the entire path from a string.
>
> The string $_ is a line in a text file. I want to use
> File::Basename to pull apart the file path and
> filename, but first I need to extract the string from
> the entire string...
>
> $_="Open Table \"Q:\\OSMAPS\\mapinfo\\gazos_rd\" As
> Gazos_Rd Interactive ReadOnly";
>
> ($path) = /(".*")/i;
>
> print "$path\n";
>
> Now my problem is: when I run this code (yep, I know
> strict isn't on) I get "Q:\OSMAPS\mapinfo\gazos_rd",
>  but I just want what's between the quotation
> marks...how do I match a value in a string but exclude
> the Quotation marks. The quotation marks delineate the
> file path so they're very useful, but I can't have
> them in my $path when it gets put into File::Basename.
>
> Any ideas? If I match on \w or \w+ I get the Open
> Table part (not wanted). The file paths will vary
> greatly so sometimes they'll be a large complex file
> path and otherwise (if in the same folder as the txt
> file, it'll just be "gazos_rd".

Hi Ben.

It looks like the record looks like:

  

in which case you can just grab all
three fields like this:

  m/ "(.*?)"  \s*  (.+?)  \s*  "(.*?)" /x
  $path = $2;

(The /x just allows embedded spaces for layout)

This allows for leading and trailing whitespace on the
file path. You can simplify this if you're sure you'll
never need the two strings, but this is a general solution.

HTH,

Rob



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




Networking-perl problem

2003-12-19 Thread chetak.sasalu

Hi,

I have to gather data from external devices and process it.
There are 3 devices to be interfaced to the pc.One of the device is
connected through the ethernet.The other two are connected through
serial(com) ports.

Are there any modules in perl to achieve this in windows?

Thanks in advance,
Chetak

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: foreach

2003-12-19 Thread Bob Showalter
Jeff Westman wrote:
> Eric Walker <[EMAIL PROTECTED]> wrote:
> 
> > I got it so I need a counter which sends me to a for loop instead
> > of a foreach.  Thanks.. 
> > 
> > perlknucklehead
> 
> I believe that 'for' and 'foreach' are completely
> interchangable. I remember
> reading somewhere that one was a synonym for the other.

Yes, it's documented in perldoc perlsyn. I never write it as "foreach". But
I never use csh either.

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




Re: foreach

2003-12-19 Thread Rob Dixon
Bob Showalter wrote:
>
> Jeff Westman wrote:
> > Eric Walker <[EMAIL PROTECTED]> wrote:
> >
> > > I got it so I need a counter which sends me to a for loop instead
> > > of a foreach.  Thanks..
> > >
> > > perlknucklehead
> >
> > I believe that 'for' and 'foreach' are completely
> > interchangable. I remember
> > reading somewhere that one was a synonym for the other.
>
> Yes, it's documented in perldoc perlsyn. I never write it as "foreach". But
> I never use csh either.

Hi Bob.

That's fair enough, as long as you have a consistent convention. I
use

  for (EXPRESSION; EXPRESSION; EXPRESSION)

and

  foreach (LIST)

unless the list has only one element, when I use

  for (EXPRESSION)

to alias $_ with the expression for the extent of the block.

Cheers,

Rob



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




Re: Networking-perl problem

2003-12-19 Thread Randy W. Sims
On 12/19/2003 7:15 AM, [EMAIL PROTECTED] wrote:

Hi,

I have to gather data from external devices and process it.
There are 3 devices to be interfaced to the pc.One of the device is
connected through the ethernet.The other two are connected through
serial(com) ports.
Are there any modules in perl to achieve this in windows?

Win32::Serial



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



RE: foreach

2003-12-19 Thread Paul Kraus
I am catching this thread late so this may have been covered.
But can you give me some examples?

I use foreach for arrays.

For for loops where I need to maintain a count and have a criteria on
the iterations.


> -Original Message-
> From: Rob Dixon [mailto:[EMAIL PROTECTED] 
> Sent: Friday, December 19, 2003 8:59 AM
> To: [EMAIL PROTECTED]
> Subject: Re: foreach
> 
> 
> Bob Showalter wrote:
> >
> > Jeff Westman wrote:
> > > Eric Walker <[EMAIL PROTECTED]> wrote:
> > >
> > > > I got it so I need a counter which sends me to a for 
> loop instead 
> > > > of a foreach.  Thanks..
> > > >
> > > > perlknucklehead
> > >
> > > I believe that 'for' and 'foreach' are completely 
> interchangable. I 
> > > remember reading somewhere that one was a synonym for the other.
> >
> > Yes, it's documented in perldoc perlsyn. I never write it as 
> > "foreach". But I never use csh either.
> 
> Hi Bob.
> 
> That's fair enough, as long as you have a consistent convention. I use
> 
>   for (EXPRESSION; EXPRESSION; EXPRESSION)
> 
> and
> 
>   foreach (LIST)
> 
> unless the list has only one element, when I use
> 
>   for (EXPRESSION)
> 
> to alias $_ with the expression for the extent of the block.
> 
> Cheers,
> 
> Rob
> 
> 
> 
> -- 
> 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: foreach

2003-12-19 Thread James Edward Gray II
On Dec 19, 2003, at 7:59 AM, Rob Dixon wrote:

That's fair enough, as long as you have a consistent convention. I
use
  for (EXPRESSION; EXPRESSION; EXPRESSION)

and

  foreach (LIST)

unless the list has only one element, when I use

  for (EXPRESSION)

to alias $_ with the expression for the extent of the block.
Just to throw another log on the fire:  I do my foreach (LIST) as Rob 
does above, unless I'm using my own variable and then because I like 
the way it reads I change it to:

for my $var (LIST)

Ah, programmers and their little rules.  :D

James

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



Re: foreach

2003-12-19 Thread Eric Walker
Thanks I was able to use a for loop and just  do a $cnt + N to access
any locations that I needed, that I have not iterated on.

Thanks...all for your help
perlknucklehead

On Fri, 2003-12-19 at 07:24, James Edward Gray II wrote:
On Dec 19, 2003, at 7:59 AM, Rob Dixon wrote:

> That's fair enough, as long as you have a consistent convention. I
> use
>
>   for (EXPRESSION; EXPRESSION; EXPRESSION)
>
> and
>
>   foreach (LIST)
>
> unless the list has only one element, when I use
>
>   for (EXPRESSION)
>
> to alias $_ with the expression for the extent of the block.

Just to throw another log on the fire:  I do my foreach (LIST) as Rob 
does above, unless I'm using my own variable and then because I like 
the way it reads I change it to:

for my $var (LIST)

Ah, programmers and their little rules.  :D

James


-- 
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: Term:ANSIColor and negative numbers

2003-12-19 Thread Chuck Fox


[EMAIL PROTECTED] wrote:

Well, in Windows 98 and below, you could add the line:

DEVICE=ANSI.SYS

to your C:\CONFIG.SYS and it would allow the command prompt to 
interpret ANSI escape sequences. Unfortunately, I do not know the 
equivelant for Windows NT/2K/XP.
Ahh, A Golden Oldie for sure!

Your Friendly Neighborhood DBA,

Chuck

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



RE: how to remove a ^M charaters from a variable

2003-12-19 Thread Tom Kinzer
right - my bad.   what i mean, not what i say!

thanks rob.

-Tom Kinzer

-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 3:07 AM
To: [EMAIL PROTECTED]
Subject: Re: how to remove a ^M charaters from a variable


Tom Kinzer wrote:
>
> tr/015//;

This will do nothing to the string. It will just return the
number of zero, one and five characters it finds.

Control-M is

  "\cM"
or
  "\x0D"
or
  "\015"
or
  "\r"

To get 'tr' to delete the characters it finds you need the /d
modifier.

  tr/\015//d

will do the trick.

Cheers,

Rob



-- 
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 remove a ^M charaters from a variable

2003-12-19 Thread Dan Muey
> Hai David,
> 
> I don't where you tried this 
> have you tried this in NT or in UNIX?
> 
> $a="jaffer^";
> $a=~s/\^M//; This works in NT
> print $a;
> 
> But it wont works in Unix.

Sure it does: 
(unless you're talking goofy data of a binary hexy sort of thing, 
which you might be since I completely missed this post ;p )

perl -Mstrict -we 'my $v = "HI^MHI";print "$v\n";$v =~ s/\^M//;print "$v\n";'
HI^MHI
HIHI

If you just want to kill the carat and not necessariy 'carat uppercase M' just do
s/\^//;

You might want to add a g so it gets them all.

Dmuey

> 
> Try this way in Unix $a=~s/\015//g; 
> 
> Let me know if any
> 
> Thank you
> jaffer

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




debugger

2003-12-19 Thread Eric Walker
Hello all,
When using the perl debugger, is there a way to load in the breakpoints
and watch variables that I want from a file.  I am using it now and as I
am debugging I am finding problems but when I start the program over I
have to re-enter all my breakpoints and watch variables again. Can these
be listed in a file and then read by the debugger to ease the amount of
things to enter?

Thanks
Perlknucklehead





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




NEVERMIND I FOUND THE ANSWER

2003-12-19 Thread Eric Walker
Never mind, I found that instead of hitting q twice , just hit it once
and the r for restart and I still keep all my settings..
Thanks...
perlknucklehead





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




RE: encrypting email address (to prevent spam)

2003-12-19 Thread Dan Muey
> 
> What's unethical about it?  What's wrong with posting it in multiple 
> places?!!  Not everyone on this list is a member of that list (and 
> vice-versa).  It is also very possible that someone on this list 
> doesn't know the answer she needs (or doesn't bother to respond).
> 

Nothing really, I think the idea was it would have been nice to know:
[example]
I posted to the [EMAIL PROTECTED] list and they said "use Crypt::OpenPGP;" 
but I'm not sure how to use that for my idea.
[/example]

Sara, are you wanting to encryp data? If so I like Crypt::OpenPGP but 
there are many many methods to accomplish that.
Or are you interested in posting to a list and then the list not 
displaying your adress on the web archive?

HTH

DMuey

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




Re: how to remove a ^M charaters from a variable

2003-12-19 Thread Dan Anderson
>   "\r"

Caveat: Only on *nix systems.  Otherwise \n is 0x1512 and not 0x12.

-Dan



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




Preventing Accidentally Fork Bombing My Box

2003-12-19 Thread Dan Anderson
I'm creating an app that uses forks in a number of places to do things
quicker.  Unfortunately, I have a bad habit of accidentally fork bombing
my box.  Is there any way I can run a perl process (even if it's a Linux
command) so that it wont eat up all available resources if I screw up? 
Or do I just need to learn to be more careful?

-Dan


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




Re: how to remove a ^M charaters from a variable

2003-12-19 Thread Dan Anderson
On Fri, 2003-12-19 at 11:54, Dan Anderson wrote:
> >   "\r"
> 
> Caveat: Only on *nix systems.  Otherwise \n is 0x1512 and not 0x12.

That should read Otherwise \n can be 0x1512 -- i.e. on Windoze boxen. 
On Macs it's something different.

-Dan


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




Re: how to remove a ^M charaters from a variable

2003-12-19 Thread agftech lists
I'd found this here
http://www.unixblog.com/quick_unix_tips/remove_m_with_vi.php

You can try this on multiple files
perl -pi -e 's/\015//g' files





On Sat, 2003-12-20 at 07:21, David Inglis wrote:
> I am reading in a csv file and it has a control character ^M at the end
> of each line how can I remove these charaters, I have tried the following
> and had no success.
> 
> $a=~s/\^M//;
> $a=~s/^M//;
> 
> 
> Any help appreciated thanks.
> 
> 
> -- 
> Regards
> 
> 
> 
> David Inglis
> 0408502342


__
Aman Raheja
AGF Technologies
http://www.agftech.com
__


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




Fwd: foreach

2003-12-19 Thread drieux


drieux,

This came just to me - I presume you meant to go to the list too?
thanks paul... must have missed one step in the
responding...
On Thu, Dec 18, 2003 at 06:36:40PM -0800, drieux wrote:
On Dec 18, 2003, at 4:43 PM, Paul Johnson wrote:
On Thu, Dec 18, 2003 at 04:31:20PM -0800, Jeff Westman wrote:
Eric Walker <[EMAIL PROTECTED]> wrote:

I got it so I need a counter which sends me to a for loop instead 
of
a
foreach.
[..]
I believe that 'for' and 'foreach' are completely interchangable. I
remember
reading somewhere that one was a synonym for the other.
That is correct, though often people will refer to foreach meaning

 foreach VAR (LIST) BLOCK

and to for meaning

 for (EXPR; EXPR; EXPR) BLOCK

perldoc perlsyn
[..]

Minor point, while it is true, per the pod, that
the foreach is a synonym, there is the little difference
that one does NOT get an 'index' of which element of
LIST is the current VAR when using the foreach.
So the transparency is more towards say
my @list = qw/bob ted carol alice/;
for ( my ($i,$var) = (0,$list[0]); $i < scalar(@list); $var =
$list[++$i] )
{
print "var is $var\n";
}
hence why the general habit of

foreach my $var (@list)
{
print "var is $var\n";
}
when all one wants to do is simply walk through the LIST
in straight linear order.
The moment that one Needs to know the 'index' into an
array to look ahead or behind, one of course needs to
do something like
my ($index, $max ) = ( -1, scalar(@list));
while(++$index < $max )
{
print "var at $index is $list[$index]\n";
}
so what one needs when iterating through an array
is an index into that array, which can be implemented
in a for loop or a while loop or a do_while or...
ciao
drieux
---
--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net


ciao
drieux
---

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



Re: Align Text

2003-12-19 Thread James Edward Gray II
On Dec 19, 2003, at 8:29 AM, Bill Jastram wrote:

James:

A coupe of things.

#1. Pardon my ignorance, but I'm not sure how to use the list where I
found the reply button to e-mail you directly. I could not find a way 
to
add to the already existing 'thread'. Your help would be appreciated.
The list is just another address you can send your messages too:

[EMAIL PROTECTED]

A lot of people just hit "Reply All" if their mail client has such a 
button.  In the case of this message, that would send your answer to me 
and the list.

#2. The challenge with the use of %20s is that in the next row of 
records
the names will not be aligned (flush left) with the row above, if the
names are not the same length. This is my dilemma.
Correct, but they will be aligned flush right.  For flush left, we just 
change the pattern a little:

> perl -e 'printf "%-20s %-20s %-20s\n", "James", "Edward", "Gray"'
JamesEdward   Gray
Does that answer your question?

James

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



RE: how to remove a ^M charaters from a variable

2003-12-19 Thread Tom Kinzer
Also to address the root cause, the OP said it was on the end of every line.
I would check the whole system - depending on the journeys and gyrations the
CSV file goes through before you get it.  An intelligent use of ASCII ftp
(binary bad) and/or chomp will usually take care of any of the
cross-platform weirdness on the end of your lines.

-Tom Kinzer

-Original Message-
From: agftech lists [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 9:00 AM
To: [EMAIL PROTECTED]
Subject: Re: how to remove a ^M charaters from a variable


I'd found this here
http://www.unixblog.com/quick_unix_tips/remove_m_with_vi.php

You can try this on multiple files
perl -pi -e 's/\015//g' files





On Sat, 2003-12-20 at 07:21, David Inglis wrote:
> I am reading in a csv file and it has a control character ^M at the end
> of each line how can I remove these charaters, I have tried the following
> and had no success.
>
> $a=~s/\^M//;
> $a=~s/^M//;
>
>
> Any help appreciated thanks.
>
>
> --
> Regards
>
>
>
> David Inglis
> 0408502342


__
Aman Raheja
AGF Technologies
http://www.agftech.com
__


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



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




RE: Align Text

2003-12-19 Thread Tom Kinzer
yes, and if that won't work for you, check out the 'format' command, you can
do lots of slick stuff with it, like centering.

-Tom Kinzer

-Original Message-
From: James Edward Gray II [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 9:16 AM
To: Bill Jastram
Cc: Perl List
Subject: Re: Align Text


On Dec 19, 2003, at 8:29 AM, Bill Jastram wrote:

> James:
>
> A coupe of things.
>
> #1. Pardon my ignorance, but I'm not sure how to use the list where I
> found the reply button to e-mail you directly. I could not find a way
> to
> add to the already existing 'thread'. Your help would be appreciated.

The list is just another address you can send your messages too:

[EMAIL PROTECTED]

A lot of people just hit "Reply All" if their mail client has such a
button.  In the case of this message, that would send your answer to me
and the list.

> #2. The challenge with the use of %20s is that in the next row of
> records
> the names will not be aligned (flush left) with the row above, if the
> names are not the same length. This is my dilemma.

Correct, but they will be aligned flush right.  For flush left, we just
change the pattern a little:

 > perl -e 'printf "%-20s %-20s %-20s\n", "James", "Edward", "Gray"'
JamesEdward   Gray

Does that answer your question?

James


--
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: Internal -e escape char

2003-12-19 Thread Dan Muey

> Dan Muey wrote:
> 
> [snip]
> 
> > I could replace all single quotes with double quotes and escape 
> > everythgin inbetween them but that seems like a lot.
> > 
> > Any ideas how to deal with the single quotes? (Since shell escape 
> > characters may or may not work since apache is executing it)
> 
> after trying (a few years ago) to do something similar to 
> what you propose 
> which lead to a total mess and difficult to maintain codes, i have 
> basically gave up this escape-shell-character approach. it's almost 
> impossible to know when to escape and when not to escape. i now use a 
> different approach. instead of involving Perl from the 
> command line with 
> -e, i simply print the code to a file and then run the code 
> within the 

Good idea!!!
I'll give that a go. The only problem is I should have thought of that!!
I'll get there one of these days :)

Thanks for the idea David.

Dan

> file. here is a strip down version of what i used to do:
> 
> #!/usr/bin/perl -w
> use strict;
> 
> use CGI;
> use File::Temp qw/tempfile tempdir/;
> 
> my $cgi = CGI->new;
> 
> if($cgi->param('code')){
> 
> my($fh,$fn) = tempfile(DIR => tempdir(CLEANUP => 1));
> 
> print $fh "#!/usr/bin/perl -w\n";
> print $fh "use strict;\n\n";
> 
> print $fh $cgi->param('code');
> 
> close($fh);
> 
> if(chmod(0755,$fn)){
> html($cgi,$cgi->param('code'),`$fn`);
> }else{
> html($cgi,"Unable to run: \n\n" . 
> $cgi->param('code'));
> }
> }else{
> html($cgi,undef);
> }
> 
> #-- DONE-- #
> 
> sub html{
> 
> my $cgi  = shift;
> my $code = shift;
> 
> my $value = $code || '';
> 
> if(@_){
> $value .= "\n\n__END__\n\n";
> $value .= $_ for(@_);
> }
> 
> print $cgi->header,< 
> 
> $value 
>HTML
> 
> }
> 
> __END__
> 
> a textarea is printed along a submit button, code is entered 
> through the 
> textarea, when the submit button is clicked, a tmp file is 
> create which 
> holds the code from the textarea. the file is then run from 
> the command 
> line and output is returned back to the textarea. finally, 
> the tmp file is 
> deleted when the script finish.
> 
> david 
> -- 
> sub'_{print"@_ ";* \ = * __ ,\ & \}
> sub'__{print"@_ ";* \ = * ___ ,\ & \}
> sub'___{print"@_ ";* \ = *  ,\ & \}
> sub'{print"@_,\n"}&{_+Just}(another)->(Perl)->(Hacker)
> 
> -- 
> 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: Preventing Accidentally Fork Bombing My Box

2003-12-19 Thread Tom Kinzer
use safe ?

just a guess if it will work for this problem.  check it out.

-Tom Kinzer

-Original Message-
From: Dan Anderson [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 8:56 AM
To: Perl Beginners
Subject: Preventing Accidentally Fork Bombing My Box


I'm creating an app that uses forks in a number of places to do things
quicker.  Unfortunately, I have a bad habit of accidentally fork bombing
my box.  Is there any way I can run a perl process (even if it's a Linux
command) so that it wont eat up all available resources if I screw up? 
Or do I just need to learn to be more careful?

-Dan


-- 
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: Preventing Accidentally Fork Bombing My Box

2003-12-19 Thread Tom Kinzer
nope, looks like it's no safety net for CPU or anything, just
compartmentalized namespace and such.

-Tom Kinzer

-Original Message-
From: Tom Kinzer [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 9:27 AM
To: Dan Anderson; Perl Beginners
Subject: RE: Preventing Accidentally Fork Bombing My Box


use safe ?

just a guess if it will work for this problem.  check it out.

-Tom Kinzer

-Original Message-
From: Dan Anderson [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 8:56 AM
To: Perl Beginners
Subject: Preventing Accidentally Fork Bombing My Box


I'm creating an app that uses forks in a number of places to do things
quicker.  Unfortunately, I have a bad habit of accidentally fork bombing
my box.  Is there any way I can run a perl process (even if it's a Linux
command) so that it wont eat up all available resources if I screw up?
Or do I just need to learn to be more careful?

-Dan


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



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



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




RE: Align Text

2003-12-19 Thread Bill Jastram
We're getting closer. But lets say the first name of the first field in the first row 
is 'Bill'. And the first name of the first field in the second row is 'Lanette'. This 
command will not compensate for the difference in the length of the two first names. 
So, the alignment of the second fields in each row will not be correct. And so on ...

Does this help you understand where I'm headed?

Bill 
__

>yes, and if that won't work for you, check out the 'format' command, 
>you can
>do lots of slick stuff with it, like centering.
>
>-Tom Kinzer
>
>-Original Message-
>From: James Edward Gray II [mailto:[EMAIL PROTECTED]
>Sent: Friday, December 19, 2003 9:16 AM
>To: Bill Jastram
>Cc: Perl List
>Subject: Re: Align Text
>
>
>On Dec 19, 2003, at 8:29 AM, Bill Jastram wrote:
>
>> James:
>>
>> A coupe of things.
>>
>> #1. Pardon my ignorance, but I'm not sure how to use the list 
>where I
>> found the reply button to e-mail you directly. I could not find a 
>way
>> to
>> add to the already existing 'thread'. Your help would be 
>appreciated.
>
>The list is just another address you can send your messages too:
>
>[EMAIL PROTECTED]
>
>A lot of people just hit "Reply All" if their mail client has such a
>button.  In the case of this message, that would send your answer to 
>me
>and the list.
>
>> #2. The challenge with the use of %20s is that in the next row of
>> records
>> the names will not be aligned (flush left) with the row above, if the
>> names are not the same length. This is my dilemma.
>
>Correct, but they will be aligned flush right.  For flush left, we just
>change the pattern a little:
>
> > perl -e 'printf "%-20s %-20s %-20s\n", "James", "Edward", "Gray"'
>JamesEdward   Gray
>
>Does that answer your question?
>
>James
>
>
>--
>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: Align Text

2003-12-19 Thread Jeff Westman
Bill Jastram <[EMAIL PROTECTED]> wrote:

Can you give an example of what you want your output to look like?

>From what I am hearing you say, you probably should be using 'format', as one
already responded.


-Jeff


> We're getting closer. But lets say the first name of the first field in the
> first row is 'Bill'. And the first name of the first field in the second row
> is 'Lanette'. This command will not compensate for the difference in the
> length of the two first names. So, the alignment of the second fields in
> each row will not be correct. And so on ...
> 
> Does this help you understand where I'm headed?
> 
> Bill 
> __
> 
> >yes, and if that won't work for you, check out the 'format' command, 
> >you can
> >do lots of slick stuff with it, like centering.
> >
> >-Tom Kinzer
> >
> >-Original Message-
> >From: James Edward Gray II [mailto:[EMAIL PROTECTED]
> >Sent: Friday, December 19, 2003 9:16 AM
> >To: Bill Jastram
> >Cc: Perl List
> >Subject: Re: Align Text
> >
> >
> >On Dec 19, 2003, at 8:29 AM, Bill Jastram wrote:
> >
> >> James:
> >>
> >> A coupe of things.
> >>
> >> #1. Pardon my ignorance, but I'm not sure how to use the list 
> >where I
> >> found the reply button to e-mail you directly. I could not find a 
> >way
> >> to
> >> add to the already existing 'thread'. Your help would be 
> >appreciated.
> >
> >The list is just another address you can send your messages too:
> >
> >[EMAIL PROTECTED]
> >
> >A lot of people just hit "Reply All" if their mail client has such a
> >button.  In the case of this message, that would send your answer to 
> >me
> >and the list.
> >
> >> #2. The challenge with the use of %20s is that in the next row of
> >> records
> >> the names will not be aligned (flush left) with the row above, if the
> >> names are not the same length. This is my dilemma.
> >
> >Correct, but they will be aligned flush right.  For flush left, we just
> >change the pattern a little:
> >
> > > perl -e 'printf "%-20s %-20s %-20s\n", "James", "Edward", "Gray"'
> >JamesEdward   Gray
> >
> >Does that answer your question?
> >
> >James
> >
> >
> >--
> >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]
>  
> 
> 


__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

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




Re: Align Text

2003-12-19 Thread James Edward Gray II
On Dec 19, 2003, at 12:04 PM, Bill Jastram wrote:

We're getting closer. But lets say the first name of the first field 
in the first row is 'Bill'. And the first name of the first field in 
the second row is 'Lanette'. This command will not compensate for the 
difference in the length of the two first names. So, the alignment of 
the second fields in each row will not be correct. And so on ...

Does this help you understand where I'm headed?
No sir, I'm afraid I don't:

perl -e '@names = (["Bill", "Gray"],["Lanette", "Jones"]); printf 
"%-20s %-20s\n", $$_[0], $$_[1] foreach @names'

Bill Gray
Lanette  Jones
The above DOES line up correctly, with a fixed width font.

If you need to adjust the size of the fields based on the names, you'll 
need to make two passes.  First, find the longest lengths.  Then print.

printf() is doing the right thing though, as you can see above.

James

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



RE: Align Text

2003-12-19 Thread Tom Kinzer
say wha?  show me, please.

-Original Message-
From: Bill Jastram [mailto:[EMAIL PROTECTED]
Sent: Friday, December 19, 2003 10:04 AM
To: Tom Kinzer
Cc: James Edward Gray II; Perl List
Subject: RE: Align Text


We're getting closer. But lets say the first name of the first field in the
first row is 'Bill'. And the first name of the first field in the second row
is 'Lanette'. This command will not compensate for the difference in the
length of the two first names. So, the alignment of the second fields in
each row will not be correct. And so on ...

Does this help you understand where I'm headed?

Bill
__

>yes, and if that won't work for you, check out the 'format' command,
>you can
>do lots of slick stuff with it, like centering.
>
>-Tom Kinzer
>
>-Original Message-
>From: James Edward Gray II [mailto:[EMAIL PROTECTED]
>Sent: Friday, December 19, 2003 9:16 AM
>To: Bill Jastram
>Cc: Perl List
>Subject: Re: Align Text
>
>
>On Dec 19, 2003, at 8:29 AM, Bill Jastram wrote:
>
>> James:
>>
>> A coupe of things.
>>
>> #1. Pardon my ignorance, but I'm not sure how to use the list
>where I
>> found the reply button to e-mail you directly. I could not find a
>way
>> to
>> add to the already existing 'thread'. Your help would be
>appreciated.
>
>The list is just another address you can send your messages too:
>
>[EMAIL PROTECTED]
>
>A lot of people just hit "Reply All" if their mail client has such a
>button.  In the case of this message, that would send your answer to
>me
>and the list.
>
>> #2. The challenge with the use of %20s is that in the next row of
>> records
>> the names will not be aligned (flush left) with the row above, if the
>> names are not the same length. This is my dilemma.
>
>Correct, but they will be aligned flush right.  For flush left, we just
>change the pattern a little:
>
> > perl -e 'printf "%-20s %-20s %-20s\n", "James", "Edward", "Gray"'
>JamesEdward   Gray
>
>Does that answer your question?
>
>James
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
> 
>
>

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



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




Re: Preventing Accidentally Fork Bombing My Box

2003-12-19 Thread drieux
On Dec 19, 2003, at 8:55 AM, Dan Anderson wrote:
[..]
I'm creating an app that uses forks in a number of places to do things
quicker.  Unfortunately, I have a bad habit of accidentally fork 
bombing
my box.
I'm not sure I get this phrase 'fork bombing' to begin with,
do you mean that you wind up forking more processes till you
over run the kernel's process table and then things start
dying off in 'un-natural states'? Or that you forgot to
do appropriate thing with managing your SIG_CHLD so that
you are not over running the kernel's process table with
a bunch of zombie processes that could be harvested?
cf perldoc perlipc

Is there any way I can run a perl process (even if it's a Linux
command) so that it wont eat up all available resources if I screw up?
Or do I just need to learn to be more careful?
Actually, no. If your linux boxes is rigged to
have various limits set, then there are some ways
to prevent a given process/user from over-running
more than that limit. But if one writes bad code, there
is almost nothing that perl can do to protect you
from your code.
What you may want to think about is rigging your
code to have a '$max_child' and that the parent
will wait on any new forks until that value is decremented.
In like manner, the 'child process' so forked, would
be limited to either
a. not Forking any children
b. no more than ($max_child - 1) number of children
then the problem is mostly factorial...
You might also strategize with say semaphours so that
all of the processes would be able to deal with getting
a common head count - but that way also leads to weirdneff
as to who keeps the write on the semaphours...
You could also try to limit some of your madness by
doing a pipe and fork, as you will might possibly
bump into the FD limit before you 'fork bomb' your box.
In this strategy the parent has some chance of being
the negotiator of what is going on...
ciao
drieux
---

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



reading formated report, excel, OLE::32

2003-12-19 Thread William Martell
Hello All,

I was wondering if anyone could offer some pointers on extracting data from
a text file that is formated.

I need to extract the data that is under the column headers.  I have
attached a sample of the printed report.  The real report repeats the same
format over and over again until completion.

I would like to extract the data and place it in an excel spreadsheet.

Your help and suggestions would be greatly appreciated.

Thanks All,
Will





19:36:36   
   PAGE:  1 
FUNCTION: ARTB 
DATE: 12/17/2003 
FROM: 00  THRU: 99  SORTED: CUSTOMER CLASS 
   1 
===
 
 CUSTOMER GROUP: CUSTOMER CLASS1 = 
 
===
 

CUS ID  CUSTOMER NAME   CYCLE  CUSTOMER TYPEACCT CONTACT  
PHONE   CREDIT LIMIT  
--  --  -  ---    
---   --  
003678    1OPEN ITEM   
   0.00 

INV NO TYP INV DATE   CURRENT  1-30 31-60 61-90   OVER 
90   ON HOLD UNAP CASH*TOTAL A/R 
-- ---    ---   ---   ---   ---   
---   ---   ---   --- 
054616  I   121703 603.73  
  603.73 
CUSTOMER TOTALS   ---   ---   ---   ---   
---   ---   ---   --- 
   603.73  
  603.73 
---
 

CUS ID  CUSTOMER NAME   CYCLE  CUSTOMER TYPEACCT CONTACT  
PHONE   CREDIT LIMIT  
--  --  -  ---    
---   --  
003662  x1OPEN ITEM
  0.00 

INV NO TYP INV DATE   CURRENT  1-30 31-60 61-90   OVER 
90   ON HOLD UNAP CASH*TOTAL A/R 
-- ---    ---   ---   ---   ---   
---   ---   ---   --- 
054601  I   121603   4,900.00  
4,900.00 
CUSTOMER TOTALS   ---   ---   ---   ---   
---   ---   ---   --- 
 4,900.00  
4,900.00 
---
 

===
 

GROUP TOTALS  ---   ---   ---   ---   
---   ---   ---   --- 
 5,503.73  
5,503.73 
PERCENTAGE OF TOTAL100.00  
  100.00 
  ===   ===   ===   ===   
===   ===   ===   === 

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


Re: reading formated report, excel, OLE::32

2003-12-19 Thread Randy W. Sims
On 12/19/2003 11:24 AM, William Martell wrote:

Hello All,

I was wondering if anyone could offer some pointers on extracting data from
a text file that is formated.
I need to extract the data that is under the column headers.  I have
attached a sample of the printed report.  The real report repeats the same
format over and over again until completion.
This looks like a fixed width format. I would use substr to extract the 
fields, trim excess spaces, then write it out to Excel.

Regards,
Randy.


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



Re: reading formated report, excel, OLE::32

2003-12-19 Thread Randy W. Sims
On 12/19/2003 11:39 AM, William Martell wrote:

Thanks Randy,

Would I read the file in line by line then get the substring of data that I
need and push that onto an array pertaining to that customer.
Correct.

The question that comes to mind is that each line is different and I would
need to write something that works with each individual line.
Is this correct?
From your example, it looks as if each field is at a fixed position, 
i.e. each field is *always* at a fixed column position.

Example:

Qty  Desc
  1  Foo Bar
 24  Hours without sleep
in the above the Qty field always starts at column 1 (offset 0) and it 
has a length of 3. The desc field always starts at colum 5 (offset 4) 
and extends to the end of the string. So, something like the following 
(untested) code should work (ASSuming the format is fixed):

my @order_detail;

while (<>) {

  # extract fields
  my %item = (
qty  => substr( $_, 0, 3 ),
desc => substr( $_, 4 ),
  );
  # trim spaces
  while ( my ($key, $value) = each %item ) {
$value =~ s/^\s+//;
$value =~ s/\s+$//;
  }
  # save for later processing
  push @order_detail, \%item;
}
Regards,
Randy.


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



Re: reading formated report, excel, OLE::32

2003-12-19 Thread Randy W. Sims
[It's best to reply to the list so that others can contribute and learn.]

On 12/19/2003 12:11 PM, William Martell wrote:

OK.  What about the trash that the substring will collect from the headers
of the printed report?
I didn't look very closely before, but it looks like this report has 
multiline records. I don't have enough time right now to go into detail 
on this, but here are a few hints.

 for 1..12;
until (eof(DATA)) {
   for 1..2; # discard record header
  my $acct = ; # break this into fields using substr()
  last if $acct =~ /^GROUP TOTALS/; # this happens at the end of the 
main report

   for 1..2; # discard blank line and item header

  while (my $line = ) {
last if $line =~ /^CUSTOMER TOTALS/; # this marks end of item detail
# $line is item details, break with substr()
  }
  my $total = ; # item totals

   for 1..2; #discard more lines
}


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



Re: reading formated report, excel, OLE::32

2003-12-19 Thread Richard Morse
On Friday, December 19, 2003, at 11:24 AM, William Martell wrote:

I need to extract the data that is under the column headers.  I have
attached a sample of the printed report.  The real report repeats the 
same
format over and over again until completion.

I would like to extract the data and place it in an excel spreadsheet.
Based on the sample data, it looks like the following things can be 
keys you use:

1) you don't have any data that needs to be extracted (if I understood 
you correctly) until after you hit a line starting with '=', followed 
by a blank line.

2) each group of data is separated by a blank line, but contains no 
blank lines.

3) the first line after a blank line is the column headers.  However to 
figure out where the columns are, you need the line after that, which 
has '-'s to indicate the length of the column.

So, at least to get the data from the section between the lines of 
'='s, I would do something like this:

when I hit a blank line, start a new report.
the line immediately following a blank line has header info, save it, 
get the next line.  locate all of the spaces in the line, use that to 
parse the header line into fields.  save this spacing information, so 
that I can also parse the following lines.
from then on, for each line, if it is a blank line, go back to the 
start.  If the line contains a row of 6 (say) or more '-', skip it.  
Otherwise split it based on the spacing info that is current.

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



RegEx Troubles

2003-12-19 Thread Jeremy Mann
Given this in $_
Most popular title searches:"Enterprise" (2001)"

why would this regex not put digits in $1 ?

$data2 =~ /popular title searches:<\/p>/

Thanks in advance...


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




RE: RegEx Troubles

2003-12-19 Thread Wolf Blaum
>Given this in $_
>Most popular title searches:HREF="/title/tt0244365/">"Enterprise" (2001)"
>
>why would this regex not put digits in $1 ?
>
>$data2 =~ /popular title searches:<\/p>HREF=\"\/title\/tt(\d*)\/\">/
>

Hi, 

Snip---

$data2='Most popular title searches:"Enterprise" (2001)"';
$data2 =~ /popular title searches:<\/p>/;
print $1;

endSnip---

prints 0244365

If that's what you are looking for.

If you realy have the html in $_, why do you bind $data2 to the regex?
That way you try to find [regex] in $data2. 

HTH, 
wolf


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




RE: RegEx Troubles

2003-12-19 Thread Wagner, David --- Senior Programmer Analyst --- WGO
>Given this in $_
>Most popular title searches:"Enterprise" 
>(2001)"
>
>why would this regex not put digits in $1 ?
>
>$data2 =~ /popular title searches:<\/p>/
 Then "$datas =~ "should be removed and just use

 /popular title searches:<\/p>/

You are going vs $data2 when you state the value is in $_.

Are you running with warnings on? If not, should be. Also use strict.

Wags ;)



**
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.



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




Re: RegEx Troubles

2003-12-19 Thread Ricardo SIGNES
* Jeremy Mann <[EMAIL PROTECTED]> [2003-12-19T13:47:26]
> Given this in $_
> Most popular title searches: HREF="/title/tt0244365/">"Enterprise" (2001)"
> 
> why would this regex not put digits in $1 ?
> 
> $data2 =~ /popular title searches:<\/p> HREF=\"\/title\/tt(\d*)\/\">/

This code:
$data2 = 'Most popular title searches:"Enterprise" (2001)';

$data2 =~ /popular title searches:<\/p>/;
print $1;

prints '0244365'.

Notice that I put the string into $data2, not $_.  A bare regex (/foo/)
would work on $_, but you're using the =~ operator to fit the regex to
$data2, so the value in $_ is irrelevant.  Perhaps you wanted:

($data2) = ($_ =~ /r(ege)x/); # assign $1 to $data2

Also, keep in mind that while // is the most common delimiter for a
regex, it can lead to readability problems.  If you're going to have a /
character in your regex, why not a different delimiter for the regex?
It'll save you from escaping the slashes.  So:

$data2 =~ m!popular title searches:!;

Also, you didn't need to escape the quotes in the regex, you could have:

$data2 =~ m!!;

I hope these pointers help.

-- 
rjbs


pgp0.pgp
Description: PGP signature


Re: Preventing Accidentally Fork Bombing My Box

2003-12-19 Thread Dan Anderson
drieux <[EMAIL PROTECTED]> writes:

> On Dec 19, 2003, at 8:55 AM, Dan Anderson wrote:
> [..]
> > I'm creating an app that uses forks in a number of places to do things
> > quicker.  Unfortunately, I have a bad habit of accidentally fork
> > bombing
> > my box.
> 
> I'm not sure I get this phrase 'fork bombing' to begin with,

I'll   do  something  dumb,   like  fork   in  a   loop  while
$number_forks < $fork_this_many.  But,  for whatever reasons, I have a
tendency to  do things like create  an infinite loop  by accident, and
fork an  infinite number of  processes, or soemthign like  that.  This
results in  what is  effectively a  DOS on my  box, because  it starts
swapping as soon as it eats up all the RAM and is unresponsive without
a hard reboot. :-(  

Now, try  as I might  to prevent these,  in the same  way that
every once in a while I leave  an infinite loop on a normal program or
do something similarly dumb, when I do it with forks I have a tendency
to eat up resources until I  get DOSed.  So instead of spending the 30
seconds killing  the process, looking  into the code,  cursing myself,
and fixing it, I end up hard rebooting and recovering all my autosaved
files. :-(

-Dan


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




Re: RegEx Troubles

2003-12-19 Thread James Edward Gray II
On Dec 19, 2003, at 12:47 PM, Jeremy Mann wrote:

Given this in $_
Most popular title searches:"Enterprise" (2001)"
why would this regex not put digits in $1 ?

$data2 =~ /popular title searches:<\/p>/
Because the regex targets the $data2 variable instead of $_, possibly.  
I don't seen anything wrong with the expression, if that's what you're 
asking though.

James

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



Re: RegEx Troubles

2003-12-19 Thread John W. Krahn
Jeremy Mann wrote:
> 
> Given this in $_
> Most popular title searches: HREF="/title/tt0244365/">"Enterprise" (2001)"
> 
> why would this regex not put digits in $1 ?
> 
> $data2 =~ /popular title searches:<\/p> HREF=\"\/title\/tt(\d*)\/\">/

If the text is in $_ then that should be:

$_ =~ m|popular title searches:|

If you are trying to store the contents of $1 into $data2 then:

my ($data2) = m|popular title searches:|



John
-- 
use Perl;
program
fulfillment

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




RE: Preventing Accidentally Fork Bombing My Box

2003-12-19 Thread Bob Showalter
Dan Anderson wrote:
> I'm creating an app that uses forks in a number of places to do things
> quicker.  Unfortunately, I have a bad habit of accidentally
> fork bombing
> my box.  Is there any way I can run a perl process (even if
> it's a Linux
> command) so that it wont eat up all available resources if I
> screw up?
> Or do I just need to learn to be more careful?

FreeBSD has a limits(1) command for this. I don't use Linux, so I don't know
if it has a similar thing...

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




Error when compiling ARSPerl-1.81 on a unix server

2003-12-19 Thread msheffie
This is my first attempt to compile a module on a unix server.  It appears
the "perl Makefile.pl" command ran without error.
Other info:
 - sun-solaris 2.6.
 - perl 5.005_02
 - I copied the api files from the current remedy server - version 5.1




Here is the output of running gmake:  Any ideas on what I'm doing wrong
?
-


bash-2.02# gmake
Skip blib/lib/ARSnt-h.pm (unchanged)
Skip blib/lib/ARSar-h.pm (unchanged)
Skip blib/lib/ARSOOmsgs.pm (unchanged)
Skip blib/lib/ARS.pm (unchanged)
Skip blib/lib/ARSOOform.pm (unchanged)
Skip blib/lib/ARSnterrno-h.pm (unchanged)
Skip blib/lib/ARSarerrno-h.pm (unchanged)
Skip blib/lib/ARSnparm.pm (unchanged)
Skip blib/lib/ARSOOsup.pm (unchanged)
gcc -c -I/opt/remedy_api//include -I/usr/local/include -O-DVERSION
=\"1.8002\" -DXS_VERSION=\"1.8002\" -fPIC
-I/usr/local/lib/perl5/5.00502/sun4-solaris/CORE -g  -DARS32  -DARS452
-DPERL_PATCHLEVEL_IS=5 -DPERL_SUBVERSION_IS=2 -DPERL_BASEREV_IS=50  ARS.c
In file included from /opt/remedy_api/include/arextern.h:65,
 from support.h:47,
 from ARS.xs:26:
/usr/include/stdio.h:22: sys/feature_tests.h: No such file or directory
/usr/include/stdio.h:23: sys/va_list.h: No such file or directory
/usr/include/stdio.h:24: stdio_tag.h: No such file or directory
/usr/include/stdio.h:25: stdio_impl.h: No such file or directory
In file included from support.h:70,
 from ARS.xs:26:
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:301: sys/types.h: No
such file or directory
In file included from support.h:70,
 from ARS.xs:26:
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:330: ctype.h: No such
file or directory
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:338: locale.h: No
such file or directory
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:355: setjmp.h: No
such file or directory
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:361: sys/param.h: No
such file or directory
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:367: stdlib.h: No
such file or directory
In file included from support.h:70,
 from ARS.xs:26:
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:427: string.h: No
such file or directory
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:517: netinet/in.h: No
such file or directory
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:521: arpa/inet.h: No
such file or directory
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:531: sys/stat.h: No
such file or directory
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:560: sys/time.h: No
such file or directory
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:567: sys/times.h: No
such file or directory
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:574: errno.h: No such
file or directory
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:631: sys/ioctl.h: No
such file or directory
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:654: dirent.h: No
such file or directory
In file included from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/include/syslimits.h:7,
 from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/include/limits.h:11,
 from
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:854,
 from support.h:70,
 from ARS.xs:26:
/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/include/limits.h:116:
limits.h: No such file or directory
In file included from
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:1112,
 from support.h:70,
 from ARS.xs:26:
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/unixish.h:93: signal.h: No
such file or directory
In file included from
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:1510,
 from support.h:70,
 from ARS.xs:26:
/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/include/math.h:5: math.h:
No such file or directory
In file included from support.h:70,
 from ARS.xs:26:
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:2431: sys/ipc.h: No
such file or directory
/usr/local/lib/perl5/5.00502/sun4-solaris/CORE/perl.h:2432: sys/sem.h: No
such file or directory
In file included from ARS.xs:26:
support.h:74: string.h: No such file or directory
gmake: *** [ARS.o] Error 1
--
This electronic message transmission contains information from the office
of Malcolm Sheffield, ITC^DeltaCom, Inc., which may be confidential or
privileged.
The information is intended to be for the use of the individual or entity
named above. If you are not the intended recipient, be aware that any
disclosure, copying,
distribution or use of the contents of this information is prohibited.

If you have received this electronic transmission in error, please notify
us by telephone at 404.214.7800 or by electronic mail
[EMAIL PROTECTED] imm

diff between packages and modules

2003-12-19 Thread christopher j bottaro
i'm reading "Programming Perl" and i'm on the chapter about packages.  it says 
that packages and modules are very similar and that novices can think of 
packages, modules, and classes as the same thing, but i wanna know exactly 
what the differences between packages and modules are (i'm a c++ programmer, 
i know what classes are).

also, what is a good perl vbulletin forum (vbulletin plz, i'm a little baby 
and dislike other kinds of web forums...=)?

thanks,
-- christopher

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




Re: Align Text

2003-12-19 Thread Rob Dixon
Bill Jastram wrote:

> We're getting closer. But lets say the first name of the first
> field in the first row is 'Bill'. And the first name of the
> first field in the second row is 'Lanette'. This command will
> not compensate for the difference in the length of the two
> first names. So, the alignment of the second fields in each
> row will not be correct. And so on ...
>
> Does this help you understand where I'm headed?

Hi Bill.

What James wrote still applies I think. See the code below,
which does what I think you want?

HTH,

Rob


foreach ('Bill Jastram', 'Lanette Smith') {
  printf "%-20s %-20s\n", split;
}

**OUTPUT

Bill Jastram
Lanette  Smith



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




Re: Align Text

2003-12-19 Thread Eric Walker
I have use the FORMAT function in perl. Its pretty nice.
perldoc -f format.

Hope that helps
perlknucklehead

On Fri, 2003-12-19 at 14:20, Rob Dixon wrote:
Bill Jastram wrote:

> We're getting closer. But lets say the first name of the first
> field in the first row is 'Bill'. And the first name of the
> first field in the second row is 'Lanette'. This command will
> not compensate for the difference in the length of the two
> first names. So, the alignment of the second fields in each
> row will not be correct. And so on ...
>
> Does this help you understand where I'm headed?

Hi Bill.

What James wrote still applies I think. See the code below,
which does what I think you want?

HTH,

Rob


foreach ('Bill Jastram', 'Lanette Smith') {
  printf "%-20s %-20s\n", split;
}

**OUTPUT

Bill Jastram
Lanette  Smith



-- 
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: diff between packages and modules

2003-12-19 Thread Bob Showalter
christopher j bottaro wrote:
> i'm reading "Programming Perl" and i'm on the chapter about packages.
> it says that packages and modules are very similar and that novices
> can think of packages, modules, and classes as the same thing, but i
> wanna know exactly what the differences between packages and modules
> are (i'm a c++ programmer, i know what classes are).

A package is a namespace. All "global" variables (aka "symbol table" or
"package" variables) and subs live in a package. The package statement is
used to define the default package to be used if no package name is
explicitly specified when the variable or sub is referenced.

A module is a collection of routines and/or data, decleared in one (or
possibly more than one) package and bundled into a source file for reuse and
distribution.

Certain Perl constructs assume a correspondence between package names and
module names. The perlmod and perlmodlib documents go in to detail on these
topics.

perldoc perlmod
perldoc perlmodlib
perldoc -f package
perldoc -f use

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




Re: how to remove a ^M charaters from a variable

2003-12-19 Thread Douglas Lentz
David Inglis wrote:

I am reading in a csv file and it has a control character ^M at the end
of each line how can I remove these charaters, I have tried the following
and had no success.
$a=~s/\^M//;
$a=~s/^M//;
Any help appreciated thanks.

 

This is an MS-DOSsy file, where each line is terminated by the famous 
CR/LF combination. "^M" is the carriage return. Between the regex 
slashes ("the jungle") "^" means "beginning of line", so what you have 
instructed regex to do is erase any capital "M" that happens to occur at 
the beginning of a line.

If you have a copy of the program dos2unix around, it will take care of 
this for you, otherwise you can try $a =~ s/\x0D//;

which means replace any CR you find with null. HTH.

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



Re: how to remove a ^M charaters from a variable

2003-12-19 Thread Ajey
if its a unix file,.open in vi
:%s/ctrl+v ctrl+m//g 
(where ctrl+v and ctrl+m gives the ^M character.)

cheers


On Fri, 19 Dec 2003, Douglas Lentz wrote:

> David Inglis wrote:
> 
> >I am reading in a csv file and it has a control character ^M at the end
> >of each line how can I remove these charaters, I have tried the following
> >and had no success.
> >
> >$a=~s/\^M//;
> >$a=~s/^M//;
> >
> >
> >Any help appreciated thanks.
> >
> >
> >  
> >
> This is an MS-DOSsy file, where each line is terminated by the famous 
> CR/LF combination. "^M" is the carriage return. Between the regex 
> slashes ("the jungle") "^" means "beginning of line", so what you have 
> instructed regex to do is erase any capital "M" that happens to occur at 
> the beginning of a line.
> 
> If you have a copy of the program dos2unix around, it will take care of 
> this for you, otherwise you can try $a =~ s/\x0D//;
> 
> which means replace any CR you find with null. HTH.
> 
> 
> -- 
> 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: Preventing Accidentally Fork Bombing My Box

2003-12-19 Thread drieux
On Dec 19, 2003, at 11:33 AM, Dan Anderson wrote:
[..]
I'll   do  something  dumb,   like  fork
in  a   loop  while $number_forks < $fork_this_many.
[..]

You might want to have a WAY different strategy!

Remember both sides of the fork get a copy of
the code space - and as such the first forked
child can think that it is the parent, and
it too is going to do the same loop at which
point each of them are trying to spawn off MORE
children, and no one remembers to exit...
Go back and peek at:

The child processes are going to be executing a specific
body of Code and not 'all' of the code.
If you peek at the runner() method, I have made it
a bit clearer that any of the dispatched code is
suppose to have it's own 'exit()' call - and that
on the child side of the call IF that 'fails' the
next piece of code that would be called would be
	exit(-1);

so that we have at least some gurantee that the
children will not go running around forking like mad.
So while it IS true that we have the dispatcher

	$process{$cmd}($cmd,$args);

inside the infinite loop "while(1) BLOCK" one
of the processes is a 'quit' and there are
some that will fork children. But the code that
the child can execute is limited.
The other idea you might really want to
deal with is what is known as a 'co-operative
multi-tasking group' - so that rather than
fork N processes you have an init script
style solution that will spawn a process as
the process leader, that will spawn and delegate
to N processes incoming new requests. One variant
of this strategy is how most web-servers work, where
there is httpd will spawn off N-processes, and pass
the connection off to another process. This saves
on the fork time as well as provide a more reasonable
control over SDOS ( self denial of servicing ).


ciao
drieux
---

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



Re: Calling another perl file

2003-12-19 Thread drieux
On Dec 18, 2003, at 10:12 PM, Tushar Gokhale wrote:

How do I call another perl script from my current perl script? I'm 
working
on one perl testing harness, currently my "bin/run.pl" has a control 
and
now I want to call script files one by one from "tests/" folder. I also
want to pass an argument to the test script file. Once the file is 
executed
from "tests" folder i want the control to come back to my run.pl file.
there are several ways to try this, my pet favorite
gag is
sub run_cmd
{
my ($cmd, $args) = @_;
return "ERROR: no command" unless $cmd;
$args ||=''; # so that it is initialized
open(CMD, "$cmd $args 2>&1")
or return "ERROR: problem running $cmd with $args:$!";
my @response;
while()
{
next if /^\s*$/; # space empty lines
chomp;  # end of line cleaner
push(@response, $_);
}
close(CMD)
[EMAIL PROTECTED];
}
this I could call inside of a loop like say

opendir(DIR, $test_dir) or die "unable to open $test_dir:$!";
my @allfiles = grep { $_ !~ /^\./ } readdir(DIR);
close(DIR)
foreach my $file (@allfiles)
{
next unless (  );
my $response = run_cmd($file);
if ( ref($response) eq 'ARRAY')
{
deal_with_response_array($file, $response)
} else {
print "$file had problem: $response\n";
}
}
but personally I like the idea of growing out my test
cases in Perl Modules so that I can dish them up with
cool dispatching solutions
ciao
drieux
---

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



Re: Timing an operation

2003-12-19 Thread drieux
On Dec 18, 2003, at 4:22 PM, HENRY,MARK (HP-Roseville,ex1) wrote:
[..]
Any other recommendations?
[..]

cf perldoc time

my $starttime = time;
cmd_foo_here
my $stoptime = time;
ciao
drieux
---

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



Re: diff between packages and modules

2003-12-19 Thread drieux
On Dec 19, 2003, at 1:16 PM, christopher j bottaro wrote:

i'm reading "Programming Perl" and i'm on the chapter about packages.  
it says
that packages and modules are very similar and that novices can think 
of
packages, modules, and classes as the same thing, but i wanna know 
exactly
what the differences between packages and modules are (i'm a c++ 
programmer,
i know what classes are).
p0: the obligatory
perldoc perl
there are some tutorials it will list, also go with
perldoc perlmod, et al for that side.
{ you really will want to pick up RS's Learning
Perl Objects, References and Modules }
Now that we have the Orthodoxy out of the way.

p1: in My Most Humbled Opinion.

a module is an externally referencable file, normally
suffixed with *.pm that contains some 'code stuff'
	a package is a specific name space.

A modules SHOULD contain at least one package line in it, it may
contain more than one of them, defining more than one
package name space. our classic illustration is
	use Foo::Bar;

will tell the compiler to look for a 'module'
that manages the package Foo::Bar - it will normally
be installed in the file system in the form Foo/Bar.pm
and is required to use the Methods/Functions in Foo::Bar name space.
So as to screw things up, it is POSSIBLE to
create a package space inside a script, a la
#!/usr/bin/perl -w
use strict;
# note - no use Foo::Bar here since we define the
# package namespace locally in this file we do not go external
my $foo = new Foo::Bar;

BEGIN { # so the perl runtime compiler compiles my package foist
package Foo::Bar;

use 5.006;
use strict;
use warnings;

#our @ISA = qw(PARENT_CLASS);

our $VERSION = '0.01';
#-
# Our Stock Constructor
sub new
{
my $type  = shift;
my $class = ref($type) || $type;
my $self = {};
bless $self, $class;

} # end of our simple new

#-
# so that AUTOLOAD finds one here

sub DESTROY {}

#
# your methods here
#

1; # so that the 'use Foo::Bar'
   # will know we are happy
} # end begin
and it will act like your expected 'class model' from
C++ land, but without all of the technical stuff about
whether or not you want to have a compiler that does
pre-compiled headers, yada-yada-yada.
Likewise one can have a perl module, a file that
is foo.pm and IT can have more than one package name
space in it. But I tend to avoid that most of the time
unless I have a really good reason to disagree with myself.
Now a Perl Module Does NOT have to be an OO approach,
as one can get into exporting the 'functions' - cf Exporter
but I rather doubt you will want to go that way.
also, what is a good perl vbulletin forum (vbulletin plz, i'm a little 
baby
and dislike other kinds of web forums...=)?
ok, I bite, what is a vbulletin, I'm an OldGuy
and use to do this with uucp doing usenet news
groups, and do it by email now.
you might scope out the monestary.

or read the docs online

ciao
drieux
---

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



Re: Align Text

2003-12-19 Thread R. Joseph Newton
Bill Jastram wrote:

> We're getting closer. But lets say the first name of the first field in the first 
> row is 'Bill'. And the first name of the first field in the second row is 'Lanette'. 
> This command will not compensate for the difference in the length of the two first 
> names. So, the alignment of the second fields in each row will not be correct. And 
> so on ...
>
> Does this help you understand where I'm headed?
>
> Bill

Yes.  And printf, sprintf, or the perl format/write function pair should be able to 
help with this.  They should at least give you a starting point, because there are 
many ways to accomplish this task.  I prefer the printf, mostly because I'd rather 
just say expplictly how many spaces each field should occupy.  Others prefer using the 
format
function to provide a parameter for write(), because they see it as WYSIWYG.  Try them 
both and see which you feel more comfortable with for any given context.

Joseph



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




When to USE shift or @_

2003-12-19 Thread Colin Johnstone
Gidday all,

I want to pass a boolean value as a parameter to a subroutine what should 
I use shift or @_

and whats the difference please.

e.g 

mySubRoutine(0);

sub mySubRoutine{
my $booleanParameter = @_;
 
return;
}

Re: When to USE shift or @_

2003-12-19 Thread Daniel Staal
--As off Saturday, December 20, 2003 1:57 PM +1100, Colin Johnstone 
is alleged to have said:

Gidday all,

I want to pass a boolean value as a parameter to a subroutine what
should  I use shift or @_
and whats the difference please.

e.g

mySubRoutine(0);

sub mySubRoutine{
my $booleanParameter = @_;
return;
}
--As for the rest, it is mine.

All parameters to subroutines are found in the @_ array for that 
subroutine.  You can assign from that array using shift or directly. 
The above looks like it is trying to assign from it directly, but it 
fails slightly.  I think you ment this:
my $booleanParameter = $_[0];
(Though I could be wrong.  If you are checking whether a parameter 
was passed at all (or how many) the above could work.  Personally I'd 
prefer not to do that, except as a check to make sure the function 
was called correctly.)

The difference with using shift or assigning it directly is shift 
removes the value from the array, assigning it directly does not. 
This may not make much difference, but occasionally it does.

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: diff between packages and modules

2003-12-19 Thread christopher j bottaro
ahh thank you.

so saying

package CJB;

is like saying

namespace CJB   {

and saying

use BinaryTree;

is like saying

#include "BinaryTree.h"

?

so a package exports certain vars/functions and those var/functions make up a 
module?

thanks again,
-- christopher

On Friday 19 December 2003 03:51 pm, Bob Showalter wrote:
> christopher j bottaro wrote:
> > i'm reading "Programming Perl" and i'm on the chapter about packages.
> > it says that packages and modules are very similar and that novices
> > can think of packages, modules, and classes as the same thing, but i
> > wanna know exactly what the differences between packages and modules
> > are (i'm a c++ programmer, i know what classes are).
>
> A package is a namespace. All "global" variables (aka "symbol table" or
> "package" variables) and subs live in a package. The package statement is
> used to define the default package to be used if no package name is
> explicitly specified when the variable or sub is referenced.
>
> A module is a collection of routines and/or data, decleared in one (or
> possibly more than one) package and bundled into a source file for reuse
> and distribution.
>
> Certain Perl constructs assume a correspondence between package names and
> module names. The perlmod and perlmodlib documents go in to detail on these
> topics.
>
> perldoc perlmod
> perldoc perlmodlib
> perldoc -f package
> perldoc -f use

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




Re: diff between packages and modules

2003-12-19 Thread christopher j bottaro
thanks for the reply.  i think i'm understanding it a little better now.  but 
i haven't really got a firm grasp on OO perl, so that example is a bit over 
my head still.

On Friday 19 December 2003 05:40 pm, drieux wrote:
> ok, I bite, what is a vbulletin, I'm an OldGuy
> and use to do this with uucp doing usenet news
> groups, and do it by email now.

vbulletin is a type of web forum.  really pretty and easy to use.  i prefer 
web forums so my email doesn't get swamped with messages.  also, vbulletin 
has an option to send you an email once some has replied to your thread.  i 
love that...

www.vbulletin.com

-- christopher

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




Re: Ending a compound statement

2003-12-19 Thread Kenton Brede
On Thu, Dec 18, 2003 at 12:37:33PM -0800, drieux wrote:
> 
> On Dec 18, 2003, at 11:35 AM, Kenton Brede wrote:
>  http://nixnotes.org/perl_dump.html

Thanks for everyones response first of all.


> So first things first, Do You REALLY want to
> know what @ARGV was prior to calling GetOptions?

Point well taken and I have modified the code to reflect that.

> 
> I take us on this misadventure to recommend my traditional
> approach of basically Hiding the 'parse command line options'
> in function of it's own that will resolve if all the
> required things are there, and returning only
> what needs to be dealt with, since the code is now Good to Go.
> 

I've worked with the examples you have shown and I have to admit I'm
just not advanced enough to follow your approach.  I'll ask a few
questions in hopes of getting a little closer to understanding.

> say something on the order of
> 
>   my ($argv, $options) = parse_cmd_line();

> where of course $argv is an array ref and $options is
> a hash ref of stuff that will be used in the code.
> 

In the context of my example would $argv and $options be something like
$string[0] and $option{version} ?

> This way down in that
> 
>   sub parse_cmd_line
>   {
>   ...
>   if ( $options{version} && $options{help} )
>   {
>   print_version('help'); # tell print_version to call 
>   help and exit
>   } elsif ( $options{help} or scalar(@ARGV) != 1 )
>   {
>   # in the case we ONLY want one argument
>   help_message();
>   } elsif ( $options{version})
>   {
>   print_version(); # just the version string
>   } 
> 
>   ([EMAIL PROTECTED],\%options);
>   }
> 

I don't understand using " print_version('help'); "?  Why not just call
" help_message "?  You have the comment "# tell print-version to call
help and exit"  How by sending the string 'help' in print_version() 
is that done?  

> I of course implement your help_message() function with
> the ability to take an argument like
> 
>   sub help_message
>   {
>   my ($whiney_msg) = @_;
> 
>   print $whiney_msg if $whiney_msg;
>   ...
> 
>   }
> 

I don't understand the reason for passing an argument to help_message()
and the reason for the conditionals.  In the example I provided I would
have to call it like this -

help_message('
print < Which of course gets me to your
> 

So I could pass the reg_ex like so -

get_record($reg_ex[0]);

>   sub get_record {
>   my ($reg_ex, $file ) = @_;

$reg_ex slurps in the value passed to it and $file contains the file
passed from below?  At least that is what appears to happen when I run
the code.

>   die "needed a regular expression"
>   unless($reg_ex);
> 
>   $file ||= "/etc/dhcpd.conf";
  ^^
I've seen || as the or operator but haven't found and example of ||=
yet.  What does that do exactly?

>open (DHCPD, $file) ||  die "Can't open $file : $!\n";
>$/ = '}'; # paragraph delimiter
>while (  ) {
>   if (m/$reg_ex/i) {print "$_\n\n"};
>   }
>   close (DHCPD) || die "Error closing /etc/dhcpd $!\n";
>   }
> 
> This way you move towards reading IN the RegEx that
> is passed to the function - and can pass in a 'test file'
> for the duration of hacking out the test context...
> 

I don't really understand what you mean here.  Are you saying some part
of the code above somehow makes the development process easier and then
parts should be discarded?

Sorry for all the questions but I would like to understand.
Thanks,
Kent

-- 
"I am always doing that which I can not do, 
   in order that I may learn how to do it." --Pablo Picasso


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




Re: Zip using Perl

2003-12-19 Thread R. Joseph Newton
Manish Uskaikar wrote:

> Hi All,
>
> I would like to "zip" a file using perl script. I used following command:-
>
> system ("zip  ");
>
> However this command fails when the filename is more than 8 characters.

Not true.  I just tested, and filenames were not rejected for length.  It does not 
ignore whitespace, though, and there doesn't seem to be any way to escape whitespace 
characters.

> Since DOS does not support more than 8 characters.

Wouldn't make any difference on Win2K.  It doesn't use DOS for its command 
environment, although the interface does closely resemble DOS.  It is a shell escaping 
issue.

> Is there any way by which I can zip a file, whose name is 9+ characters long? I am 
> working on Windows 2000.

Sure.  Just do it.  If your filename has spaces, you do have a problem.  I like the 
suggestion of using a module, since you are doing it from Perl.  No point in shelling 
out.  For what its worth, the program itself doesn't have any problem even with spaces 
in filenames.  I just zipped a directory with long filenames inside it, and they 
worked fine.  Thanks for letting me know about this command-line tool.

> Regards
>
> Manish U

Joseph


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




Re: Preventing Accidentally Fork Bombing My Box

2003-12-19 Thread R. Joseph Newton
Dan Anderson wrote:

> I'm creating an app that uses forks in a number of places to do things
> quicker.  Unfortunately, I have a bad habit of accidentally fork bombing
> my box.

This is a pretty good sign that you are over-using the fork command.
Efficiently designed programs can usually run pretty well without extra
forking.  If a certain process can do its work independtently of the rest of
the program, and one or the other needs to wait for some external event
[such as user input], that would be a good case for using a fork, very
carefully.  I can't see a good reason to ever fork processes from inside a
loop.  That is just asking for trouble.

So is speed really an issue for you?

Joseph


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




Win32 Registry

2003-12-19 Thread Jeff Westman
Hi,

I need to access the Windows registry directly (not an exported 'reg' file). 
I am not familiar with Win32::Registry::File.  

Basically, I am trying to write a script that will do some 'cleanup' of known
'values' and 'data' strings that some uninstall applications neglect to
cleanup.

Any examples on how to use this would be appreciated (or other
recommendations).

TIA


-Jeff

__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

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