[17569] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4989 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 29 18:05:59 2000

Date: Wed, 29 Nov 2000 15:05:21 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <975539121-v9-i4989@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 29 Nov 2000     Volume: 9 Number: 4989

Today's topics:
    Re: adduser <xzrgpnys@yvtugubhfrovm.pbz>
    Re: Authorising net access? nobull@mail.com
        Bash script to perl tool (Otto Wyss)
    Re: Bash script to perl tool <revjack@radix.net>
        Blind copy with sendmail <menno@streuper.nl>
    Re: Blind copy with sendmail (Flint Slacker)
    Re: Blind copy with sendmail <menno@streuper.nl>
    Re: Checking if file exists (filename contains a wildca <ana.dominguez@centurytel.com>
    Re: Coloured text in Win32 CMD window (Arek P)
    Re: Compile script to exe on many platforms (Tim Hammerquist)
    Re: Dates in perl <ubl@schaffhausen.de>
    Re: Dates in perl nobull@mail.com
    Re: Encrypting passwords <rob@frii.com>
    Re: Encrypting passwords dtbaker_dejanews@my-deja.com
    Re: Encrypting passwords <rob@frii.com>
    Re: Extracting substrings from strings (Flint Slacker)
    Re: Extracting substrings from strings (Tad McClellan)
        FAQ 4.23:   How do I expand tabs in a string? <faq@denver.pm.org>
        find function nodo70@my-deja.com
    Re: find function <tony_curtis32@yahoo.com>
    Re: for each file in dir ? <krahnj@acm.org>
    Re: Gotta weird problem...disappearing variables nobull@mail.com
    Re: how do i direct compiler errors to a file-newbie <joe+usenet@sunstarsys.com>
    Re: how do i direct compiler errors to a file-newbie <uri@sysarch.com>
    Re: how do i direct compiler errors to a file-newbie <bart.lateur@skynet.be>
    Re: How do I null terminate a string ? <uri@sysarch.com>
    Re: How do I null terminate a string ? <bart.lateur@skynet.be>
    Re: How do I null terminate a string ? andre_sanchez@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 29 Nov 2000 19:20:06 GMT
From: kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz>
Subject: Re: adduser
Message-Id: <3A255772.3D5507E3@yvtugubhfrovm.pbz>

Per- Fredrik Pollnow wrote:
> Hi,
> I'm doing a litel program, I'm a newbie @ perl, so please help me.
> Ok this is what the program is going to do:
> First the user run the program and enter all the information I need, thats
> no problem..
> The problem begins here:  when I got all the information I whant to crate an
> account with his name and a random password.
> The name I now erlier from the program, I don't whant the user to enter the
> password(the user gets an email with all the information and password later
> in the program).

Well, for starters it would be good to know what OS you are using...
Kevin
--
email: xzrgpnys@yvtugubhfrovm.pbz
Huh?  http://www.flactem.com/utils/rot13.html


------------------------------

Date: 29 Nov 2000 17:43:22 +0000
From: nobull@mail.com
Subject: Re: Authorising net access?
Message-Id: <u9y9y2oerp.fsf@wcl-l.bham.ac.uk>

Dominic Hibbs <mtx064@coventry.ac.uk> writes:

> On 28 Nov 2000 nobull@mail.com wrote:
> 
> > philhibbs@my-deja.com writes:
> > 
> > > I believe that I need LWP:UserAgent and that it will allow authenticated
> > > communication but I cannot find how to use this.  The perldoc pages are
> > > not very readable.
> > 
> > Can you go into more detail on the difficulty you have reading the
> > LWP::UserAgent perldoc?  Simply saying "are not very readable" doesn't
> > help anyone improve them.
> > 
> >        $ua->credentials($netloc, $realm, $uname, $pass)
> >            Set the user name and password to be used for a realm.
> 
> Quite possibly. I want to automatically get, and process the data in, some 
> pages which are username and password protected.
> 
> My program so far is
> 
> use strict;
> use LWP::UserAgent;
> my $ua = new LWP::UserAgent;
> my $netloc = "foo.net:80";
> my $realm = "coventry.ac.uk";
> my $uname = "d.hibbs";
> my $pass = "D0m1n1c";
> 
> $ua->credentials($netloc,$realm,$uname,$pass);
> 
> # url to fetch:
> my $url = "foo.net/dnacs/prot-doc/index.shtml";

$url should contain a valid absolute URL.  I suspect you meant:

my $url = "http://foo.net/dnacs/prot-doc/index.shtml";

> my $request = HTTP::Request->new('GET',$url);
> my $response = $ua->request($request);
> 
> my $page = $ua->content();

Should be $response->content()

> print $page;
> 
> The errors I get are
> 
> Use of uninitialized value at 
> /usr/opt/PERL5004/lib/perl5/site_perl/LWP/Protocol
> .pm line 110.

Not unreasonable, your URL lacked a protocol.

> Can't locate auto/LWP/UserAgent/content.al in @INC (@INC contains: 
> /usr/opt/PERL

Not unreasonable, LWP::UserAgent has no content() method.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Wed, 29 Nov 2000 22:05:28 +0100
From: otto.wyss@bluewin.ch (Otto Wyss)
Subject: Bash script to perl tool
Message-Id: <1ektxr3.1o286j4p01jpwN%otto.wyss@bluewin.ch>

Is there a tool, which converts a Bash shell script to a perl script?

O. Wyss


------------------------------

Date: 29 Nov 2000 21:41:06 GMT
From: revjack <revjack@radix.net>
Subject: Re: Bash script to perl tool
Message-Id: <903t5i$noi$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight

Otto Wyss explains it all:

:Is there a tool, which converts a Bash shell script to a perl script?

http://www.perl.com/pub/doc/manual/html/pod/perlfaq8.html#How_can_I_convert_my_shell_scrip

-- 
revjack@radix.net
stochasticgnosisthroughablativedissonance


------------------------------

Date: Wed, 29 Nov 2000 23:18:36 +0100
From: "Ab Abson" <menno@streuper.nl>
Subject: Blind copy with sendmail
Message-Id: <3a2580d9$0$681@reader5>

Hello,

I have the following code in my script:

open (MAIL, "|/usr/lib/sendmail -t") || &ErrorMessage("error opening
sendmail") ;
print MAIL "To: send\@mail.com\n"
print MAIL "From: from\@mail.com" ;
print MAIL "Subject: Something\n\n" ;
print MAIL "$my_mail,\n\n" ;
close (MAIL) ;

Is it possible to send also a copy or even a blind copy?

Thanx, Menno.





------------------------------

Date: Wed, 29 Nov 2000 22:24:16 GMT
From: flint@flintslacker.com (Flint Slacker)
Subject: Re: Blind copy with sendmail
Message-Id: <3a2781e4.102853789@news.tcn.net>


print MAIL "Bcc: $bcc\n";

Flint


On Wed, 29 Nov 2000 23:18:36 +0100, "Ab Abson" <menno@streuper.nl>
wrote:

>Hello,
>
>I have the following code in my script:
>
>open (MAIL, "|/usr/lib/sendmail -t") || &ErrorMessage("error opening
>sendmail") ;
>print MAIL "To: send\@mail.com\n"
>print MAIL "From: from\@mail.com" ;
>print MAIL "Subject: Something\n\n" ;
>print MAIL "$my_mail,\n\n" ;
>close (MAIL) ;
>
>Is it possible to send also a copy or even a blind copy?
>
>Thanx, Menno.
>
>



------------------------------

Date: Wed, 29 Nov 2000 23:38:10 +0100
From: "Ab Abson" <menno@streuper.nl>
Subject: Re: Blind copy with sendmail
Message-Id: <3a25856e$0$7794@reader2>

Thanx.


Flint Slacker <flint@flintslacker.com> schreef in berichtnieuws
3a2781e4.102853789@news.tcn.net...
>
> print MAIL "Bcc: $bcc\n";
>
> Flint
>





------------------------------

Date: Wed, 29 Nov 2000 12:43:12 -0600
From: Ana Dominguez <ana.dominguez@centurytel.com>
Subject: Re: Checking if file exists (filename contains a wildcard)
Message-Id: <3A254E40.BAED187F@centurytel.com>

Thanks for all the answers.

Here is a version of my code (my original code actually reads the file name
from a file. The name may be expressed in terms of environment variables to
give the full path and the name may contain *s as wildcard characters). The
script is checking for the existance of files with a certain pattern in their
names and if found, it would move them all to a different location):

   $sourcefile="/usr/myself/test/my*.txt";
   $targetdirectory="./test/";

    if (-e $sourcefile)
   {
         print "Source file exists\n";
         system "mv $sourcefile $targetdirectory" || die "failure $! \n";

    }
    else
    {
            print "Source file does not exist\n";
     }


"John W. Krahn" wrote:

> Ana Dominguez wrote:
> >
> > Hello,
> >
> > I have tried to use the -e function to determine if a file exists but my
> > filename contains *s in its name. The function always returns false. Is
>
> I just tried this and it does work.
>
> > there a different function that can be used? Do I have to use the
> > directory functions to determine if my file exists after getting the
> > list of existing files under a directory?
>
> Please show us your code.
>
> John



------------------------------

Date: Wed, 29 Nov 2000 14:51:14 EST
From: Arek@nospam._pietruszewski_.com (Arek P)
Subject: Re: Coloured text in Win32 CMD window
Message-Id: <903mni$12k7$1@earth.superlink.net>

On Thu, 23 Nov 2000 06:24:51 -0500, James <jamesmckay@MailAndNews.com>
wrote:

>Hi all,
>      Does anyone know of a way of outputing coloured text to a Dos window 
>on 
>WinNT via ActivePerl?
>Thanks in advance
>James
>


yeah, Win32::Console works very well for me...pardon my excitement
with us holiday :) , but check this out 

use Win32::Console;


$flag=new Win32::Console(STD_OUTPUT_HANDLE) ||die "Could not
create\n";
$user=Win32::LoginName();
$flag->Title("!! $user !!Let's Celebrate 4th of July!");
#save attr of current
$saved=$flag->Attr();




$indent= "\t\t";
$color=1;
print "\n\n\n";
for ($i=0;$i<5;$i++)
{
print $indent;
$flag->Attr($FG_WHITE|$BG_BLUE);
print "* " x 10;

if ($color)
		{
			
		$flag->Attr($FG_LIGHTRED|$BG_LIGHTRED);
		print " " x 20;
		$flag->Attr($saved);
		print "\n";
		$color=0;
		}
	else    {
		$flag->Attr($FG_WHITE|$BG_WHITE);
		print " " x 20;
		$flag->Attr($saved);
		print "\n";
		$color=1;	
		}

}

for ($i=0;$i<6;$i++)
{
if ($color)
		{
		print $indent;	
		$flag->Attr($FG_LIGHTRED|$BG_LIGHTRED);
		
		print " " x 40;
		$flag->Attr($saved);
		print "\n";
		$color=0;
		}
	else    {
		print $indent;
		$flag->Attr($FG_WHITE|$BG_WHITE);
		
		print " " x 40;
		$flag->Attr($saved);
		print "\n";
		$color=1;	

		}
}
print "\n";
sleep(2);


------------------------------

Date: Wed, 29 Nov 2000 18:56:45 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: Compile script to exe on many platforms
Message-Id: <slrn92alc5.f04.tim@degree.ath.cx>

kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz> wrote:
> Abigail wrote:
> > Neb (berube@odyssee.net) wrote:
> > ++ I have a script that I want to compile to exe on different platform (Unix
> > ++ and Windows).  Is it possible?
> > 
> > On Unix, you would use "cp" (compile perl).
> >     # cp program.pl program.exe
> > Abigail
> 
> This is just disturbing.

Satisfyingly enough, assuming exec permissions and a correct #! line in
the script, the legacy *nix cp command will "compile" *ahem* the script
into a nominal "exe" which will be executable.

 ...and Windoze users need never know the difference...

 ...regardless of whether or not Abigail was pulling any legs.  ;)

-- 
-Tim Hammerquist <timmy@cpan.org>
Programmers are achievement oriented; give them an impossible task,
and they'll do their best to give you what they think you would have
asked for if you had a clue as to what was possible.
	-- Peter Coffee, PC Week


------------------------------

Date: Wed, 29 Nov 2000 18:05:01 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Dates in perl
Message-Id: <3A25373D.D5471B83@schaffhausen.de>

sternr03@popmail.med.nyu.edu schrieb:
> 
> I need to find out the number of days between two dates. One idea I
> thought up for soing this is to use the localtime function and then
> take out the yday and subtract one yday from the other.
> 
> Is there a better way to do this?
> How do I pass a date such as 08/01/2000 into the localtime function

Check out Date::Calc.

Use ppm if you have ActivePerl, otherwise you'll find it at CPAN.

->malte


------------------------------

Date: 29 Nov 2000 17:48:59 +0000
From: nobull@mail.com
Subject: Re: Dates in perl
Message-Id: <u9u28qoeic.fsf@wcl-l.bham.ac.uk>

sternr03@popmail.med.nyu.edu writes:

> I need to find out the number of days between two dates.

See FAQ: "How can I compare two dates and find the difference?"

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Wed, 29 Nov 2000 13:15:50 -0700
From: Rob Greenbank <rob@frii.com>
Subject: Re: Encrypting passwords
Message-Id: <ajoa2t8spohqo3l1m45vkepleanbvoogqs@4ax.com>

Thanks to all that responded.  I had several great responses,
including this one, that pretty much confirm my orignal analysis.

There really isn't a good solution here, expecially since it's a perl
application and the Oracle I connect to is on another server, which
complicates it a bit more.  Any way it's done can still be analyzed by
someone with full access to the system.  The best I can do is make the
passwords secure.  

Unfortunately, the drive to eliminate all clear-text passwords
originated as a directive from upper management.  The simplest
solution I've found so far is still the compiled code, providing a
password as command line options to the compiler and doing a simple
scramble so "strings" won't hit it.  This is on a Unix host, so I can
then make the program execute only by group, owned by root, in a
secure directory, etc. etc. etc.

Bottom line is the O/S security will have to suffice, and eliminating
the clear text isn't a secure solution, but will satisfy management
and make it a little more difficult for someone to get in.

Thanks to all,

	Rob

On Tue, 28 Nov 2000 17:59:37 -0000, Chris Stith
<mischief@velma.motion.net> wrote:

>Rob Greenbank <rob@frii.com> wrote:
>> OK, I've searched Deja News and haven't seen anyone
>> with an acceptable solution to my problem.
>
>Good. That's the right time to post a question. ;)
>
>> I have a number of perl scripts that connect to
>> databases (Oracle).  That connection requires a
>> password, and obviously we would prefer to not
>> store that password in clear text.  
>
>There's a certain level of information that can't
>be encrypted if you want to decrypt other data.
>That's a hard fact of crypto.
>
>> The obvious solution is to encrypt the password
>> somehow.
>
>You still need something unencrypted to decrypt
>the password.
>
>> If I'm using perl, however, the information
>> on how to decrypt the password is stored in
>> human readable form.
>
>As it is with even ssh or ssl, on some level.
>There are private keys even for public-key
>cryptography. You could use one-time keys
>to unlock the password, but you still need
>a way to share the one-time keys, which is
>through either public-key or private-key
>encryption. Either way, you have to store
>the information on the system if you want
>the system to do the authentication.
>
>> The only solution I've come up with so far, less
>> than perfect, is a compiled program (C, for
>> instance) that decrypts the encrypted passwords.
>
>This still stores the means to decrypt the
>encrypted passwords. Even if you pass the
>key in at compile time, it gets compiled into
>the object code. Someone with the run of your
>system and a good debugger or hex editor could
>still find it.
>
>Some of the secure web servers require you to
>enter a password each time the program starts
>in order to decrypt the certificate(s). This
>password is then stored only in memory and is
>likely free()d after being used to decrypt the
>certificate, which is then only stored in
>memory in the plaintext form. I believe that
>the secure versions of Apache use a data
>transformation on the certificate based on the
>key, and that the plaintext produced from the
>certificate is the only proof or disproof of
>the key being valid. This uses a private-key
>encryption technique to launch a public-key
>encryption system. This still brings up issues
>of paging to disk for those who are truly
>paranoid. If you're running production machines
>with little downtime, and have someone
>responsible for making sure things come back up
>properly when they go down, this is a good
>solution in Perl or any other language.
>
>Traditionally, to log into a Unix-type box, you
>enter the password to run through a one-way
>encryption, which is then checked against the
>pre-encrypted form. If these match, the user
>is allowed to log in. You could, if you chose,
>use a one-way encryption function to match
>against a password that is stored only in
>encrypted form on disk, then use the plaintext
>version of that, if the match succeeds, to
>decrypt the password you wish to pass to your
>database server. This, like the above, is
>going to require that the initial password
>either be passed in from a terminal. It's
>not quite as elegant as the above, but there
>are plenty of ways already existing in Perl
>to do the one-way encryption part, so I
>thought I'd toss it into the mix. It is a
>tradeoff between having an additional step
>and having an additonal step succeptible to
>brute-force attack.
>
>This really isn't a cryptology/cryptography/
>crytanalysis/encryption group, but I thought
>I'd point out some possibilities to prove that
>the general design is more important here than
>the implementation language. You can do it in
>Perl as well as in C, so you might as well do it
>in Perl.
>
>Chris



------------------------------

Date: Wed, 29 Nov 2000 21:32:35 GMT
From: dtbaker_dejanews@my-deja.com
Subject: Re: Encrypting passwords
Message-Id: <903slj$k9c$1@nnrp1.deja.com>



> Unfortunately, the drive to eliminate all clear-text passwords
> originated as a directive from upper management.
-----------

aha! thats the real problem.  ;)

if you put everything under .htaccess protection, then the passwords
wont be clear text, they will have been crypt()ed. if you set up
usernames and groups to correspond to what you'll need, cant you use the
valid REMOTE_USER after they login to the webserver to establish the
username on the remote database?

Dan


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Wed, 29 Nov 2000 14:49:14 -0700
From: Rob Greenbank <rob@frii.com>
Subject: Re: Encrypting passwords
Message-Id: <59ua2t8ooehl970fpm5khda5ukc0u0bqf7@4ax.com>

There's no web server involved in this appliation.  The login is
directly into Oracle and the perl scripts are accessing and modifying
data in the database.  

While I'm aware of .htaccess, I've never actually played with it.
Sounds like I need to research that a bit more.  I won't know if or
how it will help me with Oracle until I do.

Thanks,

	Rob

On Wed, 29 Nov 2000 21:32:35 GMT, dtbaker_dejanews@my-deja.com wrote:

>
>
>> Unfortunately, the drive to eliminate all clear-text passwords
>> originated as a directive from upper management.
>-----------
>
>aha! thats the real problem.  ;)
>
>if you put everything under .htaccess protection, then the passwords
>wont be clear text, they will have been crypt()ed. if you set up
>usernames and groups to correspond to what you'll need, cant you use the
>valid REMOTE_USER after they login to the webserver to establish the
>username on the remote database?
>
>Dan
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.



------------------------------

Date: Wed, 29 Nov 2000 19:13:26 GMT
From: flint@flintslacker.com (Flint Slacker)
Subject: Re: Extracting substrings from strings
Message-Id: <3a26549b.91258754@news.tcn.net>


substr expr, offset, length

Length is optional...

$a="This is a test";
substr($a, 4, 5) = "";
print $a . "\n";

Flint

On Wed, 29 Nov 2000 18:50:46 GMT, eT <eT@quidel.com> wrote:

>$a="This is a test



------------------------------

Date: Wed, 29 Nov 2000 14:36:10 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Extracting substrings from strings
Message-Id: <slrn92amla.4bk.tadmc@magna.metronet.com>

eT <eT@quidel.com> wrote:

>I would like to extract a substring from a string


   perldoc -f substr


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Wed, 29 Nov 2000 19:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ 4.23:   How do I expand tabs in a string?
Message-Id: <NCcV5.9$_g6.135469568@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How do I expand tabs in a string?

    You can do it yourself:

        1 while $string =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;

    Or you can just use the Text::Tabs module (part of the standard Perl
    distribution).

        use Text::Tabs;
        @expanded_lines = expand(@lines_with_tabs);

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep comming up.  If you are some how irritated by
seeing these postings you are free to ignore them or add the sender
to your killfile.  If you find errors or other problems with these
postings please send corrections or comments to the posting email
address.

If you are not able to find this or other Perl documentation from
your installation you may access it via the web by following the
appropriate links from one of the addresses listed below.

    http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search
    http://www.perldoc.com
    http://www.cpan.org
    http://www.perl.com

Answers to questions about LOTS of other stuff, mostly not related to
Perl, can be found at

    news:news.answers

and in the many thousands of other useful Usenet news groups.

The perlfaq manual pages contain the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

    When included as an integrated part of the Standard
    Distribution of Perl or of its documentation (printed or
    otherwise), this work is covered under Perl's Artistic
    License.  For separate distributions of all or part of
    this FAQ outside of that, see the perlfaq manpage.

    Irrespective of its distribution, all code examples here
    are public domain.  You are permitted and encouraged to
    use this code and any derivatives thereof in your own
    programs for fun or for profit as you see fit.  A simple
    comment in the code giving credit to the FAQ would be
    courteous but is not required.

-- 
    This space intentionally left blank


------------------------------

Date: Wed, 29 Nov 2000 21:37:06 GMT
From: nodo70@my-deja.com
Subject: find function
Message-Id: <903su2$ke9$1@nnrp1.deja.com>

Below is a snip code using find.pl.  It keep complain about $name and I
don't know how to delare that in order to get rid of error message.
Please help.  Thanks in advance.

#/usr/local/bin/perl -w
use strict
require "find.pl";
use Cwd;

my (@realFiles);
my $curDir = cwd();
my $dir = $ARGV[0];

chdir "$dir";
&find(".");
chdir "$curDir";
foreach $file (@realFiles) {
   print "$file\n";
}

sub wanted {
    unless (-d $_) {
        $_ = $name;
        s/^.\///;    # get rid of leading "./"
        push @realFiles, $_;
    }
}


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 29 Nov 2000 16:19:18 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: find function
Message-Id: <87ofyya0bd.fsf@limey.hpcc.uh.edu>

>> On Wed, 29 Nov 2000 21:37:06 GMT,
>> nodo70@my-deja.com said:

> Below is a snip code using find.pl.  It keep complain
> about $name and I don't know how to delare that in order
> to get rid of error message.  Please help.  Thanks in
> advance.

> #/usr/local/bin/perl -w
> use strict

This does not compile.  Please post *real* code.

> sub wanted {
>   unless (-d $_) {
>      $_ = $name;

$name is not defined or set anywhere.  Its only occurrence
is where you try to access its value.

hth
t
-- 
Eih bennek, eih blavek.


------------------------------

Date: Wed, 29 Nov 2000 22:19:12 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: for each file in dir ?
Message-Id: <3A258181.7146B04A@acm.org>

Tad McClellan wrote:
> 
> >       my $data;
> >       read FILE, $data, -s $file;
> >       print OUT $data;
> 
> You can replace the 3 lines above with this one:
> 
>    print OUT <FILE>;

That is of course assuming that it is a "text" file. And you know what
happens when we assume something. :-)

> 
> But both of those approaches read the entire file into memory,
> so they are Not So Good for large files.

True, but it should get the OP started on solving his problem. :-)

John


------------------------------

Date: 29 Nov 2000 17:42:26 +0000
From: nobull@mail.com
Subject: Re: Gotta weird problem...disappearing variables
Message-Id: <u9zoiioet9.fsf@wcl-l.bham.ac.uk>

Daniel Bohling <dbohling@newsfactor.com> writes:

> 	print "Body:\t|$body|\n" if $self->{print}; 
> #^^^^^^^^^^^prints $body just fine
> 	unless ($body) { $self->die_gracefully("Missing body:$body"); }
> #^^^^^^^^^^^$body is undefined here?
> 	print "Body:\t|$body|\n" if $self->{print};
> #^^^^^^^^^^^prints $body just fine again

Is $body perhaps an object that uses overloading?  If so the way $body
behaves in a interpolative context and in a boolean context can be
defined independantly.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: 29 Nov 2000 13:08:03 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: how do i direct compiler errors to a file-newbie
Message-Id: <m3vgt6648s.fsf@mumonkan.sunstarsys.com>

"Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1> writes:

> "Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
> news:m31yvu7kwh.fsf@mumonkan.sunstarsys.com...
> : "Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1> writes:
> : > Ugh. That's sick. It may work but it shouldn't, the idea of a compiler
> : > redirecting its output based on the contents of an input file? ugh and
> ugh
> : > again.
> :
> : Not sick- ingenious perhaps (as is usual from this particular poster).
> 
> I'm happy to believe that it's a perfectly valid perl method. I'm simply
> stating that I think it's sick to design a compiler which runs code while it
> compiles, and actually to make use of it.
> 

I hate to break it to you, but there's a whole lot of them that do. In fact,
can you name a specific example of an implementation of an interpreted 
programming language that makes no provisions for on-the-fly 
compilation/execution? 

(Even C, which is not such a thing, has a preprocessor.)


-- 
Joe Schaefer


------------------------------

Date: Wed, 29 Nov 2000 18:19:29 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: how do i direct compiler errors to a file-newbie
Message-Id: <x73dgabpzj.fsf@home.sysarch.com>

>>>>> "GW" == Geoff Winkless <geoff-at-farmline-dot-com@127.0.0.1> writes:


  GW> I'm happy to believe that it's a perfectly valid perl method. I'm
  GW> simply stating that I think it's sick to design a compiler which
  GW> runs code while it compiles, and actually to make use of it.

you obviously don't know perl well. the whole point of use and BEGIN
code *IS* that they are executed at compile time. otherwise all pragmas
like use strict would fail, you couldn't have compile time constant
folding of constans subs (use constant) and prototypes couldn't be
declared in modules.

so learn to live and love compile time execution. it is very important.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


------------------------------

Date: Wed, 29 Nov 2000 18:21:06 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: how do i direct compiler errors to a file-newbie
Message-Id: <l2ia2t40knvg5fn1g5dogfa54r8iuid90t@4ax.com>

Geoff Winkless wrote:

>I'm simply
>stating that I think it's sick to design a compiler which runs code while it
>compiles, and actually to make use of it.

But pragma's work that way, for example "use strict" and "use integer".
What these do, is nothing but setting or resetting certain compiler
flags, in plain Perl code. The flags are in the $^H special variable,
and in the %^H special variable hash. These variables are automatically
localized in (some) blocks, so that the effect of "use integer;" for
example, only lasts till the end of that block. Sick? Rather: nifty.

Talk about sick: in Perl 6, large parts of the Perl parser (!) will be
written in Perl. That implies: user definable versions of Perl.

-- 
	Bart.


------------------------------

Date: Wed, 29 Nov 2000 18:32:57 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: How do I null terminate a string ?
Message-Id: <x7y9y2aasn.fsf@home.sysarch.com>

>>>>> "NT" == Neil Trenholm <neil@alaweb.com> writes:

  NT> I don't know how I missed this in the docs ... but ... I have a
  NT> string that

i don't know how you missed it too. :)

  NT> needs to be null terminated before being shipped off to a Win32::API

redirect Win32::API to /dev/null. it helps ease the pain.

  NT> $this_string = "StringContents";

you put a null byte after it. 

	"\0"

	$this_string .= "\0" ;

or

	$this_string = "foobar\0" ;

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


------------------------------

Date: Wed, 29 Nov 2000 18:27:08 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How do I null terminate a string ?
Message-Id: <8aia2t0ok8eg14ao5ado0mk63j4kmnpe83@4ax.com>

Neil Trenholm wrote:

>I don't know how I missed this in the docs ... but ... I have a string that
>needs to be null terminated before being shipped off to a Win32::API
>
>$this_string = "StringContents";
>
>How do I do this ?

Doesn't Win32::API do that for you?

Anyway: you can append "\0", and there is a new pack() template: 'Z'.

	$\ = "\n"; $, = " ";
	print map { sprintf '%02X', $_ } unpack 'C*', pack 'Z4', "Hello"
-->
	48 65 6C 00

That is "Hel\0".

-- 
	Bart.


------------------------------

Date: Wed, 29 Nov 2000 18:19:56 GMT
From: andre_sanchez@my-deja.com
Subject: Re: How do I null terminate a string ?
Message-Id: <903hc3$9qa$1@nnrp1.deja.com>

In article <t2aelc77u2v3d0@corp.supernews.com>,
  "Neil Trenholm" <neil@alaweb.com> wrote:
> Hi,
>
> I don't know how I missed this in the docs ... but ... I have a string
that
> needs to be null terminated before being shipped off to a Win32::API
>
> $this_string = "StringContents";
>
> How do I do this ?
>
> Thanks,
> Neil
>
>

$this_string .= "\000";

--
Their's not to make reply,
Their's not to reason why,
Their's but to do or die: -- Tennyson


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 4989
**************************************


home help back first fref pref prev next nref lref last post