compare the size of some files ...

2001-06-27 Thread perl

I want to do this :

- get the size of some files with stat
- compare these sizes with some variables 
- copy the "good" files if the size doesn't match ...






Re: Variable scope

2001-06-27 Thread Geraint Jones

> I think I see where Geraint is coming from, but a my'd
> variable is the only type of variable that is NOT a "global",
> using the term as it is used in "official" perl documentation.

Must have missed that part - you learn something new every minute with this 
list ; )



Re: Debugging the CGI - Application

2001-06-27 Thread Aaron Craig

Simple approach:

sub Debug($)
 {
 my($sMessage) = @_;
 open(DEBUG, "debug.txt") || die("Couldn't open debug file $!");
 print "$sMessage\n";
 close DEBUG;
 }

Debug("This is a debug message");
then you can read your messages after you've run the program.  I do that a 
lot when developing websites, as I do a lot of dynamic generation of pages 
that make heavy use of style sheets and positioning, etc.  Debugging prints 
to the browser screw up the look, which is sometimes the thing I'm trying 
to get debugged, or they may break the page altogether.


At 12:02 27.06.2001 +0800, Rajeev Rumale wrote:
>Thanks again.
>
>Thats a very Nice piece of information ?
>But unfortunatelly I am using IIS on Win2k platform.
>I still condsider it as a very useful and important piece of information on
>this list.
>
>with regards
>
>Rajeev Rumale
>
>~~~
>Rajeev Rumale
>MyAngel.Net Pte Ltd.,Phone  :
>(65)8831530 (office)
>#04-01, 180 B, The Bencoolen,   Email  :
>[EMAIL PROTECTED]
>Bencoolen Street, Singapore - 189648 ICQ: 121001541
>Website : www.myangel.net
>~~~
>
>
>
>
>- Original Message -
>From: "Me" <[EMAIL PROTECTED]>
>To: "Rajeev Rumale" <[EMAIL PROTECTED]>; "'Beginner Perl'"
><[EMAIL PROTECTED]>
>Sent: Wednesday, June 27, 2001 11:13 AM
>Subject: Re: Debugging the CGI - Application
>
>
> > > Any more suggestion ?
> >
> > If you are allowed to modify your web server's setup, then:
> >
> > http://www.masonhq.com/docs/manual/Mason.html
> >
> > and prepare for your world to be turned upside down...
> >
> >

Aaron Craig
Programming
iSoftitler.com




checking groups on unix

2001-06-27 Thread PURMONEN, Joni

Hi ya,

I need to check the group status on numerous files/directories, and haven't
been able to fing out the best way to do it with perl. I simply need to see
if some directories do not have certain group set on them.

Can anyone give any pointers?

Cheers,

Joni

Ps. I only have learning perl and some other fairly simple books which
didn't seem to have anything useful in them



Re: removing white space

2001-06-27 Thread Yvonne Murphy

Has anyone used the whitespace module. I downloaded it from CPAN but I
couldn't get it to work for me at all.
YM




CVS?

2001-06-27 Thread Adam Theo


Hello, Adam Theo here;

i am looking into setting up some sort of code management system for my 
website, and found CVS, but have one problem with it:

is it only for C? i understand it can likely store any code language, 
but what about the merging and other functions of CVS? is that only for 
C, or are there modules for perl and maybe lisp?

thank you all for your time.
--
   /\   Theoretic Solutions (www.Theoretic.com):
  //\\'Activism, Software, and Internet Services'
//--\\ Personal Homepage (www.Theoretic.com/adamtheo/):
   ][ 'Personal history, analysis, and favorites'
   ][   Birthright Online (www.Birthright.net):
  'Keeping the best role-playing game alive'
Email & Jabber:   Other:
-Professional: [EMAIL PROTECTED]  -AIM: AdamTheo2000
-General: [EMAIL PROTECTED]   -ICQ: 3617307
-Personal: [EMAIL PROTECTED]  -Phone: (850)8936047




Re: CVS?

2001-06-27 Thread iain truskett

* Adam Theo ([EMAIL PROTECTED]) [27 Jun 2001 09:21]:
> i am looking into setting up some sort of code management system for
> my website, and found CVS, but have one problem with it:

> is it only for C? i understand it can likely store any code language,
> but what about the merging and other functions of CVS? is that only
> for C, or are there modules for perl and maybe lisp?

It's for every sort of text file. Be it TeX document, XBM, plain text,
perl source, C source, assembler, HTML, Pascal... etc.

Merging works with all, diffs, etc. etc.

I use it for everything I do, be it my rc files, web site, work, thesis,
whatever... You should find it fine.


cheers,
-- 
iain.  



Re: Finding @INC

2001-06-27 Thread Maxim Berlin

Hello Dennis,

Tuesday, June 26, 2001, Dennis Fox <[EMAIL PROTECTED]> wrote:

DF> My difficulty is that I don't understand how to modify @INC to
DF> include the non-standard locations, so that I don't have to have the user
DF> supply commandline arguments each time the script is needed.

example:

if ( $OS ne "NT" )
{
  BEGIN { unshift(@INC,"/usr/local/etc"); }
  require "config.backup.pl";
}


Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re: checking groups on unix

2001-06-27 Thread Maxim Berlin

Hello Joni,

Wednesday, June 27, 2001, PURMONEN, Joni <[EMAIL PROTECTED]> wrote:

PJ> I need to check the group status on numerous files/directories, and haven't
PJ> been able to fing out the best way to do it with perl. I simply need to see
PJ> if some directories do not have certain group set on them.

PJ> Can anyone give any pointers?
if i correctly understand, you need 'stat' function.

($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
 $atime,$mtime,$ctime,$blksize,$blocks)
  = stat($filename);

perldoc -f stat


Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re: checking groups on unix

2001-06-27 Thread Chas Owens


How to build @files is left as an exercise for the reader.


foreach my $file (@files) {
#getgrpid returns the group file entry for a given group id.
my $groupname = (getgrgid((stat($file))[5]))[0];
if ($groupname != "groupname") {
print "$file has bad groupname: $groupname\n";
}
}



On 27 Jun 2001 09:59:07 +0100, PURMONEN, Joni wrote:
> Hi ya,
> 
> I need to check the group status on numerous files/directories, and haven't
> been able to fing out the best way to do it with perl. I simply need to see
> if some directories do not have certain group set on them.
> 
> Can anyone give any pointers?
> 
> Cheers,
> 
> Joni
> 
> Ps. I only have learning perl and some other fairly simple books which
> didn't seem to have anything useful in them
> 
--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
This statement is false.





Re: Finding @INC

2001-06-27 Thread Hasanuddin Tamir

On Wed, 27 Jun 2001, Maxim Berlin <[EMAIL PROTECTED]> wrote,

> Hello Dennis,
>
> Tuesday, June 26, 2001, Dennis Fox <[EMAIL PROTECTED]> wrote:
>
> DF> My difficulty is that I don't understand how to modify @INC to
> DF> include the non-standard locations, so that I don't have to have the user
> DF> supply commandline arguments each time the script is needed.
>
> example:
>
> if ( $OS ne "NT" )
> {
>   BEGIN { unshift(@INC,"/usr/local/etc"); }
>   require "config.backup.pl";
> }

The BEGIN blocks always execute first no matter where you put them.

#!/usr/bin/perl -w

print __LINE__, ": Am I the first?\n";

if (1) {
BEGIN {
print __LINE__, ": No, I am the one\n";
}
print __LINE__, ": Then I am the last\n";
}

__END__

7: No, I am the one
3: Am I the first?
9: Then I am the last

-- 
s::a::n->http(www.trabas.com)




Windows Background Process

2001-06-27 Thread C.Ouellette

Hello,

I need to start an external program from my perl
script.  This program will need to run in the
background so my script can continue doing other
things.  It also still needs to notify the program
when it terminates.

I would appreciate any help on how I would do this. 
My environment is Windows NT 4.0, with Activestate
perl 5.6.1.  I'm also not sure how Windows runs a
background process, so any tips there would be
appreciated.

Lastly, I've been monitoring this list for a few weeks
now. It has been extremely helpful in getting me
started with Perl. Thank you to everyone involved.

Tina Ouellette

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Finding @INC

2001-06-27 Thread Jos Boumans

Please use the the 'use lib' pragma, rather then fiddling with @INC

concider:
use lib (../foo);

rather than:

BEGIN: { push @INC, '../foo' }

perldoc lib for more info

hth
Jos Boumans


Maxim Berlin wrote:

> Hello Dennis,
>
> Tuesday, June 26, 2001, Dennis Fox <[EMAIL PROTECTED]> wrote:
>
> DF> My difficulty is that I don't understand how to modify @INC to
> DF> include the non-standard locations, so that I don't have to have the user
> DF> supply commandline arguments each time the script is needed.
>
> example:
>
> if ( $OS ne "NT" )
> {
>   BEGIN { unshift(@INC,"/usr/local/etc"); }
>   require "config.backup.pl";
> }
>
> Best wishes,
>  Maximmailto:[EMAIL PROTECTED]




Re[2]: Finding @INC

2001-06-27 Thread Maxim Berlin

Hello Tamir,

Wednesday, June 27, 2001, Hasanuddin Tamir <[EMAIL PROTECTED]> wrote:

>> if ( $OS ne "NT" )
>> {
>>   BEGIN { unshift(@INC,"/usr/local/etc"); }
>>   require "config.backup.pl";
>> }

HT> The BEGIN blocks always execute first no matter where you put them.
yes, of course. BEGIN was placed inside just for better readability.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Telnet Tucow's ?

2001-06-27 Thread EDonnelly

Hi All,

I am starting to write bits of easy peasy code today and basically I want
to know where to start, I checked the perl web site and they suggest
telneting to TUCOW'S,   Anyone ever heard of this and whats it like ? Or am
I better off just using Unix on my PC ?

Thanks,
Elaine.





RE: Telnet Tucow's ?

2001-06-27 Thread John Edwards

If you're starting to learn Perl. Take a look at this site. It might be a
better starting point than trying to write a script to telnet to a website.

http://www.netcat.co.uk/rob/perl/win32perltut.html

HTH

John

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 27 June 2001 12:06
To: [EMAIL PROTECTED]
Subject: Telnet Tucow's ?


Hi All,

I am starting to write bits of easy peasy code today and basically I want
to know where to start, I checked the perl web site and they suggest
telneting to TUCOW'S,   Anyone ever heard of this and whats it like ? Or am
I better off just using Unix on my PC ?

Thanks,
Elaine.



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





Re[2]: Finding @INC

2001-06-27 Thread Maxim Berlin

Hello Jos,

Wednesday, June 27, 2001, Jos Boumans <[EMAIL PROTECTED]> wrote:

JB> Please use the the 'use lib' pragma, rather then fiddling with @INC

JB> concider:
JB> use lib (../foo);

JB> rather than:

JB> BEGIN: { push @INC, '../foo' }

JB> perldoc lib for more info

according to perldoc lib:

   use lib LIST;

   is almost the same as saying

   BEGIN { unshift(@INC, LIST) }

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

for my configs, i don't need (and don't have) $dir/$archname/auto directories, so i
still use

>>   BEGIN { unshift(@INC,"/usr/local/etc"); }

am i wrong?

Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re: checking groups on unix

2001-06-27 Thread Matt Cauthorn

Check out the stat function -- it returns a long list of info., which will be of use
to you:

perl -e ' @list=stat("."); foreach(@list){printf "%o \n",$_;} '

The " printf %o " part prints the value in octal, which is what you're after. The
3rd value in the returned array $list[2] is the mode. on my linux box, I get this
output:
1406 
644042   
40775
27
1046
12
0
4000
7316040631
7315775540
7315775540
1
4

The 3rd element is the mode...775. 

" ls -ald . " shows: drwxrwxr-x  23 mcauthor wheel2048 Jun 25 23:02 

Hope this helps. perldoc -f stat will give you all the nitty gritty on the rest.
Chances are good your script will return much more useful information than you
initially thought!

Matt




--- "PURMONEN, Joni" <[EMAIL PROTECTED]> wrote:
> Hi ya,
> 
> I need to check the group status on numerous files/directories, and haven't
> been able to fing out the best way to do it with perl. I simply need to see
> if some directories do not have certain group set on them.
> 
> Can anyone give any pointers?
> 
> Cheers,
> 
> Joni
> 
> Ps. I only have learning perl and some other fairly simple books which
> didn't seem to have anything useful in them


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Printf

2001-06-27 Thread Govinderjit Dhinsa

I can not get the printf to print, using the following relevant line of
code:
printf sortcode $fields[0],$fields[5],$fields[70],fields[77];

I am missing something in-between;
sortcode *$fields[0]

I have tried different things but had no luck!

PS Your help would be much appreciated.

Thanks,
GD







Re: Finding @INC

2001-06-27 Thread Jos Boumans

because push @INC is a runtime statement,
use lib is a compile time statement

meaning you'll be alerted if the dir doesnt exist, or something else goes wrong at the
moment you start your script, rather then it dying half way when not findin a file.


hth
Jos Boumans

Maxim Berlin wrote:

> Hello Jos,
>
> Wednesday, June 27, 2001, Jos Boumans <[EMAIL PROTECTED]> wrote:
>
> JB> Please use the the 'use lib' pragma, rather then fiddling with @INC
>
> JB> concider:
> JB> use lib (../foo);
>
> JB> rather than:
>
> JB> BEGIN: { push @INC, '../foo' }
>
> JB> perldoc lib for more info
>
> according to perldoc lib:
>
>use lib LIST;
>
>is almost the same as saying
>
>BEGIN { unshift(@INC, LIST) }
>
>For each directory in LIST (called $dir here) the lib mod-
>ule also checks to see if a directory called $dir/$arch-
>name/auto exists.  If so the $dir/$archname directory is
>assumed to be a corresponding architecture specific direc-
>tory and is added to @INC in front of $dir.
>
> for my configs, i don't need (and don't have) $dir/$archname/auto directories, so i
> still use
>
> >>   BEGIN { unshift(@INC,"/usr/local/etc"); }
>
> am i wrong?
>
> Best wishes,
>  Maximmailto:[EMAIL PROTECTED]




RE: Printf

2001-06-27 Thread Richard_Cox

Govinderjit Dhinsa [mailto:[EMAIL PROTECTED]] wrote:
> I can not get the printf to print, using the following 
> relevant line of
> code:
> printf sortcode $fields[0],$fields[5],$fields[70],fields[77];
> 
> I am missing something in-between;
> sortcode *$fields[0]
> 

Is sort code a filehandle (i.e. obtained from open)?

If not then you need a comma (argument separator) and some prefix to
sortcode if it is a variable.

Or do you want:

printf "sortcode $fields[0]$fields[5]$fields[70]fields[77]";

?

Richard Cox 
Senior Software Developer 
Dell Technology Online 
All opinions and statements mine and do not in any way (unless expressly
stated) imply anything at all on behalf of my employer



Re: Srting matching again

2001-06-27 Thread Yvonne Murphy

Hasanuddin Tamir wrote:

> On Tue, 26 Jun 2001, Yvonne Murphy <[EMAIL PROTECTED]> wrote,
>
> 
>
> >  if ($mymatch =~  m/\'(.+)\;/gis) { #matches anything between the single
>  ^^
> 
> >
> >
> > But the problem occurs when I add this into a bigger code segment, it
> > just goes crazy! And seems to match te complete opposite.
> >
> > And ideas?
>
> You seem to be bitten by the greedy match.  By default, the quantifiers
> (such as + and *) will match as many as possible.  You need the ? to
> suppress the greed behaviour.  This ? is different form the ? used to
> optional unit.
>
> $_ = "'first; second;";
> print $1, "\n" if /'(.+);/;   # first; second
> print $1, "\n" if /'(.+?);/;  # first
>
> Btw, /gis seems redundant to me.  So do the backslases.
>
> hth;
>
> __END__
> --
> s::a::n->http(www.trabas.com)

The data in the functions2.log file takes the following format:

'fdecls' => ARRAY(0x80e53c0)
   0  'int fibonacci(int degree);'
   1  'int towerOfHanoiMoves(int numOfDisks);'
   2  'void xyzzy(char* easterEgg);'
   3  'char* interesting();'
   4  'extern void  system_alarm_run(int *alarm);'
   5  'extern void  system_alarm_pause(int *alarm);'
   6  'extern int *system_timer_new( unsigned long tag );'
   7  'extern int *system_timer_callback_new( void (*callback_function)
  (unsigned long tag), unsigned long tag );'
   8  'int system_timer_start( int * timer, long time );'
   9  'longsystem_timer_pause( int * timer );'
   10  'int system_timer_stop( int * timer );'
   11  'int system_timer_del( int * timer );'

And I need to remove the actual function declaration and assign each of
the words to variables, such as, $return_type, $function_name, etc.

Is that any clearer?

Thanks,
YM




Joining variables

2001-06-27 Thread Diego Riaño

Hi Perl guys

I have another problem:

I have three variables working:
$var1
$var2 #and
$var3

I want to join these three variables in a new one, with some formar,
something like that:

$newvar will be $var1-$var2-$var3
for example if:

$var1=2000
$var2=08 #and
$var3=15

then

$newvar=2000-08-15

I hope someone can help me

Thanks in advances

DiegoM




RE: Joining variables

2001-06-27 Thread John Edwards

This wouldn't be homework by any chance???

-Original Message-
From: Diego Riaño [mailto:[EMAIL PROTECTED]]
Sent: 27 June 2001 13:59
To: [EMAIL PROTECTED]
Subject: Joining variables


Hi Perl guys

I have another problem:

I have three variables working:
$var1
$var2 #and
$var3

I want to join these three variables in a new one, with some formar,
something like that:

$newvar will be $var1-$var2-$var3
for example if:

$var1=2000
$var2=08 #and
$var3=15

then

$newvar=2000-08-15

I hope someone can help me

Thanks in advances

DiegoM


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





Re: PostgreSQL DBD setup

2001-06-27 Thread Geraint Jones

On Wednesday 27 June 2001  2:08 pm, Geraint Jones wrote:
> I've just spent a frustrating few hours looking for the answer to my
> problem and have decided to give up and ask you guys. The docs for the Perl
> module "DBD-Pg-1.00" say I should set the following environment variables:
> POSTGRES_INCLUDE and POSTGRES_LIB. The problem is, being a Linux newbie I
> don't know where environment variables are stored.
>
> Geraint.

No worries, just found out! That's my headache gone : )
# export POSTGRES_INCLUDE=path

Geraint.



Re: Joining variables

2001-06-27 Thread Walt Mankowski

On Wed, Jun 27, 2001 at 02:07:22PM +0100, Pierre Smolarek wrote:
> $newvar = $var1."-".$var2."-".$var3;

or $newvar = "$var1-$var2-$var3";



Re: Joining variables

2001-06-27 Thread Pierre Smolarek

$newvar = $var1."-".$var2."-".$var3;


- Original Message -
From: "John Edwards" <[EMAIL PROTECTED]>
To: "'Diego Riaño'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, June 27, 2001 2:01 PM
Subject: RE: Joining variables


> This wouldn't be homework by any chance???
>
> -Original Message-
> From: Diego Riaño [mailto:[EMAIL PROTECTED]]
> Sent: 27 June 2001 13:59
> To: [EMAIL PROTECTED]
> Subject: Joining variables
>
>
> Hi Perl guys
>
> I have another problem:
>
> I have three variables working:
> $var1
> $var2 #and
> $var3
>
> I want to join these three variables in a new one, with some formar,
> something like that:
>
> $newvar will be $var1-$var2-$var3
> for example if:
>
> $var1=2000
> $var2=08 #and
> $var3=15
>
> then
>
> $newvar=2000-08-15
>
> I hope someone can help me
>
> Thanks in advances
>
> DiegoM
>
>
> --Confidentiality--.
> This E-mail is confidential.  It should not be read, copied, disclosed or
> used by any person other than the intended recipient.  Unauthorised use,
> disclosure or copying by whatever medium is strictly prohibited and may be
> unlawful.  If you have received this E-mail in error please contact the
> sender immediately and delete the E-mail from your system.
>




Re: Srting matching again

2001-06-27 Thread Maxim Berlin

Hello Yvonne,

Tuesday, June 26, 2001, Yvonne Murphy <[EMAIL PROTECTED]> wrote:


YM> But the problem occurs when I add this into a bigger code segment, it
YM> just goes crazy! And seems to match te complete opposite.
can you describe what exctly happened and can you show your bigger
code segment?


Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re: Joining variables

2001-06-27 Thread Pierre Smolarek

> On Wed, Jun 27, 2001 at 02:07:22PM +0100, Pierre Smolarek wrote:
> > $newvar = $var1."-".$var2."-".$var3;
> 
> or $newvar = "$var1-$var2-$var3";

or

$concat = '-';
$newvar .= $var1;
$newvar .= $concat;
$newvar .= $var2;
$newvar .= $concat;
$newvar .= $var3;

dude, you should really look this up in a book.. its pre-basic perl




FW: FW: rmdir

2001-06-27 Thread Porter, Chris



-Original Message-
From: Porter, Chris 
Sent: Wednesday, June 27, 2001 9:21 AM
To: 'Maxim Berlin'
Subject: RE: FW: rmdir


Hi,

It's working great.  Thank you.  But one more thing, it's removing all the
empty directories but what about directories with files in them.  It errors
out when it hits a directory with files in it.  I have just files in this
directory that I don't want to delete.  I only want to delete the
directories with Capital letters and the files in them.  Thank you for any
help or ideas.

Chris

-Original Message-
From: Maxim Berlin [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 26, 2001 10:07 AM
To: '[EMAIL PROTECTED]'
Subject: Re: FW: rmdir


Hello Chris,

Tuesday, June 26, 2001, Porter, Chris <[EMAIL PROTECTED]> wrote:

PC> It's me again, still won't work.  Here is the whole script:
PC> Again, any help would be great.

Well, script works correct now.

May be you try to rmdir not empty subdirs?

c:\>perldoc -f rmdir
rmdir FILENAME
rmdir   Deletes the directory specified by FILENAME if that
directory is empty. If it succeeds it returns TRUE,
otherwise it returns FALSE and sets `$!' (errno). If
FILENAME is omitted, uses `$_'.

you can avoid many troubles, if you check return codes, like this:

rmdir $Name or die $!;

PC>  chdir "/u131/tmp" or die $!;

PC>  opendir(HERE, '.');

PC>  @AllFiles = readdir(HERE);

PC>  foreach $Name (@AllFiles) {

PC>if (-f $Name) {next}

PC>if ((-d $Name) and ($Name =~ /^[A-Z]+$/)) {rmdir $Name}


PC>if ((-d $Name)) {print "$Name\n"}

PC>}  



Best wishes,
 Maximmailto:[EMAIL PROTECTED]




Re: PostgreSQL DBD setup

2001-06-27 Thread Ulle Siedentop

Had just yesterday the same problem. Did not get DBD::Pg
working using it with  Suse Linux 7.0 Postgres RPM
Distribution.

It might be easier to use Postgres source distribution
instead of using a RPM distribution. After compiling
Postgres as described in the INSTALL file i had to set the
environment variables as follows:

export POSTGRES_INCLUDE=/usr/local/pgsql/include
export POSTGRES_LIB=/usr/local/pgsql/lib

In the same terminal session you should run the installation
process of DBD::Pg.

Good Luck!

Ulle

- Original Message -
From: Geraint Jones <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 27, 2001 3:08 PM
Subject: PostgreSQL DBD setup


> I've just spent a frustrating few hours looking for the
answer to my problem
> and have decided to give up and ask you guys. The docs for
the Perl module
> "DBD-Pg-1.00" say I should set the following environment
variables:
> POSTGRES_INCLUDE and POSTGRES_LIB. The problem is, being a
Linux newbie I
> don't know where environment variables are stored.
>
> Geraint.
>




Re: Printf

2001-06-27 Thread Chas Owens

printf has the f on the end because it expects a format string.  If you
are on a unix box try typing  "man 3 printf".  This shows you the docs
for C's printf, but since perl's printf is does a straight pass thorugh
to C's printf that shouldn't matter.  Try this in your code:

printf sortcode "%s %s %s %s\n", $fields[0], $fields[5], $fields[70],
fields[77];

The big question I have is "why are you using printf?"  Printf should
only used when you care very much about how the output is formated (ie
printing only two decimal places on a number).


  Don't fall into the trap of using a "printf" when
  a simple "print" would do.  The "print" is more
  efficient and less error prone.


On 27 Jun 2001 13:11:46 +0100, Govinderjit Dhinsa wrote:
> I can not get the printf to print, using the following relevant line of
> code:
> printf sortcode $fields[0],$fields[5],$fields[70],fields[77];
> 
> I am missing something in-between;
> sortcode *$fields[0]
> 
> I have tried different things but had no luck!
> 
> PS Your help would be much appreciated.
> 
> Thanks,
> GD
> 
> 
> 
> 
> 
--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
Frink!




Re: Joining variables

2001-06-27 Thread Chas Owens

On 27 Jun 2001 14:37:14 +0100, Pierre Smolarek wrote:
> > On Wed, Jun 27, 2001 at 02:07:22PM +0100, Pierre Smolarek wrote:
> > > $newvar = $var1."-".$var2."-".$var3;
> > 
> > or $newvar = "$var1-$var2-$var3";
> 
> or
> 
> $concat = '-';
> $newvar .= $var1;
> $newvar .= $concat;
> $newvar .= $var2;
> $newvar .= $concat;
> $newvar .= $var3;
> 
> dude, you should really look this up in a book.. its pre-basic perl
> 
> 
or

$newvar = join "-", ($var1, $var2, $var3);

TMTOWTDI

--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
Wibble.





To replace a string with another

2001-06-27 Thread Stéphane JEAN BAPTISTE


Hi.
I want to replace the String  %0A by nothing. I'm using this line:
   $description=~tr/%0A//;

But nothing change.

What is my problem ?

tks




Re: Re[2]: Finding @INC

2001-06-27 Thread Randal L. Schwartz

> "Maxim" == Maxim Berlin <[EMAIL PROTECTED]> writes:

Maxim> Hello Tamir,
Maxim> Wednesday, June 27, 2001, Hasanuddin Tamir <[EMAIL PROTECTED]> wrote:

>>> if ( $OS ne "NT" )
>>> {
>>> BEGIN { unshift(@INC,"/usr/local/etc"); }
>>> require "config.backup.pl";
>>> }

HT> The BEGIN blocks always execute first no matter where you put them.
Maxim> yes, of course. BEGIN was placed inside just for better readability.

I actually consider that *less* readable and maintainable, because it
would lead someone to believe that the BEGIN block somehow depended on
that condition, which it doesn't.

I'd flunk it in one of our professional code reviews, in other words.
At least not without a big honkin' comment that says "THIS EXECUTES
ANYWAY, REGARDLESS OF THE ABOVE CONDITION.  WE PUT IT HERE BECAUSE WE
WANTED TO, NOT BECAUSE IT MAKES SENSE".  Usually, if a developer is
told to do that as an alternative to moving it, they just move it.

Then again, in a code review, I'm required to be an advocate for the
unseen maintenance programmer who is usually not as clever as the
original author. :)

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



RE: To replace a string with another

2001-06-27 Thread John Edwards

Try escaping the % symbol.

   $description=~tr/\%0A//;


See this link for an explanation.

http://www.netcat.co.uk/rob/perl/win32perltut.html#38-Escaping

-Original Message-
From: Stéphane JEAN BAPTISTE
[mailto:[EMAIL PROTECTED]]
Sent: 27 June 2001 15:12
To: PERL
Subject: To replace a string with another



Hi.
I want to replace the String  %0A by nothing. I'm using this line:
   $description=~tr/%0A//;

But nothing change.

What is my problem ?

tks



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





Re: To replace a string with another

2001-06-27 Thread Chas Owens

On 27 Jun 2001 16:11:56 +0200, Stéphane JEAN BAPTISTE wrote:
> 
> Hi.
> I want to replace the String  %0A by nothing. I'm using this line:
>$description=~tr/%0A//;
> 
> But nothing change.
> 
> What is my problem ?
> 
> tks
> 

tr is not what you want.  tr replaces characters with other characters.
You want s:

$desc =~ s/%0A//g;

--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
You are what you see.





Re: To replace a string with another

2001-06-27 Thread Stéphane JEAN BAPTISTE



Stéphane JEAN BAPTISTE a écrit :

> Hi.
> I want to replace the String  %0A by nothing. I'm using this line:
>$description=~tr/%0A//;
>
> But nothing change.
>
> What is my problem ?
>
> tks

PS: There is'nt only 1 string but a lot.





Re: Re[2]: Finding @INC

2001-06-27 Thread Randal L. Schwartz

> "Maxim" == Maxim Berlin <[EMAIL PROTECTED]> writes:

Maxim> for my configs, i don't need (and don't have)
Maxim> $dir/$archname/auto directories, so i still use

>>> BEGIN { unshift(@INC,"/usr/local/etc"); }

Maxim> am i wrong?

You are typing too much.  In a code review, I'd flag that as a warning
item, as in "why does he open-code a standard use-lib?"  It's more
typing, less functionality, and makes me wonder if there's some reason
you *couldn't* have done it the standard way, as in you had an arch
directory that you *didn't* want installed.

Now, if there's something else inside that BEGIN block, like:

BEGIN {
  $dir = $DEBUG ? "/my/private/dir" : "/usr/local/etc";
  unshift @INC, $dir;
}

then you're perfectly entitled to your BEGIN block.  But not when it's
standalone.  That wouldn't be a fatal in a code review (unless it was
inside a conditional, as I said in my other message), but it's flagged
as a warning fix.

Never open-code something... people smell trouble.  Sorry, 24 years of
professional programming and a half-dozen years before that of
tinkering have lead me to some pretty stiff ideas about how people can
screw up when maintaining your code, and I'm probably not gonna budge
on that.

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



Re: still: using fetchrow_hashref()

2001-06-27 Thread Marcus Willemsen

Thanks tried the row count with SELECT COUNT(*) and it works perfectly

Thanks a lot




getopt:std questions

2001-06-27 Thread Tyler Longren

Hello everyone,

Here's a section of code:
my %options;
my $u;
use strict;
use Getopt::Std;

getopts("dwmyau:", \%options);

How can I get the value of the '-u' option and print it to the screen?

I've tried this:
$u = $options{u};
print "$u";
but that doesn't work...it doesn't print anything.  Can anybody shed some
light on this for me?

Thanks,
Tyler Longren





Re: still: using fetchrow_hashref()

2001-06-27 Thread Chas Owens

Remember that count(*) will only work in those cases where nothing gets
inserted in the time between the two select statements.  You may
experience odd bugs.  Comment the area around this code well. 

On 27 Jun 2001 16:20:29 +0200, Marcus Willemsen wrote:
> Thanks tried the row count with SELECT COUNT(*) and it works perfectly
> 
> Thanks a lot
> 
> 
--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
Pzat!





AW: getopt:std questions

2001-06-27 Thread Ela Jarecka

I use it like this ( checking program options ):

my $usage = "$0 -s  -u  -b  -e  -f
\n";
my %opts;
getopts('b:e:s:u:f:', \%opts);

my $servdata = $opts{s};
my $userdata = $opts{u};
my $begtime = $opts{b};
my $endtime = $opts{e};
my $reqdata = $opts{f};

Cheers,
Ela

> -Ursprüngliche Nachricht-
> Von: Tyler Longren [mailto:[EMAIL PROTECTED]]
> Gesendet: Mittwoch, 27. Juni 2001 16:24
> An: Perl Beginners
> Betreff: getopt:std questions
> 
> 
> Hello everyone,
> 
> Here's a section of code:
> my %options;
> my $u;
> use strict;
> use Getopt::Std;
> 
> getopts("dwmyau:", \%options);
> 
> How can I get the value of the '-u' option and print it to the screen?
> 
> I've tried this:
> $u = $options{u};
> print "$u";
> but that doesn't work...it doesn't print anything.  Can 
> anybody shed some
> light on this for me?
> 
> Thanks,
> Tyler Longren
> 
> 



Re: getopt:std questions

2001-06-27 Thread Tyler Longren

Ahh..that worked wonderfully.  Thank you very much!

Tyler

- Original Message -
From: "Ela Jarecka" <[EMAIL PROTECTED]>
To: "'Tyler Longren'" <[EMAIL PROTECTED]>
Cc: "Beginners list (E-Mail)" <[EMAIL PROTECTED]>
Sent: Wednesday, June 27, 2001 9:39 AM
Subject: AW: getopt:std questions


I use it like this ( checking program options ):

my $usage = "$0 -s  -u  -b  -e  -f
\n";
my %opts;
getopts('b:e:s:u:f:', \%opts);

my $servdata = $opts{s};
my $userdata = $opts{u};
my $begtime = $opts{b};
my $endtime = $opts{e};
my $reqdata = $opts{f};

Cheers,
Ela

> -Ursprüngliche Nachricht-
> Von: Tyler Longren [mailto:[EMAIL PROTECTED]]
> Gesendet: Mittwoch, 27. Juni 2001 16:24
> An: Perl Beginners
> Betreff: getopt:std questions
>
>
> Hello everyone,
>
> Here's a section of code:
> my %options;
> my $u;
> use strict;
> use Getopt::Std;
>
> getopts("dwmyau:", \%options);
>
> How can I get the value of the '-u' option and print it to the screen?
>
> I've tried this:
> $u = $options{u};
> print "$u";
> but that doesn't work...it doesn't print anything.  Can
> anybody shed some
> light on this for me?
>
> Thanks,
> Tyler Longren
>
>




Incrementing Strings

2001-06-27 Thread Nick Transier

If I define a variable as a string
my $var = "a";

I can get the increment to work
print ++$var; --> prints b

but the decrement
print --$var --> prints -1

Why? and how can I decrement it?


Thanks,
-Nick
_
Get your FREE download of MSN Explorer at http://explorer.msn.com




Re: Incrementing Strings

2001-06-27 Thread Jeff 'japhy' Pinyan

On Jun 27, Nick Transier said:

>If I define a variable as a string
>my $var = "a";
>
>I can get the increment to work
>print ++$var; --> prints b
>
>but the decrement
>print --$var --> prints -1
>
>Why? and how can I decrement it?

The perlop documentation says that ++ is magical for strings, but that --
isn't.  The reason is because there's not a clear-cut way of defining it.

What is 'a'--? 

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




Re: Incrementing Strings

2001-06-27 Thread Kevin Meltzer

On Wed, Jun 27, 2001 at 10:55:54AM -0400, Jeff 'japhy' Pinyan ([EMAIL PROTECTED]) 
spew-ed forth:
> On Jun 27, Nick Transier said:
> 
> The perlop documentation says that ++ is magical for strings, but that --
> isn't.  The reason is because there's not a clear-cut way of defining it.
> 
> What is 'a'--? 

Is that the reason? I would think --'a' would be z, but that is my own
internal logic :)

But, why is --'a' (or any a-zA-Z) -1? Why doesn't, at least, it evaluate
'a' to true (1) and --'a' = 0 (or undef, since I don't know why it
should return a true value)? I guess there must be a reason, but it
isn't documented from what I can see.

Cheers,
Kevin

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
"I know the human being and fish can coexist peacefully."
-- G.W. Bush, Saginaw, MI 09/29/2000



Re: Incrementing Strings

2001-06-27 Thread Paul


--- Nick Transier <[EMAIL PROTECTED]> wrote:
> If I define a variable as a string
> my $var = "a";
> 
> I can get the increment to work
> print ++$var; --> prints b
> 
> but the decrement
> print --$var --> prints -1
> 
> Why? and how can I decrement it?

Incrementing strings is magic that isn't implemented backwards.
In other words, you can't decrement a string.

>From perldoc perlop:
===
Auto-increment and Auto-decrement 

``++'' and ``--'' work as in C. That is, if placed before a variable,
they increment or decrement the variable before returning
the value, and if placed after, increment or decrement the variable
after returning the value. 

The auto-increment operator has a little extra builtin magic to it. If
you increment a variable that is numeric, or that has ever
been used in a numeric context, you get a normal increment. If,
however, the variable has been used in only string contexts
since it was set, and has a value that is not null and matches the
pattern /^[a-zA-Z]*[0-9]*$/, the increment is done as a
string, preserving each character within its range, with carry: 

print ++($foo = '99');  # prints '100'
print ++($foo = 'a0');  # prints 'a1'
print ++($foo = 'Az');  # prints 'Ba'
print ++($foo = 'zz');  # prints 'aaa'

The auto-decrement operator is not magical. 



__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



to delete the trailing newline

2001-06-27 Thread Stéphane JEAN BAPTISTE



I have a variable and I want to write it into a textarea (HTML). The
problem is when I look at the textarea in my HTML page, there is the
text I want, plus a trailing newline.

How can I delete this.

My variable:
"$texte="wazaa";"

In textarea:
"wazza
"

tks

Sorry for my english

steph




Re: Incrementing Strings

2001-06-27 Thread Paul Johnson

On Wed, Jun 27, 2001 at 11:07:12AM -0400, Kevin Meltzer wrote:
> On Wed, Jun 27, 2001 at 10:55:54AM -0400, Jeff 'japhy' Pinyan ([EMAIL PROTECTED]) 
>spew-ed forth:
> > On Jun 27, Nick Transier said:
> > 
> > The perlop documentation says that ++ is magical for strings, but that --
> > isn't.  The reason is because there's not a clear-cut way of defining it.
> > 
> > What is 'a'--? 
> 
> Is that the reason? I would think --'a' would be z, but that is my own
> internal logic :)

But ++'z' isn't 'a'.

> But, why is --'a' (or any a-zA-Z) -1? Why doesn't, at least, it evaluate
> 'a' to true (1) and --'a' = 0 (or undef, since I don't know why it
> should return a true value)? I guess there must be a reason, but it
> isn't documented from what I can see.

Converting 'a' to a number gives 0.

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



Converting Unix paths to windows

2001-06-27 Thread Daryl Hoyt

Hi,
I am writing a script to be used on Windows and many different flavors
of Unix.  I am looking for a good way to convert Unix paths to Windows.  Any
Ideas?

Thanks,

Daryl J. Hoyt
Performance Engineer
Geodesic Systems
http://www.geodesic.com
[EMAIL PROTECTED]




Re: Incrementing Strings

2001-06-27 Thread Brett W. McCoy

On Wed, 27 Jun 2001, Paul wrote:

> The auto-decrement operator is not magical.

The Camel Book adds that there are not any plans to make it magical.

-- Brett
   http://www.chapelperilous.net/btfwk/

Women, when they have made a sheep of a man, always tell him that he is a
lion with a will of iron.
-- Honor'e de Balzac





Re: to delete the trailing newline

2001-06-27 Thread Brett W. McCoy

On Wed, 27 Jun 2001, Stéphane JEAN BAPTISTE wrote:

> I have a variable and I want to write it into a textarea (HTML). The
> problem is when I look at the textarea in my HTML page, there is the
> text I want, plus a trailing newline.
>
> How can I delete this.
>
> My variable:
> "$texte="wazaa";"
>
> In textarea:
> "wazza
> "

You can chomp off that trailing newline using 'chomp'.  Weren't you the
guy who was asking about it yesterday?

-- Brett
   http://www.chapelperilous.net/btfwk/

This fortune intentionally says nothing.




Re: to delete the trailing newline

2001-06-27 Thread Jos Boumans

you might want to try to use 'chomp' on your variable... this function
is specifically there to 'chomp off' trailing newlines

you'll often see it used as:

open FH, 'foo.txt';
while(){
chomp; #remove trailing newline
do something
}

perldoc -f chomp for details

hth,

Jos Boumans


Stéphane JEAN BAPTISTE wrote:

> I have a variable and I want to write it into a textarea (HTML). The
> problem is when I look at the textarea in my HTML page, there is the
> text I want, plus a trailing newline.
>
> How can I delete this.
>
> My variable:
> "$texte="wazaa";"
>
> In textarea:
> "wazza
> "
>
> tks
>
> Sorry for my english
>
> steph




Re: Incrementing Strings

2001-06-27 Thread Brett W. McCoy

On Wed, 27 Jun 2001, Paul Johnson wrote:

> > Is that the reason? I would think --'a' would be z, but that is my own
> > internal logic :)
>
> But ++'z' isn't 'a'.

Technically, you can't do ++'z' because you are modifying a constant...
but autoincrementing a variable whose value is 'z' will make it 'aa'.

-- Brett
   http://www.chapelperilous.net/btfwk/

You will win success in whatever calling you adopt.




Re: To replace a string with another

2001-06-27 Thread Tony Cook

On Wed, 27 Jun 2001, [iso-8859-1] Stéphane JEAN BAPTISTE wrote:

> 
> Hi.
> I want to replace the String  %0A by nothing. I'm using this line:
>$description=~tr/%0A//;
> 
> But nothing change.
> 
> What is my problem ?

There's a few things wrong with this, first, you're trying to replace a
string rather than characters with tr///.

To replace a string your best choice is the s/// operator, for your
example you probably want:

  $description =~ s/%0A//g;

for() makes this easy for multiple strings:

  for ($description, $name, $address) {
s/%0A//g;
  }

It isn't such a saving here, but consider the savings for a more complex
substitution.

The other problem with tr/%0A// was that if you don't supply a replacement
list, tr/// will use the search list, so that:

  $description =~ tr/%0A//;

will not modify $description at all.

If you want those characters to be deleted you need to use the d option:

  $description =~ tr/%0A//d; # remove all %, 0 and A from $description
 # but don't use such an obvious comment in
 # your code :)

Now you might be wondering where having the replacement list being the
same as the search list would be useful.  The most obvious example is to
count characters:

  $count = $description =~ tr/ //; # how many spaces?

or you can combine adjacent characters with the s option:

  $description =~ tr/ //s;

I tend to think tr/// is under-used, but this isn't a case where it's
useful.

For information on the tr/// and s/// operators see perldoc perlop under
"Quote and Quote-like Operators

Tony




Re: Joining variables

2001-06-27 Thread Paul Murphy


Umm... like  $newvar = sprintf("$var1-$var2-$var3");

Can we get uglier?

>>> Chas Owens <[EMAIL PROTECTED]> 6/27/2001 03:06:28 pm >>>
On 27 Jun 2001 14:37:14 +0100, Pierre Smolarek wrote:
> > On Wed, Jun 27, 2001 at 02:07:22PM +0100, Pierre Smolarek wrote:
> > > $newvar = $var1."-".$var2."-".$var3;
> > 
> > or $newvar = "$var1-$var2-$var3";
> 
> or
> 
> $concat = '-';
> $newvar .= $var1;
> $newvar .= $concat;
> $newvar .= $var2;
> $newvar .= $concat;
> $newvar .= $var3;
> 
> dude, you should really look this up in a book.. its pre-basic perl
> 
> 
or

$newvar = join "-", ($var1, $var2, $var3);

TMTOWTDI

--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
Wibble.





---
CRESTCo Ltd. The views expressed above are not necessarily those
33 Cannon Street.held by CRESTCo Limited.
London  EC4M 5SB (UK)  
+44 (020) 7849  http://www.crestco.co.uk 
---



Re: Incrementing Strings

2001-06-27 Thread Kevin Meltzer

On Wed, Jun 27, 2001 at 06:21:30PM +0200, Paul Johnson ([EMAIL PROTECTED]) spew-ed forth:
> On Wed, Jun 27, 2001 at 11:07:12AM -0400, Kevin Meltzer wrote:
> > 
> > Is that the reason? I would think --'a' would be z, but that is my own
> > internal logic :)
> 
> But ++'z' isn't 'a'.

No, it is aa, the next logical thing to come after z. So, --a could be
aa. or, to me, more logically z. But, I don't scream that my
logic is always logical ;)

> > But, why is --'a' (or any a-zA-Z) -1? Why doesn't, at least, it evaluate
> > 'a' to true (1) and --'a' = 0 (or undef, since I don't know why it
> > should return a true value)? I guess there must be a reason, but it
> > isn't documented from what I can see.
> 
> Converting 'a' to a number gives 0.

I'm not convinced on that. Being that magic is built in to make a++ into
b.. so it isn't being converted to 0 in that case, which would make that
statement false. Why would it be 0?
Why not 1? Why is 'b' also converted to 0? Why not use it's ord() value?
To me (again, internal, warped, logic) --a returning ` makes more sense
than -1. z++ is aa, so why isn't aa-- reverted back to z? Why must --a
be seemingly useless?

Cheers,
Kevin

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
"Families is where out nation finds hope, where wings take dream."
-- G.W. Bush, LaCrosse, WI 10/18/2000



Re: to delete the trailing newline

2001-06-27 Thread Stéphane JEAN BAPTISTE



"Brett W. McCoy" a écrit :

> On Wed, 27 Jun 2001, Stéphane JEAN BAPTISTE wrote:
>
> > I have a variable and I want to write it into a textarea (HTML). The
> > problem is when I look at the textarea in my HTML page, there is the
> > text I want, plus a trailing newline.
> >
> > How can I delete this.
> >
> > My variable:
> > "$texte="wazaa";"
> >
> > In textarea:
> > "wazza
> > "
>
> You can chomp off that trailing newline using 'chomp'.  Weren't you the
> guy who was asking about it yesterday?

Yes! But "chomp" delete it in perl but not the conversion in HTML.




Re: Incrementing Strings

2001-06-27 Thread Pierre Smolarek

does this all mean that c++ is ACTUALLY D ?

hu. food for thought.

Pierre

- Original Message -
From: "Kevin Meltzer" <[EMAIL PROTECTED]>
To: "Paul Johnson" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>; "Nick Transier" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Wednesday, June 27, 2001 4:38 PM
Subject: Re: Incrementing Strings


> On Wed, Jun 27, 2001 at 06:21:30PM +0200, Paul Johnson ([EMAIL PROTECTED])
spew-ed forth:
> > On Wed, Jun 27, 2001 at 11:07:12AM -0400, Kevin Meltzer wrote:
> > >
> > > Is that the reason? I would think --'a' would be z, but that is my own
> > > internal logic :)
> >
> > But ++'z' isn't 'a'.
>
> No, it is aa, the next logical thing to come after z. So, --a could be
> aa. or, to me, more logically z. But, I don't scream that my
> logic is always logical ;)
>
> > > But, why is --'a' (or any a-zA-Z) -1? Why doesn't, at least, it
evaluate
> > > 'a' to true (1) and --'a' = 0 (or undef, since I don't know why it
> > > should return a true value)? I guess there must be a reason, but it
> > > isn't documented from what I can see.
> >
> > Converting 'a' to a number gives 0.
>
> I'm not convinced on that. Being that magic is built in to make a++ into
> b.. so it isn't being converted to 0 in that case, which would make that
> statement false. Why would it be 0?
> Why not 1? Why is 'b' also converted to 0? Why not use it's ord() value?
> To me (again, internal, warped, logic) --a returning ` makes more sense
> than -1. z++ is aa, so why isn't aa-- reverted back to z? Why must --a
> be seemingly useless?
>
> Cheers,
> Kevin
>
> --
> [Writing CGI Applications with Perl - http://perlcgi-book.com]
> "Families is where out nation finds hope, where wings take dream."
> -- G.W. Bush, LaCrosse, WI 10/18/2000




Re: to delete the trailing newline

2001-06-27 Thread Brett W. McCoy

On Wed, 27 Jun 2001, Stéphane JEAN BAPTISTE wrote:

> > You can chomp off that trailing newline using 'chomp'.  Weren't you the
> > guy who was asking about it yesterday?
>
> Yes! But "chomp" delete it in perl but not the conversion in HTML.

Oh, I'm sorry!  Perhaps you have a newline embedded in your script, like
this:

"$variable
"

-- Brett
   http://www.chapelperilous.net/btfwk/

It'll be just like Beggars' Canyon back home.
-- Luke Skywalker




Re: Joining variables

2001-06-27 Thread Chas Owens

On 27 Jun 2001 10:06:28 -0400, Chas Owens wrote:
> On 27 Jun 2001 14:37:14 +0100, Pierre Smolarek wrote:
> > > On Wed, Jun 27, 2001 at 02:07:22PM +0100, Pierre Smolarek wrote:
> > > > $newvar = $var1."-".$var2."-".$var3;
> > > 
> > > or $newvar = "$var1-$var2-$var3";
> > 
> > or
> > 
> > $concat = '-';
> > $newvar .= $var1;
> > $newvar .= $concat;
> > $newvar .= $var2;
> > $newvar .= $concat;
> > $newvar .= $var3;
> > 
> > dude, you should really look this up in a book.. its pre-basic perl
> > 
> > 
> or
> 
> $newvar = join "-", ($var1, $var2, $var3);
> 
> TMTOWTDI
> 
> --
> Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
> Wibble.
> 
> 
>

or

$newvar='';$newvar .= "$_-" foreach ($var1, $var2, $var3); chop $newvar;

or

$newvar = sprintf "%04d-%02d-%02d", $var1, $var2, $var3;

or

$newvar =~ s/.*/$var1-$var2-$var3/;

I think I need a life.
 
--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
Kallisti!





Re: Incrementing Strings

2001-06-27 Thread Jos Boumans

> How do you mean?

concider:
if ('a' == 'b') { print "foo" } # this will print 'foo', seeing 'a' and 'b' both yield 
'1' in numeric
context here.

however

$x = 'a';
print $x + 4;

will print '4';

Jos Boumans


> Converting 'a' to a number gives 0.
>
> --
> Paul Johnson - [EMAIL PROTECTED]
> http://www.pjcj.net




Re: Incrementing Strings

2001-06-27 Thread Brett W. McCoy

On Wed, 27 Jun 2001, Pierre Smolarek wrote:

> does this all mean that c++ is ACTUALLY D ?

No, c++ is ACTUALLY a pain in the butt to code... :-)

-- Brett
   http://www.chapelperilous.net/btfwk/

Positive, adj.:
Mistaken at the top of one's voice.
-- Ambrose Bierce, "The Devil's Dictionary"




Re: Incrementing Strings

2001-06-27 Thread Chas Owens

On 27 Jun 2001 17:45:18 +0200, Jos Boumans wrote:
> > How do you mean?
> 
> concider:
> if ('a' == 'b') { print "foo" } # this will print 'foo', seeing 'a' and 'b' both 
>yield '1' in numeric
> context here.

You mean 0 not 1 don't you?

> 
> however
> 
> $x = 'a';
> print $x + 4;
> 
> will print '4';
> 
> Jos Boumans
> 
> 
> > Converting 'a' to a number gives 0.
> >
> > --
> > Paul Johnson - [EMAIL PROTECTED]
> > http://www.pjcj.net
> 
> 
--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
Kallisti!





Re: Converting Unix paths to windows

2001-06-27 Thread Aaron Craig

At 10:22 27.06.2001 -0500, Daryl Hoyt wrote:
>Hi,
> I am writing a script to be used on Windows and many different flavors
>of Unix.  I am looking for a good way to convert Unix paths to Windows.  Any
>Ideas?

What do you mean exactly.  If you just mean converting "\" to "/"  and 
getting rid of the drive you can do this:

my $sPath = "C:\\foo\\bar";
$sPath =~ s/^[a-z]+://i;
$sPath =~ s/\\/\//g;
print $sPath;
Aaron Craig
Programming
iSoftitler.com




Suggestions?

2001-06-27 Thread Bill Pierson

Greetings all - I realize this is a very broad question, however any suggestions would 
be appreciated.

I'm looking to purchase good learning tools about programming in PERL. I've been 
programming with it for several years, but I've never truly learned the basics - just 
looked at other code and learned from that.
Specifically I'd like to learn from "ground zero" about variables, hashes, etc. as 
well as MySQL connectivity.

I'd like to find something that is concise - I have several projects that I'll be 
working on in the very near future, and fine-tuning my knowledge would be of great 
benefit.

Again, any suggestions will be appreciated.




Re: Incrementing Strings

2001-06-27 Thread Kevin Meltzer

On Wed, Jun 27, 2001 at 11:51:01AM -0400, Chas Owens ([EMAIL PROTECTED]) spew-ed 
forth:
> On 27 Jun 2001 17:45:18 +0200, Jos Boumans wrote:
> > > How do you mean?
> > 
> > concider:
> > if ('a' == 'b') { print "foo" } # this will print 'foo', seeing 'a' and 'b' both 
>yield '1' in numeric
> > context here.
> 
> You mean 0 not 1 don't you?

# perl -wle 'print "a" ? "Yes" : "no";'

They are true values, 0 is false.

It would also print 'foo' if it were 'a' == 'bb' (althoug warnings
should yell at you for doing this :) If they yielded 0, it wouldn't
print 'foo'.

Cheers,
Kevin

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
"This Too Shall Pass"
-- inscription on the inside of King Solomon's Ring.



Re: Suggestions?

2001-06-27 Thread Pierre Smolarek

I learnt with Sams teach yourself perl in 21 days did teh trick here...
from that i graped the basics and then got reference books like Programming
perl, perl cookbook by oreilly

I have an html version of Sams, which i can send to you by request,

Pierre

- Original Message -
From: "Bill Pierson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 27, 2001 4:57 PM
Subject: Suggestions?


Greetings all - I realize this is a very broad question, however any
suggestions would be appreciated.

I'm looking to purchase good learning tools about programming in PERL. I've
been programming with it for several years, but I've never truly learned the
basics - just looked at other code and learned from that.
Specifically I'd like to learn from "ground zero" about variables, hashes,
etc. as well as MySQL connectivity.

I'd like to find something that is concise - I have several projects that
I'll be working on in the very near future, and fine-tuning my knowledge
would be of great benefit.

Again, any suggestions will be appreciated.






Re: Joining variables

2001-06-27 Thread Aaron Craig

Just to make it longwinded:

my $stuff = { $var1 => "-" , $var2 => "-" , $var3 => "-" };
my $newvar = "";
$newvar .= "$_$stuff->{$_}" foreach keys %{ $stuff };


At 11:45 27.06.2001 -0400, Chas Owens wrote:
>On 27 Jun 2001 10:06:28 -0400, Chas Owens wrote:
> > On 27 Jun 2001 14:37:14 +0100, Pierre Smolarek wrote:
> > > > On Wed, Jun 27, 2001 at 02:07:22PM +0100, Pierre Smolarek wrote:
> > > > > $newvar = $var1."-".$var2."-".$var3;
> > > >
> > > > or $newvar = "$var1-$var2-$var3";
> > >
> > > or
> > >
> > > $concat = '-';
> > > $newvar .= $var1;
> > > $newvar .= $concat;
> > > $newvar .= $var2;
> > > $newvar .= $concat;
> > > $newvar .= $var3;
> > >
> > > dude, you should really look this up in a book.. its pre-basic perl
> > >
> > >
> > or
> >
> > $newvar = join "-", ($var1, $var2, $var3);
> >
> > TMTOWTDI
> >
> > --
> > Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
> > Wibble.
> >
> >
> >
>
>or
>
>$newvar='';$newvar .= "$_-" foreach ($var1, $var2, $var3); chop $newvar;
>
>or
>
>$newvar = sprintf "%04d-%02d-%02d", $var1, $var2, $var3;
>
>or
>
>$newvar =~ s/.*/$var1-$var2-$var3/;
>
>I think I need a life.
>
>--
>Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
>Kallisti!

Aaron Craig
Programming
iSoftitler.com




RE: Converting Unix paths to windows

2001-06-27 Thread Robin Lavallee (LMC)


As a side note, you can still use forward slash "/" instead of "\" in
Windows. They
are compatible with all internal Windows API. 
Reasons for this is the history prior to MS-DOS being born.

-Robin

> -Original Message-
> From: Aaron Craig [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, June 27, 2001 11:50 AM
> To:   [EMAIL PROTECTED]
> Subject:  Re: Converting Unix paths to windows
> 
> At 10:22 27.06.2001 -0500, Daryl Hoyt wrote:
> >Hi,
> > I am writing a script to be used on Windows and many different
> flavors
> >of Unix.  I am looking for a good way to convert Unix paths to Windows.
> Any
> >Ideas?
> 
> What do you mean exactly.  If you just mean converting "\" to "/"  and 
> getting rid of the drive you can do this:
> 
> my $sPath = "C:\\foo\\bar";
> $sPath =~ s/^[a-z]+://i;
> $sPath =~ s/\\/\//g;
> print $sPath;
> Aaron Craig
> Programming
> iSoftitler.com



Re: Incrementing Strings

2001-06-27 Thread Jeff 'japhy' Pinyan

On Jun 27, Kevin Meltzer said:

>On Wed, Jun 27, 2001 at 11:51:01AM -0400, Chas Owens ([EMAIL PROTECTED]) spew-ed 
>forth:
>> On 27 Jun 2001 17:45:18 +0200, Jos Boumans wrote:
>> > > How do you mean?
>> > 
>> > concider:
>> > if ('a' == 'b') { print "foo" } # this will print 'foo', seeing 'a' and 'b' both 
>yield '1' in numeric
>> > context here.
>> 
>> You mean 0 not 1 don't you?
>
># perl -wle 'print "a" ? "Yes" : "no";'
>
>They are true values, 0 is false.

Values that can not be converted to a numerical value have the value of 0
in numerical context.  "a" is converted to 0 in numerical context, as are
"b", "foobar", "a1b2", and "-d3".

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




Re: Incrementing Strings

2001-06-27 Thread Kevin Meltzer

On Wed, Jun 27, 2001 at 12:04:53PM -0400, Jeff 'japhy' Pinyan ([EMAIL PROTECTED]) 
spew-ed forth:
> On Jun 27, Kevin Meltzer said:
> 
> >On Wed, Jun 27, 2001 at 11:51:01AM -0400, Chas Owens ([EMAIL PROTECTED]) spew-ed 
>forth:
> >> On 27 Jun 2001 17:45:18 +0200, Jos Boumans wrote:
> >> > > How do you mean?
> >> > 
> >
> >They are true values, 0 is false.
> 
> Values that can not be converted to a numerical value have the value of 0
> in numerical context.  "a" is converted to 0 in numerical context, as are
> "b", "foobar", "a1b2", and "-d3".

Ugh... yes.. finger vs. brain RPMs aren't the same :) The 'evaluation'
was true.. not the elements. Sorry folks.. my 1-screw-up-per-day quota
has been met.

However, I still think --a returning -1 is useless :)

Cheers,
Kevin

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
Nuclear explosions under the Nevada desert? What the f*ck are we testing for?
We already know the sh*t blows up.
-- Frank Zappa



Best practice for config file use?

2001-06-27 Thread Tim Musson


  I need to pass a number of parms to my program.  Is there a "best
  Practice" for how to do this?  Command line is not something I want
  to do.

  I did search on "Config" from search.cpan.org, but it returned 99
  modules!

  Any suggestions?  In the past, I have done it by hand, but...

-- 
[EMAIL PROTECTED]
Using The Bat! eMail v1.53d
Windows NT 5.0.2195 (Service Pack 1)
Why don't you ever see the headline "Psychic Wins Lottery"?




Re: Suggestions?

2001-06-27 Thread Chas Owens

On 27 Jun 2001 11:57:49 -0400, Bill Pierson wrote:
> Greetings all - I realize this is a very broad question, however any suggestions 
>would be appreciated.
> 
> I'm looking to purchase good learning tools about programming in PERL. I've been 
>programming with it for several years, but I've never truly learned the basics - just 
>looked at other code and learned from that.
> Specifically I'd like to learn from "ground zero" about variables, hashes, etc. as 
>well as MySQL connectivity.
> 
> I'd like to find something that is concise - I have several projects that I'll be 
>working on in the very near future, and fine-tuning my knowledge would be of great 
>benefit.
> 
> Again, any suggestions will be appreciated.
>

Canon:
Camel (_Programming Perl_ 3rd edition by Wall, et al)
Llama (_Learning Perl_ 2nd edition by Schwartz) (3rd will be out soon)

Should get:
_Object Oriented Perl_  by Conway
_Mastering Regular Expressions_ by Jeffrey E. F. Friedl
_Perl Cookbook_ by Tom Christiansen & Nathan Torkington

Good depending on you job:
_Programming the Perl DBI_   by Alligator Descartes & Tim Bunce
_Data Munging with Perl_ by David Cross


I hear that Manning is putting out a regexp book written by someone on
this list, but I can't remember his name (and am too lazy to search for
it).

--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
Keep the Lasagna flying!





Re: Joining variables

2001-06-27 Thread Chas Owens

On 27 Jun 2001 17:59:12 +0200, Aaron Craig wrote:
> Just to make it longwinded:
> 
> my $stuff = { $var1 => "-" , $var2 => "-" , $var3 => "-" };
> my $newvar = "";
> $newvar .= "$_$stuff->{$_}" foreach keys %{ $stuff };
> 

This is not guarenteed to produce the desired results (keys in a hash
have an unknown order) and $var3's value in the hash should by "" not
"-" (or you need to chop at the end).

> 
> At 11:45 27.06.2001 -0400, Chas Owens wrote:
> >On 27 Jun 2001 10:06:28 -0400, Chas Owens wrote:
> > > On 27 Jun 2001 14:37:14 +0100, Pierre Smolarek wrote:
> > > > > On Wed, Jun 27, 2001 at 02:07:22PM +0100, Pierre Smolarek wrote:
> > > > > > $newvar = $var1."-".$var2."-".$var3;
> > > > >
> > > > > or $newvar = "$var1-$var2-$var3";
> > > >
> > > > or
> > > >
> > > > $concat = '-';
> > > > $newvar .= $var1;
> > > > $newvar .= $concat;
> > > > $newvar .= $var2;
> > > > $newvar .= $concat;
> > > > $newvar .= $var3;
> > > >
> > > > dude, you should really look this up in a book.. its pre-basic perl
> > > >
> > > >
> > > or
> > >
> > > $newvar = join "-", ($var1, $var2, $var3);
> > >
> > > TMTOWTDI
> > >
> > > --
> > > Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
> > > Wibble.
> > >
> > >
> > >
> >
> >or
> >
> >$newvar='';$newvar .= "$_-" foreach ($var1, $var2, $var3); chop $newvar;
> >
> >or
> >
> >$newvar = sprintf "%04d-%02d-%02d", $var1, $var2, $var3;
> >
> >or
> >
> >$newvar =~ s/.*/$var1-$var2-$var3/;
> >
> >I think I need a life.
> >
> >--
> >Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
> >Kallisti!
> 
> Aaron Craig
> Programming
> iSoftitler.com
> 
> 
--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
Wibble.





Re: Incrementing Strings

2001-06-27 Thread Jos Boumans

ok, long day, let me write it like it IS
 concider:
 if ('a' == 'b') { print "foo" } # this will print 'foo', seeing 'a' compared to 'b'  
yields '1' even in
numeric context here
(ie, the RETURN value of the compare, not the representation of the characters)

sorry for the confusion and thanks for poining out the mistake

Chas Owens wrote:

> On 27 Jun 2001 17:45:18 +0200, Jos Boumans wrote:
> > > How do you mean?
> >
> > concider:
> > if ('a' == 'b') { print "foo" } # this will print 'foo', seeing 'a' and 'b' both 
>yield '1' in numeric
> > context here.
>
> You mean 0 not 1 don't you?
>
> >
> > however
> >
> > $x = 'a';
> > print $x + 4;
> >
> > will print '4';
> >
> > Jos Boumans
> >
> >
> > > Converting 'a' to a number gives 0.
> > >
> > > --
> > > Paul Johnson - [EMAIL PROTECTED]
> > > http://www.pjcj.net
> >
> >
> --
> Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
> Kallisti!




Re: Joining variables

2001-06-27 Thread Chas Owens

So we have:

$newvar = $var1."-".$var2."-".$var3;
$newvar = "$var1-$var2-$var3";

$concat = '-';
$newvar .= $var1;
$newvar .= $concat;
$newvar .= $var2;
$newvar .= $concat;
$newvar .= $var3;

$newvar = join "-", ($var1, $var2, $var3);
$newvar = join '', ($var1, '-', $var2, '-', $var3); #new varient
$newvar='';$newvar .= "$_-" foreach ($var1, $var2, $var3); chop $newvar;
$newvar = sprintf "%04d-%02d-%02d", $var1, $var2, $var3;
$newvar =~ s/.*/$var1-$var2-$var3/;

Does this answer your question ?  Anybody else want to add a few
ways?  I think I am tapped.
 
--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
Kallisti!





Re: Joining variables

2001-06-27 Thread Pierre Smolarek

 hahahahaha

 # This one has already been said, but hey.. thought i would make a bigger
 mess of it
 my ($newvar);
 my @new = ($var1,$cat,$var2,$cat,$var3);
 foreach (@new){
 $newvar .= $_;
 }

 #or

 # once again, already said, just making it obvious
 my @new = ($var1,$var2,$var3);
 $newvar = join("-",@new);

 #or even a bigger mess of the above.
 my (@new);
 push(@new, $var1);
 push(@new, $var2);
 push(@new, $var3);
 $newvar = join("-",@new);



> - Original Message -
> From: "Chas Owens" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, June 27, 2001 5:39 PM
> Subject: Re: Joining variables
>
>
> > So we have:
> >
> > $newvar = $var1."-".$var2."-".$var3;
> > $newvar = "$var1-$var2-$var3";
> >
> > $concat = '-';
> > $newvar .= $var1;
> > $newvar .= $concat;
> > $newvar .= $var2;
> > $newvar .= $concat;
> > $newvar .= $var3;
> >
> > $newvar = join "-", ($var1, $var2, $var3);
> > $newvar = join '', ($var1, '-', $var2, '-', $var3); #new varient
> > $newvar='';$newvar .= "$_-" foreach ($var1, $var2, $var3); chop $newvar;
> > $newvar = sprintf "%04d-%02d-%02d", $var1, $var2, $var3;
> > $newvar =~ s/.*/$var1-$var2-$var3/;
> >
> > Does this answer your question ?  Anybody else want to add a few
> > ways?  I think I am tapped.
> >
> > --
> > Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
> > Kallisti!
> >
>




FW: Joining variables

2001-06-27 Thread Andre Cavalcanti

@var=($var1,$var2,$var3);
$"="-";
$newvar="@var";


-Original Message-
From: Chas Owens [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 27, 2001 11:39 AM
To: [EMAIL PROTECTED]
Subject: Re: Joining variables


So we have:

$newvar = $var1."-".$var2."-".$var3;
$newvar = "$var1-$var2-$var3";

$concat = '-';
$newvar .= $var1;
$newvar .= $concat;
$newvar .= $var2;
$newvar .= $concat;
$newvar .= $var3;

$newvar = join "-", ($var1, $var2, $var3);
$newvar = join '', ($var1, '-', $var2, '-', $var3); #new varient
$newvar='';$newvar .= "$_-" foreach ($var1, $var2, $var3); chop $newvar;
$newvar = sprintf "%04d-%02d-%02d", $var1, $var2, $var3;
$newvar =~ s/.*/$var1-$var2-$var3/;

Does this answer your question ?  Anybody else want to add a few
ways?  I think I am tapped.
 
--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
Kallisti!


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com




Re: Best practice for config file use?

2001-06-27 Thread Jos I. Boumans

I usually use a config file for this
now you could do this 3 ways as i see it

-just have a file that holds a lot of global vars and 'require/use' that
in your mian script
-get one hashref that you globalise and thus reduce namespace pollution
-make it a module, give it a constructor returning a hashref and thus
not polluting *anything*

i usually use #2 for what it's worth

hth,

Jos Boumans

- Original Message -
From: "Tim Musson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 27, 2001 6:11 PM
Subject: Best practice for config file use?


>
>   I need to pass a number of parms to my program.  Is there a "best
>   Practice" for how to do this?  Command line is not something I want
>   to do.
>
>   I did search on "Config" from search.cpan.org, but it returned 99
>   modules!
>
>   Any suggestions?  In the past, I have done it by hand, but...
>
> --
> [EMAIL PROTECTED]
> Using The Bat! eMail v1.53d
> Windows NT 5.0.2195 (Service Pack 1)
> Why don't you ever see the headline "Psychic Wins Lottery"?
>
>




Re: FW: Joining variables

2001-06-27 Thread Randal L. Schwartz


> "Andre" == Andre Cavalcanti <[EMAIL PROTECTED]> writes:

Andre> @var=($var1,$var2,$var3);
Andre> $"="-";
Andre> $newvar="@var";

Please do this only within a local setting:

my $newvar = do { local $" = "-"; "@var" };

Otherwise, your $" will mess up the rest of the program.

And since this is just a tough way to say "join", I'd flunk it in
a code review.

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



Re: Joining variables

2001-06-27 Thread Jos I. Boumans

the obvious proof i have too much time:

for(join'',map{$_.=$:}@{[qw(2000 05 08)]}){s/\s//g&&chop&&print}

Jos


- Original Message - 
From: "Chas Owens" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 27, 2001 6:39 PM
Subject: Re: Joining variables


> So we have:
> 
> $newvar = $var1."-".$var2."-".$var3;
> $newvar = "$var1-$var2-$var3";
> 
> $concat = '-';
> $newvar .= $var1;
> $newvar .= $concat;
> $newvar .= $var2;
> $newvar .= $concat;
> $newvar .= $var3;
> 
> $newvar = join "-", ($var1, $var2, $var3);
> $newvar = join '', ($var1, '-', $var2, '-', $var3); #new varient
> $newvar='';$newvar .= "$_-" foreach ($var1, $var2, $var3); chop $newvar;
> $newvar = sprintf "%04d-%02d-%02d", $var1, $var2, $var3;
> $newvar =~ s/.*/$var1-$var2-$var3/;
> 
> Does this answer your question ?  Anybody else want to add a few
> ways?  I think I am tapped.
>  
> --
> Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
> Kallisti!
> 
> 
> 




Re: Suggestions?

2001-06-27 Thread Chris Hedemark

Someone recommended a SAMS book that will teach you perl in 21 days.  Get
the O'Reilly "Llama" book ("Learning Perl") and spend about an hour a day to
finish in less than a week and a half.

There are a few other O'Reilly titles I really like:

"Perl in a Nutshell" - great reference
"Perl for System Administration" - If you are a sysadmin or webmaster this
is a must-have.

I want to get "Programming Perl" (the Camel book) as well as their Win32
book (even though most of my work is currently in UNIX).

Chris Hedemark - Hillsborough, NC
http://yonderway.com
- Original Message -
From: "Bill Pierson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 27, 2001 11:57 AM
Subject: Suggestions?


Greetings all - I realize this is a very broad question, however any
suggestions would be appreciated.

I'm looking to purchase good learning tools about programming in PERL. I've
been programming with it for several years, but I've never truly learned the
basics - just looked at other code and learned from that.
Specifically I'd like to learn from "ground zero" about variables, hashes,
etc. as well as MySQL connectivity.

I'd like to find something that is concise - I have several projects that
I'll be working on in the very near future, and fine-tuning my knowledge
would be of great benefit.

Again, any suggestions will be appreciated.





RE: checking groups on unix

2001-06-27 Thread Stephen Nelson

Since you're doing a string compare on $groupname, you need to use 'ne', not
'!='.

 
 foreach my $file (@files) {
#getgrpid returns the group file entry for a given group id.
my $groupname = (getgrgid((stat($file))[5]))[0];
if ($groupname ne "groupname") {
print "$file has bad groupname: $groupname\n";
}
 }
 

(since "foo" == "bar" numerically)

> -Original Message-
> From: Chas Owens [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 27, 2001 3:11 AM
> To: [EMAIL PROTECTED]
> Subject: Re: checking groups on unix
>
>
>
> How to build @files is left as an exercise for the reader.
>
> 
> foreach my $file (@files) {
>   #getgrpid returns the group file entry for a given group id.
>   my $groupname = (getgrgid((stat($file))[5]))[0];
>   if ($groupname != "groupname") {
>   print "$file has bad groupname: $groupname\n";
>   }
> }
> 
>
>
> On 27 Jun 2001 09:59:07 +0100, PURMONEN, Joni wrote:
> > Hi ya,
> >
> > I need to check the group status on numerous files/directories,
> and haven't
> > been able to fing out the best way to do it with perl. I simply
> need to see
> > if some directories do not have certain group set on them.
> >
> > Can anyone give any pointers?
> >
> > Cheers,
> >
> > Joni
> >
> > Ps. I only have learning perl and some other fairly simple books which
> > didn't seem to have anything useful in them
> >
> --
> Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
> This statement is false.
>
>
>




Re[2]: Srting matching again

2001-06-27 Thread Maxim Berlin

Hello Yvonne,

Wednesday, June 27, 2001, Yvonne Murphy <[EMAIL PROTECTED]> wrote:

YM> The following is the complete code segment. I didn't use strict in the
YM> first half of the script because the Text:Tabs module would not work
YM> when I used it, so please don't hassle me about this. The main aim was
YM> to use C::Scan module to pick out the function declarations from a C
YM> header file. These are dumped to the 'functions2.log' file and this
YM> output is shown below also.

ok, here is explanation:

YM> #! /usr/local/bin/perl -w

YM> require 'dumpvar.pl';
YM> use Text::Tabs;
YM> use C::Scan;


YM> $tabstop = 1;

YM> $infile = "foo2.h"; #original header file to be parsed
YM> open(FOO2, "$infile") or die $!;
YM> @lines_with_tabs = ; #read header file into array
YM> close(FOO2);

open(FOO3, ">>foo3.h"); #open a new file to store the header file when
YM> tabs are removed
YM> select(FOO3);

YM> print expand(@lines_with_tabs,"\n"); #remove the tabs and print it to
YM> 'foo3.h' file

YM> $c = new C::Scan 'filename' => 'foo3.h'; #create a C::Scan pointing to
YM> the header file

YM> $decl_function = $c->get('fdecls'); #scan for function declarations

just a little surprise from C::Scan - after doing this call variable
$/=undef.

perdoc perlvar:

$INPUT_RECORD_SEPARATOR
$RS
$/
The input record separator, newline by default. 



YM>open(FILE, ">>functions2.log") or die $!; #file used to dump the
YM> functions declarations to later on.
YM> select(FILE);
YM>dumpValue({fdecls =>> $decl_function});#function decls dumped to file

YM> close (FILE);
YM> close (FOO3);

YM> print STDOUT "See functions2.log file for output\n\n";



YM> use strict;

YM> #this part is to remove the functions from the qoutes that
YM> #were added when the C::Scan was done.
YM> open (FUNCFILE, "functions2.log") or die $!;
open (OUTFILE, ">>thosecoolfuncs.log");
YM> my($mymatch,$line,@arr,$arr,$i);
YM> while ($mymatch = ) {

as $/ is undef, $mymatch contains all "functions2.log" up to undef,
i.e. to end of file. no more string-by-string reading. you can check
this by printing $mymatch at this point. All your troubles
follows from C::Scan.
so, you can:
1. forget about C::Scan module
2. make copy of $/ variable ( $save=$/; at start, and $/=$save; after
   C::Scan call )


Suggestions:
1. you can avoid more troubles by using something like

for(my $i=0; $i <= $#$decl_function; $i++)
{
 print FILE $$decl_function[$i],"\n";
}
instead of
dumpValue({fdecls =>> $decl_function});#function decls dumped to file

2. your algorythm does not handle multistring function definition.
   
YM>   # () required in "my($match) =" for list context
YM>  my($match) = $mymatch =~  m/\'(.+?)\;/gis;
YM>  print OUTFILE $match,  "\n\n" if $match;
YM> # if ($mymatch =~  m/\'(.+)\;/gis) { #matches anything between the
YM> single qoute and semi-colon and places it in the '$1' variable


YM> # print OUTFILE $1,  "\n\n";
YM>  # print OUTFILE $1,"{"," \n","}",  "\n\n";
YM>  # }
YM>   }
YM> close (OUTFILE);
YM> close (FUNCFILE);

YM> #This part is for breaking up the lines into individual
YM> #words so that I'll be able to reference them with
YM> #such variable names as $ret_type, $function_name,$param etc.

YM> #$numlines = 0;
YM> open (INFILE, "thosecoolfuncs.log") or die $!;


YM>  while ($line = ){
YM>   #chomp;
YM>   @arr = split(/[ (,)]+/, $line); #splits $line into words
YM>  #and stored in @arr.Words
YM>  #are separated by spaces,
YM>  #braces or commas.

YM>   for ($i=0; $i<=10; $i++) {

YM> print STDOUT $arr[$i],"\n";
YM> print STDOUT  "\n";
YM>}
YM>   }
YM> close INFILE
[...]

Best wishes,
 Maximmailto:[EMAIL PROTECTED]





DBI problems

2001-06-27 Thread SAWMaster

Hi group!  Just got back from a trip, and I'm a little rusty (a rusty newbie, JOY)

Anyway, before I left I was having trouble inserting new data into my database table, 
and oddly enough, the problem didn't solve itself while I was gone. :(

Here is my current code.  I've been racking my brain, and consulting the various books 
I have on lend from the library, with no success.  It looks right to me!  Can someone 
please help me out?

I'm using Windows 98 with ActiveState Perl on Apache Web server.

use cgi;
use DBI;   

$dbh = DBI->connect('dbi:ODBC:freq');  
DBI->trace( 2, 'errors.txt' ); 
   
$co = new CGI; 

print $co->header, $co -> start_html(title=>'Canadian Online Radio Frequency 
Database'),   
$co->center($co->h1('Thanks using our database!')), $co->h3('Here is what you 
submitted...'),$co->hr;#not done feedback yet   
print $co->hr;
print "Data Added\n";  
   
$newfreq=$co->param('txtFREQ');
$newloc=$co->param('txtLOC');
$newdesc=$co->param('txtDESC');
$newfreqtype=$co->param('txtFREQTYPE');
$newcat=$co->param('txtCAT');
$newcall=$co->param('txtCALL');
$newtx=$co->param('txtTX');
$sqlstatement = "INSERT INTO canfreqtable (freq, loc, desc, freqtype, cat, call, tx) 
VALUES (?,?,?,?,?,?,?)";
$sth = $dbh->prepare($sqlstatement) || die $dbh->errstr;
$sth->execute($newfreq, $newloc, $newdesc, $newfreqtype, $newcat, $newcall, $newtx) || 
die $dbh->errstr;
print "Thank you for submitting a frequency!";
print $co->end_html;



And here is what gets piped out to my errors.txt file.


  DBI 1.14-nothread dispatch trace level set to 2
-> prepare for DBD::ODBC::db (DBI::db=HASH(0x1b38790)~0x1b3a194 'INSERT INTO 
canfreqtable (freq, loc, desc, freqtype, cat, call, tx) VALUES (?,?,?,?,?,?,?)')
dbd_preparse scanned 7 distinct placeholders
dbd_st_prepare'd sql f32113660
 INSERT INTO canfreqtable (freq, loc, desc, freqtype, cat, call, tx) VALUES 
(?,?,?,?,?,?,?)
<- prepare= DBI::st=HASH(0x1b38880) at ADDTOF~1.PL line 29.
-> execute for DBD::ODBC::st (DBI::st=HASH(0x1b38880)~0x1b05b08 '11' 'MB' 
'TEST' 'VHF' 'FARM' 'TESTING' '2')
bind 1 <== '11' (attribs: )
bind 1 <== '11' (size 6/7/0, ptype 4, otype 1)
bind 1: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=6.
bind 2 <== 'MB' (attribs: )
bind 2 <== 'MB' (size 2/3/0, ptype 4, otype 1)
bind 2: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=2.
bind 3 <== 'TEST' (attribs: )
bind 3 <== 'TEST' (size 4/5/0, ptype 4, otype 1)
bind 3: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=4.
bind 4 <== 'VHF' (attribs: )
bind 4 <== 'VHF' (size 3/4/0, ptype 4, otype 1)
bind 4: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=3.
bind 5 <== 'FARM' (attribs: )
bind 5 <== 'FARM' (size 4/5/0, ptype 4, otype 1)
bind 5: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=4.
bind 6 <== 'TESTING' (attribs: )
bind 6 <== 'TESTING' (size 7/8/0, ptype 4, otype 1)
bind 6: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=7.
bind 7 <== '2' (attribs: )
bind 7 <== '2' (size 5/6/0, ptype 4, otype 1)
bind 7: CTy=1, STy=VARCHAR, CD=80, Sc=0, VM=5.
dbd_st_execute (for sql f32113660 after)...
st_execute/SQLExecute error -1 recorded: [Microsoft][ODBC Microsoft Access Driver] 
Syntax error in INSERT INTO statement. (SQL-37000)(DBD: st_execute/SQLExecute err=-1)
!! ERROR: -1 '[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT 
INTO statement. (SQL-37000)(DBD: st_execute/SQLExecute err=-1)'
<- execute= undef at ADDTOF~1.PL line 30.
-> errstr in DBD::_::common for DBD::ODBC::db (DBI::db=HASH(0x1b38790)~0x1b3a194)
<- errstr= ( '[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT 
INTO statement. (SQL-37000)(DBD: st_execute/SQLExecute err=-1)' ) [1 items] at 
ADDTOF~1.PL line 30.
-- DBI::END
-> disconnect_all for DBD::ODBC::dr (DBI::dr=HASH(0x1b7dda8)~0x1b387e4)
<- disconnect_all= '' at DBI.pm line 450.
-> DESTROY for DBD::ODBC::st (DBI::st=HASH(0x1b05b08)~INNER)
<- DESTROY= undef during global destruction.
-> DESTROY for DBD::ODBC::db (DBI::db=HASH(0x1b3a194)~INNER)
<- DESTROY= undef during global destruction.
-> DESTROY in DBD::_::common for DBD::ODBC::dr (DBI::dr=HASH(0x1b387e4)~INNER)
<- DESTROY= undef during global destruction.




Re: Suggestions?

2001-06-27 Thread Jos I. Boumans

so far i've read
learning perl (my first book a few months ago, really good, randal++)
programming perl
advanced perl programming

all of them were worth their cash... i'm looking for the conway book now and
i'd recommend these books to everyone

on a side note, you might also want to look at some online tutorials, as
well as the tuts that come with perl it self (like perlreftut)

hth,

Jos Boumans

- Original Message -
From: "Bill Pierson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 27, 2001 5:57 PM
Subject: Suggestions?


Greetings all - I realize this is a very broad question, however any
suggestions would be appreciated.

I'm looking to purchase good learning tools about programming in PERL. I've
been programming with it for several years, but I've never truly learned the
basics - just looked at other code and learned from that.
Specifically I'd like to learn from "ground zero" about variables, hashes,
etc. as well as MySQL connectivity.

I'd like to find something that is concise - I have several projects that
I'll be working on in the very near future, and fine-tuning my knowledge
would be of great benefit.

Again, any suggestions will be appreciated.




RE: checking groups on unix

2001-06-27 Thread Chas Owens

Arrrggg.  That is what I get for not testing my code before posting.

On 27 Jun 2001 11:05:35 -0700, Stephen Nelson wrote:
> Since you're doing a string compare on $groupname, you need to use 'ne', not
> '!='.
> 
>  
>  foreach my $file (@files) {
>   #getgrpid returns the group file entry for a given group id.
>   my $groupname = (getgrgid((stat($file))[5]))[0];
>   if ($groupname ne "groupname") {
>   print "$file has bad groupname: $groupname\n";
>   }
>  }
>  
> 
> (since "foo" == "bar" numerically)
> 
> > -Original Message-
> > From: Chas Owens [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, June 27, 2001 3:11 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: checking groups on unix
> >
> >
> >
> > How to build @files is left as an exercise for the reader.
> >
> > 
> > foreach my $file (@files) {
> > #getgrpid returns the group file entry for a given group id.
> > my $groupname = (getgrgid((stat($file))[5]))[0];
> > if ($groupname != "groupname") {
> > print "$file has bad groupname: $groupname\n";
> > }
> > }
> > 
> >
> >
> > On 27 Jun 2001 09:59:07 +0100, PURMONEN, Joni wrote:
> > > Hi ya,
> > >
> > > I need to check the group status on numerous files/directories,
> > and haven't
> > > been able to fing out the best way to do it with perl. I simply
> > need to see
> > > if some directories do not have certain group set on them.
> > >
> > > Can anyone give any pointers?
> > >
> > > Cheers,
> > >
> > > Joni
> > >
> > > Ps. I only have learning perl and some other fairly simple books which
> > > didn't seem to have anything useful in them
> > >
> > --
> > Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
> > This statement is false.
> >
> >
> >
> 
> 
--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
Umlaut Zebra über alles!





Wanted: Explanation of array slices used in hash creation

2001-06-27 Thread Peter Cline

After studying examples in "Effective Perl Programming" I devised the 
following working code snippet:

@people{@newkeys} = @$contact{sort keys %$contact};

I am trying to understand exactly how and why it works.
This appears in a subroutine that is passed a hash reference ($contact)
@newkeys is declared as a lexical in this subroutine, as is %people.

So I understand what sort keys %$contact is doing , it is simply 
dereferencing the hash reference, passing the resulting hash to the 
function keys and sorting the list returned.

I can see how something like

my ($mday,$month,$year) = (localtime)[3..5] #or whatever those indices 
should be

works. The parentheses put the return values of localtime into a list 
context which can then be indexed, correct?

Yet I'm still confused about the mechanics of how you can assign to an 
array slice of a hash. Anyone have a good explanation?

Thanks
Peter Cline
Inet Developer
New York Times Digital




subroutine as search string?

2001-06-27 Thread Noah Sussman

Hello, I am wondering how i can use a subroutine as the search string for
s//.

Specifically, I am trying to search through a large number of HTML documents
which contain an arrangement of similar (not identical!) table cells.  All I
want to do is rearange the order of the cells, but it seems innefecient to
do this:

s{
(\s*)
(\s*)
(\s*)
(\s*)
(\s*)
}{
$3 $1 $2 $5 $4
}gx;

when each of the parenthesized groupings above contains an almost identical
search string : (\s*), and it seems like I
should be able to do something like this:

s{
standard_search(Call Log)
standard_search(Billing Log)
standard_search(My Account)
standard_search(Help)
standard_search(Calling Plans)

}{
$3 $1 $2 $5 $4
}gx;

sub standard_search {
my $look_for = shift;
my $regex_is = "(

\s*)"
 return $regex_is;
}


Does anyone have ideas or code on how I could make this work?

Thanks so much!

-- 
Noah Sussman
Senior Web Developer
Deltathree, The IP Communications Network
75 Broad St, 31st Floor
New York, NY 10004
tel 212-500-4845
fax 212-500-4888
[EMAIL PROTECTED]
www.deltathree.com



"A foolish consistency is the hobgoblin of little minds."

-- Emerson 
 





Re: Joining variables

2001-06-27 Thread Chas Owens

On 27 Jun 2001 19:56:49 +0200, Jos I. Boumans wrote:
> the obvious proof i have too much time:
> 
> for(join'',map{$_.=$:}@{[qw(2000 05 08)]}){s/\s//g&&chop&&print}
> 
> Jos


Okay, I think you win.  Please let me know if my attempt at an
explaination of your abomination (modified slightly to be closer to the
rest of the other answers already in thread) is incorrect in any way.


#!/usr/bin/perl -w

use strict;

my $var1 = '2001';
my $var2 = "06";
my $var3 = "27";

my $newvar;

# $: is (by default) " \n-"
for(  #sets $_ to the value of the join below
join '',  #join every element of array created by map
  #with nothing as seperator
map{$_ .= $:} #take every element of array built below
  #and append $: (" \n-")
@{#dereference the arrayref about to be created
[$var1, $var2, $var3] #create an array ref to an array containing vars
}) {  #end of for loop declaration
   s/\s//g#remove all whitespace from $_ (gets rid of the 
  #" \n"s from the map)
   && #if substitute is successful then
   chop   #remove the last - from $_
   && #if chop is successful then
   ($newvar = $_) #assign date to $newvar
} #end of for

print "$newvar\n";


I feel dirty now.

--
Today is Pungenday, the 32nd day of Confusion in the YOLD 3167






Re:[OT]Joining variables

2001-06-27 Thread Paul


> On 27 Jun 2001 19:56:49 +0200, Jos I. Boumans wrote:
> > the obvious proof i have too much time:
> > for(join'',map{$_.=$:}@{[qw(2000 05 08)]}){s/\s//g&&chop&&print}

LOL!!!
Is there a list award for Obfuscation of the Day? =o)

Actually, that's beautiful, Jos.
Bravo. ;o]

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Wanted: Explanation of array slices used in hash creation

2001-06-27 Thread Jeff 'japhy' Pinyan

On Jun 27, Peter Cline said:

>After studying examples in "Effective Perl Programming" I devised the 
>following working code snippet:
>
>@people{@newkeys} = @$contact{sort keys %$contact};

All a slice is, is a list of elements of the structure.

  @array[1,3,5]

is

  ($array[1], $array[3], $array[5])

And

  @hash{$x, $y, $z} = @other{$m, $n, $o};

is

  ($hash{$x}, $hash{$y}, $hash{$z}) =
($other{$m}, $other{$n}, $other{$o});

So doing something like:

  @people{@newkeys} = @$contact{sort keys %$contact};

is doing this:

  1. sort the keys of %$contact
  2. access the VALUES of %$contact in that order
  3. assign to the values of %people, whose keys are in @newkeys

A long-winded expression would be:

  @values = @$contact{sort keys %$contact};

  for (@newkeys) {
$people{$_} = shift @values;
  }

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **





Re: Net::Telnet

2001-06-27 Thread Vrunda Prabhu

Matt:
I have a couple of questions regarding your code below.

1. I get an error when I include the statement 
use Term::Readkey

Should I be including anything else before it?  Where is the documentation
for Term::Readkey?

2. What is _stop.sh, and _start.sh referring to?

Thanks very much 
Vrunda


On Sat, 23 Jun 2001, Matt Cauthorn wrote:

> Here's some code that works well for us to bounce some apache instances across a
> cluster(obviously truncated). 
> 
> Notice how you stuff STDOUT from your remote call into an array that you print for
> output locally. This module rocks, and is (for us) blistering fast and super
> flexible. Also, I used Term::Readkey to prompt for (noecho) passwords so you don't
> have them sitting there in your code. 
> 
> foreach my $server (@cluster) {
> # Initialze the arrays to make sure they're not holding prev. values...
> my (@stop,@start);
> 
> my $s=Net::Telnet->new(Host=>$server,Input_log=>'telnet.txt') || die
> "Problem: $!\n";
>  
>  my $stop=qq(\./$server\_stop.sh);
>  my $start=qq(\./$server\_start.sh);
> ## Connection to telnet service on remote host
> $s->login(Name=> $user,
> Password=>$pass,
> Prompt=>'/root\@.*/',
> Timeout=>8) || die $s->errmsg, "\n";
> 
> @stop=$s->cmd(String=>$stop,Prompt=>'/matt\@.*/') or warn $s->errmsg ,"\n";
> print "Stopping $server: @stop\n";
> sleep 2;
> @start=$s->cmd(String=>$start,Prompt=>'/matt\@.*/') or warn $s->errmsg
> ,"\n";
> print "Starting $server";
> sleep 1;
> print "@start\n";
> }
> 
> The tricky part for me was to match the prompt after the command executed. I
> consider myself to be decent with regexes (for a relative beginner) but I had to
> fiddle with it for a while to get it happy. 
> 
> Hope this helps,
> Matt
> 
> 
> 
> --- Tom Yarrish <[EMAIL PROTECTED]> wrote:
> > Hey all,
> > Okay, I'm playing with Net::Telnet, and I've gotten to the point where I
> > connect to the other machine.  What I wanted to know is, can I run and
> > interact with a program just using the cmd() part of that module?  Or do I
> > need to use another module to do that.  Basically what I'm going is
> > telnetting to a server, then running a program (perl scripts actually),
> > then feeding it some options, and then exiting out of the program.  Sort
> > of like this (snipped)
> > 
> > $session->cmd("/home/export/user/Xmenu.pl");
> > $session->cmd("2"); # This is fed to the Xmenu.pl program
> > $session->cmd("1"); # and this
> > $session->cmd("y"); # and this
> > 
> > Thanks,
> > Tom
> > 
> > -- 
> > #!/usr/bin/perl -w # 526-byte qrpff, Keith Winstein and Marc Horowitz
> > <[EMAIL PROTECTED]> # MPEG 2 PS VOB file on stdin -> descrambled output
> > on stdout # arguments: title key bytes in least to most-significant order
> > $_='while(read+STDIN,$_,2048){$a=29;$c=142;if((@a=unx"C*",$_)[20]&48){$h=5;
> > $_=unxb24,join"",@b=map{xB8,unxb8,chr($_^$a[--$h+84])}@ARGV;s/...$/1$&/;$d=
> > unxV,xb25,$_;$b=73;$e=256|(ord$b[4])<<9|ord$b[3];$d=$d>>8^($f=($t=255)&($d
> > >>12^$d>>4^$d^$d/8))<<17,$e=$e>>8^($t&($g=($q=$e>>14&7^$e)^$q*8^$q<<6))<<9
> > ,$_=(map{$_%16or$t^=$c^=($m=(11,10,116,100,11,122,20,100)[$_/16%8])&110;$t
> > ^=(72,@z=(64,72,$a^=12*($_%16-2?0:$m&17)),$b^=$_%64?12:0,@z)[$_%8]}(16..271))
> > [$_]^(($h>>=8)+=$f+(~$g&$t))for@a[128..$#a]}print+x"C*",@a}';s/x/pack+/g;eval
> > 
> 
> 
> __
> Do You Yahoo!?
> Get personalized email addresses from Yahoo! Mail
> http://personal.mail.yahoo.com/
> 




Re: Converting Unix paths to windows

2001-06-27 Thread Chuck Ivy

On Wednesday, June 27, 2001, at 08:59 AM, [EMAIL PROTECTED] 
wrote:

Hi,
 I am writing a script to be used on Windows and many different 
flavors
of Unix.  I am looking for a good way to convert Unix paths to Windows.  
Any
Ideas?

Not exactly an answer to your question, but perhaps something that may 
be of use to you...

The following cross platform snippet (found somewhere on the web, I 
believe) will return the path of where the script is running.

if($0=~m#^(.*)\\#){ $cgidir = "$1"; }  # win/dos
elsif ($0=~m#^(.*)/# ){ $cgidir = "$1"; }  # Unix
else  {`pwd` =~ /(.*)/; $cgidir = "$1"; }  # Unix

I'm guessing you could use it to find a base directory, and then do 
relative stuff from there. You may also be able to use its test blocks 
to flag whether or not you're on a windows box and construct your 
relative paths accordingly. There are probably other ways that platform 
can be determined, but TMTOWTDI seems to be a credo around here.

Hope this helps.




Re: Joining variables

2001-06-27 Thread Jos I. Boumans

*applauds*

very good...
no need to feel dirty.. just feel that you have WAY too much spare time
trying to unobfuscate what i wrote =)

regards,

Jos

- Original Message -
From: "Chas Owens" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 27, 2001 8:42 PM
Subject: Re: Joining variables


> On 27 Jun 2001 19:56:49 +0200, Jos I. Boumans wrote:
> > the obvious proof i have too much time:
> >
> > for(join'',map{$_.=$:}@{[qw(2000 05 08)]}){s/\s//g&&chop&&print}
> >
> > Jos
> 
>
> Okay, I think you win.  Please let me know if my attempt at an
> explaination of your abomination (modified slightly to be closer to the
> rest of the other answers already in thread) is incorrect in any way.
>
> 
> #!/usr/bin/perl -w
>
> use strict;
>
> my $var1 = '2001';
> my $var2 = "06";
> my $var3 = "27";
>
> my $newvar;
>
> # $: is (by default) " \n-"
> for(  #sets $_ to the value of the join below
> join '',  #join every element of array created by map
>   #with nothing as seperator
> map{$_ .= $:} #take every element of array built below
>   #and append $: (" \n-")
> @{#dereference the arrayref about to be created
> [$var1, $var2, $var3] #create an array ref to an array containing vars
> }) {  #end of for loop declaration
>s/\s//g#remove all whitespace from $_ (gets rid of the
>   #" \n"s from the map)
>&& #if substitute is successful then
>chop   #remove the last - from $_
>&& #if chop is successful then
>($newvar = $_) #assign date to $newvar
> } #end of for
>
> print "$newvar\n";
> 
>
> I feel dirty now.
>
> --
> Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
>
>
>
>




Re[2]: Best practice for config file use?

2001-06-27 Thread Tim Musson

Hey Jos,

Not sure I understand entirely, but I think I usually do #2 also.

For example, I tend to do something like this in my code.  Comments
would be appreciated.  (I have not tried to run this particular bit,
for example, I was reading and think lc %Hash will tr all the hash
value chars to lower case, but I have not tested... ).

Is this what you are talking about?

my @FN = split (/\./, $0);
if (!-e "$FN[0].cfg") { # Create a cfg file (if it's not there...)
print qq[\n\tThe config file does not exist, creating $FN[0].cfg.
\tPlease check that the settings are what you need.\n\n];
CreateCFG();
} else { # read the cfg file
open(CONFIG, "<$FN[0].cfg") || die "Can't open $FN[0].cfg : $!";
while () { # process the Config file
chomp; s/#.*//; s/^\s+//; s/\s+$//; # clean the lines
next unless length; # anything left?
my ($Key, $Val) = split(/\s*=\s*/, $_, 2);
$Cfg{$Key} = "$Val\n"; # populate the hash
chomp $Cfg{$Key};
} # end while CONFIG
lc %Cfg; # no caps
} # end if/else create/use .cfg

sub CreateCFG {
open(CfgOUT, ">$FN[0].cfg") || die "Can't create $FN[0].cfg : $!";
print CfgOUT < I usually use a config file for this now you could do this 3 ways
JIB> as i see it

JIB> -just have a file that holds a lot of global vars and 'require/use' that
JIB> in your mian script
JIB> -get one hashref that you globalise and thus reduce namespace pollution
JIB> -make it a module, give it a constructor returning a hashref and thus
JIB> not polluting *anything*

JIB> i usually use #2 for what it's worth

>>
>>   I need to pass a number of parms to my program.  Is there a "best
>>   Practice" for how to do this?  Command line is not something I want
>>   to do.
>>
>>   I did search on "Config" from search.cpan.org, but it returned 99
>>   modules!
>>
>>   Any suggestions?  In the past, I have done it by hand, but...

-- 
[EMAIL PROTECTED]
Using The Bat! eMail v1.53d
Windows NT 5.0.2195 (Service Pack 1)
How do you make Windows faster ? Throw it harder




testing on symlinks

2001-06-27 Thread charles

is there a flag that will test to see if a file is a symlink? i am only
finding tests for directory, perms and such.

thanks
-charles




Re: testing on symlinks

2001-06-27 Thread Jeff 'japhy' Pinyan

On Jun 27, [EMAIL PROTECTED] said:

>is there a flag that will test to see if a file is a symlink? i am only
>finding tests for directory, perms and such.

Yes, it's the -l test.

  if (-l $foo) {
# symbolic link
print "$foo points to ", readlink($foo), "\n";
  }

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
**  Manning Publications, Co, is publishing my Perl Regex book  **




  1   2   >