[18927] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1122 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 12 21:05:31 2001

Date: Tue, 12 Jun 2001 18:05:08 -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: <992394308-v10-i1122@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 12 Jun 2001     Volume: 10 Number: 1122

Today's topics:
    Re: a question to programmers. <thinkit8@lycos.com>
    Re: directing STDOUT back to the display (isterin)
        Distributing one file to multiple servers <langer@sgi.com>
    Re: Distributing one file to multiple servers (Craig Berry)
    Re: Distributing one file to multiple servers (Jay Tilton)
    Re: fork and pass message while waiting (Rolf Krahl)
    Re: fork and pass message while waiting <ren@tivoli.com>
    Re: Help with split?vvp <godzilla@stomp.stomp.tokyo>
    Re: log file parsing (Craig Berry)
    Re: log file parsing <todd@designsouth.net>
    Re: log file parsing (Craig Berry)
    Re: REGEX (Sweth Chandramouli)
    Re: REGEX <ren@tivoli.com>
    Re: Removing ^M characters (steve)
    Re: sorting a list of files from a directory <ren@tivoli.com>
    Re: What is ${'string'} ? <wyzelli@yahoo.com>
    Re: What is ${'string'} ? <todd@designsouth.net>
    Re: What is ${'string'} ? <todd@designsouth.net>
    Re: What is ${'string'} ? <wyzelli@yahoo.com>
    Re: Why two lists instead of HOH? <mjcarman@home.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 12 Jun 2001 16:23:44 -0700
From: thinkit <thinkit8@lycos.com>
Subject: Re: a question to programmers.
Message-Id: <9g68a00a59@drn.newsguy.com>

In article <tid2dtk5i80ja6@corp.supernews.com>, cberry@cinenet.net says...
>
>thinkit (thinkit8@lycos.com) wrote:
>: if a language only offered hexadecimal and binary input literals, would
>: you be more or less likely to utilize it?  in a similar line, how much
>: hexadecimal do you use in the languages you use now?  do you count to
>: 16, or to 0x10?
>
>I wouldn't use it.  After all, even (most) assemblers offer string
>literals and the like.  Having
>
>  print 0x48656c6c6f2c20776f726c64210a;
>
>as your first program seems a bit...retro. :)
>
>-- 
>   |   Craig Berry - http://www.cinenet.net/~cberry/
> --*--  "Magick is the art and science of causing change in conformity
>   |   with Will."  - Aleister Crowley


oops, i meant only hexadecimal and binary integer literals--and no decimal. 
thus a-f would have same status as 0-9 w/regards to naming, and you would need
no "0x".



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

Date: 12 Jun 2001 16:19:43 -0700
From: isterin@hotmail.com (isterin)
Subject: Re: directing STDOUT back to the display
Message-Id: <db67a7f3.0106121519.6026ff99@posting.google.com>

Just use
if (...)
{
local *STDOUT = *FILE;
 .....
} #here STDOUT will be redirected back to the console.

Ilya

sgfoley@hotmail.com (Shon) wrote in message news:<b0a70a3a.0106121031.4d97896b@posting.google.com>...
> Basic Flow of my scripts...
> 1. script_1 redirect STDOUT to FILE
> 2. script_1 invokes script_2 via command line.
> 3. script_2 redirect STDOUT to FILE if(foo);
> 
> problem:
>   if foo = false, the STDOUT is still redirected to FILE.
>    (no the if is not inverted if foo=true i get the same thing :p )
> 
> questions:
>    1)is script_2 using the same STDOUT filehandle as script_1, i thought 
>       they would be in a different symbol table?
>    2)how do i redirect STDOUT back to the display terminal?
> 
> thx,
> Shon


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

Date: Tue, 12 Jun 2001 15:45:29 -0700
From: "Stephane Langer" <langer@sgi.com>
Subject: Distributing one file to multiple servers
Message-Id: <9g661n$g51vd$1@fido.engr.sgi.com>

Hi,

I need to distribute a single file (~50MB) from one source server to
multiple destination servers (~30) once a month. Besides the obvious option
of copying the file to every destination server one at a time, I'd like to
tap your collective wisdom for potentially better ways of doing. What kinds
of suggestions would you have to make the process fast or otherwise
efficient bandwidth-wise?

Because of our network infrastructure, copying the files one at a time can
take up to 8 hours which is sometimes not acceptable.

Thanks,

SR

--
Stephane Langer




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

Date: Tue, 12 Jun 2001 23:55:11 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Distributing one file to multiple servers
Message-Id: <tidauvqd4tsk79@corp.supernews.com>

Stephane Langer (langer@sgi.com) wrote:
: I need to distribute a single file (~50MB) from one source server to
: multiple destination servers (~30) once a month. Besides the obvious option
: of copying the file to every destination server one at a time, I'd like to
: tap your collective wisdom for potentially better ways of doing. What kinds
: of suggestions would you have to make the process fast or otherwise
: efficient bandwidth-wise?
: 
: Because of our network infrastructure, copying the files one at a time can
: take up to 8 hours which is sometimes not acceptable.

If the limitation is network throughput, spawning multiple threads on the
source machine won't help (and may hurt).

If one of the target machines has better network connectivity, and you can
put a script there, it may be worthwhile to send the file there, then
reflect it from there to the other servers.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Magick is the art and science of causing change in conformity
   |   with Will."  - Aleister Crowley


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

Date: Wed, 13 Jun 2001 00:02:00 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Distributing one file to multiple servers
Message-Id: <3b26aba2.29329067@news.erols.com>

On Tue, 12 Jun 2001 15:45:29 -0700, "Stephane Langer" <langer@sgi.com>
wrote:

>I need to distribute a single file (~50MB) from one source server to
>multiple destination servers (~30) once a month. Besides the obvious option
>of copying the file to every destination server one at a time, I'd like to
>tap your collective wisdom for potentially better ways of doing.

Make the slaves do the work.  Update the master and send it to one, then
that one forwards it to one or two others, and on down the line.  For extra
laziness, have each of the lackeys periodically verify on their own that
they have the most current file, and if necessary retrieve the update from
whichever neighbor isn't too busy.

Did you have a Perl question?


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

Date: 12 Jun 2001 22:04:51 GMT
From: rolf.krahl@gmx.net (Rolf Krahl)
Subject: Re: fork and pass message while waiting
Message-Id: <9g63m3$t17$3@rotkraut.de>

In article <54c48ac0.0106121136.765fdc19@posting.google.com>,
	kejoseph@hotmail.com (Kevin Joseph) writes:
> I have a process which takes around 10 min to complete. This process is 
> being executed from a web server. However, Netsape and IE timeout after
> 300 sec.
> I am trying to write a perl script which would fork this process and 
> pass a message back to server every 250 sec. This way IE/Netscape and 
> would not timeout and when the process has completed, it will output
> the information to the web page.

Set up a signal handler for SIGCHLD to allow the parent process to
know when the child is terminated.  Do something like this:

| use POSIX qw(:errno_h :sys_wait_h);
| use vars qw($childpid $childstatus $childretcode);
| 
| sub handle_chld
| {
|     while ((my $child = waitpid(-1, &WNOHANG)) > 0) {
| 	if ($child == $childpid) {
| 	    $childretcode = $?;
| 	    $childstatus = 0;
|         }
|     }
| }
| 
| $SIG{CHLD} = \&handle_chld;
| 
| my $chpid;
| FORK: {
|     if ($chpid = fork) {
| 	# Parent.
| 	$childpid = $chpid;
| 	$childstatus = 1;
|     }
|     elsif (defined $chpid) {
| 	# Child.
| 	exec('your_nifty_child')
| 	    or die "exec your_nifty_child: $!\n";
| 	# Should never reach here.
| 	exit 0x7f;
|     }
|     elsif ($! == &EAGAIN) {
| 	sleep 1;
| 	redo FORK;
|     }
|     else {
| 	# Error from fork.
| 	die "Cannot fork: $!\n";
|     }
| }
| 
| # Now keep the browser busy while waiting for the child.
| while ($childstatus) {
|     pass_message_back_to_client();
|     sleep 250;
| }
| 
| # Child is done, check the child's return code
| if ($childretcode > 0x80) {
|     my $code = $childretcode >> 7;
|     # Child returned non-zero return code $code signalling a problem ...
| }
| elsif ($childretcode) {
|     my $sig = $childretcode & ~0x80;
|     # Child died from catching signal $sig ...
| }
| else {
|     # Child returned zero signalling success ...
| }

Note that these are fragments from some of my scripts that run on Unix
systems.  Since i only work with Unix, i have no idea if this might
work with other OS's.

-- 
		   Rolf Krahl <rolf.krahl@gmx.net>


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

Date: 12 Jun 2001 15:55:53 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: fork and pass message while waiting
Message-Id: <m34rtll8o6.fsf@dhcp9-173.support.tivoli.com>

On 12 Jun 2001, kejoseph@hotmail.com wrote:

> I have a process which takes around 10 min to complete. This process
> is being executed from a web server. However, Netsape and IE timeout
> after 300 sec.
> I am trying to write a perl script which would fork this process and
> pass a message back to server every 250 sec. This way IE/Netscape
> and would not timeout and when the process has completed, it will
> output the information to the web page.
> How do I implement this ? I have tried various combination but still
> could not figure it out.

What have you tried?

Something like:

if ($child=fork) {
  # parent
  for (;;) { # ever
    print "Processing...\n";
    sleep 250;
    exit if waitpid($child, 0);
  }
} elsif ($child == 0) {
  # child
} else {
  die "fork() failed, $!";
}

This has the disadvantage of sleeping an extra part-cycle.  You could
use a signal handler instead:

$SIG{CHLD} = sub { exit };

or

$SIG{CHLD} = sub { exit if wait == $child };

In either case, you don't really need the waitpid call anymore.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 12 Jun 2001 15:35:42 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Help with split?vvp
Message-Id: <3B26993E.53AA12FF@stomp.stomp.tokyo>

Rolf Krahl wrote:
 
> Godzilla! wrote:

(snipped, topic is terminating newline for a file)


As promised, I ran some tests to discover truth.
My tests show I am wrong and you are right. My
programmer editor does not save files the same
as Perl writes files. I shall exercise caution
in the future.

For test one, you can see Perl writes a file
without a terminating newline. Test two, Perl
writes a file with a terminating newline. Each
test produces correct results.

My test three, I created a file with my program
editor in this format, a newline is created with
my Enter key and, those newlines are intentionally
shown as \n to be visible:

line one\n
line two\n
line three

To make a comparison, test four is a file created
with my program editor:

line one\n
line two\n
line three\n

When I close and open these files again, my program
editor includes a newline at the end of each line
even when not included in test three. Search and
replace with X creates this for both file three and
file four:

line oneXline twoXline threeX

As you can see, my editor adds a newline even
when I do not create one with my Enter key.
This is verified in my tests three and four.

Truth is you are right. My mistake is in not
noticing what my program editor does. I was
actually terminating with \n\n although my
editor only displays one terminating \n after
a search and replace.

Thank you for pointing this out and, my apologies
to those whose code I tested and indicated those
codes do not work right. This is a well hidden
technological blunder on my part. Henceforth,
I will not intentionally create a terminating
newline now knowing my editor does this quite
automatically and truncates terminating double
newlines down to a single newline upon opening.


Godzilla!
--
For testing, my code replaces lowercase
"line" with uppercase "Line" in all
test cases.


#!perl

print "Content-type: text/plain\n\n";

open (FILEHANDLE, ">test.txt");
print FILEHANDLE "line one\n",
                 "line two\n",
                 "line three";
close (FILEHANDLE);

open (FILEHANDLE2, ">test2.txt");
print FILEHANDLE2 "line one\n",
                  "line two\n",
                  "line three\n";
close (FILEHANDLE2);


print "\n\nTest One:\n\n";


open (TEST1, "test.txt");
while (<TEST1>)
 {
  substr ($_, 0, index ($_, " "), "LINE");
  print $_;
 }
close (TEST1);


print "\n\nTest Two:\n\n";


open (TEST2, "test2.txt");
while (<TEST2>)
 {
  substr ($_, 0, index ($_, " "), "LINE");
  print $_;
 }
close (TEST2);

print "\n\nTest Three:\n\n";

open (TEST3, "test3.txt");
while (<TEST3>)
 {
  substr ($_, 0, index ($_, " "), "LINE");
  print $_;
 }
close (TEST3);

print "\n\nTest Four:\n\n";

open (TEST4, "test4.txt");
while (<TEST4>)
 {
  substr ($_, 0, index ($_, " "), "LINE");
  print $_;
 }
close (TEST4);


exit;


PRINTED RESULTS:
________________

Test One:

LINE one
LINE two
LINE three

Test Two:

LINE one
LINE two
LINE three


Test Three:

LINE one
LINE two
LINE three


Test Four:

LINE one
LINE two
LINE three
LINE


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

Date: Tue, 12 Jun 2001 23:52:41 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: log file parsing
Message-Id: <tidaq92b0m2g37@corp.supernews.com>

kevin (emailkevin@charter.net) wrote:
: can someone show me how to read each new line of a log file and then take
: some action, and then read the next?  Thanks

General pattern:

  open LOG, '< logfile.name' or die "Can't open logfile.name: $!";

  while (<LOG>) {
    # Put your action here; line is in $_
  }

  close LOG;

Questions this simple indicate that you probably should be working your
way through _Learning Perl_ or an equivalent Perl-newbie book.  The time
invested will be well repaid.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Magick is the art and science of causing change in conformity
   |   with Will."  - Aleister Crowley


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

Date: Tue, 12 Jun 2001 23:55:55 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: log file parsing
Message-Id: <f_xV6.141236$I5.38438658@news1.rdc1.tn.home.com>


"kevin" <emailkevin@charter.net> wrote in message
news:tid3rk116i2i5b@corp.supernews.com...
> can someone show me how to read each new line of a log file and then take
> some action, and then read the next?  Thanks
>

$logfile = "file.log";
open I, $logfile;
while (<I>) {
    #each line goes in $_
    &do_stuff($_);
}
close I;




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

Date: Wed, 13 Jun 2001 00:42:50 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: log file parsing
Message-Id: <tiddoan5en9g22@corp.supernews.com>

Todd Smith (todd@designsouth.net) wrote:
: $logfile = "file.log";
: open I, $logfile;

Always check the result of open.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Magick is the art and science of causing change in conformity
   |   with Will."  - Aleister Crowley


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

Date: Tue, 12 Jun 2001 22:23:10 GMT
From: sweth+perl@gwu.edu (Sweth Chandramouli)
Subject: Re: REGEX
Message-Id: <iDwV6.75533$G5.16168054@news1.rdc1.md.home.com>

In article <m3bsnvnk4p.fsf@dhcp9-173.support.tivoli.com>,
Ren Maddox  <ren@tivoli.com> wrote:
>This regex might be good enough for you:
>
>/"((?:\\"|[^"])*)"/g
>
>In fact, looking back at your regex, the problem is that you have the
>order of your alternation backwards.  Matching a single character is
>always going to match the backslash before it gets a chance to match
>as part of the backslash-quote combination.  Switching that order
>should fix things.
	Friedl goes into a fair amount of detail on why this isn't
a very robust solution, including the case of matching embedded escaped
quotes but no closing quote (such as "this \"string\", which shouldn't 
match, but does).  One good step towards the right solution is
/"((?:[^"\\]|\\")*)"/g; that still doesn't allow for any other instances
of backslashes in the string, however.  Friedl's solution is to do
something like /"((?:[^"\\]|\\(.|\n))*)"/g, I believe; if you are using
a version of Perl that supports it, though, I think lookaround assertions
would be a better way to go.

-- 
Sweth Chandramouli ; <sweth+perl@gwu.edu>


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

Date: 12 Jun 2001 17:52:49 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: REGEX
Message-Id: <m3elsp2tvi.fsf@dhcp9-173.support.tivoli.com>

On Tue, 12 Jun 2001, sweth+perl@gwu.edu wrote:

> In article <m3bsnvnk4p.fsf@dhcp9-173.support.tivoli.com>,
> Ren Maddox  <ren@tivoli.com> wrote:
>>This regex might be good enough for you:
>>
>>/"((?:\\"|[^"])*)"/g
>>
> 	Friedl goes into a fair amount of detail on why this isn't
> a very robust solution, including the case of matching embedded escaped
> quotes but no closing quote (such as "this \"string\", which shouldn't 
> match, but does).  One good step towards the right solution is
> /"((?:[^"\\]|\\")*)"/g; that still doesn't allow for any other instances
> of backslashes in the string, however.  Friedl's solution is to do
> something like /"((?:[^"\\]|\\(.|\n))*)"/g, I believe; if you are using
> a version of Perl that supports it, though, I think lookaround assertions
> would be a better way to go.

Even that last one breaks down if the starting quote is preceded by a
backslash q/\"like this"/;

The look-behind solution can handle that problem as well:

/((?<!\\)".*?(?<!\\)")/sg

works well as long as you don't anchor it.  Anchoring it can lead to
mis-matches because the ".*?" portion can become over-zealous:

$_ = q/"This is a string" \"and this is not"/;
print "$_\n" for /((?<!\\)".*?(?<!\\)")/sg;  # Good
print "$_\n" for /^((?<!\\)".*?(?<!\\)")$/sg;  # Bad

Of course, you can always combine the Friedl solution with
look-behind:

/((?<!\\)"(?:[^"\\]|\\.)*")/sg

Leaving out the look-behind on the closing quote is OK here because
the restricted match isn't going to allow a bare backslash.  In fact,
this has the added benefit of matching q/"this string\\\\"/, as it
should (not that "\" still has to be doubled in single-quote strings.

There is still a weakness left, and that is q/\\\\"this string"/.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 12 Jun 2001 17:48:56 -0700
From: sam_i_am0011@yahoo.com (steve)
Subject: Re: Removing ^M characters
Message-Id: <3ed41755.0106121648.62f740b3@posting.google.com>

if you do a sub like:
while (<FILE>) {
    s/\r/\n/g;
    print $_;
}

it depends on which OS is screwing things up:
i think the above example is from a mac file...
your sub might be

s/\r\n/\n/g;

I think all that works...

good luck.


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

Date: 12 Jun 2001 15:39:21 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: sorting a list of files from a directory
Message-Id: <m38zixl9fq.fsf@dhcp9-173.support.tivoli.com>

On Tue, 12 Jun 2001, iburnedmyfingers@hotmail.com wrote:

> I am looking for the best way to sort files within a directory for
> the purpose of listing.  My ultimate goal is to sort the files in
> order of last modified (most recent at top of list).  I developed
> this:
> 
> opendir DIRH, "/path/tofolder" or die "couldn't open: $!";
> foreach (sort { -M $a <=> -M $b } readdir DIRH) {

This is a common mistake with readdir -- all it returns are the
filenames, not the complete path, so when you then use -M against the
filename, it isn't likely to do the right thing.  You want:

  foreach (sort { -M "/path/tofolder/$a" <=> -M "/path/tofolder/$b" }
                readdir DIRH) {

> $file = $_;

If you're going to use $file instead of $_, you might as well say so
on the foreach line:

  foreach my $file (...) {

> @info = stat ($file);

This stat() has the same problem as -M above.  You should really check
the result of stat() just like other system calls:

  @info = stat ($file) or die "Could not stat $file, $!";

> @date = localtime($info[9]);
> $year = sprintf("%d-%d-%d\n",$date[4]+1,$date[3],$date[5]+1900);
> $time = "$date[2]:$date[1]";
> $lastmodified = "$year $time";
> ($filename) = $file =~ m!([^/]*)$!;
> print "<tr><td><a 
> href=\"http://www.url.com/$filename\">$filename</a></td><td>$lastmodified
> </td></tr>";
> }
> closedir DIRH or die "couldn't close directory: $!";
> 
> which seems to do custom sorts fine, but then the $lastmodified
> variable is always 12-31-1969 16:0

That is likely the local time for epoch time 0, which is what stat
returned for the non-existent file.

> so i tried this:
> 
> foreach $file (</path/tofolder/*>) {

Now $file will have the full path...

> @info = stat ($file);

so the stat will work.

> @date = localtime($info[9]);
> $year = sprintf("%d-%d-%d\n",$date[4]+1,$date[3],$date[5]+1900);
> $time = "$date[2]:$date[1]";
> $lastmodified = "$year $time";
> ($filename) = $file =~ m!([^/]*)$!;
> print "<tr><td><a 
> href=\"http://www.url.com/$filename\">$filename</a></td><td>$lastmodified
> </td></tr>";
> }
> 
> which displays the $lastmodified variable as a current date and
> time, but I cannot find a way to customize the sort of the list.

The same way you tried on the first loop will actually work on this
loop:

foreach my $file (sort { -M $a <=> -M $b } </path/tofolder/*>) {

> I'm pretty new at PERL, so I'm sure I'm missing some simple coding
> trick that will solve my problem. Can anyone help?

Yeah, that readdir thing is tricky.  Notably, there is an explicit
warning in perlfunc(1), including an example:

   readdir DIRHANDLE
           Returns the next directory entry for a directory
           opened by `opendir'.  If used in list context,
           returns all the rest of the entries in the
           directory.  If there are no more entries, returns
           an undefined value in scalar context or a null
           list in list context.

           If you're planning to filetest the return values
           out of a `readdir', you'd better prepend the
           directory in question.  Otherwise, because we
           didn't `chdir' there, it would have been testing
           the wrong file.

               opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
               @dots = grep { /^\./ && -f "$some_dir/$_" } readdir(DIR);
               closedir DIR;


-- 
Ren Maddox
ren@tivoli.com


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

Date: Wed, 13 Jun 2001 08:37:24 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: What is ${'string'} ?
Message-Id: <KdxV6.4$_p6.3250@vic.nntp.telstra.net>

"Todd Smith" <todd@designsouth.net> wrote in message
news:mhuV6.140808$I5.37858595@news1.rdc1.tn.home.com...
>
> <Gordon.Haverland@gov.ab.ca> wrote in message
> news:3b26116d.340959040@news.gov.ab.ca...
> > As the subject field says, what is ${'some_string'} ?
> >
> > Would their be any reason why someone would use this, instead of any
> > other variable, when their is only 1 unique string used in the entire
> > program.
> >
>
> Sometimes I use it so I can write things like:
>
> $item = "dog";
>
> print "I have two ${item}s";

But that is not the same as

print "I have two ${'item'}s";

Which is what the OP was talking about.

Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;





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

Date: Tue, 12 Jun 2001 23:58:36 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: What is ${'string'} ?
Message-Id: <M0yV6.141244$I5.38444675@news1.rdc1.tn.home.com>


"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:KdxV6.4$_p6.3250@vic.nntp.telstra.net...
> "Todd Smith" <todd@designsouth.net> wrote in message
> news:mhuV6.140808$I5.37858595@news1.rdc1.tn.home.com...

> > print "I have two ${item}s";
>
> But that is not the same as
>
> print "I have two ${'item'}s";
>
> Which is what the OP was talking about.
>
> Wyzelli

Oh really? oops.




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

Date: Wed, 13 Jun 2001 00:07:03 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: Re: What is ${'string'} ?
Message-Id: <H8yV6.141268$I5.38461983@news1.rdc1.tn.home.com>


"Wyzelli" <wyzelli@yahoo.com> wrote in message
news:KdxV6.4$_p6.3250@vic.nntp.telstra.net...
> "Todd Smith" <todd@designsouth.net> wrote in message
> news:mhuV6.140808$I5.37858595@news1.rdc1.tn.home.com...
> >
> >
> > print "I have two ${item}s";
>
> But that is not the same as
>
> print "I have two ${'item'}s";
>
> Which is what the OP was talking about.
>

[root@raq300 Merchant3]# perl
$a = 4;
print <<STOP;
123${a}56
123${'a'}56
123${"a"}56
STOP
123456
123456
123456
[root@raq300 Merchant3]#

how's it different?




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

Date: Wed, 13 Jun 2001 09:51:40 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: What is ${'string'} ?
Message-Id: <mjyV6.11$_p6.3896@vic.nntp.telstra.net>

"Todd Smith" <todd@designsouth.net> wrote in message
news:H8yV6.141268$I5.38461983@news1.rdc1.tn.home.com...
>
> "Wyzelli" <wyzelli@yahoo.com> wrote in message
> news:KdxV6.4$_p6.3250@vic.nntp.telstra.net...
> > "Todd Smith" <todd@designsouth.net> wrote in message
> > news:mhuV6.140808$I5.37858595@news1.rdc1.tn.home.com...
> > >
> > >
> > > print "I have two ${item}s";
> >
> > But that is not the same as
> >
> > print "I have two ${'item'}s";
> >
> > Which is what the OP was talking about.
> >
>
>
> how's it different?

You are using the braces as a variable name delimiter in a double quoted
string.  The OP is using a soft reference.

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
$d='$_$a$s$b$w';$e='$_$a$s$b';sub d{$h=shift;$h=~s/\$(\w+)/${$1}/g;return$h}
sub
e{return(shift!=1)?'s':''}for(reverse(1..100)){$s=e($_);$f=d($d);$g=d($e);
$c.="$f\n$g\n$t\n";$_--;$s=e($_);$e=d($d);$c.="$e\n\n";}print"$c*hic*";




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

Date: Tue, 12 Jun 2001 16:12:41 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Why two lists instead of HOH?
Message-Id: <3B2685C9.22D1D94B@home.com>

Sweth Chandramouli wrote:
> 
> In article <3B2671F2.D9E19E6D@home.com>,
> Michael Carman  <mjcarman@home.com> wrote:
> >Tie::IxHash
>         That's not part of the std distro, though, is it?  If at
> all possible, I'd rather not have to force anyone using this code to
> install a new module, as it will probably end up running on multiple
> machines.

No, it isn't. If you aren't willing to require non-standard modules (and
enjoy the benefits of others' labors :) ) you'll have to reinvent the
wheel yourself.

There is one other option that sometimes works (and does for this
module). If your script keeps it's own module directory, you can put
Tie::IxHash in there and bundle it with your script.

-mjc


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

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


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