[18651] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 819 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 2 09:05:52 2001

Date: Wed, 2 May 2001 06:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <988808711-v10-i819@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 2 May 2001     Volume: 10 Number: 819

Today's topics:
    Re: $Response->printf ("my float rounded up to 2 dp."); <ubl@schaffhausen.de>
    Re: $Response->printf ("my float rounded up to 2 dp."); nobull@mail.com
    Re: $Response->printf ("my float rounded up to 2 dp."); <bart.lateur@skynet.be>
    Re: $Response->printf ("my float rounded up to 2 dp."); <justin.devanandan.allegakoen@intel.com>
    Re: $Response->printf ("my float rounded up to 2 dp."); <justin.devanandan.allegakoen@intel.com>
    Re: $Response->printf ("my float rounded up to 2 dp."); <justin.devanandan.allegakoen@intel.com>
    Re: $Response->printf ("my float rounded up to 2 dp."); <justin.devanandan.allegakoen@intel.com>
    Re: Another regexp question <pne-news-20010502@newton.digitalspace.net>
    Re: Does 'exec' never fail? <bernie@fantasyfarm.com>
    Re: Hacker challenge. Can you break this script for me? <bart.lateur@skynet.be>
    Re: Hacker challenge. Can you break this script for me? (Gwyn Judd)
        Help:  Could somebody tell me how to find built in func <cfs3526@ureach.com>
        Help: Time issue u518615722@spawnkill.ip-mobilphone.net
    Re: Help: Time issue (EED)
    Re: How to: Create Regex which extracts N number of wor <bart.lateur@skynet.be>
        newbie perl question ....please help.... <fail00@hotmail.com>
    Re: newbie perl question ....please help.... (Tad McClellan)
        Perl and maps u376617431@spawnkill.ip-mobilphone.net
    Re: Perl and maps (EED)
    Re: Perl and maps <bart.lateur@skynet.be>
        Please help! <jpratt@ssr-inc.com>
    Re: Q: Using 'rename' with CGI <news@shannonbrown.net>
    Re: Q: Using 'rename' with CGI <news@shannonbrown.net>
    Re: Question about float to hex <bart.lateur@skynet.be>
    Re: Question about float to hex <dodger@necrosoft.net>
    Re: Reading one character through a socket nobull@mail.com
    Re: RegExp Teaser <s.warhurst@rl.ac.uk>
    Re: RegExp Teaser <s.warhurst@rl.ac.uk>
    Re: Regular expression for zip code <pne-news-20010502@newton.digitalspace.net>
        sendmail more reliable with -t flag??? u251892089@spawnkill.ip-mobilphone.net
    Re: Should Perl be first? <tom.beer@btfinancialgroup.spamfilter.com>
    Re: Should Perl be first? <tom.beer@btfinancialgroup.spamfilter.com>
        sub z {return } print ((($x,$y)=z) ? "yes:$x,$y\n" : "n (EED)
    Re: sub z {return } print ((($x,$y)=z) ? "yes:$x,$y\n"  (Rafael Garcia-Suarez)
    Re: sub z {return } print ((($x,$y)=z) ? "yes:$x,$y\n"  (Gwyn Judd)
    Re: Testing whether a socket is still connected <hafner-usenet@ze.tu-muenchen.de>
        Unicode sucks. I'm dumb at it. (Cameron)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 02 May 2001 10:38:24 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: $Response->printf ("my float rounded up to 2 dp.");
Message-Id: <3AEFD58F.7DC52BC7@schaffhausen.de>



Just in schrieb:
> 
> Dear all,
> 
> I am using PerlScript to present a report on an asp.
> Perl is good for me, up until the point (pun intended), where I get stuck.
> If one of you kind souls could point me in the right direction, I'd be very
> much obliged.
> 
> I have a float variable that needs displaying, it has no fixed dp length,
> but I want it rounded up or down to 2 dp, and displayed.
> 
> $Response->Write displays it as a horridly long float, and what I would like
> here is printf functionality.

I'm just guessing.
What about:

$Response->Write(sprintf(...))
sprintf has the same semantics as printf but returns a value rather than printing
it.

->malte


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

Date: 02 May 2001 08:36:10 +0100
From: nobull@mail.com
Subject: Re: $Response->printf ("my float rounded up to 2 dp.");
Message-Id: <u9vgnkxi08.fsf@wcl-l.bham.ac.uk>

"Just in" <justin.devanandan.allegakoen@intel.com> writes:

> I have a float variable that needs displaying, it has no fixed dp length,
> but I want it rounded up or down to 2 dp, and displayed.

> FAQ points me to POSIX...

  ...as a second option.

Try the first option the FAQ offers.

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


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

Date: Wed, 02 May 2001 09:41:15 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: $Response->printf ("my float rounded up to 2 dp.");
Message-Id: <ahlvetsjmaid112bp5s51gdb6632brhr8r@4ax.com>

Just in wrote:

>I have a float variable that needs displaying, it has no fixed dp length,
>but I want it rounded up or down to 2 dp, and displayed.
>
>$Response->Write displays it as a horridly long float, and what I would like
>here is printf functionality.

Perhaps you should use printf, or sprintf, then.

	printf '%3.2f', $Response->Write;

I don't know where your code snippet came from, so maybe I'm talking
rubbish.

-- 
	Bart.


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

Date: Wed, 2 May 2001 17:30:16 +0800
From: "Just in" <justin.devanandan.allegakoen@intel.com>
Subject: Re: $Response->printf ("my float rounded up to 2 dp.");
Message-Id: <9cok3b$p17@news.or.intel.com>

Malte was kind enoungh to point me in the right direction with an example to
boot - thanks.

FAQ says use printf or sprintf, it didnt tell me I could stick it in
$Response->Write.
I didnt have the slightest inkling that I could stick it in. I'm not very
adventurous when it
comes to this sort of thing, and FAQ didnt really address this in a way that
a dumbo like
me could understand ; )






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

Date: Wed, 2 May 2001 17:10:00 +0800
From: "Just in" <justin.devanandan.allegakoen@intel.com>
Subject: Re: $Response->printf ("my float rounded up to 2 dp.");
Message-Id: <9coiu6$oql@news.or.intel.com>

> I'm just guessing.
> What about:
>
> $Response->Write(sprintf(...))
> sprintf has the same semantics as printf but returns a value rather than
printing
> it.
>
> ->malte

That kind Sir is the answer, it works a treat - thanks a lot.







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

Date: Wed, 2 May 2001 17:05:50 +0800
From: "Just in" <justin.devanandan.allegakoen@intel.com>
Subject: Re: $Response->printf ("my float rounded up to 2 dp.");
Message-Id: <9coiqr$on7@news.or.intel.com>

> I'm just guessing.
> What about:
>
> $Response->Write(sprintf(...))
> sprintf has the same semantics as printf but returns a value rather than
printing
> it.
>
> ->malte

That kind Sir is the answer, it works a treat - thanks a lot.





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

Date: Wed, 2 May 2001 17:10:00 +0800
From: "Just in" <justin.devanandan.allegakoen@intel.com>
Subject: Re: $Response->printf ("my float rounded up to 2 dp.");
Message-Id: <9coita$oqk@news.or.intel.com>

> I'm just guessing.
> What about:
>
> $Response->Write(sprintf(...))
> sprintf has the same semantics as printf but returns a value rather than
printing
> it.
>
> ->malte

That kind Sir is the answer, it works a treat - thanks a lot.







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

Date: Wed, 02 May 2001 13:28:00 +0200
From: Philip Newton <pne-news-20010502@newton.digitalspace.net>
Subject: Re: Another regexp question
Message-Id: <gorvet8bh5h4sivl48mhamnhpoag7r4sa7@4ax.com>

On Tue, 01 May 2001 23:26:56 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:

> \1 has a meaning outside regexes: it's a reference to the scalar 1.

And it has a different meaning inside double-quotish contexts, such as
the right-hand side of a substitution. (Try using \40, for example --
or any number larger than 9.)

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Wed, 02 May 2001 08:07:04 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: Does 'exec' never fail?
Message-Id: <eitvetoa1jti8fbk8c5bku623bhelpp7p9@news.supernews.net>

eins@durchnull.de (Rudolf Polzer) wrote:

} Bernie Cosell <bernie@fantasyfarm.com> wrote:
} > I try to be a cautious coder, and so I assume that an exec might not work
} > and try to do something reasonable [log, print to stderr, whatever...
} > depends on what sort of app it is].  the code might look like:
} >     exec <some program>
} >     [cleanup if the program doesn't go]
} >     die <WHAT HAPPENED>
} >
} > OTOH, if exec *CAN* return in the face of an error, then the warning above
} > is not only not correct but *BAD* advice: indeed, any program that
} > *doesn't* handle the case that the exec failed is basically an accident
} > waiting to happen (lest the exec return and the program race along
} > executing code it never should have --- sort of the same class of problem
} > as forgetting to put an 'exit' in the child-code after a 'fork').
} 
} See perldoc -f exec. ...

Must be in the docs for a later version of perl --- on my sys [5.004]
there's no mention of the cleanup stuff at all  [on my perl, -f exec ends
with:

 [...]
>>> or, more directly,
>>> 
>>>     exec {'/bin/csh'} '-sh';    # pretend it's a login shell
>>> 
>>> When the arguments get executed via the system shell, results will
>>> be subject to its quirks and capabilities.  See L<perlop/"`STRING`">
>>> for details.

} ... This is a 'feature' that should warn you when you
} use exec() instead of system().

What's bizarre is that it can *NEVER* be a 'feature' -- it is, IMO, very
bad programming practice not to check for errors [don't folk HARP on that
around here all the time].  Plain and simple, exec can/does fail and perl
basically encourages you to program poorly/dangerously [as I mentioned: ala
the 'forgetting to put an exit in the child fork branch' -- if, say, your
PATH is wrong and you can't find the program to exec, instead of dealing
with it gracefully, your program will just run onto what random code came
next in the source... that *can't* be a good programming practice to
virtually force on folk.


Aha... found a copy of 5.6 and indeed, the docs for 'exec' have been
changed:

>>>             Since it's a common mistake to use `exec' instead of `system',
>>>             Perl warns you if there is a following statement which isn't
>>>             `die', `warn', or `exit' (if `-w' is set - but you always do
>>>             that).

As a side note, in 5.004 turning off warnings doesn't help [I tried the
simple 'local $^W' and still got the warning...]  I can't wait until we
upgrade our system and I can move to 5.6...:o)

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: Wed, 02 May 2001 09:11:41 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Hacker challenge. Can you break this script for me?
Message-Id: <mijvets5ng8ltgtc3o1evv4ciqk0liip1k@4ax.com>

Gwyn Judd wrote:

>Actually I like this example:

># CODE
># $stripped = 0
># CODE
>
>seek DATA, 0, SEEK_SET;
>while (<DATA>)
>{
>    next unless /^# CODE/ ... /^# CODE/;
>  
>    s/^#//;
>    eval;
>}

What is eval 'CODE' supposed to do? Because both your start and end
conditions are included in the stripped and evalled lines.

(change:)
	eval;
	print ">> $@" if $@;

--->
	>> Bareword "CODE" not allowed while "strict subs" in use at
	 (eval 1) line 1, <DATA> line 9.

-- 
	Bart.


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

Date: Wed, 02 May 2001 09:38:47 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Hacker challenge. Can you break this script for me?
Message-Id: <slrn9evp9s.2qi.tjla@thislove.dyndns.org>

"mein Luftkissenfahrzeug ist voll von den Aalen"
said Bart Lateur (bart.lateur@skynet.be) in 
<mijvets5ng8ltgtc3o1evv4ciqk0liip1k@4ax.com>:
>What is eval 'CODE' supposed to do? Because both your start and end
>conditions are included in the stripped and evalled lines.
>
>--->
>	>> Bareword "CODE" not allowed while "strict subs" in use at
>	 (eval 1) line 1, <DATA> line 9.

Well, it's a good thing I didn't do 'print $@ if $@' then, isn't it?
Anyway, that's one of the point of using "eval". It's for running code
that might fail. In this case, the "code" that failed didn't do anything
interesting, so why should I print out an error message? It might have
been more significant if I was "eval"ing something that I didn't know
the contents of, but I did choose the start and end markers so that they
would have no other side effects.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
I'm very old-fashioned.  I believe that people should marry for life,
like pigeons and Catholics.
		-- Woody Allen


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

Date: Wed, 02 May 2001 11:56:16 GMT
From: "ff" <cfs3526@ureach.com>
Subject: Help:  Could somebody tell me how to find built in functions in Bash, solaris 2.6?
Message-Id: <ABSH6.9328$Aj1.4155752@typhoon2.ba-dsg.net>

I tried $builtin as some book suggested, but it failed.

Thanks




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

Date: Fri, 27 Apr 2001 19:23:33 GMT
From: u518615722@spawnkill.ip-mobilphone.net
Subject: Help: Time issue
Message-Id: <l.988399414.1134460449@[198.138.198.252]>

I have a string extracted from <STDIN>,
04/26/2001 15:03:46

how can i make it assigned as
(my $sec,my $min, my $hour, my $mday, my $mon, 
my $year)=(46,3,15,4,26,2001)?

I tried
(my $sec,my $min, my $hour, my $mday, my $mon, 
my $year, my $wday, my $yday,my $isdst)= 
timelocal(04/26/2001 15:03:46), 
but it is not working.

Thanks for your help.
 



-- 
Sent by dbadba62 from  hotmail subpart from  com
This is a spam protected message. Please answer with reference header.
Posted via http://www.usenet-replayer.com/cgi/content/new


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

Date: Wed, 02 May 2001 13:57:53 +0200
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: Re: Help: Time issue
Message-Id: <3AEFF641.B52EC154@eed.ericsson.se>

Why do you cross-post this question to .modules?

u518615722@spawnkill.ip-mobilphone.net wrote:
> I have a string extracted from <STDIN>,
> 04/26/2001 15:03:46
> 
> how can i make it assigned as
> (my $sec,my $min, my $hour, my $mday, my $mon,
> my $year)=(46,3,15,4,26,2001)?


my ($sec, $min, $hour, $mday, $mon, $year)=(46,3,15,4,26,2001);


> (my $sec,my $min, my $hour, my $mday, my $mon,
> my $year, my $wday, my $yday,my $isdst)=
> timelocal(04/26/2001 15:03:46),
> but it is not working.


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

Date: Wed, 02 May 2001 09:25:50 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to: Create Regex which extracts N number of words before target word
Message-Id: <7jkvet4oij3k7t2gc2l2801e7eo31v3ski@4ax.com>

BarryK wrote:

>Assume you have a target word, e.g. "cat", and you want to extract that word
>and a certain number of words before it. How is one to do this in a
>non-literal manner with a regular expression which will support any number
>of pre-words to be extracted?

Careful with that.

	$_ = 'dog cat mouse cat parrot';
	/((?:\S+\s+){2})cat\b/ and print $1;
-->
	'cat mouse'

I hope you like what it matched. I think not.

-- 
	Bart.


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

Date: Tue, 1 May 2001 10:01:15 +1200
From: "fail006" <fail00@hotmail.com>
Subject: newbie perl question ....please help....
Message-Id: <9comj8$445$1@lust.ihug.co.nz>

Hi,
I would like to know how can i execute bash shell commands from a perl
script?
Is there a book or website that has info on this particular subject.....

Thanks





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

Date: Wed, 2 May 2001 07:34:32 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie perl question ....please help....
Message-Id: <slrn9evs68.lia.tadmc@tadmc26.august.net>

fail006 <fail00@hotmail.com> wrote:

>I would like to know how can i execute bash shell commands from a perl
>script?

   perldoc -q external

----------------------
How can I capture STDERR from an external command?

       There are three basic ways of running external commands:

 ...
----------------------


>Is there a book or website that has info on this particular subject.....


The answer is in a file that is already on your hard disk.

Perl's standard docs are more authoritative than books or websites.
You should try to find answers there *first*.


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


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

Date: Wed, 02 May 2001 10:38:49 GMT
From: u376617431@spawnkill.ip-mobilphone.net
Subject: Perl and maps
Message-Id: <l.988799929.1756072998@gipsy.netsoft.ro>

Hi there,
I`m trying to develop a site which contains a map of a city. 
I`d like to dynamically generate the image. 
I have an image at a high resolution and when the user 
clicks on the image (which is an imagemap) then the 
CGI script will crop a part of the high resolution 
image and display it. The problem is that I`m using 
PerlMagick and it`s a little bit too slow at cropping 
and zooming. If you have any ideas about the subject 
please give me some directions. 

Thank you very much
FaCe
 



-- 
Sent by astanciu  from netsoft piece from ro
This is a spam protected message. Please answer with reference header.
Posted via http://www.usenet-replayer.com/cgi/content/new


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

Date: Wed, 02 May 2001 13:28:52 +0200
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: Re: Perl and maps
Message-Id: <3AEFEF74.7B227FF6@eed.ericsson.se>

u376617431@spawnkill.ip-mobilphone.net wrote:
> I`m trying to develop a site which contains a map of a city.
> I`d like to dynamically generate the image.
> I have an image at a high resolution and when the user
> clicks on the image (which is an imagemap) then the
> CGI script will crop a part of the high resolution
> image and display it. The problem is that I`m using
> PerlMagick and it`s a little bit too slow at cropping
> and zooming. If you have any ideas about the subject
> please give me some directions.

http://www.modperl.com/examples/chapter4/Apache::Magick.html


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

Date: Wed, 02 May 2001 13:03:12 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl and maps
Message-Id: <hb10ftkukk0bdfftolnosc4t1c09nav105@4ax.com>

u376617431@spawnkill.ip-mobilphone.net wrote:

>I`m trying to develop a site which contains a map of a city. 
>I`d like to dynamically generate the image. 
>I have an image at a high resolution and when the user 
>clicks on the image (which is an imagemap) then the 
>CGI script will crop a part of the high resolution 
>image and display it. The problem is that I`m using 
>PerlMagick and it`s a little bit too slow at cropping 
>and zooming. If you have any ideas about the subject 
>please give me some directions. 

Perhaps you should be using a vector drawing. For example, on Windows, a
WMF ought to be usable. Just convert the zoomed section to a bitmap.

-- 
	Bart.


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

Date: Wed, 02 May 2001 12:17:25 GMT
From: "Jason Pratt" <jpratt@ssr-inc.com>
Subject: Please help!
Message-Id: <pVSH6.94$X65.26299@dfiatx1-snr1.gtei.net>

Hello all, I am looking for a cgi script/program that I can use on my site
that will be implemented via SSI that will let the visitors know when a file
(a zip or exe [archives]) has been last updated.  Does anyone know where I
can find a script that'll allow me to implement this?  I've tried
lastcookie.cgi and it doesn't update the date on the page, so that's not
working.

I've also searched all of the CGI Repositories and can't find anything
that'll help with this situation.

Please help me find a program that'll help me do this...

Thanks..

Jason Pratt
pailhead@tampabay.rr.com






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

Date: Wed, 02 May 2001 12:30:30 GMT
From: "Shannon Brown" <news@shannonbrown.net>
Subject: Re: Q: Using 'rename' with CGI
Message-Id: <G5TH6.2420$tD6.49703@nnrp1.ptd.net>

Due to the log file size, sometimes several MBs, the removal from production
mode for reporting purposes reduced instances where the report would cause
problems with the logging system and caused the CGI scipts to die.  When I
ran the report using the production mode data set, the CGI process would die
randomly.  I know this is probably an odd case, but removing the log file
from production allows the report to run reliably -- well, at least to
completion.

(Don't even ask why this is not a database rather than raw text files ....
:-) )


"Andras Malatinszky" <andras@mortgagestats.com> wrote in message
news:3AEED248.A433D5F0@mortgagestats.com...
>
>
> Shannon Brown wrote:
>
> > Persistent but odd issue ....
> >
> > Perl 5.003
> > Linux 2.2
> > Apache 1.3
> >
> > I have a log file that records banner click-throughs on a private
> > dog-related web site.  The log file is executed using CGI.  The logging
> > capability has been functioning for close to two years and seems to work
> > fine.
> >
> > A log report analysis tool is available on the server to create short
> > reports on banner activity -- usually once per month.  The report seems
to
> > be creating problems because the log file is randomly deleted after
running
> > the report.
> >
> > Here is the structure of the system:
> > -- banner logging CGI scipt is running
> > -- report (separate script) runs and does
> >     -- renames the production log file to a temporary file
> >         (banner logging script regenerates a new log file if needed)
> >     -- opens the temporary log file
> >     -- locks temporary log file
> >     -- reads temporary log file
> >     -- unlocks temporary log file
> >     -- renames the tempoary log file to the production file
> >         (data is lost while the report runs and this is OK)
> >
>
> Why do you do this in the first place? Why don't you have your program
simply
> read the actual logfile?
>




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

Date: Wed, 02 May 2001 12:31:31 GMT
From: "Shannon Brown" <news@shannonbrown.net>
Subject: Re: Q: Using 'rename' with CGI
Message-Id: <D6TH6.2421$tD6.49641@nnrp1.ptd.net>

Thank you Scott, the hosting firm has control over the installed software.
I will remind them of these issues.


"Scott R. Godin" <webmaster@webdragon.unmunge.net> wrote in message
news:9cnl88$h7p$1@216.155.32.215...
> In article <GRyH6.384$tD6.31021@nnrp1.ptd.net>,
>  "Shannon Brown" <news@shannonbrown.net> wrote:
>
>  | Perl 5.003
>
> unrelated to your problem, but 5.003 is seriously buggy and should be
> replaced immediately do-not-pass-Go with at least 5.004.
>
> check out the perldelta.pod and specifically the 'Changes' file with
> extensive information for 5.004 to see why this is so. primarily
> security issues.
>
> --
> unmunge e-mail here:
> #!perl -w
> print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
> # ( damn spammers. *shakes fist* take a hint. =:P )




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

Date: Wed, 02 May 2001 08:44:16 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Question about float to hex
Message-Id: <i7ivet0tlab1hq165iferjukeu0ri5hl6e@4ax.com>

Dodger wrote:

>"Richard J. Rauenzahn" wrote:
>> perl -e'print sprintf("0x%x", unpack("L", pack("f", 42.1234)))'
>
>Not bad, but I do have to ask: why are we saying print sprintf?

Because you might like to do something other than print the result? Then
the 'print' must go,  and the 'sprintf' can stay.

-- 
	Bart.


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

Date: Wed, 02 May 2001 11:50:05 GMT
From: "Dodger" <dodger@necrosoft.net>
Subject: Re: Question about float to hex
Message-Id: <NvSH6.43718$B22.10697205@news1.rdc2.pa.home.com>

"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:i7ivet0tlab1hq165iferjukeu0ri5hl6e@4ax.com...
> Dodger wrote:
>
> >"Richard J. Rauenzahn" wrote:
> >> perl -e'print sprintf("0x%x", unpack("L", pack("f", 42.1234)))'
> >
> >Not bad, but I do have to ask: why are we saying print sprintf?
>
> Because you might like to do something other than print the result? Then
> the 'print' must go,  and the 'sprintf' can stay.

Err, okay.

I'd'a' just said printf, and said to add an 's' to the beginning if you
don't want to print it. If someone' susing pack they should probably know
printf and sprintf, too.

--
Dodger
www.dodger.org
www.necrosoft.net
www.gothic-classifieds.com





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

Date: 01 May 2001 17:06:00 +0100
From: nobull@mail.com
Subject: Re: Reading one character through a socket
Message-Id: <u9zocwxi94.fsf@wcl-l.bham.ac.uk>

Every few weeks I go back and look on Usenet at follow-ups to answers
I've posted just to see if anyone has pointed out any mistakes in
anything I've said.

I don't like to post off-topic but...

mjd@plover.com (Mark Jason Dominus) writes:

> In article <u966g4lnst.fsf@wcl-l.bham.ac.uk>,  <nobull@mail.com> wrote:
> >mjd@plover.com (Mark Jason Dominus) writes:
> >
> >> In article <9beps0$f2t$1@nets3.rz.RWTH-Aachen.DE>,
> >> Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote:
> >> >Unfortunately when telnetting to the server one still needs to press Return.
> >> 
> >> There is nothing you can do about that.  
> >
> >Wrong, you can send the Telnet commands to tell the terminal to go
> >into raw mode.
> 
> "Wrong."

How do you figure that?

>  You can only do that if you're using the 'telnet' protocol
> and talking to a client that understand the telnet protocol.

Tassilo asserts that he is.  The says "telnetting to the server" and
"telnet session".  He does not state what client program or OS he is
using, but does quite definitely state what protocol (he believes
that) he is using.  I see no evidence to doubt his assertion.

> In this case, Tassilo is obviously not doing that.  He is talking
> raw TCP.

I see no evidence to support this assertion.

> The fact that he is talking to a client program *named* 'telnet' is
> irrelevant.

Yep, I'd agree with that.  Not only is this irrelevant, there's also
compelling reason to believe it to be true.

> The Unix 'telnet' program does not use the telnet protocol except
> when it is connecting to a service on port 23 or, with some clients,
> when the *client user* specifically requests.

I am unable to find any evidence to back up this assertion.

I am able to find abundant circumstancial evidence to counter this
assertion.

Thoughout my career I have often encountered telnet implementations
that do not behave this way.

I have for decades been aware of published services such as MUDs that
use telnet protocols on ports other than 23.

I have never, to my knowledge, encountered telnet commands on any
operating systems or terminal server that do behave this way.

The "Single Unix Specification V2" does not specify a telnet program
so AFAIK this means that the telnet command is not required to behave
this way in order to brand an OS as 'Unix'.

I have confirmed that the telnet command in the only Unix-branded OS
to which I currently have immediate access (DEC-OSF/1) does not behave
this way.

I have confirmed that the telnet command in the Unix-like OS I'm using
now (SuSE Linux) does not behave this way.

I have confirmed that the telnet command in Windows2000 does not
behave this way (Tassilo said nothing about the clients being Unix).

I see no indication in the manpage that the telnet command on NetBSD
behaves this way.

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


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

Date: Wed, 2 May 2001 10:29:16 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Re: RegExp Teaser
Message-Id: <9coksi$4e6c@newton.cc.rl.ac.uk>

Hi

I did add all the "-#-" characters so that I could then say each
filename/description pair is contained between two "-#-"s, after converting
the array to a scalar. The thing that made this problem a bit trickier was
that descriptions can be more than one line, otherwise I could have just
used newline characters to separate things.

Anyway, thankyou for your help.. I have used part of your code to achieve
the results I want :)

Spencer

************************
"Ren Maddox" <ren@tivoli.com> wrote in message
news:m3y9sinsaw.fsf@dhcp9-172.support.tivoli.com...
> On Mon, 30 Apr 2001, bigusAT@btinternetDOT.com wrote:
>
> > I have a text file containing the following kind of text (a listserv
> > catalog file in case anyone recognises it):
>
> [Data moved to __DATA__ below...]
>
> Is that last "-#-" at the end of the line special in some way?  Is it
> only there on the last file description?
>
> > Now, I converted the array holding the file contents into a scalar &
> > added the "-#-" in order to make the regexp easier. Here is the one
> > I came up with:
>
> Ah... maybe you added the "-#-" on the end.  Or maybe all of them?
>
> > $tmp = $filecontents = ~ /-#-.+-#-/sg
>
> Aside from the typo "= ~", a global match in a scalar context is going
> to return the number of matches, which doesn't seem like it's going to
> be that useful.
>
> > Now that works to a point, but what it returns (I'm going by memory
> > here, but I think you will get the point) is:
>
> Ah... "going by memory".  It's usually much more useful if you post
> the actual code that you are using.
>
> > -#-file1.txt * File 1 description -#-
> > -#-file3.xls * File 3 description -#-
>
> Right, you're missing the second file because you are matching the
> "-#-" as part of the first hit and it isn't there to match the second.
>
> > What it's doing is it's including the ending "-#-" delimiter
> > thingy. How can I get it not to include the end "-#-".. (the
> > character before that could be any character).
>
> Well, a simple way would be: "(?=-#-)" which would match if "-#-"
> comes next, without actually matching the "-#-".
>
> Here's my quick-and-dirty solution:
>
> #!/usr/bin/perl
> use warnings;
> use strict;
> my %desc;
> my $filename;
> while(<DATA>) {
>   /^-#-(.*)/ and $filename = $1;
>   /^\*/ && $filename and $desc{$filename} .= $_;
> }
> for (keys %desc) {
>   print "$_:$desc{$_}";
> }
> __DATA__
> * preamble
> *
> * more preamble
> *
> -#-file1.txt
> * File 1 description
> -#-file2.htm
> * File 2 description
> * some file descriptions have more than one line
> -#-file3.xls
> * File 3 description-#-
> __END__
>
> Even better would probably be to set $/ = "\n-#-".
>
> --
> Ren Maddox
> ren@tivoli.com




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

Date: Wed, 2 May 2001 11:04:14 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Re: RegExp Teaser
Message-Id: <9com41$3k2o@newton.cc.rl.ac.uk>

Thanks for the reply :) I've got the code working now, but I'm going to come
back to the split method later, because it might trim out a couple of lines
in my routine.

Spencer

************************
"Greg Bacon" <gbacon@HiWAAY.net> wrote in message
news:tereabj54ophee@corp.supernews.com...
> In article <9ck8ul$ic2$1@plutonium.btinternet.com>,
>     S Warhurst <bigusAT@btinternetDOT.com> wrote:
>
> : You regulars must be getting fed up of regular expression questions.
> : [...]
>
> I like the regular expression questions, but I'm also interested in the
> broader field of formal languages.
>
> : I have a text file containing the following kind of text (a listserv
catalog
> : file in case anyone recognises it):
> :
> : * preamble
> : *
> : * more preamble
> : *
> : -#-file1.txt
> : * File 1 description
> : -#-file2.htm
> : * File 2 description
> : * some file descriptions have more than one line
> : -#-file3.xls
> : * File 3 description-#-
> :
> : Now, I converted the array holding the file contents into a scalar &
added
> : the "-#-" in order to make the regexp easier. Here is the one I came up
> : with:
> :
> : $tmp = $filecontents = ~ /-#-.+-#-/sg
>
> Why aren't you using split?
>
>     % cat try
>     #! /usr/local/bin/perl -w
>
>     use strict;
>
>     $/ = undef;
>
>     my $data = <DATA>;
>     $data =~ s/^.*?-#-//s;
>
>     for (split /-#-/, $data) {
>         next unless /\S/;
>         $_ .= "\n" unless /\n\z/;
>         print "CHUNK:\n$_";
>     }
>
>     __DATA__
>     * preamble
>     *
>     * more preamble
>     *
>     -#-file1.txt
>     * File 1 description
>     -#-file2.htm
>     * File 2 description
>     * some file descriptions have more than one line
>     -#-file3.xls
>     * File 3 description-#-
>     % ./try
>     CHUNK:
>     file1.txt
>     * File 1 description
>     CHUNK:
>     file2.htm
>     * File 2 description
>     * some file descriptions have more than one line
>     CHUNK:
>     file3.xls
>     * File 3 description
>
> Hope this helps,
> Greg
> --
> WARNING! In the considerations of safety, you should NEVER let a male
> dolphin attempt anal sex with you.
>     -- http://www.dolphinsex.org/




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

Date: Wed, 02 May 2001 14:01:57 +0200
From: Philip Newton <pne-news-20010502@newton.digitalspace.net>
Subject: Re: Regular expression for zip code
Message-Id: <1ntvet8iv4ugq2n64skafvbohbu269jtvs@4ax.com>

On Mon, 30 Apr 2001 21:24:23 GMT, Uri Guttman <uri@sysarch.com> wrote:

> the regex is recompiled only if any of its interpolated variables have
> changed since it last was compile.

How would the regex engine know this? As far as I know, variables and
regexes don't have timestamps on them.

For example:

    while(<>) {
        chomp;
        shout() if /$pattern/;
        do_stuff($_);
        # Has $pattern changed after the call to do_stuff?
        # If so, how does Perl know?
    }

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Tue, 01 May 2001 14:25:48 GMT
From: u251892089@spawnkill.ip-mobilphone.net
Subject: sendmail more reliable with -t flag???
Message-Id: <l.988727148.1021026611@[212.2.1.165]>

Hi 
I've recently noticed that my Perl Scripts driving sendmail after
years of working w/o a problem, had stopped working. Without ever
finding out what had gone wrong I found that the problem could be solved
by using the -t flag. Has sendmail been upgraded over the last 6 months or so. Any suggestions welcome
 



-- 
Sent  by davidr from provecta-online within  area co in field  uk
This is a spam protected message. Please answer with reference header.
Posted via http://www.usenet-replayer.com/cgi/content/new


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

Date: Wed, 2 May 2001 18:06:46 +1000
From: "Tom Beer" <tom.beer@btfinancialgroup.spamfilter.com>
Subject: Re: Should Perl be first?
Message-Id: <9cof60$8es$1@merki.connect.com.au>

While I agree, I don't think IT recruitment agencies really see it that way.

What they want to hear is an interview is "yep, 10 years Perl experience",
rather than "no Perl experience, but I know a heap of other languages!!".

You might still get the job, but it will be harder.

Tom.

"Billy Chambless" <billy@localhost.net> wrote in message
news:9cnkka$gjq$1@news.datasync.com...
> In article <teto4umcm4u49c@corp.supernews.com>,
> Chris Stith  <mischief@velma.motion.net> wrote:
>
>
> >    The trouble with teaching Perl as a first computer language is that
your
> >    students won't appreciate it till they start learning their second.
>
> >*   Don't let anyone tell you what your first computer language should be
> >    before you've learned several.
>
> These two add up to an important point:
>
> Although a person can certainly learn one language and start getting
> real work done, learning several languages is part of the process of
> learning the profound truths of programming that are needed to make a
> Really Great Programmer.
>
> The best programmers I know know enough languages that they're not bound
> by the conceptual limits of any one of them.
>




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

Date: Wed, 2 May 2001 18:09:44 +1000
From: "Tom Beer" <tom.beer@btfinancialgroup.spamfilter.com>
Subject: Re: Should Perl be first?
Message-Id: <9cofbi$8l8$1@merki.connect.com.au>


"Milton Road" <miltonroad@btinternet.com> wrote in message
news:1MQG6.12695$PP3.844238@nnrp3.clara.net...
>
> Money-wise, I'm not sure of the situation where you are.  If you're
> thinking of undertaking bespoke work for a multitude of clients ( who in
> all likeliness, will be sporting different hardware and software
> configurations ) then Perl would be better, because it runs on more
> platforms.  There are plenty of Perl contracts here in the UK - it's
fairly
> easy to get to most of them - although your mileage may vary - depending
on
> where you are.
>

Why not jump on an on-line recruitment site offering jobs near where you are
and check out the various markets for yourself? It should be fairly easy.

Tom.




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

Date: Wed, 02 May 2001 13:11:53 +0200
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: sub z {return } print ((($x,$y)=z) ? "yes:$x,$y\n" : "no\n")
Message-Id: <3AEFEB79.B5FCC51D@eed.ericsson.se>

Hi,

could someone please explain the different results of:

  maas34: perl -e 'sub z {return undef} print ((($x,$y)=z) ? "yes:$x,$y\n" : "no\n")'
  yes:,

  maas34: perl -e 'sub z {return}       print ((($x,$y)=z) ? "yes:$x,$y\n" : "no\n")'
  no

And actually my problem is: I would like to use 
a subroutine to extract 4 values. However if these
values couldn't be found, I want to return an undef
(or something else, so that I can use it with "if"):

  if ($but and not check_pass ($pass))
  {
    print abstract (q{<SPAN CLASS="pink">Wrong password......
  }
  elsif ($but eq 'Create' and $proj and $sub and $pack and $prel)
  {
    insert_update_pack ($dbh, $proj, $sub, $pack, $prel);
  }                                                                # a "Delete"-
  elsif (($proj, $sub, $pack, $prel) = find_button ($query))       # button has
  {                                                                # been clicked
    delete_pack ($dbh, $proj, $sub, $pack, $prel);
  }
  else
  {
    print abstract (q{Please specify a project and co........
  }

Thanks
Alex


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

Date: 2 May 2001 11:55:12 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: sub z {return } print ((($x,$y)=z) ? "yes:$x,$y\n" : "no\n")
Message-Id: <slrn9evteq.egu.rgarciasuarez@rafael.kazibao.net>

Alexander Farber (EED) wrote in comp.lang.perl.misc:
} Hi,
} 
} could someone please explain the different results of:
} 
}   maas34: perl -e 'sub z {return undef} print ((($x,$y)=z) ? "yes:$x,$y\n" : "no\n")'
}   yes:,
} 
}   maas34: perl -e 'sub z {return}       print ((($x,$y)=z) ? "yes:$x,$y\n" : "no\n")'
}   no

The answer is given by "perldoc -f return" :

    [...] If no EXPR is given, returns an empty list in list
    context, the undefined value in scalar context, [...]

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
@s = ((' ')x3, ",\n"); sub DESTROY {}
sub AUTOLOAD { print (($AUTOLOAD =~ /\w+$/g), shift @s); bless {} }
Just()->another()->Perl()->hacker();


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

Date: Wed, 02 May 2001 12:48:24 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: sub z {return } print ((($x,$y)=z) ? "yes:$x,$y\n" : "no\n")
Message-Id: <slrn9f04db.3ts.tjla@thislove.dyndns.org>

"mein Luftkissenfahrzeug ist voll von den Aalen"
said Rafael Garcia-Suarez (rgarciasuarez@free.fr) in 
<slrn9evteq.egu.rgarciasuarez@rafael.kazibao.net>:
>Alexander Farber (EED) wrote in comp.lang.perl.misc:
>} 
>}   maas34: perl -e 'sub z {return undef} print ((($x,$y)=z) ? "yes:$x,$y\n" : "no\n")'
>}   yes:,
>} 
>}   maas34: perl -e 'sub z {return}       print ((($x,$y)=z) ? "yes:$x,$y\n" : "no\n")'
>}   no
>
>The answer is given by "perldoc -f return" :
>
>    [...] If no EXPR is given, returns an empty list in list
>    context, the undefined value in scalar context, [...]

Not quite I think. Both times the subroutine is called in list context,
however in the first case, a value is given to the return statement.
What happens in the first case is that an undefined value is returned in
list context. An undefined value in list context is simply a list
containing a single element, the undefined value. The list assignment is
then evaluated in scalar context. A list assignment in scalar context
returns the number of elements produced by the expression on the right
side of the assignment*. The number of items on the right side of this
assignment is 1. This is a valid true value, so "yes" is printed out.

The second one is then simply explained by realising that an empty list
is returned from the function call. The number of itmes on the right of
the assignment is then obviously 0 so "no" is printed.

* you may have been confused by the list on the left hand side of the
assignment. This is a red herring. You can restructure the code above
like:

perl -e 'sub z {return undef} print ((()=z) ? "yes:$x,$y\n" : "no\n")

and it still prints "yes". It is true that evaluating a list in scalar
context evaluates to the last item, and an array in list context
evaluates to the number of items. This is evaluating a list assignment
in scalar context which appears to be different again.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Intolerance is the most socially acceptable form of egotism, for it
permits  us to assume superiority without personal boasting.
-Sidney J. Harris


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

Date: 02 May 2001 09:44:50 +0200
From: Walter Hafner <hafner-usenet@ze.tu-muenchen.de>
Subject: Re: Testing whether a socket is still connected
Message-Id: <srju2346vpp.fsf@w3proj1.ze.tu-muenchen.de>

cfedde@fedde.littleton.co.us (Chris Fedde) writes:

> >I need some kind of timeout for the test routine. All I can think of is
> >the following:
> >
> 
> From the perlfaq:
> $ perldoc -q timeout 
> Found in /usr/local/lib/perl5/5.6.1/pod/perlfaq8.pod
>        How do I timeout a slow event?
> 
>        Use the alarm() function, probably in conjunction with a
>        signal handler, as documented in the Signals entry in the
>        perlipc manpage and the section on ``Signals'' in the
>        Camel.  You may instead use the more flexible Sys::Alarm-
>        Call module available from CPAN.

Thanks a lot!

  Sys::Alarmcall

seems to do all I want. And it seems from reading the sources that I
thought way too complex again.

The problem I have with "perldoc": I often simply don't know which
keywords to ask for! E.g., "perdoc -q alarm" (which i tried) didn't
return anything useful for my problem.

Thanks again! I started programming Perl about a year ago (seriously)
and learned as much in this group as I did from the camel book!

Regarding the subject "which language as a first computer language": In
the last 15 years I went the unconventional way 

basic -> pascal -> forth -> scheme -> prolog -> assembler -> C -> Shell
-> Perl -> Java (just started)

I still like the functional programming style of scheme best! Sue
me. :-)

For small applications - say up to 1000 lines - I wouldn't choose
anything else than Perl (don't know Python, though). However, I wouldn't
program larger applications in Perl. Imho that requires a language that
FORCES you to more programming discipline. Otherwise you end up in
managing the code instead of programming. Sorry, if can't make my point
clear - my english is not as good as it could be.

-Walter


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

Date: Wed, 2 May 2001 12:46:10 +0000 (UTC)
From: cameron@nicnames.co.uk (Cameron)
Subject: Unicode sucks. I'm dumb at it.
Message-Id: <8F4C1E471642D411B0BB00508B9A779F6492D7@SOLAR>

Ok, here's my problem, incase anyone knows anything about unicode =
bizness.
i've got a cgi, and here is basically what it does:

#!/usr/local/bin/perl5.6.1
use CGI;

$query=3Dnew CGI;

$site =3D $query->param('whois');

print "Content-type: text/html; charset=3DISO-8859-1\n\n";
print $site;

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

now, say i enter a utf-8 heart symbol into my little submission html =
page,
one would expect that to be passed as the param for "whois" into $site. =
it
works, all except for the fact that the heart symbol turns into =
something
that isn't even utf-8 anymore. it turns into a =A2=BE - a "cents" =
symbol, and a
3/4 symbol.=20

now. this, to me, doesn't make a hell of a lot of sense. i know i'm =
doing
something wrong, or forgetting something, but i havent got the vaguest =
idea
what. anyone out there know what it is that i'm being stupid about?

=3D=3D=3D=3D=3D
"In a perfect world, we'd all lie blind and motionless in stacked =
coffins
filled with pudding. It would be dark and warm and nobody would have to
compete with anybody and also the government would pay for the =
pudding." -
Erik.


-- 
Posted from iis4.fastnt.co.uk [193.116.54.251] 
via Mailgate.ORG Server - http://www.Mailgate.ORG


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

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.  

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


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