© # -*- coding: utf-8 -*-
©
© # in Python, there's a special type of
© # data structure called keyed list. it
© # is a unordered list of pairs, each
© # consists of a key and a value. It is
© # also known as dictionary.
©
© # define a keyed list
© aa = {'john':3, 'mary':4, 'jane':5, 'vicky':7}
© print aa
©
© # getting value from a key
© print 'mary is', aa['mary']
©
© # delete an entry
© del aa['vicky']
© print aa
©
© # get just the keys
© print aa.keys()
©
© # check if a key exists
© print aa.has_key('mar y')
©
© # to learn more,
© # type help() and DICTIONARIES
© # or see
© # http://python.org/doc/2.3.4/tut/node7.html
©
© -------------------------------------------
© # in perl, keyed-list is done like this:
©
© %a = ('john',3, 'mary', 4, 'jane', 5, 'vicky',7);
© use Data::Dumper qw(Dumper);
© print Dumper \%a;
©
© # the syntax of keyed list in Perl is too complex
© # to be covered in a short message.
© # see "perldoc perldata" for an unix-styled course.
©
© Xah
© xa*@xahlee.org
© http://xahlee.org/PageTwo_dir/more.html 6 1852
"Xah Lee" <xa*@xahlee.org > wrote:
: # the syntax of keyed list in Perl is too complex
: # to be covered in a short message.
You've got to be joking. You couldn't even muster enough skill to provide
Perl equivalents for the four simple Python statements you showed?
: # see "perldoc perldata" for an unix-styled course.
It's good to see your opinion on the _fantastic incompetent writting_[1] of
Perl's documentation has changed enough that you can recommend it to
novices.
[1]Message-ID: <7f************ **************@ posting.google. com>
Xah Lee wrote: © # in perl, keyed-list is done like this:
Just FYI: those thingies are called hashes. The legacy name would be
associative array.
© %a = ('john',3, 'mary', 4, 'jane', 5, 'vicky',7); © use Data::Dumper qw(Dumper); © print Dumper \%a;
Wow, my compliments. The very first time that using Data::Dumper actually
may do something useful (formats the data more nicely). Still, why you are
passing a reference is beyond me.
© # the syntax of keyed list in Perl is too complex © # to be covered in a short message.
Excuse me? If (using the same examples as for your Python section)
print "Mary is $a{mary}";
delete $a{vicky}; print %a;
print keys(%a);
exists $a{mary};
is too complex for your to cover, then I strongly suggest you stop posting
your "explanatio ns".
© # see "perldoc perldata" for an unix-styled course.
Excuse me? Do you mind explaining where exactly perldata is "Unix-styled"?
jue
Also sprach Jürgen Exner: Xah Lee wrote: © %a = ('john',3, 'mary', 4, 'jane', 5, 'vicky',7); © use Data::Dumper qw(Dumper); © print Dumper \%a;
Wow, my compliments. The very first time that using Data::Dumper actually may do something useful (formats the data more nicely). Still, why you are passing a reference is beyond me.
How else would you use 'Dumper' on a hash?
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_ $;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus}) (rekcah{lrePbus })(lreP{rehtona bus})!JAPH!qq(r ehtona{tsuJbus# ;
$_=reverse,s+(? <=sub).+q#q!'"q q.\t$&."'!#+sex isexiixesixeseg ;y~\n~~dddd;eva l
Jay Tilton wrote: : # the syntax of keyed list in Perl is too complex : # to be covered in a short message.
JFTR: "keyed lists" are called dictionaries in Python. [1]Message-ID: <7f************ **************@ posting.google. com>
This guy's wish-wash is starting to be funny, after all!
Reinhold
Jürgen Exner wrote: © # see "perldoc perldata" for an unix-styled course.
Excuse me? Do you mind explaining where exactly perldata is "Unix-styled"?
Remember: Perl == Unix == Satan.
Reinhold
Tassilo v. Parseval wrote: Also sprach Jürgen Exner:
Xah Lee wrote:
© %a = ('john',3, 'mary', 4, 'jane', 5, 'vicky',7); © use Data::Dumper qw(Dumper); © print Dumper \%a;
Wow, my compliments. The very first time that using Data::Dumper actually may do something useful (formats the data more nicely). Still, why you are passing a reference is beyond me.
How else would you use 'Dumper' on a hash?
Well, fair enough. If you do a plain
print Dumper(%a);
you do loose a lot of the nifty pretty printing that is provided by Dumper
otherwise.
jue This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mark Wilson CPU |
last post by:
This must be easy, but I'm missing something...
I want to execute a Perl script, and capture ALL its output into a PHP
variable. Here are my 2 files:
-------------------------------------
test3.pl
-------------------------------------
print "PERL Hello from Perl! (plain print)<br>\n";
print STDERR "PERL This is text sent to STDERR<br>\n";
$output="PERL Some output:<br>\n";
for ($i=0; $i<5; $i++) {
|
by: David F. Skoll |
last post by:
Hi,
I'm tearing my hair out on this one. I'm trying to embed a Perl
interpreter into a C program. I need to be able to create and destroy
the interpreter periodically, but will never actually have two interpreters
at the same time.
On Red Hat Linux 7.3 with Perl 5.6.1, the attached program segfaults. On
Red Hat 9 with Perl 5.8.0, it works perfectly. Save the program code
as "test-embed-perl.c" and the build script as "buildte". ...
|
by: Julia Bell |
last post by:
I would like to run the same script on two different platforms. The
directory in which the script(s) will be stored is common to the two
platforms. (I see the same directory contents regardless of which
platform I use to access the directory.)
Platform 1: perl is installed in /tps/bin/perl. CPAN modules are available
Perl is also installed in /usr/bin/perl Platform 1, but the modules are
not accessible with this version.
Platform...
|
by: sm00thcrimnl13 |
last post by:
if i have windows 2000 and know how to write perl scripts, how to i
actuvate the script through perl?
|
by: smsabu2002 |
last post by:
Hi,
I am facing the build problem while installing the DBD-MySql perl
module (ver 2.9008) using both GCC and CC compilers in HP-UX machine.
For the Build using GCC, the compiler error is produced due to the
unknown GCC compiler option "+DAportable".
For the Build using CC, the preprocessor error is produced due to the
recursive declration of macro "PerlIO" in perlio.h file.
| |
by: Otto J. Makela |
last post by:
I'm trying to install to php the Perl-1.0.0.tgz package (from
http://pecl.php.net/package/perl, enabling one to call perl libraries)
to a pre-existing Solaris system.
Unfortunately, the attempt fails in a rather dramatic way, spewing out
thousands of "relocation remains"... I'm somewhat lost on what to do
next, the documentation that came along with the Perl package is
somewhat sparse. Anyone have suggestions?
% uname -a
|
by: surfivor |
last post by:
I may be involved in a data migration project involving databases and
creating XML feeds. Our site is PHP based, so I imagine the team might
suggest PHP, but I had a look at the PHP documentation for one of the
Pear modules for creating XML and it didn't look like much. I've used
Perl XML:Twig and I have the impression that there is more Perl stuff
available as well as the Perl stuff being well documented as I have a
Perl DBI book, a Perl...
|
by: billb |
last post by:
I installed a perl extension for PHP to use some perl inside my php
primarily because I have perl working with oracle and not php and
oracle. So I want to use my old perl scripts, and use the
functionality of php. The extension uses the '$perl->eval' function.
i am kind of stuck with the syntax or how to put the php variable into
the perl script. I have a form where the user puts in a grid
reference. Then a php script that gets the...
|
by: vijayarl |
last post by:
Hi All,
i have the following software installed in my system :
1.OS: Win2k
2.Eclipse Version used :3.4.0 & even the perl too...
1. I have imported the my own perl project in Eclipse, when i tried to run the External Tools --> Perl -w
am getting the popup saying then it says :
" Variable references empty selection:
|
by: KevinADC |
last post by:
Note: You may skip to the end of the article if all you want is the perl code.
Introduction
Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script.
What You Need
Any recent...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |