[7408] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1033 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 16 15:19:33 1997

Date: Tue, 16 Sep 97 12:02:46 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 16 Sep 1997     Volume: 8 Number: 1033

Today's topics:
     Re: "hello.pl > x" gives empty x on NT <Jan.Krynicky@st.mff.cuni.cz>
     Re: A simple regular epression question. (SJK)
     Re: about using 'require' with NT <lkasdorf@pressroom.com>
     Re: about using 'require' with NT <lkasdorf@pressroom.com>
     Re: Animated GIF problem in Perl (Jeremy D. Zawodny)
     can I continuously read & empty logfile? <suqstmbl@reading.ac.uk>
     Re: can I continuously read & empty logfile? (Jeremy D. Zawodny)
     Re: Can I specify fonts? <rjo100@york.ac.uk>
     Re: CGI and Mail on NT <Jan.Krynicky@st.mff.cuni.cz>
     Re: CGI: Installing "Adverts" <rjo100@york.ac.uk>
     Re: Chicago User Group (Faust Gertz)
     Confusion of passing references into/outof subs... <rjm@seymour.chem.ubc.ca>
     Re: How do I check who is connected to my socket? (Jeremy D. Zawodny)
     Re: How to setup list as class data member <cmargoli@world.northgrum.com>
     Re: Inserting \n in a string <rjo100@york.ac.uk>
     Intel v. Randal Schwartz in Washington Post <jeffrey@rahul.net>
     Re: Is Perl for Win32 really as brain damaged as it see <rjo100@york.ac.uk>
     Re: Is there a simpler syntax for: defined $a && $a ne  <rjo100@york.ac.uk>
     method to calculate the time <bremenlee@att.net.hk>
     Re: method to calculate the time (Jeremy D. Zawodny)
     Re: method to calculate the time <merlyn@stonehenge.com>
     Need bulk Unix <-> PC file conversion <lkasdorf@pressroom.com>
     Re: Need bulk Unix <-> PC file conversion (Jeremy D. Zawodny)
     Re: Need bulk Unix <-> PC file conversion <aaron@soltec.net>
     Re: NO SPACE (SJK)
     Re: NT Mail Question <rjo100@york.ac.uk>
     Perl equivalent to #ifdef in C? <lkasdorf@pressroom.com>
     perl launcher which copies STDIN+STDOUT+STDERR to a fil (Vincent DETZEL)
     perl relative path refs w/NT <lkasdorf@pressroom.com>
     Re: perl relative path refs w/NT (Jeremy D. Zawodny)
     Re: perl relative path refs w/NT <Jan.Krynicky@st.mff.cuni.cz>
     Re: test <flavell@mail.cern.ch>
     Re: Why can't I talk directly to the mail daemon? <justinb@springer.cray.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 16 Sep 1997 19:36:05 -0700
From: Jan Krynicky <Jan.Krynicky@st.mff.cuni.cz>
To: olli.blackburn@visigenic.com
Subject: Re: "hello.pl > x" gives empty x on NT
Message-Id: <341F4215.343E@st.mff.cuni.cz>

Olli Blackburn wrote:
> 
> I'm having problems redirecting the stdout of perl scripts from the
> cmd.exe command line on NT4.0 using perl:
> 
> The problem is that running the command without redirection works fine,
> as does running it via "perl hello.pl", but using the NT associations to
> allow me to simply run "hello.pl" results in no output in the output
> file. Here's a transcript:

Ask Bill. They've never been able to make anything working 100%.


> I've created a PerlScript file type to 'open' (i.e. run) a perl script
> and added an association from .pl files to PerlScript. I used the ftype
> and assoc commands to do this, which results in new entries in
> HKEY_CLASSES_ROOT.
Please do not use name PerlScript. PerlScript is the language engine
used in .ASP files and in browsers (and othe scripting hosts).

It doesn't make any difference for the computer, just to make terms
stright.
Be sure to distinguish a perl script from PerlScript.

> So where does the stdout go!!!

Maybe it's being forwarded to One Microsoft Way :-]


 
> On a related subject, why is the output from system() not correctly
> interleaved with that from print when stdout is redirected? Another
> transcript shows what I'm having trouble with:
> 
> C:\temp> cat mixlines.pl
> print("print 1\n");
> system("echo echo 1");
> print("print 2\n");
> system("echo echo 2");
> C:\temp> perl mixlines.pl
> print 1
> echo 1
> print 2
> echo 2
> C:\temp> perl mixlines.pl > x
> C:\temp> cat x
> echo 1
> echo 2
> print 1
> print 2
> 
Caching !!!

If you want to intermix print and system you have to set
	$|=1;
to disable the output cache. See perlvar.


> 
> Thanks,
> Olli

HTH, Jenda

BTW: the actual version is 310, 110 is pretty dated.
	http://www.activestate.com/


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

Date: Tue, 16 Sep 1997 18:31:37 GMT
From: knetsch@golden.net.no.spam (SJK)
Subject: Re: A simple regular epression question.
Message-Id: <341ec714.3973651@news.golden.net>

On Tue, 09 Sep 1997 16:45:56 +0300, Zohar Tsaba <ztsaba@iil.intel.com> wrote:

>Hi.
>
>How can I match only 'not 00' ?
>
>When I tried to use:
> 
>$x = "01010100001100" ;
>$x =~ s/[^00]/X/g ; 	# I want to replace 'not 00' with X
>			# 
>
>printf "$x\n" ; 	# $x is '0X0X0X0000XX00'
>			# which means, I replaced 'not 0 or not 0'
>
>Please Help !
>Thanks.

It would help if you provided of an example of what result you are expecting.

ie  01010100001100 should become XXX0000X00

Otherwise I'm just guessing, like I am now

To achieve this particular result involves stepping through the string two
characters at a time.  I do not believe this is achievable with s/// because it
single steps from character to character.  

With s///  the best I can do is

$x = "01010100001100" ;

$x =~ s/(\d[1-9])|([1-9]\d)/X/g;

print "$x\n";

which gives me XXX000XX0

This happens because the substitution matched every pair found, so that means it
tried matching pair 1,2 2,3 3,4 4,5 5,6 etc.

I believe you want to compare 1,2 3,4 5,6 7,8 etc.

To do that, we have to loop.

Try as follows

$x = "01010100001100" ;
$y = "";
@pairs = $x=~/(\d\d)/g;

foreach $pair (@pairs)
{
   if ($pair=~/(\d[1-9])|([1-9]\d)/)
   {
      $y.="X";
   }
   else
   {
      $y.=$pair;
   }
}

print "$y\n";


Which gives you

XXX0000X00

The result I believe you are trying to achieve.

HTH

Stu
Stuart Knetsch

Remove the you know what from my address to send me E-mail


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

Date: Tue, 16 Sep 1997 13:04:05 +0100
From: lynn kasdorf <lkasdorf@pressroom.com>
To: Y Chen <yinso@u.washington.edu>
Subject: Re: about using 'require' with NT
Message-Id: <341E75B5.B16712B2@pressroom.com>

Y Chen wrote:

> Hi,
>
> sorry for the repost, but no one answered my question, I guess it just
> got
> lost in the many emails posted in this newsgroup.  Hope someone gets
> to
> read this email this time :)
>
> I am using NT 4.0 along w/ Website 1.1 and ActiveWare Perl 307.  And
> whenever I do a require, it just doesn't want to work w/ the CGI
> scripts.
> I got an error message saying that the cgi doesn't produce an new line
> to
> separate the header and the body.  I wonder if anyone knows what's
> going
> on?
>
> any help is appreciated.
>
> yin-so

Sounds like what I've been encountering...2 things to look out for.
Windows needs PC style text files (0D 0A at the end of a line) whereas
unix servers need unix style text files (0A at the end of a line).

Also- I have found that I have to use DOS style paths when referring to
paths from within a perl script- this really sux, but there it is.
Moreover, I have not found a way to refer to RELATIVE paths AT ALL when
on windows.

in unix- require "./Library/cgi-lib.pl";
in Windows- require
"C:\\Netscape\SuiteSpot\docs\cgi-bin\Database-manager\Library\cgi-lib.pl";

I hope this helps, and that someone knows the REAL answer to this
problem.

Lynn Kasdorf
lkasdorf@pressroom.com



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

Date: Tue, 16 Sep 1997 13:02:06 +0100
From: lynn kasdorf <lkasdorf@pressroom.com>
To: "Jeremy D. Zawodny" <zawodny@hou.moc.com>
Subject: Re: about using 'require' with NT
Message-Id: <341E753E.4BD0767E@pressroom.com>

Jeremy D. Zawodny wrote:

> [cc'd automagically to original author]
>
> On Mon, 15 Sep 1997 15:01:17 -0700, Y Chen <yinso@u.washington.edu>
> wrote:
>
> >sorry for the repost, but no one answered my question, I guess it
> just got
> >lost in the many emails posted in this newsgroup.  Hope someone gets
> to
> >read this email this time :)
> >
> >I am using NT 4.0 along w/ Website 1.1 and ActiveWare Perl 307.  And
> >whenever I do a require, it just doesn't want to work w/ the CGI
> scripts.
> >I got an error message saying that the cgi doesn't produce an new
> line to
> >separate the header and the body.  I wonder if anyone knows what's
> going
> >on?
>
> At first glance, it sounds like a permissions or path problem... Are
> any error messages generated?
>
> Jeremy
> --
> Jeremy Zawodny
> Internet Technology Group
> Information Technology Services
> Marathon Oil Company, Findlay Ohio
>
> http://www.marathon.com/
>
> Unless explicitly stated, these are my opinions only--not those of my
> employer.

   Sounds like what I've been encountering...2 things to look out for.
Windows needs PC style text files (0D 0A at the end of a line) whereas
unix servers need unix style text files (0A at the end of a line).

Also- I have found that I have to use DOS style paths when referring to
paths from within a perl script- this really sux, but there it is.
Moreover, I have not found a way to refer to RELATIVE paths AT ALL when
on windows.

in unix- require "./Library/cgi-lib.pl";
in Windows- require
"C:\\Netscape\SuiteSpot\docs\cgi-bin\Database-manager\Library\cgi-lib.pl";

I hope this helps, and that someone knows the REAL answer to this
problem.

Lynn Kasdorf
lkasdorf@pressroom.com




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

Date: Tue, 16 Sep 1997 17:55:35 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: Animated GIF problem in Perl
Message-Id: <3421c7bc.16207244@igate.hst.moc.com>

[cc'd automagically to original author]

On Sun, 14 Sep 1997 19:18:53 -0400, Mark Van Buren
<vanburen@3dlinks.com> wrote:

>I've written a really simple script whose only job in life is to pass
>back an image from a query_string call.

[snip]

>This works and passes the image back, but if it's an animated gif, it
>only animates one cycle, then stops (NAV3/4) works fine under MSIE.
>
>Anyone have any idea why NAV3/4 doesn't recognize it as an animated gif,
>and let it loop?

Dunno. Sounds like a graphics problem, not a Perl problem.

As Tom Phoenix would say, I can tell that this isn't a Perl problem
because the solution is probably the same no matter what language you
had coded it in.

I'd check in one of the web authoring (or maybe graphics) newsgroups
and see what they know.

Good Luck,

Jeremy
-- 
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio

http://www.marathon.com/

Unless explicitly stated, these are my opinions only--not those of my employer.


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

Date: Tue, 16 Sep 1997 17:46:59 +0100
From: John Stumbles <suqstmbl@reading.ac.uk>
Subject: can I continuously read & empty logfile?
Message-Id: <Pine.SOL.3.96.970916171901.12884V-100000@suma3.reading.ac.uk>

Problem: I have a log file, written by a separate process (which I have to
treat as unmodifiable) and I want to get the log records out of the file
and into my perl script, and close up the file as I go. The log file is on
a unix (SunOS 4.something, not Solaris) filesystem. 

At present I have a cron job calling a shell script which copies the
logfile off to somewhere else and then truncates the logfile to 0. Of
course between copying the contents of the file and zeroing it I sometimes
lose some data. (I could modify it to rename the logfile and swap in an
empty file but that's still non-atomic).

At present I empty the logfile once a day, but I'd like to get finer
granularity, but since the operation is statistically lossy I'd end up
losing more data. 

I've considered a couple of ways of doing what I want, but I know too
little about the finer details of perl and unix filesystems to know
whether they're viable approaches or good ways of doing horrible things to
my filesystem ;-) 

1: make the current file-swapping scheme non-lossy by making it atomic: 
using perl to modify the file inode to point to a different physical file
(i.e. from the current logfile to a new, empty file). I don't know whether
the logging process keeps the file open at all times or closes it between
writes, and what would be the implications of doing what I suggest in
either of these cases! 

2: do a 'tail -f' equivalent in perl as per the FAQ to continuously get
stuff out of the logfile, and (somehow!) truncate the file from the
beginning as I go along. (In effect this would make it like a pipeline
from the logging process to my perl script, except that my perl script
could stop and the logfile would fill up like a buffer until my script
started again.) I don't know whether you can change the physical starting
point of a file on-the-fly as this would seem to require.


any idea?


tia

[BTW email copies of replies would be appreciated - our newsserver can be
a bit picky about which articles it propagates]

--
John Stumbles                                      j.d.stumbles@reading.ac.uk
Computer Services, University of Reading       http://www.rdg.ac.uk/~suqstmbl 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  The rain it raineth on the Just, and on the Unjust fella
       But more upon the Just because the Unjust's got the Just's umbrella



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

Date: Tue, 16 Sep 1997 18:10:24 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: can I continuously read & empty logfile?
Message-Id: <3425cae9.17020574@igate.hst.moc.com>

[cc'd automagically to original author]

On Tue, 16 Sep 1997 17:46:59 +0100, John Stumbles
<suqstmbl@reading.ac.uk> wrote:

>2: do a 'tail -f' equivalent in perl as per the FAQ to continuously get
>stuff out of the logfile, and (somehow!) truncate the file from the
>beginning as I go along. (In effect this would make it like a pipeline
>from the logging process to my perl script, except that my perl script
>could stop and the logfile would fill up like a buffer until my script
>started again.) I don't know whether you can change the physical starting
>point of a file on-the-fly as this would seem to require.

I like option 2, or at least the idea behind it. You should be able to
use the read() function in Perl to read in chunks of the log file. You
can use stat() to figure out how big the file is and if/when it has
changed.

If your script can "remember" between successive runs how many bytes
into the file it read the last time, it can pick up right where it
left off.

Make sense? Need more detail?

Lemme know...

If nothing else, you won't be relying on external utilities like tail
anymore.

>[BTW email copies of replies would be appreciated - our newsserver can be
>a bit picky about which articles it propagates]

Not a problem... :-)

Jeremy
-- 
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio

http://www.marathon.com/

Unless explicitly stated, these are my opinions only--not those of my employer.


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

Date: Tue, 16 Sep 1997 14:34:29 +0100
From: Russell Odom <rjo100@york.ac.uk>
To: Gina Anderson <ginakra@one.net>
Subject: Re: Can I specify fonts?
Message-Id: <341E8AE5.E396DA47@york.ac.uk>

Gina Anderson wrote:
> 
> I have a guestbook that I am currently trying to customize.  I use the
> font Arial or Helvetica in all my web pages using the font face tag in
> the HTML, and the guestbook cgi outputs regular times new roman, or
> default font for the platform.

I think you'll find the script doesn't specify the font, so it's the
browser default which is used.

> Is it possible to specify a certain font output to create? I know,
> picky, picky! :)
> 
> If this is possible, how and where would I put this in the CGI?

Just output the font face tag with the text from the guestbook script...

#!perl -w
# Print header (use the CGI.pm module instead, this is just an example)
print "Content-type: text/html\n\n";
print "<HTML>\n<HEAD>\n<TITLE>My guestbook</TITLE>\n</HEAD>\n<BODY>\n";

# Set the font face
print "<FONT FACE=\"whatever\">\n";

# Print whatever you want here

# close the <FONT> tag
print "</FONT>\n";

# Print footer (again, use CGI.pm)
print "</BODY>\n</HTML>\n";

__END__

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Tue, 16 Sep 1997 20:06:52 -0700
From: Jan Krynicky <Jan.Krynicky@st.mff.cuni.cz>
To: tlawall@concentric.net
Subject: Re: CGI and Mail on NT
Message-Id: <341F494C.13F8@st.mff.cuni.cz>

T. LaWall wrote:
> 
> Does anyone know out there of a way to interface to the Windows NT
> Mail system through Perl?  I need a way for an NT Perl CGI script
> to e-mail results to some individuals with Internet email addresses.
> Pointers to sites with info on this, or some examples would help.
> Please email me when you post.
> 
> Thanks in advance,
> Todd

You may use some commandline based program to send the mails
(wSendmail.exe, Blat.exe, etc. don't remember links, sorry)
	system("blat.exe params < tempfile.txt");
or a module sending the mails through socket()s.
Say SendMailEx.pm or Mail::Sender.pm from
http://www.chipnet.cz/depot/perl.htm

HTH, Jenda


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

Date: Tue, 16 Sep 1997 13:41:08 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: CGI: Installing "Adverts"
Message-Id: <341E7E64.F65EE715@york.ac.uk>


In article <5v69c1$gpu@bgtnsc03.worldnet.att.net>, swspain@value1.com
(Scott W. Spain) wrote:
>
> The problem is that when I run the ads_admin.pl file, it doesn't run.
> I just get a display of the script.  It is chmoded to 755.
> [...]
> In fact, all scripts can be viewed (again, unfortunately) at:
>
> http://www.researchinfo.com/cgi-adverts/

Does your web server know that /cgi-adverts/ is a cgi directory? Also,
check that /cgi-adverts/ is not aliased to anything else, which may
override this setting.

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Tue, 16 Sep 1997 18:29:17 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Chicago User Group
Message-Id: <341ecfc1.337239@news.wwa.com>

On Mon, 15 Sep 1997 20:13:51 -0400, Mus <mus24@erols.com> wrote:

>Is there a Chicago Perl User Group, if so please email me thanks!

And before we have a string of "me too" posts, please post that
information to the group too.  :-)

Faust Gertz


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

Date: Tue, 16 Sep 1997 11:22:55 -0700
From: Richard Moss <rjm@seymour.chem.ubc.ca>
Subject: Confusion of passing references into/outof subs...
Message-Id: <341ECE7E.2781@seymour.chem.ubc.ca>

Hi ya,

I'm kinda new to real reference programming, and am a bit confused over
what prototypes to use (and how) to pass references to (and from) arrays
(the FAQ's were a bit fuzzy over passing references and protos I
thought).  My questions are at the bottom, but here is a bit of
background:

I have a bit of code that returns a ref (to a list of lists):

sub blah {
  my $jobs_split = [];   #make it a ref
  ...
  push @$jobs_split, [@a_job];
  ...
  return $jobs_split
}

That is OK, I get back a good referrence:

$jobs = blah();  #  $jobs->[0][0] etc is fine

But, then to pass that reference to another subroutine I was a bit
confused over how to read it from @_ in the sub, plus how to prototype
it.

At the moment I've got a sub:

my sort_jobs($$$$) {
  my ($first,$second,$third,$jobsref) = @_;
  ...
}

this seems OK (ie the $jobsref->[0][0] etc works fine in the sub), but I
had to proto that argument as "$", not as @ (well obviously?), but _not_
as "\@" ...when I use that I get a ref to a ref to the thing I want.


So when you send ref's directly to subs you proto them as "$"?

You only use the "\" on an arg when you want perl to first take a ref to
you arguement, and then pass that ref?

If the reference arg is proto'd as "$" only, how/can you/ stop a normal
scalar being passed?  (ie is there a proto way of saying "this arg is
_already_ a reference to a whatever, don't re-reference it, but make
sure it's a reference"


thanks for any info/help/tips!

Richard


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

Date: Tue, 16 Sep 1997 18:06:10 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: How do I check who is connected to my socket?
Message-Id: <3424ca60.16883827@igate.hst.moc.com>

[cc'd automagically to original author]

On Tue, 16 Sep 97 11:45:02 -0400, bsa@void.apk.net (Brandon S. Allbery
KF8NH; to reply, change "void" to "kf8nh") wrote:

>In <341E8A72.8949D73E@mekb2.sps.mot.com>, on 09/16/97 at 02:32 PM,
>   Michael Scott <michaels@mekb2.sps.mot.com> said:
>+-----
>| I am in the process of writing my first client-server programs with sockets,
>| but have encountered a problem. I can check what (remote) machine connected
>| to the server port, but cannot find a simple way of finding out who owns the
>| remote (client) process. Any suggestions?
>+--->8
>
>There is no really simple way, because it's not available as such:  you have
>to query identd on the remote machine (and be ready to deal with the remote
>not running identd, in which case you're SOL).

Either that, or build an authentication mechanism into your
application such that users on one end or another can identify
themselves via some trusted mechanism.

Good Luck,

Jeremy
-- 
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio

http://www.marathon.com/

Unless explicitly stated, these are my opinions only--not those of my employer.


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

Date: Tue, 16 Sep 1997 17:03:40 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: How to setup list as class data member
Message-Id: <341EBBEC.4D54@world.northgrum.com>

Sylvain St.Germain wrote:
> 
> In my constructor I do:
> 
>    my $self = $class->SUPER::new(@args);
>     $self->{ValidActions} =
>       ("Print",
>       "Add",
>       "Remove",
>       "Install",
>       "Save Information",
>       "Delete");
> 
> This does not work because of the scalar context of
> $self->{ValidActions} (I think)

Good guess.  Keep in mind that $self->{ValidActions} *IS*
a scalar, so it can hold either a single string/number
or a reference.

> 
> My question is: How can I have list
> assigned to a datamember in the above context??
> 

In this case you can use square brackets to
specify an anonymous array:

   $self->{ValidActions} =
      ["Print",
       "Add",
       "Remove",
       "Install",
       "Save Information",
       "Delete"];

> I would like to be able to do:
> 
> foreach $thing ($myobj->{ValidActions}) {
>         ...
> }

Now that $myobj->{ValidActions} contains a reference to an array,
the actual array would be used as:

   foreach $thing (@{$myobj->{ValidActions}}) {
           ...
   }

See perlref, perldsc and perllol for more examples.


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

Date: Tue, 16 Sep 1997 13:25:14 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: Inserting \n in a string
Message-Id: <341E7AA9.71D56F87@york.ac.uk>

Matt Weber wrote:
> 
> I want to insert a new line (\n) every 75 charectors in a string...any
> suggestions?  I just don't know what function to use.

$line =~ s/(.{0,75})/$1\n/gs;

You could also have a look at Text::Wrap.

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: 16 Sep 1997 17:11:42 GMT
From: Jeffrey Kegler <jeffrey@rahul.net>
Subject: Intel v. Randal Schwartz in Washington Post
Message-Id: <5vmeke$6ro$1@samba.rahul.net>

An article came out in yesterday's (Monday, September 15, 1997, page
F17) _Washington Post_, on Oregon v. Schwartz.  You can find it on the
Web as

<URL:http://search.washingtonpost.com/wp-srv/WPcap/1997-09/15/031r-091597-idx.ht
ml>

You can learn more about the case from 
<URL:http://www.rahul.net/jeffrey/ovs/>.

Cheers!

Jeffrey Kegler



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

Date: Tue, 16 Sep 1997 14:12:59 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: Is Perl for Win32 really as brain damaged as it seems?
Message-Id: <341E85DB.32CC1CA@york.ac.uk>

Bart Lateur wrote:
> 
> jdm@thetics.europa.com (Jessica) wrote:
> 
> >I tried using backticks to execute the command and it would run the
> >command correctly and return the correct output to my script, but for
> >no apparent reason, _it would access a:\ every time the external command
> >was executed_.
> 
> I've seen this once before on a Win95 machine, and Perl had nothing to
> do with it.
> 
> This behaviour started after he ran WinZip once from the floppy drive.
> Apparently, WinZip had installed itself in the registry.
> 
> You need to uninstall it (or any other program that did this) properly.

Not necessarily: just run the registry editor (regedit.exe) and search for
all occurences of 'A:\'. Remove the ones that aren't absolutely necessary
(usually all of them).

HTH,

Russ (more my area of expertise, this, even if not strictly on-topic!)

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Mon, 15 Sep 1997 18:51:14 +0100
From: Russell Odom <rjo100@york.ac.uk>
To: Brett Denner <Brett.W.Denner@lmtas.lmco.com>
Subject: Re: Is there a simpler syntax for: defined $a && $a ne ''
Message-Id: <341D7592.DE8F5FDD@york.ac.uk>

Brett Denner wrote:
> 
> Russell Odom wrote:
> > The Llama book, 1st Ed, p12 (footnote), says undef 'looks like an empty
> > string to the eq operator'. Therefore you could use...
> >
> > $a = 1 if $a eq '';
> 
> It works, unless I've started perl with -w, in which case I still get a
> warning for using an undefined value, which I'm trying to avoid.

Just define it somewhere, then: put "$a = '';" somewhere right at the 
start of your script. 

Randal's suggestion of "$a ||= 1;" would work fine then.

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Wed, 17 Sep 1997 01:27:21 +0800
From: Bremen Lee <bremenlee@att.net.hk>
Subject: method to calculate the time
Message-Id: <341EC179.3A0F@att.net.hk>

Hi,

Is there any simple method to check a file is created today, not
yesterday or other day??

Please send me a mail if you know the answer.


Cheers,

Bremen
bremenlee@attmail.com


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

Date: Tue, 16 Sep 1997 18:27:03 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: method to calculate the time
Message-Id: <3426cf4b.18142257@igate.hst.moc.com>

[cc'd automagically to original author]

On Wed, 17 Sep 1997 01:27:21 +0800, Bremen Lee <bremenlee@att.net.hk>
wrote:

>Hi,
>
>Is there any simple method to check a file is created today, not
>yesterday or other day??
>
>Please send me a mail if you know the answer.

Sure.

Have a look through the perlfunc manpage and be sure to check out the
stat() function and localtime(). They're all you'll need.

Good Luck,

Jeremy
-- 
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio

http://www.marathon.com/

Unless explicitly stated, these are my opinions only--not those of my employer.


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

Date: 16 Sep 1997 11:37:44 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Bremen Lee <bremenlee@att.net.hk>
Subject: Re: method to calculate the time
Message-Id: <8csov5qf47.fsf@gadget.cscaper.com>

>>>>> "Bremen" == Bremen Lee <bremenlee@att.net.hk> writes:

Bremen> Hi,
Bremen> Is there any simple method to check a file is created today, not
Bremen> yesterday or other day??

No.  Unix doesn't store the creation time.  So, no.

Bremen> Please send me a mail if you know the answer.

OK.  I'll send you this. :-)

But if you had asked www.dejanews.com for "created" or "creation time"
in comp.lang.perl.misc, you would have gotten quite a few hits
already, all saying something like this.  So please look there first
next time.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 349 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Tue, 16 Sep 1997 12:50:21 +0100
From: lynn kasdorf <lkasdorf@pressroom.com>
Subject: Need bulk Unix <-> PC file conversion
Message-Id: <341E727C.72FF4874@pressroom.com>

Riddle me this...

I'm doing perl development on my Windows NT box. I'm testing my perl on
my local web server, then uploading to the final destination, which is a
unix server.

I need to convert the PC style (CR LF) files to unix style (LF) files.
The text editor I use can do this (UltraEdit32) but it is kinda tedious.

What is needed is a util for 32 bit Windows that you can drag a tree of
files onto, and it will convert all text files in that tree to unix
style, without changing file names. Also a companion that does the
inverse.

Surely this exists???

I have played with unix2PC and u2x. unix2pc does not do drag and drop,
and makes a new filename, and does not recurse down the tree, and only
goes one way.

u2x truncates file names to 8.3!, does not recurse the dir tree, and
simply flips between modes (I need 2 utils).

Any ideas? Maybe I had better just write this thing...

Lynn Kasdorf
lkasdorf@pressroom.com



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

Date: Tue, 16 Sep 1997 18:04:35 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: Need bulk Unix <-> PC file conversion
Message-Id: <3423c9bf.16722756@igate.hst.moc.com>

[cc'd automagically to original author]

On Tue, 16 Sep 1997 12:50:21 +0100, lynn kasdorf
<lkasdorf@pressroom.com> wrote:

>Riddle me this...
>
>I'm doing perl development on my Windows NT box. I'm testing my perl on
>my local web server, then uploading to the final destination, which is a
>unix server.
>
>I need to convert the PC style (CR LF) files to unix style (LF) files.
>The text editor I use can do this (UltraEdit32) but it is kinda tedious.
>
>What is needed is a util for 32 bit Windows that you can drag a tree of
>files onto, and it will convert all text files in that tree to unix
>style, without changing file names. Also a companion that does the
>inverse.
>
>Surely this exists???
>
>I have played with unix2PC and u2x. unix2pc does not do drag and drop,
>and makes a new filename, and does not recurse down the tree, and only
>goes one way.
>
>u2x truncates file names to 8.3!, does not recurse the dir tree, and
>simply flips between modes (I need 2 utils).
>
>Any ideas? Maybe I had better just write this thing...

Lynn,

How are you transferring the files? If you're using an FTP program,
simply transferring them in ASCII mode instead of BINARY mode will do
the CRLF conversion automatically.

WS-FTP and Cute-FTP for Windows are both capable of this. You should
be able to find either one at www.shareware.com or other large
download repositories. And, yes, they're drag 'n drop. Since they're
32-bit, you won't have filename truncation, either. :-)

Good Luck,

Jeremy
-- 
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio

http://www.marathon.com/

Unless explicitly stated, these are my opinions only--not those of my employer.


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

Date: 16 Sep 1997 18:43:16 GMT
From: "Aaron" <aaron@soltec.net>
Subject: Re: Need bulk Unix <-> PC file conversion
Message-Id: <01bcc2d0$65b86260$b5910a9f@aurora.cna.com>



Hmmmmmmmm
> I need to convert the PC style (CR LF) files to unix style (LF) files.
> The text editor I use can do this (UltraEdit32) but it is kinda tedious.
> 

Let's see

If I were going to do this (and I have wrestled with the problem in the
past)

I would write a perl script that did something like

s/\r/\n/g *.htm

I know you can do it from the command line (UNIX) like this

perl -pi.bak -e 's/\r/\n/g' *.htm

You could write a script that went recursively through the directory system
running this command on each file.

As far as dragging and dropping them while still on your NT system, I don't
know.  I know that on either NT or 95, if I ftp a perl application from a
unix box, and then back I get all those ^Ms.  I usually do it from the
command line like mentioned.

I'm curious if there is a fast utiltity for NT though


> What is needed is a util for 32 bit Windows that you can drag a tree of
> files onto, and it will convert all text files in that tree to unix
> style, without changing file names. Also a companion that does the
> inverse.
> 

I don't know if you can make drag and drop type stuff in Perl (although I
imagine that you might be able to using WinPerl or something)


> Surely this exists???



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

Date: Tue, 16 Sep 1997 18:42:33 GMT
From: knetsch@golden.net.no.spam (SJK)
Subject: Re: NO SPACE
Message-Id: <341ed265.6871278@news.golden.net>

>$variable = "test;
>$variable1 = "";
>$variable2 = "test";
>
>returns
>test
>
>test
>
>but want it to return
>
>test
>test
>
>it returns a blank line in its formated output.... i don't want to have
>that blank line there... but can't figure out what i can put to return
>nothing... 

*sigh*  Ever thought of including your source code?

$variable = "test;
$variable1 = "";
$variable2 = "test";

does not return anything, these lines are all assignment lines.  Until we see
how you are generating your output, we have no idea what you are trying to do,
or what is wrong!

Most likely though, you will have to do test on the variable to see if it has
any content that you want to display.  

Stu

Stuart Knetsch

Remove the you know what from my address to send me E-mail


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

Date: Mon, 15 Sep 1997 19:47:22 +0100
From: Russell Odom <rjo100@york.ac.uk>
Subject: Re: NT Mail Question
Message-Id: <341D82BA.DD9139C1@york.ac.uk>

Ryan wrote:
> 
> First of all, you'll need to
> download or purchase a sendmail program for NT.

Try Blat! from http://gepasi.dbs.aber.ac.uk/softw/Blat.html

>  You should throw away
> Activeware's port of perl for win32's ( really annoying when trying to use
> pipes ) and get Garusam...some funny name's port of perl from CPAN.

 ... at http://www.perl.com/CPAN/ports/win95/Gurusamy_Sarathy/

> Ranson <ranson@infoave.net> wrote in article
> <5ukjqh$18e@news1.infoave.net>...
> >
> > Forgive me, but I know little about NT servers.  I need to write a
> program that
> > is going to send mail from a perl script.

HTH,

Russ

---------------------------------------------------------------------
--[ R u s s e l l    O d o m ]---[ *NEW:* mailto:russ@mail.org.uk ]--
--[  University of York, UK  ]---[ http://www.york.ac.uk/~rjo100/ ]--
---------------------------------------------------------------------
--[    FAQ maintainer, news:comp.os.ms-windows.win95.moderated    ]--
---------------------------------------------------------------------




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

Date: Tue, 16 Sep 1997 12:43:16 +0100
From: lynn kasdorf <lkasdorf@pressroom.com>
Subject: Perl equivalent to #ifdef in C?
Message-Id: <341E70D4.3D22EBC1@pressroom.com>

What is an easy way to enable/disable blocks of code in perl. In C I
would go...


#define    THIS_WAY    TRUE

#ifdef    THIS_WAY
// some c code done one way
#else
// the same code done another way
#endif

There must be an equivalent structure in Perl. This is related to my
previous post in which I *seem* to have to provide DOS style paths in my
perl modules when they are running on a Windows web server, and unix
style paths when on unix. If I can't get the Windows web server to
respond to unix paths, I at least want to be able to flip one "switch"
and go from one style to another without having make changes to the code
in several places.

Any suggestions???

Lynn Kasdorf
lkasdorf@pressroom.com



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

Date: Tue, 16 Sep 1997 19:14:26 +0200
From: vd@bbp.ch (Vincent DETZEL)
Subject: perl launcher which copies STDIN+STDOUT+STDERR to a file
Message-Id: <vd-ya02408000R1609971914260001@news.eunet.ch>

Hello,

I intend to write a perl script which copies STDIN+STDOUT+STDERR to a file
for logging and documentation purpose.

Indeed, instead of writing extra documentation about how to perform some
tasks, what should be the output of a command, what was the installation
parameters we typed, ... I only need to run this perl script with the
program I want to "spy", well ... theorically ...

for example (trivial but more useful than any further words) ...

      % spy.pl csh output.txt
program to spy--^    ^----------output file

      % ls
      this/         is/       a/     directory/       
      % pwd
      /home/users/vd
      % ls file
      file: No such file or directory
      % exit

This will produce the file output.txt with lines ...

      % ls
      this/         is/       a/     directory/       
      % pwd
      /home/users/vd
      % ls file
      file: No such file or directory
      % exit

I tried something with select & fork and exec, but nothing work correctly.
Trouble with buffering and flushing lines (I use select(FD);$|=1;
statement).

But perhaps someone has already written such script ?

-- 
Vincent Detzel, vd@bbp.ch
Biveroni Batschelet Partners AG


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

Date: Tue, 16 Sep 1997 12:38:11 +0100
From: lynn kasdorf <lkasdorf@pressroom.com>
Subject: perl relative path refs w/NT
Message-Id: <341E6FA3.40FECAC@pressroom.com>

Perl/Windows gurus- I could use a little help...

I have been unable to get my perl scripts to refer to other perl modules
via relative paths when running on my NT server. When I move the scripts
to a unix server, relative paths are fine. When on NT, I need to have
absolute pathnames. And, I need to use backslashes (escaped).

Here are some examples: (i'm using Selena Sol's DB manager code). It is
trying to access a file in a subdirectory called "Data_files" at the
same level as the script. This is just one example...

# this works on unix
$data_file_path = "./Data_files/mydata.data";
open (DATABASE, ">>$data_file_path");

# this is what I have to do on windows
$data_file_path =
"C:\\Netscape\\SuiteSpot\\docs\\cgi-bin\\windows_Database_manager\\Data_files\\mydata.data";

open (DATABASE, ">>$data_file_path");

# I've tried...
$data_file_path = ".\\Data_files\\mydata.data";

I get an error message indicating that it cannot open the ptah (and the
path looks correct: ".\Data_Files\mydata.data").


Is this likely a Perl issue, or a web server issue? It is a real bummer
to have to keep 2 copies of the code around. I would think that a
Windows port of Perl should be able to understand unix style paths,
since Windows web servers do.

Help!!
Lynn Kasdorf
lkasdorf@pressroom.com



I'm running Netscape Enterprise server 3.0 on Windows NT 4.0. I'm
running Perl for Win32  version 5.003 built 3.10.




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

Date: Tue, 16 Sep 1997 18:01:01 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: perl relative path refs w/NT
Message-Id: <3422c8d3.16486826@igate.hst.moc.com>

[cc'd automagically to original author]

On Tue, 16 Sep 1997 12:38:11 +0100, lynn kasdorf
<lkasdorf@pressroom.com> wrote:

>Perl/Windows gurus- I could use a little help...
>
>I have been unable to get my perl scripts to refer to other perl modules
>via relative paths when running on my NT server. When I move the scripts
>to a unix server, relative paths are fine. When on NT, I need to have
>absolute pathnames. And, I need to use backslashes (escaped).
>
>Here are some examples: (i'm using Selena Sol's DB manager code). It is
>trying to access a file in a subdirectory called "Data_files" at the
>same level as the script. This is just one example...
>
># this works on unix
>$data_file_path = "./Data_files/mydata.data";
>open (DATABASE, ">>$data_file_path");
>
># this is what I have to do on windows
>$data_file_path =
>"C:\\Netscape\\SuiteSpot\\docs\\cgi-bin\\windows_Database_manager\\Data_files\\mydata.data";
>
>open (DATABASE, ">>$data_file_path");
>
># I've tried...
>$data_file_path = ".\\Data_files\\mydata.data";
>
>I get an error message indicating that it cannot open the ptah (and the
>path looks correct: ".\Data_Files\mydata.data").
>
>
>Is this likely a Perl issue, or a web server issue? It is a real bummer
>to have to keep 2 copies of the code around. I would think that a
>Windows port of Perl should be able to understand unix style paths,
>since Windows web servers do.

Doesn't look like a Perl problem. On my NT Workstation 4.0sp3, using
ActiveState's Perl 306, I did the following:

---sample run---

 M:\perl\test>perl filetest.pl
 File exists using DOS type file paths.
 File exists using Unix type file paths.

 M:\perl\test>

---end sample run---
The contents of filetest.pl are:

---code---

if (-e ".\\filetest.pl") {
	print "File exists using DOS type file paths.\n";
}

if (-e "./filetest.pl") {
	print "File exists using Unix type file paths.\n";
}

---end code---

Try it and see if it runs for you, too...

Jeremy
-- 
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio

http://www.marathon.com/

Unless explicitly stated, these are my opinions only--not those of my employer.


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

Date: Tue, 16 Sep 1997 20:34:40 -0700
From: Jan Krynicky <Jan.Krynicky@st.mff.cuni.cz>
To: lkasdorf@pressroom.com
Subject: Re: perl relative path refs w/NT
Message-Id: <341F4FD0.301B@st.mff.cuni.cz>

lynn kasdorf wrote:
> 
> Perl/Windows gurus- I could use a little help...
> 
> I have been unable to get my perl scripts to refer to other perl modules
> via relative paths when running on my NT server. When I move the scripts
> to a unix server, relative paths are fine. When on NT, I need to have
> absolute pathnames. And, I need to use backslashes (escaped).
> 
> Here are some examples: (i'm using Selena Sol's DB manager code). It is
> trying to access a file in a subdirectory called "Data_files" at the
> same level as the script. This is just one example...
> 
> # this works on unix
> $data_file_path = "./Data_files/mydata.data";
> open (DATABASE, ">>$data_file_path");
> 
> # this is what I have to do on windows
> $data_file_path =
> "C:\\Netscape\\SuiteSpot\\docs\\cgi-bin\\windows_Database_manager\\Data_files\\mydata.data";
> 

The problem ocures only if you run the script as a CGI? Right?
Try to print the current directory. You may find out it's not set
properly.
You have to cwd to the directory where the main script resides

	use cwd;
	{
	 my $path=$0;
	 $path =~ s{(.*)[/\\][^/\\]+$}{$1};
	 cwd $path;
	}

on top of the scripts should help.

HTH, Jenda

> Help!!
> Lynn Kasdorf
> lkasdorf@pressroom.com
> 

HTH, Jenda


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

Date: Tue, 16 Sep 1997 18:39:43 GMT
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: test
Message-Id: <Pine.A41.3.95a.970916203844.116418D-100000@sp052>

On Tue, 16 Sep 1997, RobStone wrote:

> This is a test message 

Can't be - this isn't a test group.  QED.

-- 

         "Any sufficiently advanced cluelessness is indistinguishable
         from humor"  (I'm not sure who said it first, but how true).





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

Date: 16 Sep 1997 13:32:30 -0500
From: Justin Banks <justinb@springer.cray.com>
Subject: Re: Why can't I talk directly to the mail daemon?
Message-Id: <o8npvq9yurl.fsf@springer.cray.com>

Lars Thegler <lth@dannet.dk> writes:

> You can't pipe input to telnet via STDIN like that. telnet is an
> interactive application, and so assumes a bi-directional terminal.

On every system I've used, the following works just fine :

springer<justinb>68% set a="MAIL FROM: justinb@cray.com\nRCPT TO: justinb@cray.com\nDATA\nTest Line 1\n.\n"
springer<justinb>69% echo $a | telnet localhost 25


> In 'perldoc perlipc', there's a section titeled 'Bidirectional
> Communication with Another Process' which should show you what to do. But
> beware: this is not for the faint-of-heart!
> 
> A *much* easier solution for you is to use the Net::SMTP module:
> 

Doesn't this just use sendmail? I thought he said he didn't want to use 
sendmail. The following works just fine for me :

$a = "MAIL FROM: justinb\@cray.com\nRCPT TO: justinb\@cray.com\nDATA\n";
$a .= "Test Line 1\nQUIT\n";
open MAIL, "|telnet springer 25" || die "Aaaagh : $!";
select MAIL;
$| = 1;
print $a;
close MAIL;
exit;



-- 
Justin Banks      \ If you spam me, I promise to go upstream from you until I
Silicon Graphics  \ find someone that cares. Then, I'll think about charging
Eagan, Minnesota  \ you for my time. Do it at your own risk


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

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 1033
**************************************

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