[8474] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2091 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 13 14:08:05 1998

Date: Fri, 13 Mar 98 11:00:37 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 13 Mar 1998     Volume: 8 Number: 2091

Today's topics:
    Re: closing files (sometimes not & effiency) <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
    Re: complex reg expression help (Sameer Anand Siruguri)
    Re: Date Zeros preservation (Greg Bacon)
        File::Find and -w (Kent E. Holsinger)
    Re: Good Perl book <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
    Re: Help sought with web programming security problem (Steve Linberg)
    Re: How to export an environment variable ? (Craig Berry)
    Re: How to use Perl for Win95? (Maxine G.)
    Re: How to use Perl for Win95? (Al Thomas)
    Re: lower case fails on strings with newlines?? schwern@starmedia.net
    Re: Newbie: stuck in endless loop! (Mike Stok)
    Re: Perl equivalent for /bin/which schwern@starmedia.net
    Re: Perl For Windows NT <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
    Re: Perl4 vs Perl 5 (Craig Berry)
    Re: Read one line of a file <kose@cae.wisc.edu>
        regular expressions and control characters <lespin03@fiu.edu>
    Re: tainted glob confusion (Greg Bacon)
    Re: Tom, grow up [Re: The -w switch (was Re: better way <hsommer@micro.ti.com>
    Re: using exec to call telnet in perl schwern@starmedia.net
    Re: Weak references? schwern@starmedia.net
    Re: Win32 Perl question <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
    Re: You have 1 message(s) - how to print plurals? <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 13 Mar 1998 10:21:56 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: closing files (sometimes not & effiency)
Message-Id: <6ebtbu$k7g@bgtnsc02.worldnet.att.net>

I think all this means is that if you open a file that's already open, it's
sort of like doing this:

# open(MYFILE,"?foo.txt") or die "blah blah"; -- we did this earlier
close (MYFILE);
open (MYFILE,"?foo.txt") or die "blah blah";

Personally, I think explicitly closing filehandles when you're done with
them is a good idea, if only because it makes your script easier to follow.
(It's possible a guru will come along and tell you something different is
going on. In that case, believe them. :D)

--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl

dk smith wrote in message ...
>In the Blue Camel book on page 151, the text says that you do not have to
>explicitly close a FILEHANDLE if you are immediately going to do another
>open on it.
>
>What consititutes immediately?
>
>Does this also hold true for files that opened for writing/appending as
>well as for files that are opened for reading?





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

Date: Fri, 13 Mar 1998 17:55:40 GMT
From: sam@bhishma.cse.iitb.ernet.in (Sameer Anand Siruguri)
Subject: Re: complex reg expression help
Message-Id: <Eprr4s.LCH@bhishma.cse.iitb.ernet.in>

On Wed, 04 Mar 1998 23:16:18 -0600, Mike Binkley wrote:
>>    foreach $value (@reg){$_ =~ s/\W\Q$value\E\W/ $value /g};
>
>Damn, I realized that I mistyped this.  It should be:
>  
>   foreach $value (@reg){$_ =~ s/\b\Q$value\E\b/ $value /g};
>
>so it looks for word boundaries as opposed to the non-word characters. 
>*This* is the code that doesn't work.  (incidentally, \W didn't work

My server dropped the posting previous to this so I have to reconstruct from
just the correction quoted here. I dont know what your original problem was,
but seems to me that:

1. You mean \q{$value} instead of \Q\E. \Q\E quotes regular exp
metacharacters, not all "metacharacters". 

2. There doesn't seem to be any point to looping, because since $_ is modified
with =~, the next modification will probably not have any effect, unless the
elements of @reg are such that there will be some kind of incremental
substitution.

2.  you can't have $_ in that foreach() loop. It would have an uninitialised
value, unless you have something outside this loop that sets it. 

If this doesn't help, you could try mailing me your whole code.

Sam.


-- 
------------------------------------------------------------------------------
Sameer Anand Siruguri, 4th year, B. Tech. programme,
Department of Computer Science and Engineering,
Indian Institute of Technology, Mumbai, India.

sam@cse.iitb.ernet.in		http://www.cse.iitb.ernet.in/~sam
------------------------------------------------------------------------------


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

Date: 13 Mar 1998 18:12:32 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Date Zeros preservation
Message-Id: <6ebsug$hom$11@info.uah.edu>

[Posted and mailed]

In article <7xd8fqzg1s.fsf@beavis.vcpc.univie.ac.at>,
	Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> writes:
: Re: Date Zeros preservation, Eric <emathias@wwa.com> said:
: 
: Eric> Is there a way to preserve the zeros in a time when
: Eric> putting it into a variable from the localtime()
: Eric> funtion?  What I seem to end up with is stuff that
: Eric> looks like this:
: 
: POSIX::strftime

Overkill.

    my($s,$m,$h,$dd,$mm,$yyyy) = localtime(time);

    $mm++;

    ## remain Y2K compilant :-)
    $yyyy += 1900;

    $date = sprintf "%04d/%02d/%02s - %02d:%02d:%02d",
                     $yyyy,$mm,$dd,   $h,  $m,  $s;

    % perldoc -f printf
    % man 3 printf

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 13 Mar 1998 13:12:58 -0500
From: kent@darwin.eeb.uconn.edu (Kent E. Holsinger)
Subject: File::Find and -w
Message-Id: <87en061mtx.fsf@darwin.eeb.uconn.edu>

Running the following very simple script with appropriate command line
arguments: 

   #!/usr/local/bin/perl -w
   
   use File::Find;
   use strict;
   
   my $pattern = $ARGV[0];
   my $directory = $ARGV[1];
   
   # Traverse desired filesystems
   find(\&wanted, "$directory");
   
   sub wanted {
           -f && mygrep ($pattern, $File::Find::name);
   }
   
   sub mygrep {
       my ($pattern, $name) = @_;
       open (FILE, "<$name") or die "Could not open $name for input: $!";
       while ( <FILE> ) {
           print "$name:$_" if /$pattern/oi;
       }
       close (FILE);
   }

produces the following output

   Use of unitialized value at /usr/local/lib/perl5/File/Find.pm line 150

Looking at the relevant line in Find.pm, I suspect that the culprit is
the variable $Is_VMS. Have I done something wrong in building the
installation (probably), or is this something that needs to be fixed
in File::Find (unlikely)?

Kent

-- 
Kent E. Holsinger                Kent@Darwin.EEB.UConn.Edu
                                 http://darwin.eeb.uconn.edu
-- Department of Ecology & Evolutionary Biology          
-- University of Connecticut, U-43                                       
-- Storrs, CT   06269-3043                                               


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

Date: Fri, 13 Mar 1998 10:32:04 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: Good Perl book
Message-Id: <6ebtuu$ne0@bgtnsc02.worldnet.att.net>

IMHO, Perl 5 for Dummies' biggest deficiency is that it doesn't really cover
much of the non-Perl 4 aspects of Perl 5. For example, about all you get on
objects is "here they are, this is a brief overview of how they work, we're
not going to try to teach you how to write them because it's a pretty
complicated art and not something you want to try to tackle as a beginner."

And you know what? I think they're right, especially if you don't have an
object-oriented background (like I didn't when I jumped into Perl).

I have Perl 5 for Dummies and I refer to it fairly often. Its biggest asset
is that it's readable, not intimidating, and will either give you the
information you need to know or tell you "once you want to know about
*this,* you don't qualify as a Dummy any more" (in so many words). In which
case you should be using Programming Perl to look up that particular
function.

Under no circumstances should you have Perl 5 for Dummies as your only Perl
book. Me, I have maybe a dozen Perl and Perl-related books (e.g. Mastering
Regular Expressions) and every single one of them has paid for itself in
information gathered and things learned. Yes, even Perl 5 for Dummies (well,
it helps that it's cheap <grin>).

--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl


User wrote in message <35096c7e.13642887@news.btinternet.com>...
>Whats wrong with the book specifically ?
>
>I found it a really useful book, as someone who knew nothing about
>perl, to someone who now knows they know very little about perl :->
>
>As a beginners book ,what is specifically wrong with it to be "sub par
>quality". The other books are very dry to start with, and not
>something you can really read on the train on the way home.
>
>Ian
>
>On Fri, 13 Mar 1998 15:21:06 GMT,
>edwardt@i.really.really.hate.spam.jamison.com (Ed Jamison) wrote:
>
>>Hmmm, no.  Avoid this one if you can.  It fits well in the listings with
>>the other ones.  Sub par quality.  Stick with Learning Perl, or
>>Programming Perl.
>>
>>Ed
>>
>>
>>Long ago (Fri, 13 Mar 1998 14:34:19 GMT), in a land far far away,
>>you@somehost.somedomain spouted nonsense similar to this...
>>> On Tue, 10 Mar 1998 14:05:57 -0600, bwb@acm.org wrote:
>>>
>>> 8-< Snip !
>>>
>>> I'll vouce for Perl for Dummies, geat book , you can actually read it
>>> as a book rather than a dry text book, not geat at the advanced stuff
>>> but really good for beginners.
>>> >
>>> >  http://www.flathill.com/languages/perl/
>>> >
>>> >
>>> >-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>>> >http://www.dejanews.com/   Now offering spam-free web-based newsreading
>>>
>>>
>




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

Date: Fri, 13 Mar 1998 12:50:01 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Help sought with web programming security problem
Message-Id: <linberg-1303981250010001@projdirc.literacy.upenn.edu>

In article <3508F97E.61B4@isporg.com>, wdl@isporg.com wrote:

> I am in need of a way of providing web page readers with a visual
> certification that they are viewing an "official" web page and
> not someone's copy of it. I have been thinking along the lines
> of developing a "seal of approval" gif file image which will be kept
> secure. At the top of each web page using this scheme would be a request
> to a CGI program for the "seal of approval" image. If the requesting
> page were a "proper" one (i.e. located on the secured server rather
> than on someone's own server) the program would return the gif file.
> Otherwise, the program would return a different "seal of unapproval"
> gif file contents.
> 
> So, can one do this and if so how or what might be another approach?

1.  What does this question have to do with Perl?
2.  What's to stop me from stealing your image and putting it on my web
page?  I don't have to call your CGIs.
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: 13 Mar 1998 17:47:41 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How to export an environment variable ?
Message-Id: <6ebrft$8v1$1@marina.cinenet.net>

Mike Lacey (Mike_Lacey@Cargill.Com) wrote:
: The array %ENV is what you need.

The hash %ENV, that is.

: Set it like this in a perl script:
: 
: $ENV{'PATH'}='/bin;/usr/bin;/usr/local/bin';

No need to quote PATH, though it's harmless to do so.

Also, isn't the Unix path item separator a colon, not a semicolon? 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Fri, 13 Mar 98 17:48:49 GMT
From: *nospam*mg*nospam*@pcg*nospam*.net (Maxine G.)
Subject: Re: How to use Perl for Win95?
Message-Id: <6ebril$8qs@examiner.concentric.net>

Thanks to you and everyone who responded by e-mail.
I am now able to run my scripts in a dos window.
I tried setting up the win95 associations as suggested below, but when I try 
to run the scripts directly, the dos window opens, the script runs and the dos 
window immediately closes, so that I can just barely make out the results. 
Does anyone know a way to keep the window open?

In article <01bd4e91$f6a1b860$d53ec69b@leicester>, "Jeff Wilson" 
<jwilson@ic.ac.uk> wrote:
>I run perl on winnt now but I think the win95 process was as follows ...
>
>Create a perl script with an editor - save it as anything you like, but a
>suffix of ".pl" is usual, i.e., fred.pl
>Run "pl2bat.exe fred.pl" which will create a dos executable, fred.bat.
>Execute fred.bat in a dos window.
>
>Alternatively set a file type for .pl in the My Computer options window.
>The command should be something like .. c:\perl\bin\perl.exe %  (this may
>have been done by the install already).
>Then a right-click OPEN on any file suffixed .pl will run it. 
>
>                                Jeff Wilson
>                                London - UK
>
>Maxine G. <*nospam*mg*nospam*@*nospam*pcg*nospam.net> wrote in article
><6e9toj$ih4@examiner.concentric.net>...
>> I think I'm missing a very basic concept:
>> I've downloaded and installed the Activestate Win32 version of Perl and 
>> PerlScript on my Win95 machine. Now what do I do? If I double-click on
>any of 
>> the three .exe files in the bin directory, a dos window opens briefly and
>then 
>> closes. 
>> So, what do I need to do to create and run perl scripts in this
>environment? I 
>> couldn't find anything about this in the documentation, but perhaps I
>wasn't 
>> looking in the right place.It seems like such an obvious question, so I
>assume 
>> that the answer must be obvious too.
>> 
>> tia!
>> 
>>  
>> *********************************************************
>> return address changed to prevent spamming
>> Remove "NOSPAM" in the return address
>> Maxine Gerber
>> PCG Systems
>> *********************************************************
>> 


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

Date: Fri, 13 Mar 1998 18:21:54 GMT
From: althomas@together.net (Al Thomas)
Subject: Re: How to use Perl for Win95?
Message-Id: <350977e4.19429202@news.together.net>

On Fri, 13 Mar 98 17:48:49 GMT, *nospam*mg*nospam*@pcg*nospam*.net
(Maxine G.) wrote:

>Thanks to you and everyone who responded by e-mail.
>I am now able to run my scripts in a dos window.
>I tried setting up the win95 associations as suggested below, but when I try 
>to run the scripts directly, the dos window opens, the script runs and the dos 
>window immediately closes, so that I can just barely make out the results. 
>Does anyone know a way to keep the window open?
>
perldoc -f getc() ?


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

Date: Fri, 13 Mar 1998 12:21:33 -0600
From: schwern@starmedia.net
To: kevin@cmhcsys.com
Subject: Re: lower case fails on strings with newlines??
Message-Id: <6ebtd8$eak$1@nnrp1.dejanews.com>

I'll betcha $5 I know what it is.  I betcha I betcha I betcha!

Are you not checking to see if this file you're reading from opens? :)


In article <6e8v2l$hcu$1@nnrp1.dejanews.com>,
  kevin@cmhcsys.com wrote:
>
> my problem is that i've got a code snippet that makes an input string be
> lowercase, e.g.
>
> $string = lc($string);
>
> typically, $string contains something like "ATYPICAL CHEST PAIN", and
> everything words just fine.
>
> now, i'm reading in my data with $/ = "" and a line like $string = <INFILE>.
> my problems start when i read in something that's more than one line long.
> in such a case, $string might contain something like
>
> 1.   ATYPICAL CHEST PAIN
> 2.  RULE OUT ESOPHAGEAL SPASM
>
> or, it might contain a straightforward paragraph-like thing, such as
>
> Serum coffee was triple the legal state limit at 3.4 meq/liter.  Chest x-ray
> was normal, with no infiltrate, cardiomegaly, or missing lungs.  There was a
> cylindrical object in the region of the second through fifth left ribs,
> consist with a lead pencil that was not removed from a pocket before
> radiography.
>
> in either of these cases where i've got multiline data, lc returns zip.
it's
> not that it doesn't do lower-casing--- rather, $string now holds "".


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 13 Mar 1998 17:53:33 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Newbie: stuck in endless loop!
Message-Id: <6ebrqt$a2q@news-central.tiac.net>

In article <35096B48.7566@elk.cray.com>,
Mark P Stackhouse  <stackhou@elk.cray.com> wrote:

>print "$which_end";
>if ($which_end ne /source/ || $which_end ne /destination/)
>	{
>		print "\n\n";
>		print "Excuse me?... that must be a typo!";
>		print "  Try again please.  ";
>		chomp ($which_end = <STDIN>);
>		$which_end = "\L$which_end";
>	}

You probably mean something like

  if ($which_end !~ /source/ && $which_end !~ /destination/) {
    ...
  }

where the !~ topicalises the pattern match to $which_end (rather than the
default $_) and logically negates the result of the match.  You can make
the match case insensitive anda little more selectve like this:

  unless ($which_end =~ /^\s*(source|destination)\s*$/i) {
    ...
  }

which sees if $which_end matches source or destination with optional
whitespace at each end (the \s*) and ignores case in the comparison (the i
modifieer for insensitivity to case.

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Fri, 13 Mar 1998 11:35:50 -0600
From: schwern@starmedia.net
To: stephane.barizien@ocegr.fr
Subject: Re: Perl equivalent for /bin/which
Message-Id: <6ebqmp$b4n$1@nnrp1.dejanews.com>

Whoops!  I just read Randal's Pathfinder WT article.  Add his path cleaning
stuff to my which() and it should work better.


In article <6e6c2c$oh01@janus.ocegr.fr>,
  "Stephane Barizien" <NOSPAM.stephane.barizien@ocegr.fr> wrote:
>
> Maybe (probably) a newbie's question: how do I perform the equivalent of
> /bin/which (or, for Korn Shell addicts, the equivalent of "whence" or
> "type") in a Perl program?
>
> I can of course parse $ENV{"PATH"} myself, but there sure is a
> simpler-don't-reinvent-the-wheel method out there (CPAN?)
>
> TIA
>
>


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Fri, 13 Mar 1998 09:42:38 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: Perl For Windows NT
Message-Id: <6ebr2a$890@bgtnsc02.worldnet.att.net>

Unfortunately this is a Perl newsgroup and a lot of us (like me) don't know
CGI, so we can't help you with that part. I do know you have to have proper
permissions set, have files in the proper directory, etc. but not specifics.

As to your Perl code, it looks to me like you're missing one important
element and may be missing another one. The syntax for a "here" statement is

print <<"EndOfMessage";

(you only have one less than sign). It must be terminated with the word
"EndOfMessage" on a line, all by itself, with nothing before or after it but
newlines. So the following are all wrong:

print <<"HERE";
fooHERE                # no newline

print <<"HERE";
foo
 HERE
print "bar";           # space before HERE

print <<"HERE"
foo
HERE
print "bar";           # there's a space after HERE

print <<"HERE";
foo
HERE; print "bar";     # HERE has to be on a line all by itself

I believe there's a mention of this in the FAQ.

--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl



Husky wrote in message <6eatug$9sn@news.microsoft.com>...
>This is my first time to try to use Perl on Windows NT platform.
>But when I use browser to see the result, it shows:
>    HTTP/1.0 501 Not Support
>
>I write down my step and hope you can help me...
>
>1. launch Pw32i315.exe (1,510 KB) (Perl for Win32 Intel/x86 binary) and
>install Perl on my NT 4.0 successfully.
>2. Prepare a HTML in my web (d:\InetPub\wwwroot) like this:
>
><form method="POST" action="http://husky/cgi-bin/comments.pl">
>  <p>Please :<input type="text" name="address" size="20"></p>
>  <p>Your Comments:</p>
>  <p><textarea rows="5" name="comments" cols="20" </textarea></p>
>  <p><input type="submit" value="Submit" name="B1">
>    <input type="reset" value="Reset" name="B2"</p>
></form>
>
>3. Prepare a PL file named comments.pl in (D:\InetPub\wwwroot\cgi-bin) and
>jsut print something:
>
>print <"EndOfMessage";
><html>
><head>
><title>This is a test </title>
></head>
><body>
> <h1>Hi</h1>
></body>
></html>
>EndOfMessage
>
>4. Browser HTML and click the Submit button.
>
>Is there any steps I lost something?
>Please do me a favor...
>
>Thanks
>Andrew Wang
>
>




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

Date: 13 Mar 1998 17:58:17 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl4 vs Perl 5
Message-Id: <6ebs3p$8v1$2@marina.cinenet.net>

User (you@somehost.somedomain) wrote:
: I really hate to follow up my own post (sort of) but FYI Jim
: 
: Perl 4 is Y2K compliant, as comliant as a pen is

Jim was doing a distorted version of what amounts to a c.l.p.m in-joke. 
The canonical phrase is "There are no plans to make Perl 4 Y2K-compliant." 
This is a true statement, as Perl 4 already *is* Y2K-compliant, to the
extent that its underlying C compiler and OS services are.  However, the
phrase can be used to strike terror in the hearts of non-technical
managers (a redundancy?), thereby getting them to approve an upgrade to
Perl 5. 

: if you write 1/1/99 with your pen does that mean your pen is not Y2K ?

Damn!  I just had to throw out five pens. :-)

: To craig, thanks for the Help, that was just what I was looking for.

Glad I could help.  I might add that Perl 5 has better security features 
(e.g., taint checking) as well.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Fri, 13 Mar 1998 11:24:01 -0600
From: Sadi Kose <kose@cae.wisc.edu>
To: "Jeffrey M. Cook" <cook.jeff@usa.net>
Subject: Re: Read one line of a file
Message-Id: <35096BB0.EC98248A@cae.wisc.edu>

Jeffrey M. Cook wrote:

> How do I read one line of a text file do something then the same to the
> next line in the text file?
>
> Thank you for any help!
>
> Jeff
> --
> ____________________________________________________________
> When sending me e-mail sent it to cook.jeff@usa.net
>
> PC & CADD Solutions NW
> www2.memes.com/pcandcad
> ____________________________________________________________

open(FIN,"somefile");
while($line = <FIN>){

    #do something;

}
close(FIN);


This will read one line at a time from the named file until the end of the

file is reached. When it reaches the end of the file <FIN> will return
"undef"
and which will look to the "while" as false thus loop will end.

hope this helps
Sadi




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

Date: Fri, 13 Mar 1998 13:23:15 -0500
From: luis a espinal <lespin03@fiu.edu>
Subject: regular expressions and control characters
Message-Id: <35097993.2666971D@fiu.edu>

Hi everyone,

I need to do the following:
Given a text file that may contain ^U or ^D ( these are actual ascii
chars
'^' and 'U', 'D' not the actual ^U and ^U ), I need to replace those
substrings by the real ^U and ^D. I did that already with
s/^U/\xU/g;
s/^D/\xD/g;

The problem is that I haven't been able to do the following:
$a="D"; # or "U"
s/^\\$a/\x\\$a/g;

and what I get is
s/^a/\xa/g;

How can I solve this? What am I doing wrong?

Thanks.

Luis Espinal.

------------------
What does not kill us makes us stronger.
Nietzche.

L^3=Long Live Linux




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

Date: 13 Mar 1998 18:05:44 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: tainted glob confusion
Message-Id: <6ebsho$hom$10@info.uah.edu>

In article <Pine.A41.3.95a.980313172132.86824A-100000@rsplus10.cern.ch>,
	"Alan J. Flavell" <flavell@mail.cern.ch> writes:
: On 13 Mar 1998, Greg Bacon wrote:
: > Note to the wise: be extremely careful with filenames returned from
: > readdir.  Treat them as though they were tainted (else someone will
: > hand you filenames like `rm -f *|').
: 
: I understand the problem!  In this particular application, though,
: the filenames (and the patterns being used for matching the filenames)
: are entirely under the designer's control.

Famous last words.  If you're running with -T, trust nothing from
the outside world.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Fri, 13 Mar 1998 11:29:49 -0600
From: Holly Sommer <hsommer@micro.ti.com>
Subject: Re: Tom, grow up [Re: The -w switch (was Re: better way to do this?)]
Message-Id: <35096D0D.D0D6B8AC@micro.ti.com>

brian moore wrote:

: >--to
: 
:      ^-- now you're gonna hafta explain the lack of an m.
: 
: Is it anti-Microsoft?  Telling us, in effect, to drop the M from our
: lives?

Hee! Zump! :) I think I saw Alan Schwartz around here, too.

-Holly, will keep her "M"s


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

Date: Fri, 13 Mar 1998 11:59:28 -0600
From: schwern@starmedia.net
To: dspeidel@thunder.ocis.temple.edu
Subject: Re: using exec to call telnet in perl
Message-Id: <6ebs33$csv$1@nnrp1.dejanews.com>

Net::Telnet.  Your friend, and mine.

In article <Pine.OSF.3.91.980311233711.1456A-100000@thunder.ocis.temple.edu>,
  Duncan Speidel <dspeidel@thunder.ocis.temple.edu> wrote:
>
> Hi Everybody,
>
> I use several different servers all are some variety of unix.  I have a
> base server that I always check first get my mail and then from there I
> telnet to one of the servers that I'm currently working with (I am a CIS
> student at Temple University and very few classes use the same machine).
> I figured I could do the telnet quickier if i wrote a script to connect
> to the machine.  The script below took no time to create and it
> intializes telnet okay its after the exec that things get weird.  I can
> enter user name in okay but after I push enter and it prompts me for my
passwd
> problems arise.  First I now can see the password that I'm entering (no
> biggie I figured that the script was echoing my input to the screen and
> ignoring the password hiding function of the remote machine- I know this
> as a name but I never dealt with it).  The bigger
> problem is that when I enter the password it doesn't all arrive.  I tried
> just entering the known password and not worring about so charecters not
> appearing -login failed.  I entered the password so it all appeared
> -login failed.  I'm now wondering if forking a telnet from the parent is
> possible. The script used is below
> #!/usr/local/bin/perl
> #y.pl 3/12/98 by Duncan Speidel
> if (!defined($kidpid=fork()) )
> {
> #fork failed
>         warn "could not fork: $!";
> }
> elsif ($pid==0){
> #fork returned zero so this is the child process
> #including user name and password as print commands fail to help
> #including user name as an argument to exec gives invalid port error
>         exec("telnet yoda.cis.temple.edu");
>         die "can't execute telnet $!";
> }else {
>         #fork returned neither 0 nor undef so this branch is the parent
>         waitpid($kidpid, 0);
> }
>
> #end script
>
> The yoda account is on a Sun Solaris (ver 2.4 I think). The script itself
> is called from a Alpha running Digtial Unix 64
>
> An suggestions would be greatly apperciated
> Thanks in Advance,
> Duncan
>


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Fri, 13 Mar 1998 12:11:10 -0600
From: schwern@starmedia.net
To: jll@skynet.be
Subject: Re: Weak references?
Message-Id: <6ebsp1$dh3$1@nnrp1.dejanews.com>

Until Ilya's patch propigates into the norm, you might want to have a look at
the Storable module from CPAN.
http://www.perl.com/CPAN/modules/by-module/Storable

Also, Sriram's object persistance discussion in the Panther (Advanced Perl
Programming) might give you some other ideas.


In article <VA.0000007a.013c4843@jll>,
  jll@skynet.be wrote:
>
> Hello,
>
> I'm working on a persistence layer. Given the ID of an object, I need
> to find out whether it is already present in memory. This is to
> ensure object unicity:
>
>     $id = read_id($storage);
>     return $objects{$id} if exists $objects{$id};
>     $obj = instantiate($class);
>     read_data($obj, $storage);
>     $objects{$id} = $obj;
>
> If I use a global hash, however, the object will never be freed,
> because its reference count will always be at least 1 (the reference
> from the hash). Weak references would do fine, alas Perl doesn't have
> them.
>
> So what's the solution?
>
> I've thought of maintaining my own refcount inside in the object, and
> returning a tied scalar that would manage my refcount.
>
> I also considered converting references into strings and storing *that*
> in the hash (it would contains pairs like 23 => 'SCALAR(0x123456)').
> This would not prevent freeing the object, but is there a way to
> convert the string back to a reference?
>
> Or does anybody have another hack (using typeglobs or whatever) or
> solution?
>
> jl
>
>


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Fri, 13 Mar 1998 10:17:02 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: Win32 Perl question
Message-Id: <6ebt2o$ijb@bgtnsc02.worldnet.att.net>

You don't have to use "net use" to get to a remote share. You can open it
directly by specifying the UNC:

open(FOO,"\\\\foo\\bar\\baz.txt") or die "Can't open baz.txt: $!";

However, I do often find it convenient to use "net use," especially when I'm
shelling out to utilities that understand drive letters but not UNCs. For
instance:

$myCommand = "net use * \\\\foo\\bar";
$nu = `$myCommand`;
if ($nu =~ /(\w:) connected/i) { $myDrive = $1; }
else { die "Unable to connect to \\\\foo\\bar: $nu\n"; }

Now, assuming the script is still alive, $myDrive contains the drive letter
that was assigned to \\foo\bar.

If you're under Windows95 or using NT share level security, you can access a
different share by changing $myCommand to

"net use * \\\\foo\\bar password"

I don't have access to NT at the moment, but I suspect there's a similar
syntax for user level security, probably something like

"net use * \\\\foo\\bar username:password"

Try typing "net use /?" at an NT console prompt and see what it says. Hope
this helps.

--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl




keydet89@yahoo.com wrote in message <6ebfr6$db4$1@nnrp1.dejanews.com>...
>I have written a couple of small scripts for accessing shares on remote
>computers using "net use".  In some cases, I need to supply a username
>and password.
>
>Is there a way in Perl to set up a connection using a different username
>and password, without using something like "open(NET,"net use.....")"?
>
>Thanks
>
>H. Carvey
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/   Now offering spam-free web-based newsreading




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

Date: Fri, 13 Mar 1998 09:48:52 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: You have 1 message(s) - how to print plurals?
Message-Id: <6ebrdv$9ud@bgtnsc02.worldnet.att.net>


Tom Christiansen wrote in message <6ebkmp$39m$1@csnews.cs.colorado.edu>...

>Fox and vixen (vichsen) aren't what they used to be either.
>Why doesn't fax go to faxen, or box to boxen?

I do, however, occasionally see references to Unix boxen and Digital VAXen.

>Doubling your fianci or fiancie will get you
>fiancis and fiancies, and a prison sentence outside of Utah.

Not unless you actually marry both of them. If you don't, you just have two
people who will want an explanation. By the way, do you know what the
penalty is these days for having two spouses in Utah? Actually, it's the
same as it is everywhere else -- two mothers in law.

OK, I'll go now . . .





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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 2091
**************************************

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