[24540] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6718 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 23 06:05:49 2004

Date: Wed, 23 Jun 2004 03:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 23 Jun 2004     Volume: 10 Number: 6718

Today's topics:
    Re: 2 queries- first day of month and  reading zipped f <josef.moellers@fujitsu-siemens.com>
    Re: alternative to cwd() <nick@erkert.com>
    Re: anonymous fork, one writer, many readers <bobsmith@[spamguard]jippii.fi>
    Re: anonymous fork, one writer, many readers <Joe.Smith@inwap.com>
    Re: Failed to connect to <spam@infocopter.ch>
    Re: Help! - Need a CGI redirect which passes a querystr <postmaster@castleamber.com>
    Re: Help! - Need a CGI redirect which passes a querystr <flavell@ph.gla.ac.uk>
    Re: Idiom for partitioning array? (Anno Siegel)
    Re: Perl DNS reverse lookups -- multiple IP addresses p <vetro@online.no>
    Re: Perl editors and debuggers (krakle)
        split xml file between two processing instructions (kcwolle)
    Re: split xml file between two processing instructions (Anno Siegel)
        Unable to send email from perl script (da_sotong)
    Re: Unable to send email from perl script <andre.wisniewski@gmx.de>
    Re: Unable to send email from perl script <bernard.el-haginDODGE_THIS@lido-tech.net>
    Re: Using Perl to create user accounts on Windows 2003 <ThomasKratz@REMOVEwebCAPS.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 23 Jun 2004 09:12:01 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: 2 queries- first day of month and  reading zipped files directly off server
Message-Id: <cbbab4$hd7$1@nntp.fujitsu-siemens.com>

Paul Lalli wrote:
> On Tue, 22 Jun 2004, Shalini Joshi wrote:

>>I am supposed to be writing perl code which , opens and reads a
>>particular file only if it's the first day of the month; otherwise it
>>reads another file always. I'd really appreciate any comments on how
>>to proceed with this one.
>=20
>=20
> What part do you need help with?  What have you done so far?  Where did=

> you get stuck?

> perldoc Date::Manip

You're shooting with canons on sparrows, as we say in Germany.
The first of the month usually has a dom of 0, so

perldoc -f localtime

Unless, of course, Shalini is looking for "the first working day" of the =

month. Then, I'm afraid, even Date::Manip falls short in detemining the=20
local holidays.

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Tue, 22 Jun 2004 18:49:05 -0700
From: Nicholas Erkert <nick@erkert.com>
Subject: Re: alternative to cwd()
Message-Id: <40d8e58b@nntp0.pdx.net>

Sunil wrote:

> Hi All,
>     I need to find the current working directory, Is there any alternative
> to
>             use Cwd;
>             $pwd = cwd();
> 
>         I am looking for a solution other than using system() or backtics
> (``).
> 
> Thanks,
> Sunil.
> 
> 
> 
> 
One way you could do it would be using the syscall function. 
Unfortunately doing so seems to take about twice the time to run than 
just using cwd.
-----------------Using syscall-----------------------
#!/usr/bin/perl
require 'syscall.ph';

#prepare the gunk string for up to 2048 chars
$gunk = pack('A2048', ' ');

#call getcwd, not sure if it would be off by one if I used 2048
#here so just to be safe I used 2047.
syscall(&SYS_getcwd, $gunk, 2047);

#trim off trailing whitespace
$gunk =~ s/\s+$//;

print "$gunk\n";
-----------------------------------------------------
time ./test.pl
/home/nekret/public_html
0.07user 0.00system 0:00.08elapsed 84%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (385major+206minor)pagefaults 0swaps


---------------Using cwd-----------------------------
#!/usr/bin/perl
use Cwd;

print cwd() . "\n";
-----------------------------------------------------
time ./test2.pl
/home/nekret/public_html
0.04user 0.00system 0:00.05elapsed 70%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (535major+222minor)pagefaults 0swaps


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

Date: Wed, 23 Jun 2004 10:25:40 +0300
From: "greger" <bobsmith@[spamguard]jippii.fi>
Subject: Re: anonymous fork, one writer, many readers
Message-Id: <D3aCc.2563$mK.1555@reader1.news.jippii.net>


"Edouard GAULUE" <Edouard.Gaulue@ensg.ign.fr> wrote in message
news:77a8fc.0406221343.19870327@posting.google.com...
> Hi,
>
> I'm lookink for help on a little script using the perl 'pipe' :
> - pipe creation
> - writing in the pipe (with $|=1)
> - closing the writing side
> - fork 1
>  while :
>   * reading in the pipe and showing
>   * waiting randomly
>  exit
> - fork 2
>  while :
>   * reading in the pipe and showing
>   * waiting randomly
>  exit
> - père
>  while :
>   * reading in the pipe and showing
>   * waiting randomly
>  exit
>
> If I write in my pipe :
> aze
> qsd
> wxc
> I get 3 time those lines (whatever the order). I thought after a fork,
> childrens and father dealt with the same count on the file in their
> file descriptor so that a line read by one couldn't be read by
> another.
>
> Is that wrong ? How to do ? Is this link with the way 'pipe' has been
> implemented in perl ? Will it work with a named pipe (I would have
> prefered not to give any filename that mean controling access right to
> this file) ? Your opinion ?
>
> Thanks for your answers, EG
it depends, can you post some code?
/G
--
www.gh-webinteractive.com





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

Date: Wed, 23 Jun 2004 09:35:38 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: anonymous fork, one writer, many readers
Message-Id: <K9cCc.92246$eu.35784@attbi_s02>

Edouard GAULUE wrote:

> I get 3 time those lines (whatever the order). I thought after a fork,
> childrens and father dealt with the same count on the file in their
> file descriptor so that a line read by one couldn't be read by
> another.

Depends on how fork() is implemented on your system.
In some cases, the children have duplicates of all the parent's
variables, including unread data in file handle input buffers.

It's better to write to the pipe *after* all the child processes
have been created.
	-Joe


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

Date: Wed, 23 Jun 2004 10:31:13 +0200
From: Reto Hersiczky <spam@infocopter.ch>
To:  bobo_shooter85@hotmail.com
Subject: Re: Failed to connect to
Message-Id: <40D93FD1.5010803@infocopter.ch>

Sounds like your host doesn't have the privilege to connect to
the related mail server. I suggest to make a

telnet mailhost.example.org 25

at your shell prompt on the machine where this problem occurs
and look if you see the remote mailserver's welcome message
or not.

You can use MIME::Lite in a fashion with Sendmail instead of smtp:

MIME::Lite->send("sendmail", "/usr/sbin/sendmail -t -oi -oem");

(Check the path: "which sendmail" as root)
This will work if your Sendmail is configured correctly ;-)

HTH
--Reto

p.s.
I agree with Bob's posting:
Copy/paste your code!

da_sotong wrote:
> Hi all, 
> 
> I've a perl script that does the sending of email using MIME..however
> i keep getting this error when i run the script: Failed to connect to
> mail server: Unknown error.
> 
> Any one has any idea how i can solve this problem? Thanks in advance =)


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

Date: Wed, 23 Jun 2004 00:27:53 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Help! - Need a CGI redirect which passes a querystring  value
Message-Id: <40d914db$0$213$58c7af7e@news.kabelfoon.nl>

raymond wrote:

> Should not be sent content-type for redirection so need this line for below example
> 
> print "Content-type: text/html\n\n";  **no need
> 
> 
> raymond raj

If you don't top-post, it's more easy to reply for you, and for us to 
understand.

-- 
John                               MexIT: http://johnbokma.com/mexit/
                            personal page:       http://johnbokma.com/
    Experienced Perl programmer available:     http://castleamber.com/
             Happy Customers: http://castleamber.com/testimonials.html


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

Date: Wed, 23 Jun 2004 09:08:45 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Help! - Need a CGI redirect which passes a querystring  value
Message-Id: <Pine.LNX.4.53.0406230905570.31962@ppepc56.ph.gla.ac.uk>

On Wed, 22 Jun 2004, raymond blurted out atop a fullquote:

> Should not be sent content-type for redirection

Wrong.  RTFRFC.  This is off-topic for a Perl language group so I'll
say no more about that.  Discerning usenauts know that anything posted
in TOFU format needs to be distrusted.


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

Date: 23 Jun 2004 09:56:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Idiom for partitioning array?
Message-Id: <cbbk4o$gol$2@mamenchi.zrz.TU-Berlin.DE>

J Krugman  <jkrugman345@yahbitoo.com> wrote in comp.lang.perl.misc:
> 
> 
> Is there a nice Perl idiom for partitioning an array of length N
> into "subarrays of length n" (i.e. array refs pointing to arrays
> of length n)?  (If N is not a multiple of n, the last entry of the
> partitioned array should be a subarray of length N mod n.) For
> example, if n = 3, and the input array is
> 
>   ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h')
> 
> the partitioned array should be:
> 
>   (['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h'])

    map [ splice @a, 0, $n], 0 .. $#a/$n;

Anno


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

Date: Wed, 23 Jun 2004 09:48:20 +0200
From: "Vetle Roeim" <vetro@online.no>
Subject: Re: Perl DNS reverse lookups -- multiple IP addresses per line
Message-Id: <opr91emuwc3hk3cf@quickfix.opera.com>

On 22 Jun 2004 15:05:12 -0700, Maynard <rev_maynard3@hotmail.com> wrote:

> Petri <Petri_member@newsguy.com> wrote...
>
>> It may be useful at the OP's network.
>> He might be running split-DNS, with an internal reverse zone for
>> 0.0.168.192.in-addr.arpa.
>> In that case he would catch names of internal systems, instead of their
>> IP-addresses.
>
>
> Which is true in my case.  Those get translated to host names on my
> network, which is always nice.
>
> Thanks everyone for your responses and suggestions; I took some of
> them and implemented a couple extras... like a hash file that "caches"
> names/IPs, so that only new ones get looked up (saves tons of time
> when there's a 2 second delay when a host doesn't have a DNS record),
> and just for you John, I added a switch that skips non-routable IP
> addrs, just in case you want to do that.

   For maximum speed I recommend using Net::DNS::Resolver and the
   bgsend method, to send multiple requests before waiting for
   answers, and then using IO::Select to read the answers as they
   become available.

   Incidentally, there's already a script that does this:
   <URL: http://jdrowell.com/projects/jdresolve >

   It may not be neccessary to do it like this, but that depends on
   the amount of data. I've created a script that has to resolve
   millions of IP addresses in a reasonable amount of time, and
   Net::DNS::Resolver in combination with IO::Select seems to be
   the way to go.


[...]
-- 
Touch eyeballs to screen for cheap laser surgery!


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

Date: 23 Jun 2004 00:07:55 -0700
From: krakle@visto.com (krakle)
Subject: Re: Perl editors and debuggers
Message-Id: <237aaff8.0406222307.5a898d83@posting.google.com>

"William Fields" <Bill_Fields@azb.uscourts.gov> wrote in message news:<cba8rv$plc$1@apollo.nyed.circ2.dcn>...
> Hello,
> 
> Just looking for recommendations.
> 

As for editors... I use Scite/Scrintella...


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

Date: 23 Jun 2004 01:05:56 -0700
From: kcwolle@freenet.de (kcwolle)
Subject: split xml file between two processing instructions
Message-Id: <4e98b249.0406230005.35fa05a9@posting.google.com>

hello,

I want to split an xml file on processing instructions into different
files.
All content between the two PIs should be included in the new file.
The file name should contain the content of first and the last <no>
elements.


example:
<?split ?>
<h1>... text ...</h1>
<start-element/>
<text>
 ...text text text...
<nr>4</nr>
</text>
text text text
<nr>18</nr>
<end-element/>
<h6> ... text ...</h6>
<?split ?>

In this case the file name should be: test-no4to18.xml and everything
from <h1> to </h6> should be included.
(btw there can be different start and end tags so that no rule on the
starting and ending elements is possible)
I would like to use an XML module (eg XML::Twigs) but how do I get a
node list that contains all nodes between the processing instructions
for further processing?

Can anybody help me?

Yours

Wolfgang


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

Date: 23 Jun 2004 08:55:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: split xml file between two processing instructions
Message-Id: <cbbgi3$gol$1@mamenchi.zrz.TU-Berlin.DE>

kcwolle <kcwolle@freenet.de> wrote in comp.lang.perl.misc:
> hello,
> 
> I want to split an xml file on processing instructions into different
> files.
> All content between the two PIs should be included in the new file.
> The file name should contain the content of first and the last <no>
> elements.
> 
> 
> example:
> <?split ?>
> <h1>... text ...</h1>
> <start-element/>
> <text>
> ...text text text...
> <nr>4</nr>
> </text>
> text text text
> <nr>18</nr>
> <end-element/>
> <h6> ... text ...</h6>
> <?split ?>
> 
> In this case the file name should be: test-no4to18.xml and everything
> from <h1> to </h6> should be included.
> (btw there can be different start and end tags so that no rule on the
> starting and ending elements is possible)
> I would like to use an XML module (eg XML::Twigs) but how do I get a
> node list that contains all nodes between the processing instructions
> for further processing?

What have you tried so far?

We help people with programming, but we don't deliver programs
according to specification.

Anno


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

Date: 23 Jun 2004 00:27:59 -0700
From: bobo_shooter85@hotmail.com (da_sotong)
Subject: Unable to send email from perl script
Message-Id: <9cd15a3b.0406222327.31df6679@posting.google.com>

Hi all, 

I have a perl script that does the sending of email. However i keep
getting the same error when i run the script:

Failed to connect to mail server: Unknown error

I'm quite sure that the codes are correct (as the script COULD work on
my colleagues' machine)..i'm suspecting that it's my configuration of
my machine...I'm using win2k for now...installed all the necessary
modules and IIS ....wat could be the error?


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

Date: Wed, 23 Jun 2004 09:36:13 +0200
From: "Andre Wisniewski" <andre.wisniewski@gmx.de>
Subject: Re: Unable to send email from perl script
Message-Id: <opr91d2nh8udlqzq@ares>

>
> I have a perl script that does the sending of email. However i keep
> getting the same error when i run the script:
>
> Failed to connect to mail server: Unknown error
>
> I'm quite sure that the codes are correct (as the script COULD work on
> my colleagues' machine)

So why ask here?

> ..i'm suspecting that it's my configuration of
> my machine...I'm using win2k for now...installed all the necessary
> modules and IIS ....wat could be the error?

How about asking a win2k group?

Unbelievable!



-- 
Andre

---

Fighting for peace is like f..ing for virginity


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

Date: Wed, 23 Jun 2004 09:35:13 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Unable to send email from perl script
Message-Id: <Xns951161D69C06Belhber1lidotechnet@62.89.127.66>

bobo_shooter85@hotmail.com (da_sotong) wrote:

> Hi all, 
> 
> I have a perl script that does the sending of email. However i
> keep getting the same error when i run the script:
> 
> Failed to connect to mail server: Unknown error
> 
> I'm quite sure that the codes are correct (as the script COULD
> work on my colleagues' machine)..i'm suspecting that it's my
> configuration of my machine...I'm using win2k for now...installed
> all the necessary modules and IIS ....wat could be the error?


If you're sure the code is correct and you suspect that it's a problem 
with your machine why are you asking here?


-- 
Cheers,
Bernard


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

Date: Wed, 23 Jun 2004 11:16:08 +0200
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: Using Perl to create user accounts on Windows 2003
Message-Id: <40d94a58$0$14527$bb690d87@news.main-rheiner.de>

Maynard wrote:
> Hello all,
> 
> I have Windows 2003 FTP servers that I store content on for external
> users to pick up on a schedule.  Unfortunately I have about 300 of
> such users, and multiple servers.  The time and energy to create these
> user accounts is obviously a factor, especially if I have to rebuild a
> box and have it up and running quickly.
> 
> So, I went looking for Perl scripts / modules that could do this, but
> all I came up with was some old (for NT4) ones that used
> Win32::Lanman.  I'm not creating domain (Active Directory) accounts,
> just local ones on the box.  I have the users in a comma-delimited
> file, and really just need a shove in the right direction.
> 
> Any suggestions would be most appreciated.

What's wrong with Win32::Lanman? AFAIK it should work under W2k+3.
Alternatively use Win32::OLE to do it via the WMI interface.

Thomas

-- 
open STDIN,"<&DATA";$=+=14;$%=50;while($_=(seek( #J~.> a>n~>>e~.......>r.
STDIN,$:*$=+$,+$%,0),getc)){/\./&&last;/\w| /&&( #.u.t.^..oP..r.>h>a~.e..
print,$_=$~);/~/&&++$:;/\^/&&--$:;/>/&&++$,;/</  #.>s^~h<t< ..~. ...c.^..
&&--$,;$:%=4;$,%=23;$~=$_;++$i==1?++$,:_;}__END__#....>>e>r^..>l^...>k^..


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V10 Issue 6718
***************************************


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