Regex needed.

2003-01-21 Thread George P.

Hi,

my ($str) = "HI, HELLO, GREETINGS";
my ($reg) = "(BYE|HI|CIAO)";

if ($str =~ /$reg/)
{ print "Exists in $str\n"; }

The above code, will return true if BYE, HI or CIAO exists
in $str.
I want a regex to be put in $reg, which will return true
if neither BYE, HI nor CIAO exists in $str.

I could've done something like:
if ($str !~ /$reg/)
{ ... }

but, I don't want to change the code, just $reg.

I've been trying to find something in Programming Perl,
but couldn't.

Does anyone know how you can do this??

Thanks.

George P.


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




Re: My, our, local

2003-01-21 Thread John W. Krahn
Carlos Diaz wrote:
> 
> Can anyone explain in simple terms the difference between the three (my,
> our, local). Especially the difference between my and local. Thanks...

local is a leftover from pre-Perl5 versions.  It is used on package
(global) variables and does not define them it only affects the value of
the variable.

our defines package variables so they can be used in Perl5 when
strictures are enforced ("use strict".)

my defines and creates variables that are local to the current scope and
are not related to any package.

[I hope I got it right.  :-)]



John
-- 
use Perl;
program
fulfillment

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




Re: translation and its attachment

2003-01-21 Thread R. Joseph Newton
It's a pgp [Pretty Good Privacy] signature file--used to assure that this post is 
indeed from:
Mat Harris  OpenGPG Public Key ID: C37D57D9.

Netscape Messenger 4.x doesn't seem to know what to do with it when I try to open it.. 
The plug-in finder found no appropriate plug-ins, but presumably it has already put it 
to use under the surface, since his message showed in clear, readable text, while it 
was probably transmitted in some encrypted form.\

Joseph


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




Re: Upload - File Lock question

2003-01-21 Thread Mkrous
Thank you all for your replies,

>Play around with *FILEHANDLE.  For example:
>open FILEHANDLE, ">blah.txt";
>&closeFile( *FILEHANDLE );
>sub closeFile {
>   my $fh = shift;
>   print $fh "I closed you.\n";
>   close $fh;
>} 
Still I was not able to delete the file.


>you don't need to lock the file when you are deleting
>it. if you lock the file when you are reading /
writing >/ updating it, the deletion of the file 
>is block until the lock is released. the locking of
the >file when you are 
>trying to deleting it is uneccessary and might create
>dead lock while your 
>delete lock is waiting for the r/w/u lock but the
r/w/u >is again waiting 
>for the delete lock. does that make sense? if you
have >coded your lock 
>correctly when you are reading / writing / updating
the >file, you don't 
>have to lock the file when you are deleting it
because >the operation will 
>be blocked until your r/w/u lock is released. simply'
>unlink($filePath);' 
>should do it.
>david

I guess that in this case since unlink would not
honour the lock, then it could delete the file anyway,
but what would happen if i delete while a user has not
finished downloading?

I think of putting the files themselves in the
database
but it does not seem right to me.
Thanks once more for your valuable feedback.

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




Path to script

2003-01-21 Thread Brian Ling
Hi all,

I have the following bit of code that works out the directory path to
the currently executing script.

My $path = $0;
$path =~ s#(^/.+/).+$#$1# ;

This works but doesn't make me happy, is there a better way? 

Thanks

Brian 



BBCi at http://www.bbc.co.uk/

This e-mail (and any attachments) is confidential and may contain 
personal views which are not the views of the BBC unless specifically 
stated.
If you have received it in error, please delete it from your system, do 
not use, copy or disclose the information in any way nor act in 
reliance on it and notify the sender immediately. Please note that the 
BBC monitors e-mails sent or received. Further communication will 
signify your consent to this.




Re: Upload - File Lock question

2003-01-21 Thread Mark Goland
The problem is that you this lock is not mandetory, if you really really
want to lock the file, you have to set mendatory lock's. You have to setup a
system in which a user will be able to delete/create a file. you can setup
semaphore scheme.

Mark


- Original Message -
From: "Mkrous" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, January 21, 2003 3:59 AM
Subject: Re: Upload - File Lock question


> Thank you all for your replies,
>
> >Play around with *FILEHANDLE.  For example:
> >open FILEHANDLE, ">blah.txt";
> >&closeFile( *FILEHANDLE );
> >sub closeFile {
> >   my $fh = shift;
> >   print $fh "I closed you.\n";
> >   close $fh;
> >}
> Still I was not able to delete the file.
>
>
> >you don't need to lock the file when you are deleting
> >it. if you lock the file when you are reading /
> writing >/ updating it, the deletion of the file
> >is block until the lock is released. the locking of
> the >file when you are
> >trying to deleting it is uneccessary and might create
> >dead lock while your
> >delete lock is waiting for the r/w/u lock but the
> r/w/u >is again waiting
> >for the delete lock. does that make sense? if you
> have >coded your lock
> >correctly when you are reading / writing / updating
> the >file, you don't
> >have to lock the file when you are deleting it
> because >the operation will
> >be blocked until your r/w/u lock is released. simply'
> >unlink($filePath);'
> >should do it.
> >david
>
> I guess that in this case since unlink would not
> honour the lock, then it could delete the file anyway,
> but what would happen if i delete while a user has not
> finished downloading?
>
> I think of putting the files themselves in the
> database
> but it does not seem right to me.
> Thanks once more for your valuable feedback.
>
> __
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


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




RE: Path to script

2003-01-21 Thread NYIMI Jose (BMB)
C:\>perldoc File::Basename
NAME
fileparse - split a pathname into pieces

basename - extract just the filename from a path

dirname - extract just the directory from a path

SYNOPSIS
use File::Basename;

($name,$path,$suffix) = fileparse($fullname,@suffixlist)
fileparse_set_fstype($os_string);
$basename = basename($fullname,@suffixlist);
$dirname = dirname($fullname);

($name,$path,$suffix) =
fileparse("lib/File/Basename.pm","\.pm");
fileparse_set_fstype("VMS");
$basename = basename("lib/File/Basename.pm",".pm");
$dirname = dirname("lib/File/Basename.pm");

DESCRIPTION
These routines allow you to parse file specifications into useful
pieces
using the syntax of different operating systems.

fileparse_set_fstype
You select the syntax via the routine fileparse_set_fstype().

If the argument passed to it contains one of the substrings
"VMS",
"MSDOS", "MacOS", "AmigaOS" or "MSWin32", the file specification
syntax of that operating system is used in future calls to
fileparse(), basename(), and dirname(). If it contains none of
these
substrings, Unix syntax is used. This pattern matching is
case-insensitive. If you've selected VMS syntax, and the file
specification you pass to one of these routines contains a "/",
they
assume you are using Unix emulation and apply the Unix syntax
rules
instead, for that function call only.

If the argument passed to it contains one of the substrings
"VMS",
"MSDOS", "MacOS", "AmigaOS", "os2", "MSWin32" or "RISCOS", then
the
pattern matching for suffix removal is performed without regard
for
case, since those systems are not case-sensitive when opening
existing files (though some of them preserve case on file
creation).

If you haven't called fileparse_set_fstype(), the syntax is
chosen
by examining the builtin variable "$^O" according to these
rules.

fileparse
The fileparse() routine divides a file specification into three
parts: a leading path, a file name, and a suffix. The path
contains
everything up to and including the last directory separator in
the
input file specification. The remainder of the input file
specification is then divided into name and suffix based on the
optional patterns you specify in "@suffixlist". Each element of
this
list is interpreted as a regular expression, and is matched
against
the end of name. If this succeeds, the matching portion of name
is
removed and prepended to suffix. By proper use of "@suffixlist",
you
can remove file types or versions for examination.

You are guaranteed that if you concatenate path, name, and
suffix
-- More  --



> -Original Message-
> From: Brian Ling [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, January 21, 2003 10:25 AM
> To: [EMAIL PROTECTED]
> Subject: Path to script
> 
> 
> Hi all,
> 
> I have the following bit of code that works out the directory 
> path to the currently executing script.
> 
> My $path = $0;
> $path =~ s#(^/.+/).+$#$1# ;
> 
> This works but doesn't make me happy, is there a better way? 
> 
> Thanks
> 
> Brian 
> 
> 
> 
> BBCi at http://www.bbc.co.uk/
> 
> This e-mail (and any attachments) is confidential and may contain 
> personal views which are not the views of the BBC unless specifically 
> stated.
> If you have received it in error, please delete it from your 
> system, do 
> not use, copy or disclose the information in any way nor act in 
> reliance on it and notify the sender immediately. Please note 
> that the 
> BBC monitors e-mails sent or received. Further communication will 
> signify your consent to this.
> 
> 


 DISCLAIMER 

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

Thank you for your cooperation.

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


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




Re: Path to script

2003-01-21 Thread Mark Goland
my $path=`pwd` on *nix
my $path=`cd` on win*

- Original Message - 
From: "Brian Ling" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 21, 2003 4:25 AM
Subject: Path to script


> Hi all,
> 
> I have the following bit of code that works out the directory path to
> the currently executing script.
> 
> My $path = $0;
> $path =~ s#(^/.+/).+$#$1# ;
> 
> This works but doesn't make me happy, is there a better way? 
> 
> Thanks
> 
> Brian 
> 
> 
> 
> BBCi at http://www.bbc.co.uk/
> 
> This e-mail (and any attachments) is confidential and may contain 
> personal views which are not the views of the BBC unless specifically 
> stated.
> If you have received it in error, please delete it from your system, do 
> not use, copy or disclose the information in any way nor act in 
> reliance on it and notify the sender immediately. Please note that the 
> BBC monitors e-mails sent or received. Further communication will 
> signify your consent to this.
> 
> 

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




RE: Path to script

2003-01-21 Thread NYIMI Jose (BMB)
Have a look to :

http://search.cpan.org/author/LIBERTY/Cwd-2.06/Cwd.pm

José.


> -Original Message-
> From: Mark Goland [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, January 21, 2003 10:42 AM
> To: Brian Ling
> Cc: perl
> Subject: Re: Path to script
> 
> 
> my $path=`pwd` on *nix
> my $path=`cd` on win*
> 
> - Original Message - 
> From: "Brian Ling" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, January 21, 2003 4:25 AM
> Subject: Path to script
> 
> 
> > Hi all,
> > 
> > I have the following bit of code that works out the 
> directory path to 
> > the currently executing script.
> > 
> > My $path = $0;
> > $path =~ s#(^/.+/).+$#$1# ;
> > 
> > This works but doesn't make me happy, is there a better way?
> > 
> > Thanks
> > 
> > Brian
> > 
> > 
> > 
> > BBCi at http://www.bbc.co.uk/
> > 
> > This e-mail (and any attachments) is confidential and may contain
> > personal views which are not the views of the BBC unless 
> specifically 
> > stated.
> > If you have received it in error, please delete it from 
> your system, do 
> > not use, copy or disclose the information in any way nor act in 
> > reliance on it and notify the sender immediately. Please 
> note that the 
> > BBC monitors e-mails sent or received. Further communication will 
> > signify your consent to this.
> > 
> > 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


 DISCLAIMER 

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

Thank you for your cooperation.

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


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




RE: Path to script

2003-01-21 Thread Brian Ling
Thanks for that,

I'll go with the File::Basename option as I may need to change the 'pwd' by the time 
the call is made.

Brian 

-Original Message-
From: NYIMI Jose (BMB) [mailto:[EMAIL PROTECTED]] 
Sent: 21 January 2003 09:48
To: Mark Goland; Brian Ling
Cc: perl
Subject: RE: Path to script


Have a look to :

http://search.cpan.org/author/LIBERTY/Cwd-2.06/Cwd.pm

José.


> -Original Message-
> From: Mark Goland [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 21, 2003 10:42 AM
> To: Brian Ling
> Cc: perl
> Subject: Re: Path to script
> 
> 
> my $path=`pwd` on *nix
> my $path=`cd` on win*
> 
> - Original Message -
> From: "Brian Ling" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, January 21, 2003 4:25 AM
> Subject: Path to script
> 
> 
> > Hi all,
> > 
> > I have the following bit of code that works out the
> directory path to
> > the currently executing script.
> > 
> > My $path = $0;
> > $path =~ s#(^/.+/).+$#$1# ;
> > 
> > This works but doesn't make me happy, is there a better way?
> > 
> > Thanks
> > 
> > Brian
> > 
> > 
> > 
> > BBCi at http://www.bbc.co.uk/
> > 
> > This e-mail (and any attachments) is confidential and may contain 
> > personal views which are not the views of the BBC unless
> specifically
> > stated.
> > If you have received it in error, please delete it from
> your system, do
> > not use, copy or disclose the information in any way nor act in
> > reliance on it and notify the sender immediately. Please 
> note that the
> > BBC monitors e-mails sent or received. Further communication will
> > signify your consent to this.
> > 
> > 
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


 DISCLAIMER 

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

Thank you for your cooperation.

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



BBCi at http://www.bbc.co.uk/

This e-mail (and any attachments) is confidential and may contain 
personal views which are not the views of the BBC unless specifically 
stated.
If you have received it in error, please delete it from your system, do 
not use, copy or disclose the information in any way nor act in 
reliance on it and notify the sender immediately. Please note that the 
BBC monitors e-mails sent or received. Further communication will 
signify your consent to this.


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




RE: how to print array element & count

2003-01-21 Thread Eri Mendz
Dear All,

I'm greatly overwhelmed by your quick help to my problem. 
Here's the corrected code:

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

# filename: reverse_string.pl
# editor: # VIM - Vi IMproved 6.1 
# description: get user input and reverse input 

print "Please enter any string, to quit press Ctrl-Z:\n";
#im at work right now :-)
chomp(my @input = );
my $total_elements = scalar(@input);
print "You have entered $total_elements arguments.\n";
print "They are: \n";

foreach(1..$total_elements){
print "\t\[$_\] my $input[$_ - 1 ]\n";
}

print "Press enter to see inputs in reverse order: ";
my $press = ;
@input = reverse(@input);
print "The reverse -> @input \n";

Just a quickie. Why did scalar $input in the foreach loop 
"works" without predeclaring it with my? I tried running both 
and it runs as expected. No scoping required for this control 
variable?

Thanks a lot. It sure is nice to learn when there are helpful 
hands around. C yah.

-- 
Best wishes,
Eri Mendz [Windows XP Pro Version 2002]
This is perl, v5.8.0 built for MSWin32-x86-multi-thread


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




RE: Path to script

2003-01-21 Thread NYIMI Jose (BMB)
> -Original Message-
> From: Brian Ling [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, January 21, 2003 10:59 AM
> To: NYIMI Jose (BMB); Mark Goland
> Cc: perl
> Subject: RE: Path to script
> 
> 
> Thanks for that,
> 
> I'll go with the File::Basename option as I may need to 
> change the 'pwd' by the time the call is made.

Be aware that $0 doesn't always contains the full path of your script
Example: myhost:> ./myscript.pl
Running a script with above command line, $0 will be ./myscript.pl
So File::Basename will no longer help.

So I suggest you using FindBin module instead:

C:\>perldoc FindBin
NAME
FindBin - Locate directory of original perl script

SYNOPSIS
 use FindBin;
 use lib "$FindBin::Bin/../lib";

 or

 use FindBin qw($Bin);
 use lib "$Bin/../lib";

DESCRIPTION
Locates the full path to the script bin directory to allow the use of
paths relative to the bin directory.

This allows a user to setup a directory tree for some software with
directories /bin and /lib and then the above example will
allow the use of modules in the lib directory without knowing where the
software tree is installed.

If perl is invoked using the -e option or the perl script is read from
"STDIN" then FindBin sets both "$Bin" and "$RealBin" to the current
directory.

EXPORTABLE VARIABLES
 $Bin - path to bin directory from where script was invoked
 $Script  - basename of script from which perl was invoked
 $RealBin - $Bin with all links resolved
 $RealScript  - $Script with all links resolved

KNOWN BUGS
if perl is invoked as

   perl filename

and *filename* does not have executable rights and a program called
*filename* exists in the users "$ENV{PATH}" which satisfies both -x and
-T then FindBin assumes that it was invoked via the "$ENV{PATH}".

Workaround is to invoke perl as

 perl ./filename

AUTHORS
FindBin is supported as part of the core perl distribution. Please send
bug reports to <[EMAIL PROTECTED]> using the perlbug program included
with perl.

Graham Barr <[EMAIL PROTECTED]> Nick Ing-Simmons <[EMAIL PROTECTED]>

COPYRIGHT
Copyright (c) 1995 Graham Barr & Nick Ing-Simmons. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

> 
> Brian 
> 
> -Original Message-
> From: NYIMI Jose (BMB) [mailto:[EMAIL PROTECTED]] 
> Sent: 21 January 2003 09:48
> To: Mark Goland; Brian Ling
> Cc: perl
> Subject: RE: Path to script
> 
> 
> Have a look to :
> 
> http://search.cpan.org/author/LIBERTY/Cwd-2.06/Cwd.pm
> 
> José.
> 
> 
> > -Original Message-
> > From: Mark Goland [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, January 21, 2003 10:42 AM
> > To: Brian Ling
> > Cc: perl
> > Subject: Re: Path to script
> > 
> > 
> > my $path=`pwd` on *nix
> > my $path=`cd` on win*
> > 
> > - Original Message -
> > From: "Brian Ling" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Tuesday, January 21, 2003 4:25 AM
> > Subject: Path to script
> > 
> > 
> > > Hi all,
> > > 
> > > I have the following bit of code that works out the
> > directory path to
> > > the currently executing script.
> > > 
> > > My $path = $0;
> > > $path =~ s#(^/.+/).+$#$1# ;
> > > 
> > > This works but doesn't make me happy, is there a better way?
> > > 
> > > Thanks
> > > 
> > > Brian
> > > 
> > > 
> > > 
> > > BBCi at http://www.bbc.co.uk/
> > > 
> > > This e-mail (and any attachments) is confidential and may contain
> > > personal views which are not the views of the BBC unless
> > specifically
> > > stated.
> > > If you have received it in error, please delete it from
> > your system, do
> > > not use, copy or disclose the information in any way nor act in 
> > > reliance on it and notify the sender immediately. Please
> > note that the
> > > BBC monitors e-mails sent or received. Further communication will 
> > > signify your consent to this.
> > > 
> > > 
> > 
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> 
>  DISCLAIMER 
> 
> "This e-mail and any attachment thereto may contain 
> information which is confidential and/or protected by 
> intellectual property rights and are intended for the sole 
> use of the recipient(s) named above. 
> Any use of the information contained herein (including, but 
> not limited to, total or partial reproduction, communication 
> or distribution in any form) by other persons than the 
> designated recipient(s) is prohibited. 
> If you have received this e-mail in error, please notify the 
> sender either by telephone or by e-mail and delete the 
> material from any computer".
> 
> Thank you for your cooperation.
> 
> For further information about Proximus mobile phone services 
> please see our website at http://www.proximus.be or refer to 
> any Proximus agent.
> 
> 
> 
> BBCi at http://www.

Re: Path to script

2003-01-21 Thread Rob Dixon
"Brian Ling" wrote:
> Hi all,
>
> I have the following bit of code that works out the directory path to
> the currently executing script.
>
> My $path = $0;
> $path =~ s#(^/.+/).+$#$1# ;
>
> This works but doesn't make me happy, is there a better way?

If you're doing other path manipulation in the script then you could
use File::Spec or File::Basename, but otherwise all I can do is tidy
up your code for you:

my ($path) = $0 =~ m[^.+/]g;

What does it take to make you happy? :-D

Rob




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




RE: Path to script

2003-01-21 Thread Paul Johnson

Brian Ling said:

> Thanks for that,
>
> I'll go with the File::Basename option as I may need to change the 'pwd'
> by the time the call is made.

What you really want is the FindBin module.

perldoc FindBin

>> > I have the following bit of code that works out the
>> directory path to
>> > the currently executing script.
>> >
>> > My $path = $0;
>> > $path =~ s#(^/.+/).+$#$1# ;
>> >
>> > This works but doesn't make me happy, is there a better way?

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


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




Re: how to print array element & count

2003-01-21 Thread Rob Dixon

"Eri Mendz" <[EMAIL PROTECTED]> wrote in message
3E2D45F0.14555.14A0579@localhost">news:3E2D45F0.14555.14A0579@localhost...
> chomp(my @input = );
> my $total_elements = scalar(@input);

Assigning to a scalar variable puts the right-hand-side in scalar
context anyway.

my $total_elements = @input;

will do.

> print "You have entered $total_elements arguments.\n";
> print "They are: \n";
>
> foreach(1..$total_elements){
> print "\t\[$_\] my $input[$_ - 1 ]\n";
> }
>
> Just a quickie. Why did scalar $input in the foreach loop
> "works" without predeclaring it with my? I tried running both
> and it runs as expected. No scoping required for this control
> variable?

You're not actually using scalar $input, you're using $input[$_-1],
which is a scalar element of the array @input. You declared this
in your chomp() line at the start.

Cheers,

Rob




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




RE: Path to script

2003-01-21 Thread Brian Ling
Yep I did really want FindBin, as I did not know the possible problems with $0,



-Original Message-
From: NYIMI Jose (BMB) [mailto:[EMAIL PROTECTED]] 
Sent: 21 January 2003 10:13
To: Brian Ling; Mark Goland
Cc: perl
Subject: RE: Path to script


> -Original Message-
> From: Brian Ling [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 21, 2003 10:59 AM
> To: NYIMI Jose (BMB); Mark Goland
> Cc: perl
> Subject: RE: Path to script
> 
> 
> Thanks for that,
> 
> I'll go with the File::Basename option as I may need to
> change the 'pwd' by the time the call is made.

Be aware that $0 doesn't always contains the full path of your script
Example: myhost:> ./myscript.pl
Running a script with above command line, $0 will be ./myscript.pl So File::Basename 
will no longer help.

So I suggest you using FindBin module instead:

C:\>perldoc FindBin
NAME
FindBin - Locate directory of original perl script

SYNOPSIS
 use FindBin;
 use lib "$FindBin::Bin/../lib";

 or

 use FindBin qw($Bin);
 use lib "$Bin/../lib";

DESCRIPTION
Locates the full path to the script bin directory to allow the use of
paths relative to the bin directory.

This allows a user to setup a directory tree for some software with
directories /bin and /lib and then the above example will
allow the use of modules in the lib directory without knowing where the
software tree is installed.

If perl is invoked using the -e option or the perl script is read from
"STDIN" then FindBin sets both "$Bin" and "$RealBin" to the current
directory.

EXPORTABLE VARIABLES
 $Bin - path to bin directory from where script was invoked
 $Script  - basename of script from which perl was invoked
 $RealBin - $Bin with all links resolved
 $RealScript  - $Script with all links resolved

KNOWN BUGS
if perl is invoked as

   perl filename

and *filename* does not have executable rights and a program called
*filename* exists in the users "$ENV{PATH}" which satisfies both -x and
-T then FindBin assumes that it was invoked via the "$ENV{PATH}".

Workaround is to invoke perl as

 perl ./filename

AUTHORS
FindBin is supported as part of the core perl distribution. Please send
bug reports to <[EMAIL PROTECTED]> using the perlbug program included
with perl.

Graham Barr <[EMAIL PROTECTED]> Nick Ing-Simmons <[EMAIL PROTECTED]>

COPYRIGHT
Copyright (c) 1995 Graham Barr & Nick Ing-Simmons. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

> 
> Brian
> 
> -Original Message-
> From: NYIMI Jose (BMB) [mailto:[EMAIL PROTECTED]]
> Sent: 21 January 2003 09:48
> To: Mark Goland; Brian Ling
> Cc: perl
> Subject: RE: Path to script
> 
> 
> Have a look to :
> 
> http://search.cpan.org/author/LIBERTY/Cwd-2.06/Cwd.pm
> 
> José.
> 
> 
> > -Original Message-
> > From: Mark Goland [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, January 21, 2003 10:42 AM
> > To: Brian Ling
> > Cc: perl
> > Subject: Re: Path to script
> > 
> > 
> > my $path=`pwd` on *nix
> > my $path=`cd` on win*
> > 
> > - Original Message -
> > From: "Brian Ling" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Tuesday, January 21, 2003 4:25 AM
> > Subject: Path to script
> > 
> > 
> > > Hi all,
> > > 
> > > I have the following bit of code that works out the
> > directory path to
> > > the currently executing script.
> > > 
> > > My $path = $0;
> > > $path =~ s#(^/.+/).+$#$1# ;
> > > 
> > > This works but doesn't make me happy, is there a better way?
> > > 
> > > Thanks
> > > 
> > > Brian
> > > 
> > > 
> > > 
> > > BBCi at http://www.bbc.co.uk/
> > > 
> > > This e-mail (and any attachments) is confidential and may contain 
> > > personal views which are not the views of the BBC unless
> > specifically
> > > stated.
> > > If you have received it in error, please delete it from
> > your system, do
> > > not use, copy or disclose the information in any way nor act in
> > > reliance on it and notify the sender immediately. Please
> > note that the
> > > BBC monitors e-mails sent or received. Further communication will
> > > signify your consent to this.
> > > 
> > > 
> > 
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> 
>  DISCLAIMER 
> 
> "This e-mail and any attachment thereto may contain
> information which is confidential and/or protected by 
> intellectual property rights and are intended for the sole 
> use of the recipient(s) named above. 
> Any use of the information contained herein (including, but 
> not limited to, total or partial reproduction, communication 
> or distribution in any form) by other persons than the 
> designated recipient(s) is prohibited. 
> If you have received this e-mail in error, please notify the 
> sender either by telephone or by e-mail and delete the 

Re: how to print array element & count

2003-01-21 Thread John W. Krahn
Eri Mendz wrote:
> 
> Dear All,
> 
> I'm greatly overwhelmed by your quick help to my problem.
> Here's the corrected code:
> 
> #!/usr/bin/perl -w
> use strict;
> 
> # filename: reverse_string.pl
> # editor: # VIM - Vi IMproved 6.1
> # description: get user input and reverse input
> 
> print "Please enter any string, to quit press Ctrl-Z:\n";
> #im at work right now :-)
> chomp(my @input = );
> my $total_elements = scalar(@input);
> print "You have entered $total_elements arguments.\n";
> print "They are: \n";
> 
> foreach(1..$total_elements){
> print "\t\[$_\] my $input[$_ - 1 ]\n";
> }

You could also write this as:

foreach ( 1 .. @input ) {
print "\t[$_] my $input[ $_ - 1 ]\n";
}


> print "Press enter to see inputs in reverse order: ";
> my $press = ;
> @input = reverse(@input);
> print "The reverse -> @input \n";
> 
> Just a quickie. Why did scalar $input in the foreach loop
> "works" without predeclaring it with my? I tried running both
> and it runs as expected. No scoping required for this control
> variable?

If you are referring to:

foreach ( 0 .. $#input ) {

you will notice that input starts with $# and not $ so it is NOT the
scalar $input.  If you have an array, say @input, then $#input contains
the value of the index of the last element in @input so that $array[
$#array ] and $array[ -1 ] and $array[ @array - 1 ] all refer to the
same array element.



John
-- 
use Perl;
program
fulfillment

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




RE: Nested hash creation help !

2003-01-21 Thread Scot Needy

Thanks Jose!

I have the hash created and now can see the values
using Data::Dumper but now I an having trouble walking the hashtree.
Trying to walk back out to each leaf value in the tree.

Hash def
$time=>{$custname}{$custsub}{$site}{$YYMMDDay}{'start'} = $hhmmsss;


This doesn't seem to get anything but $c.

  foreach my $c (sort keys %time) {
 print "Cust $c\n";
 foreach my $cs (sort keys %{$time->{$c}}) {
foreach my $s (sort keys %{$time->{$c}->{$cs}}) {
 print "Site $c.$cs.$s \n"
 #..etc . next branch . etc
}
 }
  }


-Original Message-
From: NYIMI Jose (BMB) [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 20, 2003 6:11 AM
To: [EMAIL PROTECTED]; Beginners Perl
Subject: RE: Nested hash creation help !


Afterwards, to see how your nested hash looks like,
try this:

use Data::Dumper;
print Dumper(\%time);

José.

> -Original Message-
> From: Scot Needy [mailto:[EMAIL PROTECTED]]
> Sent: Monday, January 20, 2003 6:50 AM
> To: Beginners Perl
> Subject: Nested hash creation help !
>
>
> Hi;
>
>  Trying to crate a nested hash from variables parsed out of
> log files but
> as I am a "Beginner Perl' coder it is failing terribly. The
> basic question
> is given you have 5 variables how would you make a nested hash.
>
> Thanks !
> Scot
>
> I hope this is enough code to example my problem.
> -- snip --
> foreach (@wwwlogs) {
>   %time=();
>   ($wwwname,$cust,$YYMMDDay) = split('\.',$_);
>   open (LOG, $_ ) || die "Can't open $_!: $! \n";
>   while (LOG>) {
>   chomp;
>  # Walk through log file and look for our string.
>  ($pid,$hhmmss,$host,$custname,$custsub,$site,$junk)
> = split('\|',$_);
>  # print(SPLITVARS=
> $hhmmss,$host,$custname,$custsub,$site\n);
>  $time=>{$custname}=>{$custsub}=>{$site}=>{$YYMMDDay}
> = $hhmmss;
>
>   } etc etc etc
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


 DISCLAIMER 

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

Thank you for your cooperation.

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


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


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




Re: Adding new path to @INC

2003-01-21 Thread Jon
or

#! /usr/bin/perl -w

use lib qw(/path/to/your/stuff)

- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, January 20, 2003 4:14 PM
Subject: RE: Adding new path to @INC


Sure.
#!/usr/local/bin/perl

BEGIN {
   unshift (@INC, "Your/path/needed");
}

print "@INC\n";

good luck

YG

Original Message:
-
From: Nils-Anders Persson [EMAIL PROTECTED]
Date: Mon, 20 Jan 2003 16:05:52 +0100
To: [EMAIL PROTECTED]
Subject: Adding new path to @INC


Hello PERL-gurus,

I wonder if there is a way to add a new path to the @INC-array permanently
under UNIX and, if so, how to do it.

Regards,
Nils-Anders



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



mail2web - Check your email from the web at
http://mail2web.com/ .



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



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




Re: Perldoc?

2003-01-21 Thread Alan C.
Kevin Old wrote:

have noticed that the perldoc command isn't availableI've looked for


Doesn't that one use man ?

man html::parser

etc.

--
Alan.


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




IO::Getline Methode

2003-01-21 Thread Angerstein
...already searched cpan.

Has anybody an idea where I can get the Modul or Methode IO::Getline or
IO::Getlines

Are they only in Perl 5.8?
(I am using 5.0)

Thx,
Bastian


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




deleting files

2003-01-21 Thread Piotr
Hi all,

I am new to perl and I try to remove file with it,
but I don't known how :(
I find modules File::Copy, File::Find,  but not File::Delete :(

How can I do this ?

Peter


***r-e-k-l-a-m-a**

Chcesz oszczedzic na kosztach obslugi bankowej ?
mBIZNES - konto dla firm
http://epieniadze.onet.pl/mbiznes

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




RE: deleting files

2003-01-21 Thread NYIMI Jose (BMB)
C:\>perldoc -f unlink
unlink LIST
unlink  Deletes a list of files. Returns the number of files
successfully deleted.

$cnt = unlink 'a', 'b', 'c';
unlink @goners;
unlink <*.bak>;

Note: "unlink" will not delete directories unless you are
superuser and the -U flag is supplied to Perl. Even if these
conditions are met, be warned that unlinking a directory can
inflict damage on your filesystem. Use "rmdir" instead.

If LIST is omitted, uses "$_".


C:\>

> -Original Message-
> From: Piotr [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, January 21, 2003 1:34 PM
> To: [EMAIL PROTECTED]
> Subject: deleting files
> 
> 
> Hi all,
> 
> I am new to perl and I try to remove file with it,
> but I don't known how :(
> I find modules File::Copy, File::Find,  but not File::Delete :(
> 
> How can I do this ?
> 
> Peter
> 
> 
> 
> 
> ***r-e-k-l-a-m-a**
> 
> 
> 
> Chcesz oszczedzic na kosztach obslugi bankowej ?
> 
> mBIZNES - konto dla firm
> 
http://epieniadze.onet.pl/mbiznes

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



 DISCLAIMER 

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

Thank you for your cooperation.

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


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




Duplicate Mail

2003-01-21 Thread Paul Kraus
I just set up a new pc. For some reason I am getting double mail from
the list. Any ideas? It not just the mail where "my" email address is in
the header but every single message period.

Paul


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




RE: Duplicate Mail

2003-01-21 Thread Paul Kraus
Was a double filter. Fixed.

-Original Message-
From: Paul Kraus [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, January 21, 2003 8:22 AM
To: Perl
Subject: Duplicate Mail


I just set up a new pc. For some reason I am getting double mail from
the list. Any ideas? It not just the mail where "my" email address is in
the header but every single message period.

Paul


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


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




RE: My, our, local

2003-01-21 Thread wiggins


On Mon, 20 Jan 2003 21:11:56 -0600, "Carlos Diaz" <[EMAIL PROTECTED]> wrote:

> Can anyone explain in simple terms the difference between the three (my,
> our, local). Especially the difference between my and local. Thanks...
> 
> CD

I know you asked for simple, but I feel obligated:

http://perl.plover.com/FAQs/Namespaces.html

If you don't have the time now, then bookmark it and come back later, well worth the 
read.

http://danconia.org

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




RE: Regex needed.

2003-01-21 Thread Dan Muey


> Hi,
> 
> my ($str) = "HI, HELLO, GREETINGS";
> my ($reg) = "(BYE|HI|CIAO)";
> 
> if ($str =~ /$reg/)
>   { print "Exists in $str\n"; }
> 
> The above code, will return true if BYE, HI or CIAO exists
> in $str.
> I want a regex to be put in $reg, which will return true
> if neither BYE, HI nor CIAO exists in $str
> 
> I could've done something like:
> if ($str !~ /$reg/)
>   { ... }

Seems like if($str !~ /$reg/) {} would do what you want.
What exactly are you trying to do?

> 
> but, I don't want to change the code, just $reg.

Not sure that's possible and I can't really see what benefit you'd get anyway.

> 
> I've been trying to find something in Programming Perl,
> but couldn't.
> 
> Does anyone know how you can do this??
> 
> Thanks.
> 
> George P.
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




Re: slurping function like shell

2003-01-21 Thread Harry Putnam

Thanks for tips posters..

"John W. Krahn" <[EMAIL PROTECTED]> writes:

> You should _always_ verify that the file opened successfully.
>
> open(FILE,">somefile") or die "Cannot open 'somefile' $!";

Not being argumentative here but I've seen this said before.  Not
really sure why it is important.  I mean why is the open action
singled out for this protection.  It seems other actions could also
cause a misfired script?

>>   print FILE "An extra numeral <" . &lctime . "> appears\n";
>   ^
> You shouldn't use ampersands unless you need the different behavior they
> provide.
>
> print FILE "An extra numeral <" . lctime() . "> appears\n";

I use them simply for recognition in my own code.  I wasn't aware of
different behavior from the () indicator.  Can you aim me at some
documentation for elaboration?

> You should probably be using POSIX::strftime instead which is simpler
> and faster.

Thanks.



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




Re: slurping function like shell

2003-01-21 Thread Ben Siders
You should always perform all error checking in any language to ensure 
that your program, if it fails, declines gracefully.  One of the 
greatest shortcomings of C is that error checking is entirely manual, 
and you simply must, in every real-world application, check the return 
value of almost every function.  Perl is no different.  If the result of 
the statement fails in such a way that your program cannot continue, you 
must check for the error and deal with it appropriately.  If you need to 
write the output of the program to a file and it can't be opened, then 
you need to print it to the terminal or abort, or both, or at least 
inform the user of the condition.  People single out open probably 
because it's so common and when it fails it's almost always a 
show-stopping error.  Ultimately, in good programming practice, you 
should sanity check the result of any function that could make or break 
your application.  There are, obviously, some exceptions (I had to build 
a C program once for which speed was the #1 priority, which meant going 
light on error checking ), but that's just a good general rule.

Harry Putnam wrote:

Thanks for tips posters..

"John W. Krahn" <[EMAIL PROTECTED]> writes:

 

You should _always_ verify that the file opened successfully.

   open(FILE,">somefile") or die "Cannot open 'somefile' $!";
   


Not being argumentative here but I've seen this said before.  Not
really sure why it is important.  I mean why is the open action
singled out for this protection.  It seems other actions could also
cause a misfired script?

 

 print FILE "An extra numeral <" . &lctime . "> appears\n";
 

 ^
You shouldn't use ampersands unless you need the different behavior they
provide.

   print FILE "An extra numeral <" . lctime() . "> appears\n";
   


I use them simply for recognition in my own code.  I wasn't aware of
different behavior from the () indicator.  Can you aim me at some
documentation for elaboration?

 

You should probably be using POSIX::strftime instead which is simpler
and faster.
   


Thanks.



 


--
Benjamin J. Siders
Software Engineer




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




RE: My, our, local

2003-01-21 Thread Paul Kraus
Great article. Cleared up all of my confusion. However it did not touch
on "our". Anyone care to explain what its used for. 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, January 21, 2003 8:40 AM
To: Carlos Diaz; [EMAIL PROTECTED]
Subject: RE: My, our, local




On Mon, 20 Jan 2003 21:11:56 -0600, "Carlos Diaz" <[EMAIL PROTECTED]>
wrote:

> Can anyone explain in simple terms the difference between the three 
> (my, our, local). Especially the difference between my and local. 
> Thanks...
> 
> CD

I know you asked for simple, but I feel obligated:

http://perl.plover.com/FAQs/Namespaces.html

If you don't have the time now, then bookmark it and come back later,
well worth the read.

http://danconia.org

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


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




Re: slurping function like shell

2003-01-21 Thread Harry Putnam
"John W. Krahn" <[EMAIL PROTECTED]> writes:

> You should probably be using POSIX::strftime instead which is simpler
> and faster.
>
> use POSIX 'strftime';
>
> print FILE strftime( "An extra numeral <%D %T %w> appears\n",
> localtime );

Probably coming off like some kind of carpy here but I'm puzzled by
this.

Its a nice tip and new material for me to use.  But I don't really
see how its easier.

I'm guessing you say `easier' because its already written and all I
have to do is call it in and know the syntax.

Using this approach I'm required to remember the syntax for calling
strftime and the strftime operators when ever I need a specialized
date format.  Even if its usually the same one I want.

I had in mind a dating subroutine I could call that gives a dating
string I prefer in most cases (for log lines etc).  Without having to
remember date operators or other syntax.  Just its name.

That is, I would look up the operators once.  Put them in the
function and not ever think about them again.

To use the strftime example like that would require something similar
ie, writing a function that calls it in just the right way using
strftime, when ever needed.  In that case it seems it would be about
par either way.

My knowledge of perl is not very deep so I may be missing other
obvious advantages. I mean besides the mentioned speed factor.




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




Re: slurping function like shell

2003-01-21 Thread Harry Putnam
"John W. Krahn" <[EMAIL PROTECTED]> writes:

> You shouldn't use ampersands unless you need the different behavior they
> provide.

John,
I asked for a documentation pointer on this in a previous post that
hasn't hit the server here yet, but don't bother with that please.  I
found the info in perlfaq7... thanks.


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




Re: slurping function like shell

2003-01-21 Thread Ben Siders
strftime is an interface to a C function of the same name.  It's a 
fairly common function in many applications that have to deal with dates 
and times.  You may not need it here, but it's not a bad idea to get a 
little familiar with it.  For the life of me, I can't ever remember all 
the format characters, so I wouldn't sweat those kinds of details.  'man 
strftime' provides you with easy access to a well-organized list on 
almost any UNIX-like OS.

I don't know which would be easier for your specific case, but I like to 
encourage people to look into all the options.  Most of the format 
characters are intuitive, and there's some "shortcuts" to common 
formats.  I use this function specifically for timestamps on log 
messages because its versatile, fast, and simple.  Honestly. :)

Harry Putnam wrote:

"John W. Krahn" <[EMAIL PROTECTED]> writes:

 

You should probably be using POSIX::strftime instead which is simpler
and faster.

use POSIX 'strftime';

   print FILE strftime( "An extra numeral <%D %T %w> appears\n",
localtime );
   


Probably coming off like some kind of carpy here but I'm puzzled by
this.

Its a nice tip and new material for me to use.  But I don't really
see how its easier.

I'm guessing you say `easier' because its already written and all I
have to do is call it in and know the syntax.

Using this approach I'm required to remember the syntax for calling
strftime and the strftime operators when ever I need a specialized
date format.  Even if its usually the same one I want.

I had in mind a dating subroutine I could call that gives a dating
string I prefer in most cases (for log lines etc).  Without having to
remember date operators or other syntax.  Just its name.

That is, I would look up the operators once.  Put them in the
function and not ever think about them again.

To use the strftime example like that would require something similar
ie, writing a function that calls it in just the right way using
strftime, when ever needed.  In that case it seems it would be about
par either way.

My knowledge of perl is not very deep so I may be missing other
obvious advantages. I mean besides the mentioned speed factor.




 


--
Benjamin J. Siders
Software Engineer




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




Re: slurping function like shell

2003-01-21 Thread Harry Putnam
Ben Siders <[EMAIL PROTECTED]> writes:

> You should always perform all error checking in any language to ensure

Well thanks Ben.  That was nice full explanation and makes a lot of sense.


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




RE: My, our, local

2003-01-21 Thread Bob Showalter
Paul Kraus wrote:
> Maybe I am misunderstanding but that seems to be the exact same thing
> my does.

No. my() creates a new variable. our() refers to a global variable.

Try this:

  use strict;
  print "Global \$main::foo is at ", \$main::foo, "\n";
  our $foo = 'One';
  print "a: addr=", \$foo, ", val=$foo\n";
  {
  our $foo = 'Two';
  print "b: addr=", \$foo, ", val=$foo\n";
  }
  print "c: addr=", \$foo, ", val=$foo\n";

That produces output like:

  Global $main::foo is at SCALAR(0x81017b4)
  a: addr=SCALAR(0x81017b4), val=One
  b: addr=SCALAR(0x81017b4), val=Two
  c: addr=SCALAR(0x81017b4), val=Two

Note that there's only one variable involved, the global $main::foo. "our"
simply lets us refer to it without the main:: qualifier and have use strict
no complain. It does not create any new variables.

Now, change the "our" declarations to "my" and re-run. That produces output
like:

  Global $main::foo is at SCALAR(0x81017b4)
  a: addr=SCALAR(0x81017c0), val=One
  b: addr=SCALAR(0x8103854), val=Two
  c: addr=SCALAR(0x81017c0), val=One

Each "my" has created an entirely new variable. Inside the block, the first
"my" variable is hidden, so we only see the second one. Once the block ends,
the second variable goes out of scope, and the first one can be seen again.
The global, $main::foo is separate from either of these.

> 
> -Original Message-
> From: Bob Showalter [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 21, 2003 11:17 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: My, our, local
> 
> 
> Paul Kraus wrote:
> > Great article. Cleared up all of my confusion. However it did not
> > touch on "our". Anyone care to explain what its used for.
> 
> "our" provides a lexical scope (from the point of "our" to the end of
> the enclosing block or file) within which a global variable may be
> used without a package qualifier, even under "use strict".
> 
> It replaces the old vars pragma, which always had file scoping, IIRC.
> 
>use strict;
> 
>our $foo;
> 
>$foo = 1;# OK
> 
>{
>   our $bar;
>   $bar = 2; # OK
>}
> 
>$bar = 2;# ERROR: outside scope of "our" declaration
> 
> HTH


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




Re: My, our, local

2003-01-21 Thread Rob Dixon
Paul Kraus wrote:
> Great article. Cleared up all of my confusion. However it did not
> touch on "our". Anyone care to explain what its used for.

Hi Paul.

An 'our' variable has the same visibility as a 'my' variable declared
in the same place, i.e. through to the end of the current lexical
scope (block or file). Unlike 'my', however, it is a permanent
package variable and its value will be retained across calls to a
subroutine (unless modified elsewhere). It may be accessed
anywhere (even from another package) by fully qualifying it.

Take a look at this:

#!perl
use strict;
use warnings;

&a; # sets $main::val
&b; # prints '10'

print $val; # illegal - undeclared
print $main::val;   # prints '10'

sub a {
our $val = 10;
}

sub b {
our $val;
print $val;
}

__END_

HTH,

Rob





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




other new news ???

2003-01-21 Thread km
Hi all,

i have head that switch is introduced from perl 5.8. what are all the
other new additions to the perl???

enlighten me --
km


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




RE: other new news ???

2003-01-21 Thread Perry, Alan
[EMAIL PROTECTED] wrote:
> Hi all,
> 
> i have head that switch is introduced from perl 5.8. what are all the
> other new additions to the perl???

For a complete list of changes, go to:

http://dev.perl.org/perl5/news/2002/07/18/580ann/perldelta.html

Alan

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




Apples, Carrots, and Pecans

2003-01-21 Thread Bob Williams
I appreciate the input on my recent post for comparing apples and oranges.
Got it working great! Thanks. Now for some more food.

I have a directory: food. In the directory, there are three files: apple,
carrot, pecan. Each file has three descriptions each. Apple has: fruit red
round (as its three descriptions). Carrot has: vegetable orange long. Pecan
has: nut brown oval.

I would like a script that creates an array from the food directory -
apple:fruit:red:round . The next line would be carrot:vegetable:orange:long
. The third line would pecan:nut:brown:oval .

Thanks.

Bob Williams


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




RE: Apples, Carrots, and Pecans

2003-01-21 Thread Dan Muey

> I appreciate the input on my recent post for comparing apples 
> and oranges. Got it working great! Thanks. Now for some more food.
> 
> I have a directory: food. In the directory, there are three 
> files: apple, carrot, pecan. Each file has three descriptions 
How are the descriptions formatted ?

Apple.txt:
Fruit
Red
Round

Here's a qucik and dirty way. Obviously you'd probably want to do lot more my's in 
there and probably functions instead of backtick executions. But that will give you a 
basic outline of what needs done. 
If this isn't on unix the stuff in the backticks probably won't do you much good 
because windows stinks.

@list = ();
@files = `ls food`;
foreach $file(@files) {
my @content = `cat food/$file`;
$file .= ":";
foreach $line(@content) {
$file .= "$line\:";
}
$file =~ s/\:$//;
push(@list, $file);
}


Hope that helps

Dan

> each. Apple has: fruit red round (as its three descriptions). 
> Carrot has: vegetable orange long. Pecan
> has: nut brown oval.
> 
> I would like a script that creates an array from the food 
> directory - apple:fruit:red:round . The next line would be 
> carrot:vegetable:orange:long . The third line would 
> pecan:nut:brown:oval .
> 
> Thanks.
> 
> Bob Williams
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




Current package name

2003-01-21 Thread Beau E. Cox
Hi -

How do I get the current package name? For example,
if I have a module that starts with:

package Beau::Cool::Stuff;
...

and I want to give an error (die) later in this module:

...
die "invalid stuff passed to Beau::Cool::Stuff::function\n";
...

where is the 'package name variable' so I don't
have to type 'Beau::Cool::Stuff' all over the place?

Aloha => Beau;


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




RE: Current package name

2003-01-21 Thread wiggins
__PACKAGE__

3rd Camel, page 68, Literals

http://danconia.org 



On Tue, 21 Jan 2003 08:15:09 -1000, "Beau E. Cox" <[EMAIL PROTECTED]> wrote:

> Hi -
> 
> How do I get the current package name? For example,
> if I have a module that starts with:
> 
> package Beau::Cool::Stuff;
> ...
> 
> and I want to give an error (die) later in this module:
> 
> ...
> die "invalid stuff passed to Beau::Cool::Stuff::function\n";
> ...
> 
> where is the 'package name variable' so I don't
> have to type 'Beau::Cool::Stuff' all over the place?
> 
> Aloha => Beau;
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

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




a split(); question

2003-01-21 Thread justino berrun
#hello, is there a way to split a string between a digit and character 
#without losing the digit or the character
#Any help would be very appreciated

$string='hello...4546perl...2366Pogrammers..3435'; #e.g. would make three new 
strings

@newstrings=split(/(\d)([a-zA-Z])/,$string);   #<--- no success here
print join(":",@newstrings);

#working toward an output like so:
#hello...4546:perl...2366:Pogrammers..3435
-- 
__
http://www.linuxmail.org/
Now with POP3/IMAP access for only US$19.95/yr

Powered by Outblaze

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




Re: Current package name

2003-01-21 Thread Janek Schleicher
On Tue, 21 Jan 2003 08:15:09 +, Beau E. Cox wrote:

> How do I get the current package name? For example,
> if I have a module that starts with:

It's in 
__PACKAGE__


Greetings,
Janek

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




Re: a split(); question

2003-01-21 Thread Janek Schleicher
On Wed, 22 Jan 2003 02:46:27 +0800, Justino Berrun wrote:

> #hello, is there a way to split a string between a digit and character 
> #without losing the digit or the character
> #Any help would be very appreciated
> 
> $string='hello...4546perl...2366Pogrammers..3435'; #e.g. would make three new 
>strings
> 
> @newstrings=split(/(\d)([a-zA-Z])/,$string); #<--- no success here

use the look-ahead and look-behind features of regexes:

split /(?<=\d)(?=[a-zA-Z])/, $string


Greetings,
Janek

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




Re: how to print array element & count

2003-01-21 Thread R. Joseph Newton
"...
foreach(1..$total_elements){
print "\t\[$_\] my $input[$_ - 1 ]\n";
}
...Why did scalar $input in the foreach loop
"works" without predeclaring it with my?"  --Eri

HI Eri,

The my is probably not doing what you think it is.  Otherwise it would constitute a 
redeclaration error.  My guess is that you are creating an implicit anonymous scalar 
here:
print "\t\[$_\] (my $Phantom_scalar = $input[$_ - 1 ])\n";
You dont need to do this.  Perl should interpolate the element directly.

An underlying issue here is that you are using foreach to do the work of for.  The for 
function is designed to work on indices.  Use foreach to work on the elements 
directly, without reference to their indices.
my $element;
for  (1..$total_elements){
print "\t\[$_\] my $input[$_ - 1 ]\n";
}

Joseph




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




RE: a split(); question

2003-01-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
justino berrun wrote:
> #hello, is there a way to split a string between a digit and character
> #without losing the digit or the character
> #Any help would be very appreciated
> 
> $string='hello...4546perl...2366Pogrammers..3435'; #e.g. would
> make three new strings 
> 
> @newstrings=split(/(\d)([a-zA-Z])/,$string); #<--- no success
> here print join(":",@newstrings);
> 
> #working toward an output like so:
> #hello...4546:perl...2366:Pogrammers..3435
> --
> __
> http://www.linuxmail.org/
> Now with POP3/IMAP access for only US$19.95/yr
> 
> Powered by Outblaze
When you use split, the split portion is removed from the output, so
I don't believe that is what you are after.

Here is a quick snippet:

my $string='hello...4546perl...2366Pogrammers..3435'; #e.g. would make
three new strings 
while ( $string =~ /(\w+\.+\d+)/g ) { # looking for a combination of alpha,
periods and numerics
push(@newstrings, $1);
 }

print join(":",@newstrings);

#output:

hello...4546:perl...2366:Pogrammers..3435

Wags ;)



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



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




Need help parsing a DN

2003-01-21 Thread Paul Harwood
What would be the best method to parse the following DN? I just want the
first part of this DN so I can create a server list into an array
(EX-MSG-01, EXMSG-02 etc). I've tried using SPLIT but I am not sure how
to get the first part of the text I want. Any help appreciated. 

 

 

CN=EX-MSG-01,CN=Servers,CN=foreignlocation,CN=Administrative
Groups,CN=domain,CN=Microsoft
Exchange,CN=Services,CN=Configuration,DC=company,DC=domain,DC=com

 

 

 

--Paul




RE: Current package name

2003-01-21 Thread Beau E. Cox
__THANKS__  ;)

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 21, 2003 8:27 AM
> To: Beau E. Cox; 'Beginners
> Subject: RE: Current package name
> 
> 
> __PACKAGE__
> 
> 3rd Camel, page 68, Literals
> 
> http://danconia.org 
> 
> 
> 
> On Tue, 21 Jan 2003 08:15:09 -1000, "Beau E. Cox" 
> <[EMAIL PROTECTED]> wrote:
> 
> > Hi -
> > 
> > How do I get the current package name? For example,
> > if I have a module that starts with:
> > 
> > package Beau::Cool::Stuff;
> > ...
> > 
> > and I want to give an error (die) later in this module:
> > 
> > ...
> > die "invalid stuff passed to Beau::Cool::Stuff::function\n";
> > ...
> > 
> > where is the 'package name variable' so I don't
> > have to type 'Beau::Cool::Stuff' all over the place?
> > 
> > Aloha => Beau;
> > 
> > 
> > -- 
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> 


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




RE: how to print array element & count

2003-01-21 Thread Bob Showalter
R. Joseph Newton wrote:
> "...
> foreach(1..$total_elements){
> print "\t\[$_\] my $input[$_ - 1 ]\n";
> }
> ...Why did scalar $input in the foreach loop
> "works" without predeclaring it with my?"  --Eri
> 
> HI Eri,
> 
> The my is probably not doing what you think it is.  Otherwise
> it would constitute a redeclaration error.  My guess is that
> you are creating an implicit anonymous scalar here:
> print "\t\[$_\] (my $Phantom_scalar = $input[$_ - 1 ])\n";
> You dont need to do this.  Perl should interpolate the element
> directly. 

I don't know if that's what he wants to do, but that definitely is not
what's happening. the characters "my" in the string are just characters.
Perl isn't doing anything with them.

> 
> An underlying issue here is that you are using foreach to do
> the work of for.  The for function is designed to work on
> indices.  Use foreach to work on the elements directly,
> without reference to their indices.
> my $element;
> for  (1..$total_elements){
> print "\t\[$_\] my $input[$_ - 1 ]\n";
> }

>From perldoc perlsyn,

  The "foreach" keyword is actually a synonym for the "for"
  keyword, so you can use "foreach" for readability or "for"
  for brevity.  (Or because the Bourne shell is more famil-
  iar to you than csh, so writing "for" comes more natu-
  rally.)

Personally, I never use foreach. (Nor csh, for that matter :~)

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




RE: Current package name

2003-01-21 Thread Bob Showalter
Beau E. Cox wrote:
> Hi -
> 
> How do I get the current package name? For example,
> if I have a module that starts with:
> 
> package Beau::Cool::Stuff;
> ...
> 
> and I want to give an error (die) later in this module:
> 
> ...
> die "invalid stuff passed to Beau::Cool::Stuff::function\n"; ...
> 
> where is the 'package name variable' so I don't
> have to type 'Beau::Cool::Stuff' all over the place?
> 
> Aloha => Beau;

In addition to __PACKAGE__, you should be aware of the caller() function.
This will let you find the package of the routine that called yours. Helpful
if you want to put your error reporting routines in their own package. (cf.
Carp)

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




RE: Need help parsing a DN

2003-01-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Paul Harwood wrote:
> What would be the best method to parse the following DN? I just want
> the first part of this DN so I can create a server list into an array
> (EX-MSG-01, EXMSG-02 etc). I've tried using SPLIT but I am not sure
> how to get the first part of the text I want. Any help appreciated.
> 
> CN=EX-MSG-01,CN=Servers,CN=foreignlocation,CN=Administrative
> Groups,CN=domain,CN=Microsoft
> Exchange,CN=Services,CN=Configuration,DC=company,DC=domain,DC=com
> --Paul

If you only care for what comes after the first CN, then you could
do something like:

my $Myfile ;
if ( /^CN=([^,]+)/ ) { # collect into $1 everything up to the next
,(in this case EX-MSG-01)
   $Myfile = $1;
   }else {
 # no hit, so do what is necessary here
   }

Wags ;)


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



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




My list declaration

2003-01-21 Thread Paul Kraus

Can you define a list with my?

I tried 
 my ($var1, $var2) = 'something','something else';
I have also tried
 my ($var1, $var2 = 'something','something else');

Thanks.

Paul


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




Re: slurping function like shell

2003-01-21 Thread R. Joseph Newton
" ...
> open(FILE,">somefile") or die "Cannot open 'somefile' $!";

Not being argumentative here but I've seen this said before.  Not
really sure why it is important.  I mean why is the open action
singled out for this protection.  It seems other actions could also
cause a misfired script?
..."   --Harry

Hi Harry,

Your scepticism is appropriate here, although possibly for the wrong reason.  The die 
function can be very useful working in console mode, but it is hell for CGI debugging. 
 Since errors go into the server error log, which tends to be accessible only to the 
system admin, it can be damn near useless to have die statements in a CGI script.

File opening is particularly vulnerable to forces external to your program compared 
with other operations.  The basic concept is that if you don't have a source for your 
information, you have nothing to go on.  Still, unless further activity in your 
scri8pt can be destructive of data, it may not be necessary to die.  For cont3exts 
where die leaves me without sufficient information for debugging, I prefer print:

open (NEWMEMBERS, "< newmember.txt" or print " Sorry, file newmembers.txt did not 
open because $!\n";

Of course, I am now in debugging mode.  Before I release my CGI for public use, I will 
probably substitue a cleanup function:
$FileName = "newmember.txt"
open (NEWMEMBERS, "< $FileName" or SignalOpenFailureAndDie($FileName, $!);
where SignalOpenFailureAndDie() prints a page briefly explaining to the user why they 
are not getting expected results.

Joseph


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




Re: slurping function like shell

2003-01-21 Thread John W. Krahn
Harry Putnam wrote:
> 
> "John W. Krahn" <[EMAIL PROTECTED]> writes:
> 
> > You shouldn't use ampersands unless you need the different behavior they
> > provide.
> 
> John,
> I asked for a documentation pointer on this in a previous post that
> hasn't hit the server here yet, but don't bother with that please.  I
> found the info in perlfaq7... thanks.

perlsub contains the documentation on Perl's subroutines and should
answer all your questions.  :-)

perldoc perlsub


John
-- 
use Perl;
program
fulfillment

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




RE: My list declaration

2003-01-21 Thread Bob Showalter
Paul Kraus wrote:
> Can you define a list with my?
> 
> I tried
>  my ($var1, $var2) = 'something','something else';
> I have also tried
>  my ($var1, $var2 = 'something','something else');

Close! You need:

   my ($var1, $var2) = ('something', 'something else');

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




RE: My list declaration

2003-01-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Paul Kraus wrote:
> Can you define a list with my?
> 
> I tried
>  my ($var1, $var2) = 'something','something else';
> I have also tried
>  my ($var1, $var2 = 'something','something else');
> 
> Thanks.
> 
> Paul

When you say list, then hash comes to mind. So to do a list then you need
key and data.

my %MyList = ( 'key1', 'data1', 'key2, 'data2');

So the %MyList now has 
$MyList{key1} has data of 'data1'
and
$MyList{key2} has data of 'data2';

Wags ;)


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



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




RE: My list declaration

2003-01-21 Thread wiggins


On Tue, 21 Jan 2003 14:17:19 -0500, "Paul Kraus" <[EMAIL PROTECTED]> wrote:

> 
> Can you define a list with my?
> 
> I tried 
>  my ($var1, $var2) = 'something','something else';
> I have also tried
>  my ($var1, $var2 = 'something','something else');
> 

my ($var1, $var2) = ('something', 'something else');

http://danconia.org

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




Tie? Why?

2003-01-21 Thread Rob Richardson
Greetings!

I am beginning to seriously consider what I am going to have to do to
wrestle some reasonable amount of organization out of the unbelievable
pile of spaghetti I've been trying to update.  I managed to add what I
needed; now I'm going to go back and do it the way it should have been
done, mainly as an academic exercise.  

The new version of my script will be based on objects.  So, I was
reading the Camel Book (2nd ed) about objects.  It started talking
about "tie", and the process of tying variables to classes.  It went
into some detail about how to do it, but it didn't say a durn thing
about why o do it.  

Why would I want to "tie" a variable, and what actually happens when a
variable is tied?

Thanks!

RobR


__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




RE: slurping function like shell

2003-01-21 Thread Bob Showalter
R. Joseph Newton wrote:
> The die function can be very useful
> working in console mode, but it is hell for CGI debugging.
> Since errors go into the server error log, which tends to be
> accessible only to the system admin, it can be damn near
> useless to have die statements in a CGI script.

You might want to investigate CGI::Carp for an approach to this problem.

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




Win32 File Attribs Example.

2003-01-21 Thread Michael Kingsbury
Does anyone have an example of determinting the file attibute bits of a 
file?  I can get the bits, but have no easy way of determining what's 
what.  I'm using the Win32::File::GetAttributes function.  

-mike


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




Pack syntax

2003-01-21 Thread Paul Kraus
I am creating a simple database that needs to contain 3 fields.
Date, order number, tracking number.

I figured I would use a dbmhash and use pack to get the data in.
So my hash would be %hash{tracking_number}=$packeddata.

The date and order number are both strings.
So using the information I received from perldoc -f pack.
I determined that I need to use the format 'A'.
$stuffed = pack("A A", $date, $order);

All this does is steal the first character of each string.

So reading more I find that I need a quantifier so I tried *
$stuffed = pack("A* A*", $date, $order);
This stole the 1st char of $date and the second char of $order.

Any ideas?

Paul


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




Re: Tie? Why?

2003-01-21 Thread John W. Krahn
Rob Richardson wrote:
> 
> Greetings!

Hello,

> I am beginning to seriously consider what I am going to have to do to
> wrestle some reasonable amount of organization out of the unbelievable
> pile of spaghetti I've been trying to update.  I managed to add what I
> needed; now I'm going to go back and do it the way it should have been
> done, mainly as an academic exercise.
> 
> The new version of my script will be based on objects.  So, I was
> reading the Camel Book (2nd ed) about objects.

Ouch!  The second edition is out of date and wasn't very good (probably
because Randal was still involved :-) [Please don't hurt me Randal!]). 
The definitive book on Perl OO is "Object Oriented Perl" by Damian
Conway.  The best documentation is still the documents that are
installed with Perl.

perldoc perlmod
perldoc perlmodlib
perldoc perlboot
perldoc perltoot
perldoc perltootc
perldoc perlobj
perldoc perltie
perldoc perlbot



John
-- 
use Perl;
program
fulfillment

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




RE: Pack syntax

2003-01-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Paul Kraus wrote:
> I am creating a simple database that needs to contain 3 fields.
> Date, order number, tracking number.
> 
> I figured I would use a dbmhash and use pack to get the data in.
> So my hash would be %hash{tracking_number}=$packeddata.
> 
> The date and order number are both strings.
> So using the information I received from perldoc -f pack.
> I determined that I need to use the format 'A'.
>   $stuffed = pack("A A", $date, $order);
> 
> All this does is steal the first character of each string.
> 
> So reading more I find that I need a quantifier so I tried *
>   $stuffed = pack("A* A*", $date, $order);
> This stole the 1st char of $date and the second char of $order.
> 
> Any ideas?
> 
> Paul

Why do you say that? I ran under w2k AS 5.6.0 build 623 and placed
all in $stuffed. I printed it out and $stuffed had te data from both items
as one long stream.

Wags ;)



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



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




Re: other new news ???

2003-01-21 Thread Rob Dixon
[EMAIL PROTECTED] wrote:
> Hi all,
>
> i have head that switch is introduced from perl 5.8. what are all the
> other new additions to the perl???
>
> enlighten me --

Hi.

Take a look at "perldelta - what is new for perl v5.8.0" here:

http://dev.perl.org/perl5/news/2002/07/18/580ann/perldelta.html

HTH,

Rob







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




doubt in pattern matching

2003-01-21 Thread kasi ramanathen

dear friends:

i have a simple doubts in reguler exepration see the the passage that follows is 
stored in a variable by name v. in the fifth line see the words like this "Next 20 ^ " 
now i want delete all the charecter before ^- sign in my variable v.

shall i use find and replace to find all the pattern before ^ and repalce it with 
single space charecter. please mail me the actual code of pattern

$v="Description:

/flash/hp/pb/pbhp_84x28_blu_yahoo.gif"; var pb_width=84; var pb_height=28; var 
pb_FitNewWinHeight = new Array; var pb_FitNewWinWidth = new Array; 
pb_FitNewWinWidth[1] = 790; 

Description:

20 of 31,900,000 | Next 20 ^

Title: Java .Sun.com 

Description:

Sun's Java page, featuring developer resources, community, documentations, support, 
news, and more. java .sun.com/ search within ";

 

Catch all the cricket action. Download Yahoo! Score tracker


Re: a split(); question

2003-01-21 Thread Rob Dixon
Justino Berrun wrote:
> #hello, is there a way to split a string between a digit and character
> #without losing the digit or the character
> #Any help would be very appreciated
>
> $string='hello...4546perl...2366Pogrammers..3435'; #e.g. would
> make three new strings
>
> @newstrings=split(/(\d)([a-zA-Z])/,$string);#<--- no success
> here
> print join(":",@newstrings);
>
> #working toward an output like so:
> #hello...4546:perl...2366:Pogrammers..3435

Hi.

And another way. If you just need the colon-separated string and not
the intermediate array you might as well go straight there.

($newstring = $string) =~ s/(\d)([a-zA-Z])/$1:$2/g;

HTH,

Rob






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




RE: Pack syntax

2003-01-21 Thread Paul Kraus
You are of course correct. After some digging I seems that the problem
was in my unpack statement. When I actually checked the packed variable
all the data was there.

I was doing .. My ($a,$b) = unpack("A A",$buffer);
When I added ... Unpack "A* A*"
It sort of worked. It just unloads $buffer into $a.

Here is the snippet of code.
$date contains scalar(localtime).
$fields[0] contains a 10 character order number.

 $buffer = pack("A* A*",$date,$fields[0]);
print "\$buffer = $buffer\n";

my ($a, $b) = unpack("A* A*", $buffer);
print "\$a=$a\n\$b=$b\n";

Output
--
$buffer = Tue Jan 21 15:17:09 2003GULLIFER
$a=Tue Jan 21 15:17:09 2003GULLIFER
$b=

So know I am going to assume that pack and unpack could care less about
the data. The unpack needs to know the exact length of each record in
order to unpack the data correctly into separate variables.

If so then that really makes this useless to me :(
So all pack and unpack are is wrapped up '.' and substr.



-Original Message-
From: Wagner, David --- Senior Programmer Analyst --- WGO
[mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, January 21, 2003 3:02 PM
To: '[EMAIL PROTECTED]'; Perl
Subject: RE: Pack syntax


Paul Kraus wrote:
> I am creating a simple database that needs to contain 3 fields. Date, 
> order number, tracking number.
> 
> I figured I would use a dbmhash and use pack to get the data in. So my

> hash would be %hash{tracking_number}=$packeddata.
> 
> The date and order number are both strings.
> So using the information I received from perldoc -f pack.
> I determined that I need to use the format 'A'.
>   $stuffed = pack("A A", $date, $order);
> 
> All this does is steal the first character of each string.
> 
> So reading more I find that I need a quantifier so I tried *
>   $stuffed = pack("A* A*", $date, $order);
> This stole the 1st char of $date and the second char of $order.
> 
> Any ideas?
> 
> Paul

Why do you say that? I ran under w2k AS 5.6.0 build 623 and
placed all in $stuffed. I printed it out and $stuffed had te data from
both items as one long stream.

Wags ;)



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



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


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




Re: Need help parsing a DN

2003-01-21 Thread Rob Dixon
Paul Harwood wrote:
> What would be the best method to parse the following DN? I just want
> the first part of this DN so I can create a server list into an array
> (EX-MSG-01, EXMSG-02 etc). I've tried using SPLIT but I am not sure
> how to get the first part of the text I want. Any help appreciated.
>
> CN=EX-MSG-01,CN=Servers,CN=foreignlocation,CN=Administrative
> Groups,CN=domain,CN=Microsoft
> Exchange,CN=Services,CN=Configuration,DC=company,DC=domain,DC=com

Hi.

If you want to use split, this will work:

my $DN =
'CN=EX-MSG-01,CN=Servers,CN=foreignlocation,CN=Administr...';

my ($server) = split ',', $DN;  # 'CN=EX-MSG-01'
(undef, $server) = split '=', $server;  # 'EX-MSG-01'

HTH,

Rob








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




RE: doubt in pattern matching

2003-01-21 Thread Dan Muey

> dear friends:
Howdy
> 
> i have a simple doubts in reguler exepration see the the 
> passage that follows is stored in a variable by name v. in 
> the fifth line see the words like this "Next 20 ^ " now i 
> want delete all the charecter before ^- sign in my variable v.
> 
> shall i use find and replace to find all the pattern before ^ 
> and repalce it with single space charecter. please mail me 
> the actual code of pattern
> 
> $v="Description:
> 
> /flash/hp/pb/pbhp_84x28_blu_yahoo.gif"; var pb_width=84; var 
> pb_height=28; var pb_FitNewWinHeight = new Array; var 
> pb_FitNewWinWidth = new Array; pb_FitNewWinWidth[1] = 790; 
> 

What is all of the code above? Since its using special chars that may have problems.

To simply delete everything before the '^'

$description =~ s/^.*\^//;
That will remove everything before the last ^ you have. So if there are two carets 
then it will remove both.

Is that what you're trying to do or maybe you could elaborate a smidge more?

> Description:
> 
> 20 of 31,900,000 | Next 20 ^
> 
> Title: Java .Sun.com 
> 
> Description:
> 
> Sun's Java page, featuring developer resources, community, 
> documentations, support, news, and more. java .sun.com/ 
> search within ";
> 
>  
> 
> Catch all the cricket action. Download Yahoo! Score tracker
> 

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




Windows XP - xemacs - Color syntax

2003-01-21 Thread Paul Kraus
I have just installed xemacs on my windows xp machine. I am working in
mode cperl-mode. From my understanding it is supposed to have syntax
highlighting. Is this untrue of the windows port? Do I need to turn it
on somewhere?

Paul Kraus


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




RE: Pack syntax

2003-01-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Paul Kraus wrote:
> You are of course correct. After some digging I seems that the problem
> was in my unpack statement. When I actually checked the packed
> variable all the data was there.
> 
> I was doing .. My ($a,$b) = unpack("A A",$buffer);
> When I added ... Unpack "A* A*"
> It sort of worked. It just unloads $buffer into $a.
> 
> Here is the snippet of code.
> $date contains scalar(localtime).
> $fields[0] contains a 10 character order number.
> 
>  $buffer = pack("A* A*",$date,$fields[0]);
> print "\$buffer = $buffer\n";
> 
> my ($a, $b) = unpack("A* A*", $buffer);
> print "\$a=$a\n\$b=$b\n";
> 
> Output
> --
> $buffer = Tue Jan 21 15:17:09 2003GULLIFER
> $a=Tue Jan 21 15:17:09 2003GULLIFER
> $b=
> 
> So know I am going to assume that pack and unpack could care less
> about the data. The unpack needs to know the exact length of each
> record in order to unpack the data correctly into separate variables.
> 
> If so then that really makes this useless to me :(
> So all pack and unpack are is wrapped up '.' and substr.
> 

Paul,
Usually you have a set length that you are going with. SO date is 10
maybe and order # is 20, so you would use "A10A20" for the pack and unpack
to break out the data into variables or arrays.  The pack/unpack is really
for extracting from fix length record setups and/or getting of binary data
so you can work with it.  Not useless, but depends on what you are after and
what you want to do.

Wags ;)


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



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




Re: My list declaration

2003-01-21 Thread Rob Dixon
Bob Showalter wrote:
> Paul Kraus wrote:
>> Can you define a list with my?
>>
>> I tried
>>  my ($var1, $var2) = 'something','something else';
>> I have also tried
>>  my ($var1, $var2 = 'something','something else');
>
> Close! You need:
>
>my ($var1, $var2) = ('something', 'something else');

...but that's not a 'my' list, it's a list of 'my' scalars.

It's the same as:

my $var1 = 'something';
my $var2 = 'something else';

Is that what you want Paul? Or do you need an array:

my @var = ('something', 'something else');

Cheers,

Rob







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




RE: Pack syntax

2003-01-21 Thread Paul Kraus
I have two text files that are exported from our shipping computers each
night.

One is FedEx and contains a space delimitated file with two fields.
OrderNumber TrackingNumber

The other is UPS and contains a CSV file with two fields.
"OrderNumber","TrackingNumber"

I wanted to have a script that would dump both files into a simple 3
field database.
Trackingnumber(key),date,ordernumber.

I then was going to create a web page that could be used as a front end
to perform searches on these numbers.

My thinking was to just store them into a packed dmbhash. Seemed
reasonable as I think a full fledge DB would be overkill.

The problem is that the fields from the two files are of different
lengths meaning my original solution will not work. 

I guess I could create to dbm databases and have them both queried for
the search but that would be to easy.
I could also record the length of the fields in the first 4 characters
of the packed string and then use them as references but that seems
messy :)

XXYYDATA1DATA2
XX = length of datafield1
YY = length of datafield2

 Any other suggestions on a way to handle this?

Paul Kraus

-Original Message-
From: Wagner, David --- Senior Programmer Analyst --- WGO
[mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, January 21, 2003 3:37 PM
To: '[EMAIL PROTECTED]'; Wagner, David --- Senior Programmer Analyst
--- WGO; 'Perl'
Subject: RE: Pack syntax


Paul Kraus wrote:
> You are of course correct. After some digging I seems that the problem

> was in my unpack statement. When I actually checked the packed 
> variable all the data was there.
> 
> I was doing .. My ($a,$b) = unpack("A A",$buffer);
> When I added ... Unpack "A* A*"
> It sort of worked. It just unloads $buffer into $a.
> 
> Here is the snippet of code.
> $date contains scalar(localtime).
> $fields[0] contains a 10 character order number.
> 
>  $buffer = pack("A* A*",$date,$fields[0]);
> print "\$buffer = $buffer\n";
> 
> my ($a, $b) = unpack("A* A*", $buffer);
> print "\$a=$a\n\$b=$b\n";
> 
> Output
> --
> $buffer = Tue Jan 21 15:17:09 2003GULLIFER
> $a=Tue Jan 21 15:17:09 2003GULLIFER
> $b=
> 
> So know I am going to assume that pack and unpack could care less 
> about the data. The unpack needs to know the exact length of each 
> record in order to unpack the data correctly into separate variables.
> 
> If so then that really makes this useless to me :(
> So all pack and unpack are is wrapped up '.' and substr.
> 

Paul,
Usually you have a set length that you are going with. SO date
is 10 maybe and order # is 20, so you would use "A10A20" for the pack
and unpack to break out the data into variables or arrays.  The
pack/unpack is really for extracting from fix length record setups
and/or getting of binary data so you can work with it.  Not useless, but
depends on what you are after and what you want to do.

Wags ;)


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



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




RE: Tie? Why?

2003-01-21 Thread Bob Showalter
Rob Richardson wrote:
> Greetings!
> 
> I am beginning to seriously consider what I am going to have to do to
> wrestle some reasonable amount of organization out of the unbelievable
> pile of spaghetti I've been trying to update.  I managed to add what I
> needed; now I'm going to go back and do it the way it should have been
> done, mainly as an academic exercise.
> 
> The new version of my script will be based on objects.  So, I was
> reading the Camel Book (2nd ed) about objects.  It started talking
> about "tie", and the process of tying variables to classes.  It went
> into some detail about how to do it, but it didn't say a durn thing
> about why o do it. 
> 
> Why would I want to "tie" a variable, and what actually happens when
> a variable is tied? 

Tying a variable allows you to write code to handle the normal operations
against that variable. The classic case of this is tying a hash to an
external file or database, so you can write the normal:

   $hash{key} = "value";

and have code that automatically stores that value out to a database or
file.

Here's a real simple example with a scalar:

  #!/usr/bin/perl

  package Timestamp;
  use base qw/Tie::Scalar/;

  sub TIESCALAR { my $self; bless \$self, shift }
  sub FETCH { localtime }

  package main;

  tie $now, 'Timestamp';

  print "The time is $now\n";
  sleep 5;
  print "Now it's $now\n";

The tied variable $now will evaluate to a timestamp string whenever you use
it. This is because the interpolation of the variable in the print statement
(it could also have been a normal assignment or other expression) causes the
FETCH method of the class Timestamp to be called.

So $now is a "magic" variable that always evaluates to the current
timestamp.

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




Re: My, our, local

2003-01-21 Thread R. Joseph Newton
"...
Unlike 'my', however, it is a permanent
package variable and its value will be retained across calls to a
subroutine ..."  --Rob

Hi Rob,

So does this make it equivalent to a C-style static variable?
I've been trying to test it, and it seems to be impossible to even declare it using 
strict.  When I try to declare a variable as local, I get an error telling me that the 
global symbol needs an explicit package name.  When I try to modify an existing 
variable, I get an error saying that I can't modify a lexical variable.

Without strict, I have yet to find any configuration that would actually retain value 
between calls to a function.

Can you show any examples of local at work--preferably using strict?

Thanks,

Joseph

I do have a little demo for the our and my scoping, about the way I would use them.  I 
actually couldn't detect any difference when declared in the global scope, so I take 
the our declaration as a comment, to remind me that I've done something dumb by 
declaring in the global context.  Essentially, I would say that visibility protection 
comes down to the location of the declaration.

#!/usr/bin/perl -w

#use strict;

our $FirstName = "Robert";

FeedSub();
sub FeedSub {
  $MiddleName = "Joseph";
  my $LastName = "Newton";

  for (1...4) {
TestIt($LastName, $MiddleName);
   print "$LastName\n";
   print "$FirstName\n";
   print "$MiddleName\n";
  }
}

sub TestIt {
  my ($LastName, $MiddleName) = @_;
 print "$LastName\n";
 $MiddleName .= '_';
 $FirstName .= '_';
 print "$FirstName\n";
 print "$MiddleName\n";
 print "$LastName\n";
}



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




Re: Win32 File Attribs Example.

2003-01-21 Thread Rob Dixon
Michael Kingsbury wrote:
> Does anyone have an example of determinting the file attibute bits of
> a file?  I can get the bits, but have no easy way of determining
> what's what.  I'm using the Win32::File::GetAttributes function.
>

Hi Mike.

The bitmasks COMPRESSED, DIRECTORY, HIDDEN, NORMAL, OFFLINE,
READONLY, SYSTEM and TEMPORARY are exported byt the module.
You can check for each one with:

Win32::File::GetAttributes ('file.ext', my $attrs);
if ($attrs & SYSTEM) {
:
}

HTH,

Rob




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




RE: My list declaration

2003-01-21 Thread Paul Kraus
My ($var1,$var2) = ('something','something else');
Was exactly what I wanted. 

:)

-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, January 21, 2003 3:40 PM
To: [EMAIL PROTECTED]
Subject: Re: My list declaration


Bob Showalter wrote:
> Paul Kraus wrote:
>> Can you define a list with my?
>>
>> I tried
>>  my ($var1, $var2) = 'something','something else';
>> I have also tried
>>  my ($var1, $var2 = 'something','something else');
>
> Close! You need:
>
>my ($var1, $var2) = ('something', 'something else');

...but that's not a 'my' list, it's a list of 'my' scalars.

It's the same as:

my $var1 = 'something';
my $var2 = 'something else';

Is that what you want Paul? Or do you need an array:

my @var = ('something', 'something else');

Cheers,

Rob







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


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




RE: Pack syntax

2003-01-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Paul Kraus wrote:
> I have two text files that are exported from our shipping computers
> each night.
> 
> One is FedEx and contains a space delimitated file with two fields.
> OrderNumber TrackingNumber
> 
> The other is UPS and contains a CSV file with two fields.
> "OrderNumber","TrackingNumber"
> 
> I wanted to have a script that would dump both files into a simple 3
> field database.
> Trackingnumber(key),date,ordernumber.
> 
> I then was going to create a web page that could be used as a front
> end to perform searches on these numbers.
> 
> My thinking was to just store them into a packed dmbhash. Seemed
> reasonable as I think a full fledge DB would be overkill.
> 
> The problem is that the fields from the two files are of different
> lengths meaning my original solution will not work.
> 
> I guess I could create to dbm databases and have them both queried for
> the search but that would be to easy.
> I could also record the length of the fields in the first 4 characters
> of the packed string and then use them as references but that seems
> messy :)
> 
> XXYYDATA1DATA2
> XX = length of datafield1
> YY = length of datafield2
> 
>  Any other suggestions on a way to handle this?
> 
> Paul Kraus

Since you are going to be parsing the data anyway, why not just concatenate
together with a say ;, so you would have order#;Trackingnumber. Now for
presenting the data, you just split on the ;.  I do this, not in a CGI
presentation, but when gathering data and hold within a hash.

A thoght.

Wags ;)


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



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




RE: Pack syntax

2003-01-21 Thread Paul Kraus
Thanks!

I like to make more work for myself.

-Original Message-
From: Wagner, David --- Senior Programmer Analyst --- WGO
[mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, January 21, 2003 3:56 PM
To: '[EMAIL PROTECTED]'; Wagner, David --- Senior Programmer Analyst
--- WGO; 'Perl'
Subject: RE: Pack syntax


Paul Kraus wrote:
> I have two text files that are exported from our shipping computers 
> each night.
> 
> One is FedEx and contains a space delimitated file with two fields. 
> OrderNumber TrackingNumber
> 
> The other is UPS and contains a CSV file with two fields. 
> "OrderNumber","TrackingNumber"
> 
> I wanted to have a script that would dump both files into a simple 3 
> field database. Trackingnumber(key),date,ordernumber.
> 
> I then was going to create a web page that could be used as a front 
> end to perform searches on these numbers.
> 
> My thinking was to just store them into a packed dmbhash. Seemed 
> reasonable as I think a full fledge DB would be overkill.
> 
> The problem is that the fields from the two files are of different 
> lengths meaning my original solution will not work.
> 
> I guess I could create to dbm databases and have them both queried for

> the search but that would be to easy. I could also record the length 
> of the fields in the first 4 characters of the packed string and then 
> use them as references but that seems messy :)
> 
> XXYYDATA1DATA2
> XX = length of datafield1
> YY = length of datafield2
> 
>  Any other suggestions on a way to handle this?
> 
> Paul Kraus

Since you are going to be parsing the data anyway, why not just
concatenate together with a say ;, so you would have
order#;Trackingnumber. Now for presenting the data, you just split on
the ;.  I do this, not in a CGI presentation, but when gathering data
and hold within a hash.

A thoght.

Wags ;)


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



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




Re: My, our, local

2003-01-21 Thread R. Joseph Newton
"...
Hi Paul.

n 'our' variable has the same visibility as a 'my' variable declared
in the same place, i.e. through to the end of the current lexical
scope (block or file). Unlike 'my', however, it is a permanent
package variable and its value will be retained across calls to a
subroutine (unless modified elsewhere). It may be accessed
anywhere (even from another package) by fully qualifying it.
.."

The previous example I sent was a bit rough, due to a lack of symmetry in the code.  I 
also structured it to show the way I would use each scope identifier comment.  I say 
comment because I don't see a whit of difference between the actual behaviors.  I just 
tried substituting our for my in the line: "my ($LastName, $MiddleName) = @_;" and it 
behaved in exactly the same way.

Can you show us an example where they bvehave differently?

Thnaks,

Joseph


#!/usr/bin/perl -w

use strict;

our $FirstName = "Robert";
my $MiddleName = "Joseph";

FeedSub($MiddleName);
sub FeedSub {
  my $MiddleName = $_[0];
  my $LastName = "Newton";

  for (1...4) {
TestIt($LastName, $MiddleName);
   print "$FirstName\n";
   print "$MiddleName\n";
   print "$LastName\n";
  }
}

sub TestIt {
  my ($LastName, $MiddleName) = @_;
 $MiddleName .= '_';
 $FirstName .= '_';
 print "$FirstName\n";
 print "$MiddleName\n";
 print "$LastName\n";
}



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




Re: a split(); question

2003-01-21 Thread John W. Krahn
Rob Dixon wrote:
> 
> Justino Berrun wrote:
> > #hello, is there a way to split a string between a digit and character
> > #without losing the digit or the character
> > #Any help would be very appreciated
> >
> > $string='hello...4546perl...2366Pogrammers..3435'; #e.g. would
> > make three new strings
> >
> > @newstrings=split(/(\d)([a-zA-Z])/,$string);#<--- no success
> > here
> > print join(":",@newstrings);
> >
> > #working toward an output like so:
> > #hello...4546:perl...2366:Pogrammers..3435
> 
> Hi.
> 
> And another way. If you just need the colon-separated string and not
> the intermediate array you might as well go straight there.
> 
> ($newstring = $string) =~ s/(\d)([a-zA-Z])/$1:$2/g;

If you use look-ahead and look-behind as in Janek's example then you
don't need to capture anything to $1 and $2:

 ( my $newstring = $string ) =~ s/(?<=\d)(?=[a-zA-Z])/:/g;


John
-- 
use Perl;
program
fulfillment

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




Re: My, our, local

2003-01-21 Thread Rob Dixon
R. Joseph Newton wrote:
> "...
> Unlike 'my', however, it is a permanent
> package variable and its value will be retained across calls to a
> subroutine ..."  --Rob
>
> Hi Rob,
>
> So does this make it equivalent to a C-style static variable?

Sort of, but beware that any occurrence of 'our $var' in the same
package is the same variable. It's more like Fortran COMMON blocks
if that means anything to you?

> I've been trying to test it, and it seems to be impossible to even
> declare it using strict.

The main point of 'our' is that it lets you use package variable with
'use strict'. Any variable used without first declaring it as 'my' is
a package variable which won't go away. 'use strict' stops you
from using variables without first declaring them, and 'our' lets you
declare them after all.

> When I try to declare a variable as local,
> I get an error telling me that the global symbol needs an explicit
> package name.

That's 'use strict' helping you out! Forget about 'local' for now. All
it does is create a temporary copy of an existing global variable
for the duration of the current scope. The variable has to be
there first or 'use strict' will complain.

> When I try to modify an existing variable, I get an
> error saying that I can't modify a lexical variable.
>

You can't apply 'local' to anything but a global variable. A 'my'
variable is a local variable anyway, so there's no point in making
a temporary local copy of it.

>
> Without strict, I have yet to find any configuration that would
> actually retain value between calls to a function.
>

Easy. Try this:

#!perl
use strict;
use warnings;

sub p {
our $val;
print ++$val, "\n";
}

p;p;p;p;p;p;

__END__


>
> Can you show any examples of local at work--preferably using strict?
>

Like I said, forget about it. I've never used it except for temporarily
changing the value of a Perl predefined variable. For instance, enable
'slurp' mode like this:

my $buffer = do { local $/;  };

you can put

local $var = 'value'

but without the assignment it leaves the variable as 'undef'. The new
value only exists until the end of the scope (i.e. for the duration
of the ) after which Perl puts the old value back for you.

Don't use local apart from for this sort of thing.

>
> I do have a little demo for the our and my scoping, about the way I
> would use them.  I actually couldn't detect any difference when
> declared in the global scope, so I take the our declaration as a
> comment, to remind me that I've done something dumb by declaring in
> the global context.  Essentially, I would say that visibility
> protection comes down to the location of the declaration.
>
> #!/usr/bin/perl -w
>
> #use strict;
>
> our $FirstName = "Robert";

That's global variable $main::FirstName, but since you've
declared it at file level it's in scope all the way through.

>
> FeedSub();
> sub FeedSub {
>   $MiddleName = "Joseph";

$MiddleName is undeclared, so 'use strict' will barf on it.

>   my $LastName = "Newton";

A local variable. It will be reallocated and reassigned here
every time the sub is called.

>   for (1...4) {
> TestIt($LastName, $MiddleName);
>print "$LastName\n";
>print "$FirstName\n";
>print "$MiddleName\n";
>   }
> }
>
> sub TestIt {
>   my ($LastName, $MiddleName) = @_;

These two parameters passed by value from FeedSub() and
copied into local (non-persistent) variables.

>  print "$LastName\n";
>  $MiddleName .= '_';
>  $FirstName .= '_';

This is the only package variable that you're changing. It will
grow by one underscore per call if you look at your output
carefully.

>  print "$FirstName\n";
>  print "$MiddleName\n";
>  print "$LastName\n";
> }

I hope this helps. Cheers Joseph,

Rob




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




RE: Pack syntax

2003-01-21 Thread wiggins


On Tue, 21 Jan 2003 15:59:12 -0500, "Paul Kraus" <[EMAIL PROTECTED]> wrote:

> Thanks!
> 
> I like to make more work for myself.

In that case you could always just create your hash/array data structure and then use 
Storable and Freezethaw :-)

http://danconia.org

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




max floating point number

2003-01-21 Thread Konrad Foerstner
Hi,

does anybody know the maximum value of floating point numbers I could use
in Perl?

Konrad

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




looking for a string in multiple files

2003-01-21 Thread Marco
What I'm trying to achieve is the following:

I have an ASCII text file (zonelist.input) for input which contains a domainname (that 
is i.e. foo.com) on each line ( a total of about 230 lines are in this file).
Furthermore, I have 3 other text files.
I'm looking for a method to read each line from the input file and search for each 
string against the 3 other files and have the program tell me in which of the 3 files 
the string from the input file was found.
Would this be hard to achieve (I'm looking for some code)?

Sofar, I've tried the following code:

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

my ($file1, $file2, $file3) = ('boot.fixed', 'boot.wise', 'boot.dynamic.new');
my @input = `cat /data0/store/mars/pri/mars/named/zonelist.input`;
foreach my $result (@input) {
if ($result eq $file1) {
print "$result was found in $file1";
} elsif ($result eq $file2) {
print "$result was found in $file2";
} elsif ($result eq $file3) {
print "$result was found in $file3";
} else {
print "$result was not found in any file!\n";
}
}

This only prints each line of the input file with the final print statement appended 
to it. 

TIA

Gr,

-- 
Marco van Lienen <[EMAIL PROTECTED]>
GPG:0x8580E6CB Available on keyservers.
We are BitchX of Borg. You will be assimilated. Using mIRC is futile
 
S@H:6551WU/11.052yr --> setiathome.ssl.berkeley.edu Put those CPU cycles to use!
 
Why did it happen ? BOFH Excuse:
  Fatal error #6 occurred while trying to report error 6.



msg37029/pgp0.pgp
Description: PGP signature


RE: My, our, local

2003-01-21 Thread david
Bob Showalter wrote:

> Paul Kraus wrote:
>> Maybe I am misunderstanding but that seems to be the exact same thing
>> my does.
> 
> No. my() creates a new variable. our() refers to a global variable.

not sure what you mean by that. 'our' does create new variable if that 
variable does NOT already exists in the current package's symble table. 
otherwise, it shadows it.

'my' creates a new variable but only in the local lex. scope. the largest 
lex. scope in Perl is file which means all variable tagged with 'my' can 
never be visialbe outside of its current package because 'my' does not put 
any variable in the current package's symble table.

the following shows just that:

[panda@dzhuo]$ perl
my $a_variable = 1234;
/a_variable/ and print "$_\n" for(keys %::);
^D
[panda@dzhuo]$

print nothing because $a_variable is not in the package's symble table

the following, however, does find the variable:

[panda@dzhuo]$ perl
our $a_variable = 1234;
/a_variable/ and print "$_\n" for(keys %::);
^D
a_variable
[panda@dzhuo]$

because 'our' creates (if it doesn't already exists) and puts it in the 
package's symble table.

> 
> Try this:
> 
>   use strict;
>   print "Global \$main::foo is at ", \$main::foo, "\n";
>   our $foo = 'One';

the above does create a new variable.

>   print "a: addr=", \$foo, ", val=$foo\n";
>   {
>   our $foo = 'Two';

the 'our' keyword here has no effect. $foo already exists so it simply 
shadows the outsider scope. it's the same as "$foo = 'Two'". Because 'our' 
doesn't create a new variable (because it already exists), nothing is 
destoried after the block exit so the value 'Two' is retain even after the 
block. this is another difference between 'our' and 'local' because 'local' 
never creates new variable but does make local copy of the variable so the 
old value can be retained after the block exit.

david

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




Regular Expression - Search for Form Feed

2003-01-21 Thread Paul Kraus
How can I search for form feed. I have tried

/\f/

But I realize that the regexp engine doesn't use \f



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




RE: Regular Expression - Search for Form Feed

2003-01-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Paul Kraus wrote:
> How can I search for form feed. I have tried
> 
> /\f/
> 
> But I realize that the regexp engine doesn't use \f

But it does! page 72, Mastering Regular Expressions, Friedl.
Usually maps to ASCII  character, 014 octal.

Wags ;)


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



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




RE: My, our, local

2003-01-21 Thread Bob Showalter
david wrote:
> Bob Showalter wrote:
> 
> > Paul Kraus wrote:
> > > Maybe I am misunderstanding but that seems to be the exact same
> > > thing my does.
> > 
> > No. my() creates a new variable. our() refers to a global variable.
> 
> not sure what you mean by that. 'our' does create new variable if that
> variable does NOT already exists in the current package's symble
> table. otherwise, it shadows it.

No. See below.

> 
> 'my' creates a new variable but only in the local lex. scope. the
> largest lex. scope in Perl is file which means all variable tagged
> with 'my' can never be visialbe outside of its current package
> because 'my' does not put any variable in the current package's
> symble table. 

OK, fine. As I said, "my" creates a new variable.

> 
> the following shows just that:
> 
> [panda@dzhuo]$ perl
> my $a_variable = 1234;
> /a_variable/ and print "$_\n" for(keys %::);
> ^D
> [panda@dzhuo]$
> 
> print nothing because $a_variable is not in the package's symble table
> 
> the following, however, does find the variable:
> 
> [panda@dzhuo]$ perl
> our $a_variable = 1234;
> /a_variable/ and print "$_\n" for(keys %::);
> ^D
> a_variable
> [panda@dzhuo]$
> 
> because 'our' creates (if it doesn't already exists) and puts it in
> the package's symble table.

I think you're missing the point. Any reference to the symbol anywhere in
the program "creates" the variable, in the sense you indicated here.

For example:

   package Foo;
   our $x = 1;
   print "$_\n" for keys %Foo::;
   our $y = 1;

This prints:
   x
   y

So how did y get created "before" the our declaration? Ans: it is entered
into the symbol table at compile time. Take out the "our"'s and you get the
same results:

   package Foo;
   $x = 1;
   print "$_\n" for keys %Foo::;
   $y = 1;

So the "our" does not create a variable.

for instance:

   package Foo;
   use strict;
   $Foo::x = 1;
   our $x;
   print $x;# prints "1"

"our" simply lets us refer to $Foo::x without the $Foo:: part. It does not
create a new variable.

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




RE: My, our, local

2003-01-21 Thread david
Bob Showalter wrote:

> I think you're missing the point. Any reference to the symbol anywhere in
> the program "creates" the variable, in the sense you indicated here.
> 
> For example:
> 
>package Foo;
>our $x = 1;
>print "$_\n" for keys %Foo::;
>our $y = 1;
> 
> This prints:
>x
>y
> 
> So how did y get created "before" the our declaration? Ans: it is entered
> into the symbol table at compile time. Take out the "our"'s and you get

you are right and that's because Perl compiles the whole program before it 
start executing it. 'our $y = 1;' CREATES the varibale and it's in the 
symble table. you said earlier that 'our' does not create a new variable 
but that's not true. it's true that if the variable already exists in the 
current scrope then 'our' does not create it (it simply shadows it like 
'local') otherwise, that variable is created.

> 
> "our" simply lets us refer to $Foo::x without the $Foo:: part. It does not
> create a new variable.
>

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

#--
#-- you are saying that the following doesn't create $i?
#--
#-- you said it lets you refers $i somewhere else? Refer where?
#--
our $i = 1234;

#--
#-- where does $i come from if it isn't created in the above?
#--
print "$i\n";

__END__

> Take out the "our"'s and you get the same results:
>
> package Foo;
>   $x = 1;
>   print "$_\n" for keys %Foo::;
>   $y = 1;

that doesn't mean 'our' doesn't create the variable.

> 
> "our" simply lets us refer to $Foo::x without the $Foo:: part. It does not
> create a new variable.

so it does create a new variable. maybe we are referring to the same thing 
but with different terminology. i don't like to argue over things like 
that. i am done on this one.

david

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




Re: max floating point number

2003-01-21 Thread Wiggins d'Anconia
Konrad Foerstner wrote:

Hi,

does anybody know the maximum value of floating point numbers I could use
in Perl?



This is likely either system architecture (aka 32 bit vs. 64 bit) and/or 
memory size dependent.  And then there is the whole signed vs. unsigned 
thing, but all of that just makes my head hurt.

http://danconia.org


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



Re: IO::Getline Methode

2003-01-21 Thread Wiggins d'Anconia


Angerstein wrote:

...already searched cpan.

Has anybody an idea where I can get the Modul or Methode IO::Getline or
IO::Getlines

Are they only in Perl 5.8?
(I am using 5.0)



This appears to be a method(s) included as part of the IO::Handle 
module, which I believe became available around 5.6.  What is the last 
digit(s) of your perl version, aka 5.000xx??

From perldoc IO::Handle:

"$io->getline

This works like <$io> described in "I/O Operators" in perlop except that 
it’s more readable and can be safely called in a list context but still 
returns just one line.

$io->getlines

This works like <$io> when called in a list context to read all the 
remaining lines in a file, except that it’s more readable.  It will also 
croak() if accidentally called in a scalar context."

This is from a 5.8 install on RH 8.0.

http://danconia.org


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



Re: My list declaration

2003-01-21 Thread Janek Schleicher
On Tue, 21 Jan 2003 14:17:19 +, Paul Kraus wrote:

> Can you define a list with my?
> 
> I tried 
>  my ($var1, $var2) = 'something','something else';
> I have also tried
>  my ($var1, $var2 = 'something','something else');

Of course, but it like with mathematics.
If at the left side of a = is a list then there must be also a list at the
right side.

Try:

my ($var1, $var2) = ('something', 'something else');


Greetings,
Janek

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




Re: looking for a string in multiple files

2003-01-21 Thread Pete Emerson
> if ($result eq $file1)

This is checking to see if each line matches the filename itself, not the 
contents of file1. You were going for the contents of $file1, correct?

Here's my stab. Read in the target files first, then match.
When it walks through the source file, it will print out the name of all 
target files that match.

my $sourcefile='source';
my @targetfiles=('one', 'two', 'three');

my %dest;

foreach my $file (@targetfiles) {
open INFILE, $file or die "Can't open $file: $!\n";
while () {
chomp;
(defined $dest{$_}) ? ($dest{$_}=$dest{$_}.", $file") : ($dest{$_}=$file);
}
close INFILE;
}

open INFILE, $sourcefile or die "Can't open $sourcefile: $!\n";
while () {
chomp;
print "$_ was found in $dest{$_}\n" if (exists $dest{$_});
}
close INFILE;


On Tue, 21 Jan 2003, Marco wrote:

> I have an ASCII text file (zonelist.input) for input which contains a domainname 
>(that is i.e. foo.com) on each line ( a total of about 230 lines are in this file).
> Furthermore, I have 3 other text files.
> I'm looking for a method to read each line from the input file and search for each 
>string against the 3 other files and have the program tell me in which of the 3 files 
>the string from the input file was found.
> Would this be hard to achieve (I'm looking for some code)?





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




Bareword Constant from Package giving problems with use strict....

2003-01-21 Thread Michael Kingsbury
How do I use a (known) Bareword constant from a package when strict's on?  

-mike


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




RE: Bareword Constant from Package giving problems with use stric t....

2003-01-21 Thread Toby Stuart


> -Original Message-
> From: Michael Kingsbury [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 22, 2003 12:28 PM
> To: [EMAIL PROTECTED]
> Subject: Bareword Constant from Package giving problems with use
> strict
> 
> 
> How do I use a (known) Bareword constant from a package when 
> strict's on?  
> 

Try adding the following to your script:

no strict 'subs';

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




Re: Bareword Constant from Package giving problems with use strict....

2003-01-21 Thread simran
not sure what you mean... 

but perhaps the following might help:

* use constant ABC => 'this is some text';

* use vars ...



On Wed, 2003-01-22 at 12:28, Michael Kingsbury wrote:
> How do I use a (known) Bareword constant from a package when strict's on?  
> 
> -mike


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




Re: Bareword Constant from Package giving problems with use strict....

2003-01-21 Thread Michael Kingsbury
The Win32::File uses ARCHIVE, READONLY, SYSTEM, HIDDEN, etc as constants 
for use with the file attribute types.  However, with use strict, perl 
barfs due to a bareword.  




On 22 Jan 2003, simran wrote:

> not sure what you mean... 
> 
> but perhaps the following might help:
> 
> * use constant ABC => 'this is some text';
> 
> * use vars ...
> 
> 
> 
> On Wed, 2003-01-22 at 12:28, Michael Kingsbury wrote:
> > How do I use a (known) Bareword constant from a package when strict's on?  
> > 
> > -mike
> 
> 


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




Re: Bareword Constant from Package giving problems with use strict....

2003-01-21 Thread david
Michael Kingsbury wrote:

> The Win32::File uses ARCHIVE, READONLY, SYSTEM, HIDDEN, etc as constants
> for use with the file attribute types.  However, with use strict, perl
> barfs due to a bareword.
> 

they should be used the same way vars, subs are used. if they are exported, 
just use them. if they are not exported but is visible from outside the 
package they are declared, fully qualify them. example:

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

#--
#-- Dog.pm
#--
package Dog;

use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(HI);

#--
#-- Export by default
#--
use constant HI => "hi\n";

#--
#-- not exported but is visible outside of package
#--
use constant HELLO => "hello\n";

1;

__END__

then in another script:

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

use Dog;

print HI;
print Dog::Hello;

__END__

prints:

hi
hello

david

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




  1   2   >