[30773] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2018 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 30 03:09:44 2008

Date: Sun, 30 Nov 2008 00:09:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 30 Nov 2008     Volume: 11 Number: 2018

Today's topics:
        =?ISO-2022-JP?B?Q2hpbmVzZSBHaXJscyBQaWN0dXJlcyAbJEIhJBs <yingwen@1dis.cn>
        find files by date <dave1198@hotmail.com>
    Re: find files by date <someone@example.com>
    Re: find files by date <tadmc@seesig.invalid>
    Re: find files by date <jurgenex@hotmail.com>
    Re: find files by date <dave1198@hotmail.com>
    Re: How to forbid functions of some package be introduc <spamtrap@dot-app.org>
        How to forbid functions of some package be introduced t <PengYu.UT@gmail.com>
    Re: how to force a symbolic link? <whynot@pozharski.name>
    Re: Is there a command or package to search for all ins <tadmc@seesig.invalid>
    Re: Is there a command or package to search for all ins <jurgenex@hotmail.com>
    Re: Is there a command or package to search for all ins <nospam-abuse@ilyaz.org>
        Is there a command or package to search for all instanc <PengYu.UT@gmail.com>
    Re: Is there a command or package to search for all ins <someone@example.com>
    Re: mail address validation <sbryce@scottbryce.com>
        new CPAN modules on Sun Nov 30 2008 (Randal Schwartz)
        Using strings as keys of hash <PengYu.UT@gmail.com>
    Re: Using strings as keys of hash <martien.verbruggen@invalid.see.sig>
    Re: Using strings as keys of hash <tadmc@seesig.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 29 Nov 2008 21:34:05 -0800 (PST)
From: "yingwen@1dis.cn" <yingwen@1dis.cn>
Subject: =?ISO-2022-JP?B?Q2hpbmVzZSBHaXJscyBQaWN0dXJlcyAbJEIhJBsoQkluZGlhIEdpcmxzIFBpY3R1cmVzIBskQiEkGyhCV2U=?= =?ISO-2022-JP?B?c3Rlcm4gR2lybHMgcGljdHVyZXM=?=
Message-Id: <9a6fa87c-d0af-44b4-8f73-c346de424d1b@v5g2000prm.googlegroups.com>

Chinese Girls Pictures $B!$(BIndia Girls Pictures $B!$(BWestern Girls pictures
http://www.cn.1dis.cn/

India Girls Pictures
http://www.india.1dis.cn/

Western Girls pictures
http://www.western.1dis.cn/

Russia Girls Pictures
http://www.russia.1dis.cn/

Cartoon Girls Pictures
http://cartoongirlspictures.blogspot.com/
other
www.chinesegirls8.cn
www.freegirlspictures.cn

Unofficial Phone,the most cheap mobile phones from china

http://www.unofficialphone.cn/2008/11/friends-of-walled-design-ahead-...
http://www.unofficialphone.cn/2008/11/wf188-history-of-mountain-fastn...

Free Girls Picture
http://freegirlspictures.blogspot.com/

Non-mainstream Pictures
http://non-mainstream.1dis.cn/

koreagirls  pictures
http://koreagirls.blogspot.com/

free sexy videu
www.henub.cn


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

Date: Sat, 29 Nov 2008 21:57:08 -0500
From: "Dave" <dave1198@hotmail.com>
Subject: find files by date
Message-Id: <493200f8@news.x-privat.org>

Hi,

I want to get all the files in a folder that are newer that a certain 
(determined) date.

I know how to get all ".csv" files (for example):

my @files = (grep (/\.csv/,readdir(foldername)));

How do I "grep" files according to the date?

Note: I don't want to grep -M > (a number of days)
cause I don't know the number of days. I just have the date of a file to 
compare with.

TIA,
Dave. 



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

Date: Sat, 29 Nov 2008 19:29:03 -0800
From: "John W. Krahn" <someone@example.com>
Subject: Re: find files by date
Message-Id: <2MnYk.8017$kn7.44@newsfe08.iad>

Dave wrote:
> 
> I want to get all the files in a folder that are newer that a certain 
> (determined) date.
> 
> I know how to get all ".csv" files (for example):
> 
> my @files = (grep (/\.csv/,readdir(foldername)));
> 
> How do I "grep" files according to the date?

perldoc -q "How do I get a file.s timestamp in perl"


John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Sat, 29 Nov 2008 21:50:42 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: find files by date
Message-Id: <slrngj43ci.ons.tadmc@tadmc30.sbcglobal.net>

Dave <dave1198@hotmail.com> wrote:
> Hi,
>
> I want to get all the files in a folder that are newer that a certain 
> (determined) date.
>
> I know how to get all ".csv" files (for example):
>
> my @files = (grep (/\.csv/,readdir(foldername)));
                                           ^^^^
                                           ^^^^

readdir() does not operate on a name, it operates on a directory handle.

Directory handles should be UPPER CASE.

Superfluous parenthesis make code harder to read.

Your code will put a file named "not.csv.at.all" into @files...

    my @files = grep /\.csv$/, readdir DIRHANDLE;


> How do I "grep" files according to the date?
>
> Note: I don't want to grep -M > (a number of days)
> cause I don't know the number of days. 


If you know the current time(), and you know some other time (in epoch time), 
then simple arithmetic can be used to calculate the number of days.

    my $days = (time - $epoch) / (24 * 60 * 60);
    my @newer_files = grep -f && -M $_ < $days, readdir DIR;


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Sat, 29 Nov 2008 20:48:12 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: find files by date
Message-Id: <li64j4dmfpi7m0do5dt05p309fl0it5289@4ax.com>

"Dave" <dave1198@hotmail.com> wrote:
>Hi,
>
>I want to get all the files in a folder that are newer that a certain 
>(determined) date.
>
>I know how to get all ".csv" files (for example):
>
>my @files = (grep (/\.csv/,readdir(foldername)));

Maybe glob() is easier to use because you don't have to open and read
and grep explicitely.

>How do I "grep" files according to the date?

perldoc -f stat

>Note: I don't want to grep -M > (a number of days)
>cause I don't know the number of days. I just have the date of a file to 
>compare with.

But you could still easily calculate the difference between now and the
desired date and use that as the bar for -M.

jue


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

Date: Sat, 29 Nov 2008 23:55:20 -0500
From: "Dave" <dave1198@hotmail.com>
Subject: Re: find files by date
Message-Id: <49321caf@news.x-privat.org>


Don't inspect all the code, was hand written without any care for the it.

Thanks a lot!


"Tad J McClellan" <tadmc@seesig.invalid> wrote in message 
news:slrngj43ci.ons.tadmc@tadmc30.sbcglobal.net...
> Dave <dave1198@hotmail.com> wrote:
>> Hi,
>>
>> I want to get all the files in a folder that are newer that a certain
>> (determined) date.
>>
>> I know how to get all ".csv" files (for example):
>>
>> my @files = (grep (/\.csv/,readdir(foldername)));
>                                           ^^^^
>                                           ^^^^
>
> readdir() does not operate on a name, it operates on a directory handle.
>
> Directory handles should be UPPER CASE.
>
> Superfluous parenthesis make code harder to read.
>
> Your code will put a file named "not.csv.at.all" into @files...
>
>    my @files = grep /\.csv$/, readdir DIRHANDLE;
>
>
>> How do I "grep" files according to the date?
>>
>> Note: I don't want to grep -M > (a number of days)
>> cause I don't know the number of days.
>
>
> If you know the current time(), and you know some other time (in epoch 
> time),
> then simple arithmetic can be used to calculate the number of days.
>
>    my $days = (time - $epoch) / (24 * 60 * 60);
>    my @newer_files = grep -f && -M $_ < $days, readdir DIR;
>
>
> -- 
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/" 



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

Date: Sat, 29 Nov 2008 21:06:03 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: How to forbid functions of some package be introduced to the global  name space?
Message-Id: <m1vdu6ge7o.fsf@dot-app.org>

Peng Yu <PengYu.UT@gmail.com> writes:

> File::Copy would introduce 'copy' in the current namespace, which
> would result in conflict in the example below. I'm wondering if there
> is anyway to forbid 'copy' be introduced in the current namespace.
>
> Thanks,
> Peng
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> use File::Copy;

use File::Copy(); # Empty import list, so nothing is imported

See 'perldoc -f use' for details.

sherm--

-- 
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Sat, 29 Nov 2008 17:24:45 -0800 (PST)
From: Peng Yu <PengYu.UT@gmail.com>
Subject: How to forbid functions of some package be introduced to the global  name space?
Message-Id: <ae4d5770-7503-4169-a88b-368799c5658b@x8g2000yqk.googlegroups.com>

Hi,

File::Copy would introduce 'copy' in the current namespace, which
would result in conflict in the example below. I'm wondering if there
is anyway to forbid 'copy' be introduced in the current namespace.

Thanks,
Peng

#!/usr/bin/perl

use strict;
use warnings;

use File::Copy;

File::Copy::copy('copy.pl', 'some.pl');
copy('copy.pl', 'other.pl');#conflicts with the following subroutine

__END__

#The following function can not be defined as it is conflicted with
File::Copy::copy.
sub copy {
    print "in copy\n";
}


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

Date: Sat, 29 Nov 2008 22:35:03 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: how to force a symbolic link?
Message-Id: <slrngj39t1.86n.whynot@orphan.zombinet>

On 2008-11-29, John W. Krahn <someone@example.com> wrote:
> Peng Yu wrote:
>> 
>> In shell, 'ln' has an option -f. I'm wondering if there is such option
>> for symlink in perl.
>
> -e 'oldlink' and unlink 'oldlink';
> symlink 'yourfile', 'oldlink' or die "oldlink: $!";

If my understanding of unlink(2) and symlink(2) is correct either one
would fail or both.  Anyway there's race, so:

	unlink 'oldlink;
	symlink 'yourfile', 'oldlink' or die $!;

Then what's wrong with that:

	#/usr/bin/perl
	use strict;
	use warnings;
	use File::Temp qw|tempfile|;
	use File::Basename;
	my ($link, $yourfile) = ( @ARGV );
	my ($fd, $fn) = ( dirname($link), basename $link );
	my($fh), $fn = tempfile "$fn.XXXXXX", DIR => $fd;
	unlink $fn or die "unlink: $!";
	symlink $yourfile, $fn or die "symlink: die $!";
	close $fd;
	rename $fn, $link or die "rename: $!";
	__END__

Did I really needed to keep I<$fn> open?


-- 
Torvalds' goal for Linux is very simple: World Domination


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

Date: Sat, 29 Nov 2008 22:40:01 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Is there a command or package to search for all instances of a  substring in a string?
Message-Id: <slrngj4691.ons.tadmc@tadmc30.sbcglobal.net>

Peng Yu <PengYu.UT@gmail.com> wrote:

> Can somebody let me know if there is a command or function to find all
> the occurance of a substring in a string?


What does "find" mean when you say it?

If string="aaa" and substring="aa", should it "find" the substring 1 or 2 times?


> I just want to know what is the best way to do this.


That depends entirely on what "this" is...

If "this" is:

    find all of the starting indexes of a substring in a larger string

then to find non-overlapping substrings:

    push @indexes, pos($string) - length $substr, while $string =~ /$substr/g;

or to find overlapping substrings:

    for (my $pos = -1;;) {
        $pos = index $string, $substr, $pos+1;
        last if $pos == -1;
        push @indexes, $pos;
    }


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Sat, 29 Nov 2008 20:50:07 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Is there a command or package to search for all instances of a  substring in a string?
Message-Id: <gq64j4lquvr7ek92a8djo68063h1q4judf@4ax.com>

Peng Yu <PengYu.UT@gmail.com> wrote:
>Can somebody let me know if there is a command or function to find all
>the occurance of a substring in a string? I can write a program to do
>this. I just want to know what is the best way to do this.

	perldoc -f index

and keep looking ( aka looping)

jue


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

Date: Sun, 30 Nov 2008 05:38:49 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Is there a command or package to search for all instances of a  substring in a string?
Message-Id: <ggt8t9$1d5i$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Tad J McClellan 
<tadmc@seesig.invalid>], who wrote in article <slrngj4691.ons.tadmc@tadmc30.sbcglobal.net>:
>     find all of the starting indexes of a substring in a larger string
> 
> then to find non-overlapping substrings:
> 
> push @indexes, pos($string) - length $substr, while $string =~ /$substr/g;

One should keep in mind that overlapping substrings can be done in the
same way:

 push @indexes, pos($string) - length $substr, while $string =~ /(?=$substr)/g;

 # As above, $substr should not contain metachars; otherwise \Q\E may
   be needed...

Hope this helps,
Ilya


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

Date: Sat, 29 Nov 2008 18:04:06 -0800 (PST)
From: Peng Yu <PengYu.UT@gmail.com>
Subject: Is there a command or package to search for all instances of a  substring in a string?
Message-Id: <fdbe6710-10c7-45ca-9a8e-5d63794862ba@z1g2000yqn.googlegroups.com>

Hi,

Can somebody let me know if there is a command or function to find all
the occurance of a substring in a string? I can write a program to do
this. I just want to know what is the best way to do this.

Thanks,
Peng


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

Date: Sat, 29 Nov 2008 19:31:02 -0800
From: "John W. Krahn" <someone@example.com>
Subject: Re: Is there a command or package to search for all instances of a  substring in a string?
Message-Id: <VNnYk.8018$kn7.552@newsfe08.iad>

Peng Yu wrote:
> 
> Can somebody let me know if there is a command or function to find all
> the occurance of a substring in a string? I can write a program to do
> this. I just want to know what is the best way to do this.

perldoc -f m
perldoc -f index
perldoc -f rindex


John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Sat, 29 Nov 2008 14:30:58 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: mail address validation
Message-Id: <ggscau$msk$1@news.motzarella.org>

Petr Vileta "fidokomik" wrote:
> I have read RFC822 and check groups and ansk Uncle Google but I'm still 
> confused.
> I want to perform mail address validation as simple as possible.

The simplest way in Perl is to use the Email::Valid module.

http://search.cpan.org/~rjbs/Email-Valid-0.179/lib/Email/Valid.pm


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

Date: Sun, 30 Nov 2008 05:42:23 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Nov 30 2008
Message-Id: <KB4t6n.1s01@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Apache-Mojo-0.003
http://search.cpan.org/~dsheroh/Apache-Mojo-0.003/
mod_perl handler for Mojo 
----
Astro-SIMBAD-Client-0.017
http://search.cpan.org/~wyant/Astro-SIMBAD-Client-0.017/
Fetch astronomical data from SIMBAD 4. 
----
Audio-WMA-1.3
http://search.cpan.org/~daniel/Audio-WMA-1.3/
Perl extension for reading WMA/ASF Metadata 
----
Biblio-Refbase-0.0.1
http://search.cpan.org/~hma/Biblio-Refbase-0.0.1/
Perl interface to refbase bibliographic manager 
----
Bundle-DBD-PO-2.01
http://search.cpan.org/~steffenw/Bundle-DBD-PO-2.01/
A bundle to install all DBD::PO related modules 
----
CPANPLUS-Dist-Gentoo-0.03
http://search.cpan.org/~vpit/CPANPLUS-Dist-Gentoo-0.03/
CPANPLUS backend generating Gentoo ebuilds. 
----
Catalyst-Authentication-Store-RDBO-0.1000
http://search.cpan.org/~doneill/Catalyst-Authentication-Store-RDBO-0.1000/
A storage class for Catalyst Authentication using RDBO 
----
Catalyst-Plugin-Authentication-0.100091
http://search.cpan.org/~jayk/Catalyst-Plugin-Authentication-0.100091/
Infrastructure plugin for the Catalyst authentication framework. 
----
Class-XSAccessor-0.09
http://search.cpan.org/~smueller/Class-XSAccessor-0.09/
Generate fast XS accessors without runtime compilation 
----
Class-XSAccessor-0.10
http://search.cpan.org/~smueller/Class-XSAccessor-0.10/
Generate fast XS accessors without runtime compilation 
----
Class-XSAccessor-0.11
http://search.cpan.org/~smueller/Class-XSAccessor-0.11/
Generate fast XS accessors without runtime compilation 
----
Class-XSAccessor-Array-0.07
http://search.cpan.org/~smueller/Class-XSAccessor-Array-0.07/
Generate fast XS accessors without runtime compilation 
----
Class-XSAccessor-Array-0.11
http://search.cpan.org/~smueller/Class-XSAccessor-Array-0.11/
Generate fast XS accessors without runtime compilation 
----
Crypt-Skip32-XS-0.02
http://search.cpan.org/~gray/Crypt-Skip32-XS-0.02/
Drop-in replacement for Crypt::Skip32 
----
DBD-PO-2.01
http://search.cpan.org/~steffenw/DBD-PO-2.01/
DBI driver for PO files 
----
Devel-CoreDump-0.02
http://search.cpan.org/~flora/Devel-CoreDump-0.02/
create core dumps of the running perl interpreter, without terminating 
----
Email-Blaster-0.0001_03
http://search.cpan.org/~johnd/Email-Blaster-0.0001_03/
Scalable Mass Email System 
----
Email-Blaster-0.0001_04
http://search.cpan.org/~johnd/Email-Blaster-0.0001_04/
Scalable Mass Email System 
----
Email-Outlook-Message-0.905
http://search.cpan.org/~mvz/Email-Outlook-Message-0.905/
Read Outlook .msg files 
----
File-Util-3.24
http://search.cpan.org/~tommy/File-Util-3.24/
Easy, versatile, portable file handling 
----
Gtk2-Ex-WidgetBits-7
http://search.cpan.org/~kryde/Gtk2-Ex-WidgetBits-7/
miscellaneous Gtk widget helpers 
----
HTTP-Headers-Fast-0.05
http://search.cpan.org/~tokuhirom/HTTP-Headers-Fast-0.05/
faster implementation of HTTP::Headers 
----
HTTP-Server-Simple-Recorder-0.03
http://search.cpan.org/~jesse/HTTP-Server-Simple-Recorder-0.03/
Mixin to record HTTP::Server::Simple's sockets 
----
Kephra-0.4.0_1
http://search.cpan.org/~lichtkind/Kephra-0.4.0_1/
crossplatform, GUI-Texteditor along perllike Paradigms 
----
Log-Facile-0.03
http://search.cpan.org/~sera/Log-Facile-0.03/
Perl extension for facile logging 
----
Log-Facile-0.04
http://search.cpan.org/~sera/Log-Facile-0.04/
Perl extension for facile logging 
----
MIME-Types-1.25
http://search.cpan.org/~markov/MIME-Types-1.25/
Definition of MIME types 
----
MooseX-Declare-0.03
http://search.cpan.org/~flora/MooseX-Declare-0.03/
Declarative syntax for Moose 
----
Muldis-D-0.51.0
http://search.cpan.org/~duncand/Muldis-D-0.51.0/
Formal spec of Muldis D relational DBMS lang 
----
Net-OpenID-Consumer-1.03
http://search.cpan.org/~mart/Net-OpenID-Consumer-1.03/
library for consumers of OpenID identities 
----
Net-OpenID-Consumer-Lite-0.01
http://search.cpan.org/~tokuhirom/Net-OpenID-Consumer-Lite-0.01/
OpenID consumer library for minimalist 
----
Net-OpenID-Server-1.02
http://search.cpan.org/~mart/Net-OpenID-Server-1.02/
library for building your own OpenID server 
----
NetAddr-IP-4.018
http://search.cpan.org/~miker/NetAddr-IP-4.018/
Manages IPv4 and IPv6 addresses and subnets 
----
NetAddr-IP-4.019
http://search.cpan.org/~miker/NetAddr-IP-4.019/
Manages IPv4 and IPv6 addresses and subnets 
----
Ogg-Vorbis-Decoder-0.8
http://search.cpan.org/~daniel/Ogg-Vorbis-Decoder-0.8/
An object-oriented Ogg Vorbis to decoder 
----
POE-Component-IRC-Plugin-MegaHAL-0.13
http://search.cpan.org/~hinrik/POE-Component-IRC-Plugin-MegaHAL-0.13/
A PoCo-IRC plugin which provides access to a MegaHAL conversation simulator. 
----
POE-Component-IRC-Plugin-MegaHAL-0.14
http://search.cpan.org/~hinrik/POE-Component-IRC-Plugin-MegaHAL-0.14/
A PoCo-IRC plugin which provides access to a MegaHAL conversation simulator. 
----
POE-Component-IRC-Plugin-MegaHAL-0.15
http://search.cpan.org/~hinrik/POE-Component-IRC-Plugin-MegaHAL-0.15/
A PoCo-IRC plugin which provides access to a MegaHAL conversation simulator. 
----
POE-Component-Server-SimpleContent-1.14
http://search.cpan.org/~bingos/POE-Component-Server-SimpleContent-1.14/
The easy way to serve web content with POE::Component::Server::SimpleHTTP. 
----
Parse-Gnaw-0.29
http://search.cpan.org/~gslondon/Parse-Gnaw-0.29/
An extensible parser. Define grammars using subroutine calls. Define your own grammar extensions by defining new subroutines. Parse text in memory or from/to files or other streams. 
----
Parse-Gnaw-0.30
http://search.cpan.org/~gslondon/Parse-Gnaw-0.30/
An extensible parser. Define grammars using subroutine calls. Define your own grammar extensions by defining new subroutines. Parse text in memory or from/to files or other streams. 
----
SOAPjr-1.0.0
http://search.cpan.org/~robman/SOAPjr-1.0.0/
the love child of SOAP and JR (JSON-RPC) 
----
Sub-Uplevel-0.21_01
http://search.cpan.org/~dagolden/Sub-Uplevel-0.21_01/
apparently run a function in a higher stack frame 
----
TRD-DebugLog-0.0.9
http://search.cpan.org/~ichi/TRD-DebugLog-0.0.9/
debug log 
----
Tie-TZ-2
http://search.cpan.org/~kryde/Tie-TZ-2/
tied $TZ setting %ENV and calling tzset() 
----
Variable-Magic-0.26
http://search.cpan.org/~vpit/Variable-Magic-0.26/
Associate user-defined magic to variables from Perl. 
----
WWW-HatenaStar-0.03
http://search.cpan.org/~woremacx/WWW-HatenaStar-0.03/
perl interface to Hatena::Star 
----
WWW-Rediff-iShare-02
http://search.cpan.org/~shardiwal/WWW-Rediff-iShare-02/
get ishare.rediff.com audio and video stream URL and download it to your system 
----
WWW-Search-2.507
http://search.cpan.org/~mthurn/WWW-Search-2.507/
Virtual base class for WWW searches 
----
WWW-Search-AltaVista-2.154
http://search.cpan.org/~mthurn/WWW-Search-AltaVista-2.154/
class for searching www.altavista.com 
----
WWW-Search-Ask-1.011
http://search.cpan.org/~mthurn/WWW-Search-Ask-1.011/
class for searching www.search.com 
----
WebService-Google-Language-0.07
http://search.cpan.org/~hma/WebService-Google-Language-0.07/
Perl interface to the Google AJAX Language API 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: Sat, 29 Nov 2008 15:09:36 -0800 (PST)
From: Peng Yu <PengYu.UT@gmail.com>
Subject: Using strings as keys of hash
Message-Id: <b22316a5-26b4-43f9-909c-10377ed796e9@x14g2000yqk.googlegroups.com>

Hi,

It seems that if strings are keys, the single quote can be omitted. I
don't see why on perl hash tutorial webpage such as
http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/hash/#add_a_key_value_pair_to_a_hash

Can somebody give me a brief explanation why the single quote can be
omitted if the strings are used as the keys of a hash?

Thanks,
Peng

#!/usr/bin/perl

use strict;
use warnings;

my %hash = (
    Fred => 'Flintstone',
    Barney => 'Rubble'
);

# I can use the following code as well.
#my %hash = (
#    'Fred' => 'Flintstone',
#    'Barney' => 'Rubble'
#);

#The strings does not have single quotes as well.
print "$hash{Fred}\n";
print "$hash{Barney}\n";

print "$hash{'Fred'}\n";
print "$hash{'Barney'}\n";


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

Date: Sun, 30 Nov 2008 10:26:04 +1100
From: Martien Verbruggen <martien.verbruggen@invalid.see.sig>
Subject: Re: Using strings as keys of hash
Message-Id: <slrngj3jsc.qv6.martien.verbruggen@mgjv.heliotrope.home>

On Sat, 29 Nov 2008 15:09:36 -0800 (PST),
	Peng Yu <PengYu.UT@gmail.com> wrote:
> Hi,
>
> It seems that if strings are keys, the single quote can be omitted. I
> don't see why on perl hash tutorial webpage such as
> http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/hash/#add_a_key_value_pair_to_a_hash
>
> Can somebody give me a brief explanation why the single quote can be
> omitted if the strings are used as the keys of a hash?

It really has nothing to do with strings being keys in a hash, and
everything to do with the => operator. The reason is simply that that
is how the => operator was designed.

$ perldoc perlop
[snip]
       The "=>" operator is a synonym for the comma, but forces any word
       (consisting entirely of word characters) to its left to be
       interpreted as a string (as of 5.001).  This includes words that
       might otherwise be considered a constant or function call.
[snip]

Note that the => is simply a comma, except for the auto-quoting
behaviour of its left operand. It can be used in other places where a
comma would normally be used, such as subroutine calls.

my $foo = Foo->new(arg1 => 12, arg3 => 4);

is exactly equivalent to

my $foo = Foo->new("arg1", 12, "arg3", 4);

(or with single quotes if you prefer). There is no hash involved at any
time.

Martien
-- 
                             | 
Martien Verbruggen           | The gene pool could use a little
first.last@heliotrope.com.au | chlorine.
                             | 


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

Date: Sat, 29 Nov 2008 20:14:05 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Using strings as keys of hash
Message-Id: <slrngj3tnd.ode.tadmc@tadmc30.sbcglobal.net>

Martien Verbruggen <martien.verbruggen@invalid.see.sig> wrote:
> On Sat, 29 Nov 2008 15:09:36 -0800 (PST),
> 	Peng Yu <PengYu.UT@gmail.com> wrote:
>> Hi,
>>
>> It seems that if strings are keys, 


Hash keys are *always* strings.


>> the single quote can be omitted. I
>> don't see why on perl hash tutorial webpage such as
>> http://www.cs.mcgill.ca/~abatko/computers/programming/perl/howto/hash/#add_a_key_value_pair_to_a_hash
>>
>> Can somebody give me a brief explanation why the single quote can be
>> omitted if the strings are used as the keys of a hash?
>
> It really has nothing to do with strings being keys in a hash, and
> everything to do with the => operator. The reason is simply that that
> is how the => operator was designed.
>
> $ perldoc perlop
> [snip]
>        The "=>" operator is a synonym for the comma, but forces any word
>        (consisting entirely of word characters) to its left to be
>        interpreted as a string (as of 5.001).  This includes words that
>        might otherwise be considered a constant or function call.


Note also that hash keys that are all word chars do not need quoting,
even without the "fat comma" operator:

   $hash{some_key}
and
   $hash{'some_key'}
are the same thing.


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

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 V11 Issue 2018
***************************************


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