[26248] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8432 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 19 09:05:36 2005

Date: Mon, 19 Sep 2005 06: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           Mon, 19 Sep 2005     Volume: 10 Number: 8432

Today's topics:
    Re: ActivePerl perlscript output inconsistencies <news@lawshouse.org>
    Re: ActivePerl perlscript output inconsistencies (Anno Siegel)
    Re: ActivePerl perlscript output inconsistencies <news@lawshouse.org>
        chenga script to show one houer more <antonio.meic@zg.htnet.hr>
    Re: convert $array[0] into $new-array[0,0] (Anno Siegel)
    Re: Newbie: Help Substituting from a Hash <nospam@free.fr>
    Re: Newbie: Help Substituting from a Hash <nospam@free.fr>
    Re: sorting data - hash vs. list <Fred@fred.net>
    Re: sorting data - hash vs. list <flavell@ph.gla.ac.uk>
        Thanks -Re: convert $array[0] into $new-array[0,0] <t18_pilot@hotmail.spam.com>
        why is important to use : use strict? <martina@martina.yu>
    Re: why is important to use : use strict? <no@email.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 19 Sep 2005 07:01:41 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: ActivePerl perlscript output inconsistencies
Message-Id: <1127109701.98159.0@demeter.uk.clara.net>

xhoster@gmail.com wrote:
> Henry Law <news@lawshouse.org> wrote:
> 
> 
>>                $WScript->Echo($arg->Item($i));
>>                #print OUTPUT "$arg->Item($i)\n";
> 
> ....
> 
>>Can anyone help me find out why replacing this "Echo" thing with a print
>>statement apparently changes the data printed?  I'm mystified.
> 
> 
> It is not because you changed print to Echo, it is because in the
> process you changed  (...) to "..." in the process.
> 
> print OUTPUT $arg->Item($i), "\n";

Xho, thank you for seeing what my eyes had failed to see a hundred 
times.  You've led me to an even more surprising conclusion, however, 
which is that Perlscript and Perl don't seem to interpolate strings the 
same way.  Another version of the test program shows the problem:

<Job ID="tryit">
<script language=PerlScript>

	use strict;
	use warnings;
	use vars('$WScript');	# Avoid "strict" warnings
	
	my $arg = $WScript->{Arguments};

	open OUTPUT,">tryit.log";

	for(my $i=0; $i<$arg->{Count}; $i++) {
		print OUTPUT   $arg->Item($i),"\n";
		print OUTPUT  "$arg->Item($i)\n";		
	}
</script>
</job>

F:>tryit.wsf one two three

F:>type tryit.log
one
Win32::OLE=HASH(0x17da744)->Item(0)
two
Win32::OLE=HASH(0x17da744)->Item(1)
three
Win32::OLE=HASH(0x17da744)->Item(2)

Should those two print statements not produce the same result in Perl?


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

Date: 19 Sep 2005 07:17:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: ActivePerl perlscript output inconsistencies
Message-Id: <dglomq$2lj$1@mamenchi.zrz.TU-Berlin.DE>

Henry Law  <news@lawshouse.org> wrote in comp.lang.perl.misc:
> xhoster@gmail.com wrote:
> > Henry Law <news@lawshouse.org> wrote:

[...]

> times.  You've led me to an even more surprising conclusion, however, 
> which is that Perlscript and Perl don't seem to interpolate strings the 
> same way.  Another version of the test program shows the problem:
> 
> <Job ID="tryit">
> <script language=PerlScript>
> 
> 	use strict;
> 	use warnings;
> 	use vars('$WScript');	# Avoid "strict" warnings
> 	
> 	my $arg = $WScript->{Arguments};
> 
> 	open OUTPUT,">tryit.log";
> 
> 	for(my $i=0; $i<$arg->{Count}; $i++) {
> 		print OUTPUT   $arg->Item($i),"\n";
> 		print OUTPUT  "$arg->Item($i)\n";		
> 	}
> </script>
> </job>
> 
> F:>tryit.wsf one two three
> 
> F:>type tryit.log
> one
> Win32::OLE=HASH(0x17da744)->Item(0)
> two
> Win32::OLE=HASH(0x17da744)->Item(1)
> three
> Win32::OLE=HASH(0x17da744)->Item(2)
> 
> Should those two print statements not produce the same result in Perl?

No, neither on Perl, nor in perlscript.  Perl doesn't interpolate
function calls (including method calls) in double-quote context.

    perl -le 'print sin(0); print "sin(0)"'

shows the same discrepancy.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Mon, 19 Sep 2005 09:01:48 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: ActivePerl perlscript output inconsistencies
Message-Id: <1127116908.29165.0@nnrp-t71-02.news.clara.net>

Anno Siegel wrote:

> No, neither on Perl, nor in perlscript.  Perl doesn't interpolate
> function calls (including method calls) in double-quote context.
> 
>     perl -le 'print sin(0); print "sin(0)"'
> 
> shows the same discrepancy.

Bother, I hadn't spotted that it's a method call and not a dereference. 
  All is clear now; thanks.

-- 

Henry Law       <><     Manchester, England


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

Date: Mon, 19 Sep 2005 14:19:36 +0200
From: kozmos241 <antonio.meic@zg.htnet.hr>
Subject: chenga script to show one houer more
Message-Id: <1c6hmu6fot6up.jjvp5etx8jj7$.dlg@40tude.net>

Hi,

i am new to perl and i am wondering how to change this script to show one
houer more, i will change it back for daylight saving.



#!/usr/bin/perl

use strict;

(my $secT, my $minT, my $hourT, my $mdayT, my $monT, my $yearT, my $wdayT,
my $ydayT, my $isdstT) = localtime();

$yearT += 1900;
$monT  += 1;
$monT = (length($monT)==1?"0$monT":$monT);
$mdayT = (length($mdayT)==1?"0$mdayT":$mdayT);

my $fechaT = $yearT.$monT.$mdayT;

my $diferencia;

if (
    ($fechaT >= "20020407" && $fechaT <= "20021027" ) ||
    ($fechaT >= "20030406" && $fechaT <= "20031026" ) ||
    ($fechaT >= "20040404" && $fechaT <= "20041031" ) ||
    ($fechaT >= "20050403" && $fechaT <= "20051030" ) ||
    ($fechaT >= "20060402" && $fechaT <= "20061029" )
){
    $diferencia = 3600;
}else{
    $diferencia = 7200;
}

(my $sec, my $min, my $hour, my $mday, my $mon, my $year, my $wday, my
$yday, my $isdst) = localtime(time + $diferencia);
$year += 1900;
$mon  += 1;
if ($mon == 1){
    $mon = "Januar";
}elsif ($mon == 2){
    $mon = "Februar";
}elsif ($mon == 3){
    $mon = "März";
}elsif ($mon == 4){
    $mon = "April";
}elsif ($mon == 5){
    $mon = "Mai";
}elsif ($mon == 6){
    $mon = "Juni";
}elsif ($mon == 7){
    $mon = "Juli";
}elsif ($mon == 8){
    $mon = "August";
}elsif ($mon == 9){
    $mon = "September";
}elsif ($mon == 10){
    $mon = "Oktober";
}elsif ($mon == 11){
    $mon = "November";
}elsif ($mon == 12){
    $mon = "Dezember";
}

$mday = (length($mday)==1?"0$mday":$mday);
$hour = (length($hour)==1?"0$hour":$hour);
$min = (length($min)==1?"0$min":$min);

my $fecha = $mday.". ".$mon." ".$year.", ".$hour.":".$min."h";

print "content-type: text/html\n\n";
print << "FIN";

                <tr>
                    <td width=185 valign=top height=15>
                        <p>
                        <B>City, State</B><br>
                        $fecha
                        </p>
                    </td>
                </tr>
FIN


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

Date: 19 Sep 2005 09:34:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: convert $array[0] into $new-array[0,0]
Message-Id: <dgm0n3$7cv$1@mamenchi.zrz.TU-Berlin.DE>

William Hymen <t18_pilot@hotmail.spam.com> wrote in comp.lang.perl.misc:
> Thanks Jim.
> 
> Would the syntax for the split remian
> the same? I need to split using the pipe char
> as a separator, and I'm not sure what
> to place between [] in your example.
> 
> My split _was_ split(/\|/ , $entry);

Actually it wasn't.  You OP had

    @entry_parts = split(/\!/ , $entry);

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Mon, 19 Sep 2005 13:44:55 +0200
From: Elisa Francesca Roselli <nospam@free.fr>
Subject: Re: Newbie: Help Substituting from a Hash
Message-Id: <432ea4b7$0$18035$626a14ce@news.free.fr>

Josef Moellers a écrit :

> 
> Remember that $q_format{...} is the value, while ... is the key.
> If you replace $q_format{key} with $key and $q_format{value} with 
> $q_format{$key}, it should work.
> 
> foreach $key (keys %q_format) {
> $Fr =~s/$key/$q_format{$key}/g;
> }

Thanks for the clarifaication, it's now working. The only problem is 
that I had to use double-quotes instead of single and all hell broke 
loose with the despecifications. Why on earth does it take no less than 
SIX backslashes to get a statement like \^e to be read correctly?

EFR
Ile de France


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

Date: Mon, 19 Sep 2005 13:46:37 +0200
From: Elisa Francesca Roselli <nospam@free.fr>
Subject: Re: Newbie: Help Substituting from a Hash
Message-Id: <432ea51d$0$18035$626a14ce@news.free.fr>

Brian McCauley a écrit :

> You should consdier using conventional entities like '&eacute;' rather 
> than your home-rolled convention.
> 
Yes, that would be nice. Unfortunately I have no control over the input 
code. I'm just the poor technical writer who is trying to extract some 
readable strings for the translation tables.

EFR
Ile de France


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

Date: Sun, 18 Sep 2005 20:16:08 -0500
From: "Fred@fred.net" <Fred@fred.net>
Subject: Re: sorting data - hash vs. list
Message-Id: <hh3si1t5nvrg47n1nsbg6602bgi4kfefti@4ax.com>

On Sun, 18 Sep 2005 19:42:28 -0400, "Matt Garrish" <matthew.garrish@sympatico.ca> wrote:

>
><Fred@fred.net> wrote in message 
>news:d4rri1dvgn5n2mmrpv8su1ic8kip5urel2@4ax.com...
>> On Sat, 17 Sep 2005 19:21:00 -0400, "Matt Garrish" 
>> <matthew.garrish@sympatico.ca> wrote:
>>
>> Free advice, yes that is what I want. And the honest reason I don't ever
>> respond to posts here is because:
>> (1. They are too old!!)
>> And if not that then just a general caution that I don't like
>> being crictized, it's an uncomfortable expereince.
>
>You're taking usenet too seriously, then. Everyone gets corrected from time 
>to time. It's part of the learning process. If someone corrects your code 
>it's usually because there is a better way (and if it's not, someone will 
>correct them). If you take offense at being corrected you're losing out on 
>what the group has to offer.
Constant badgering.
>
>As for being flamed, just remember that if you play with fire you're going 
>to get burned.
I don't have anything else to play with.
>
>That said, I won't deny you that there are some offensive posters here. Tad 
>isn't one of them, though.
Right, Tad is ok, just sort of Sheriff like.
>And it's pointless to tell someone their tone is 
>offensive; they'll just come back at you in a more offensive tone. That's 
>why you're being called a troll. You want to make an argument of something 
>that can never be resolved, but just makes for a lot of flame-bait. You may 
>not feel you started it, but trust me, it's pointless to pursue it.
You know I have to agree. I have learned something counterintuitive about Usenet, 
and that is, in an environment where information should be profoundly free, we find such strictures.
That's the incurable argument. At least for me.
I am an anarchist to the extent that rules are and always should be, the last resort.
Imiagine the erstwhile proogrammer who had never been counseled in creativity.
As a discrete topic. Imagining things.. systems, etc.
Like having a hammer and no nails.
>

>> I get flamed and
>> I have replied and it became tedious, honestly so I went anonymous
>> and rarely post. I'd try and help someone and some other
>> SOB would jump my ass for it and I got to where, I said.....
>> WITFP. What is the piont.
>> So I quit "hanging out"
>> becuase each and every time I do, I get flamed for it.
>> No matter what I say.
>> Case in point.
>
>It's too bad you feel that way. There is a lot that can be learned from the 
>people here.
I keep trying to learn how to play ball. It's likely there might be those who think
me mad, but I'll stand by just about every point I made. 
I'm excluding the potential outlier produced by a bizarre typo!
>
>Matt 
>



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

Date: Mon, 19 Sep 2005 12:26:15 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: sorting data - hash vs. list
Message-Id: <Pine.LNX.4.62.0509191218340.24819@ppepc56.ph.gla.ac.uk>


On Sun, 18 Sep 2005, Matt Garrish revealed to all and sundry that 
someone purportedly posting as <Fred@fred.net> , who'd already 
blustered his way into at least one killfile and probably plenty more, 
was still trying to lecture seasoned Usenauts on how it should be 
done.  Matt helpfully responded:

> You're taking usenet too seriously, then. Everyone gets corrected 
> from time to time. It's part of the learning process. If someone 
> corrects your code it's usually because there is a better way (and 
> if it's not, someone will correct them). If you take offense at 
> being corrected you're losing out on what the group has to offer.

Wise words indeed.  I found myself in just that position on another 
group, only days ago, and was glad to have learned from the 
correction - and expressed my thanks accordingly.

all the best

RCPT to fred was refused: 550 <fred@fred.net>: Recipient address 
rejected: User unknown in virtual mailbox table



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

Date: Mon, 19 Sep 2005 01:43:29 GMT
From: "William Hymen" <t18_pilot@hotmail.spam.com>
Subject: Thanks -Re: convert $array[0] into $new-array[0,0]
Message-Id: <5JoXe.364$q1.281@newsread3.news.atl.earthlink.net>

I'm new at this. Thanks
a lot for your help.

Bill

"Jim Gibson" <jgibson@mail.arc.nasa.gov> wrote in message
news:180920051048431314%jgibson@mail.arc.nasa.gov...
> In article <555Xe.13500$_84.11603@newsread1.news.atl.earthlink.net>,
> William Hymen <t18_pilot@hotmail.spam.com> wrote:
>
> > Thanks Jim.
> >
> > Would the syntax for the split remian
> > the same? I need to split using the pipe char
> > as a separator, and I'm not sure what
> > to place between [] in your example.
> >
> > My split _was_ split(/\|/ , $entry);
>
> Yes, sorry. I overlooked that bit. Here it is modified, with a chomp
> added, since you probably don't want the newline in the last field:
>
> my @entry_parts;
> while(<INFILE>) {
>   chomp;
>   push( @entry_parts, [ split(/\|/) ]);
> }
>
> The default string for split, like many Perl functions, is $_, which is
> where <INFILE> puts the line read. You can also use an explicit scalar
> variable, if you need to do any more processing on the input data:
>
> my @entry_parts;
> while(my $entry = <INFILE>) {
>   chomp($entry);
>   push( @entry_parts, [ split(/\|/,$entry) ]);
> }
>
> Hope I got it right that time.
>
>  Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
>     ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
>                 http://www.usenet.com




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

Date: Mon, 19 Sep 2005 14:31:23 +0200
From: "Martina" <martina@martina.yu>
Subject: why is important to use : use strict?
Message-Id: <dgmb2o$9cq$1@ss405.t-com.hr>

Why is important to use "use strict"?
Perl script work very good without this command.
Am I forgot something?

Tnx.




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

Date: Mon, 19 Sep 2005 13:45:35 +0100
From: Brian Wakem <no@email.com>
Subject: Re: why is important to use : use strict?
Message-Id: <3p7q7fF93t7oU1@individual.net>

Martina wrote:

> Why is important to use "use strict"?
> Perl script work very good without this command.
> Am I forgot something?
> 
> Tnx.


There's a million reasons.  It really helps with typos, that could go
unnoticed without strict.


Consider:-

my $num0 = 9;
my $num1 = 9;

my $num2 = $numO * $num1;

print "\$num2=$num2\n";


The output is '$num2=0'.  It wouldn't run under strict as Global symbol
"$numO" requires explicit package name at....

Now imagine hundreds of lines, dozens of variables.  Make a typo without
strict and everything still runs, but you get runtime errors.  Hard to
track down.  You might not even notice, but your output would be skewed.


-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


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

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


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