Hi,
in the following example there is a output difference in version 5.00 and
5.8 of Perl. In case of a missmatch in element 2, the whole element gets
lost instead of an "undef" value. Does anybody know why in version 5.8 we
lost the element and is that an error in Perl interpreter or does it work as
designed.
Thanks
Farhad
----------------------------------
#!/usr/local/bin/perl -w
my $var="Test";
my @list=('a', # Element 1
$var=~m/\n/, # Element 2
$var=~m/es/ # Element 3
);
print scalar(@list)." (should be 3)\n";
push @list, {
'd' => $var=~m/\n/, # Element 4
};
print scalar(@list)." (should be 4)\n" 2 1804
Farhad <fa************ @dresdner-bank.com> wrote: my $var="Test"; my @list=('a', # Element 1 $var=~m/\n/, # Element 2 $var=~m/es/ # Element 3 );
print scalar(@list)." (should be 3)\n";
No, it should be 2. m// in list context returns an empty list when
the match fails.
--
Steve
Hi Farhad,
i believe 5.8 works as designed.
try running your script in the debugger:
perl -d yourscriptname. pl
step through the commands using s, the first time, then return.
in the debugger, try:
p $var =~ /\n/
and
p $var =~ /es/
also, play with:
x @list
i do not see why $var would match a newline.
hope this helps, good luck.
Jim
"Farhad" <fa************ @dresdner-bank.com> wrote in message news:<bk******* **@news-1.bank.dresdner .net>... Hi,
in the following example there is a output difference in version 5.00 and 5.8 of Perl. In case of a missmatch in element 2, the whole element gets lost instead of an "undef" value. Does anybody know why in version 5.8 we lost the element and is that an error in Perl interpreter or does it work as designed.
Thanks Farhad
----------------------------------
#!/usr/local/bin/perl -w
my $var="Test"; my @list=('a', # Element 1 $var=~m/\n/, # Element 2 $var=~m/es/ # Element 3 );
print scalar(@list)." (should be 3)\n";
push @list, { 'd' => $var=~m/\n/, # Element 4 };
print scalar(@list)." (should be 4)\n" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jacob |
last post by:
I just wrote a function that draws a fractal by recursively calling
itself, and ran into an odd (odd from my point of view anyway) problem.
I've managed to solve (or rather, circumnavigate) the problem, but I still
don't understand why it happened and would like to.
For starters, here's the function:
void draw_series(SDL_Surface *img, float x1, float y1, float x2, float y2,
MAT_matrix<float> *pointlist, int depth, int R, int G, int B)
{...
|
by: Herrcho |
last post by:
in K&R Chapter 6.3
it mentions two methods to calculate NKEYS.
and points out the first one which is to terminate the list of
initializers with a null pointer, then loop along keytab until the end
is found is less efficient than using sizeof operator , since size of
the array is completely determined at compile time.
i don't quite understand this. Could anyone explain to me in detail ?
|
by: Jean Pierre Daviau |
last post by:
I am a newbe not only in C but in programming. I am actually reading K&R.
This is why I tried to run your application.
It seems not to be running on my system. There is maybe a copy/paste
mistake somewhere. As I know everybody on this newsgroup cares about
portability I thought about writing this.
From a previous thread
================
|
by: windandwaves |
last post by:
Hi Folk
I have the following array:
$m = array();
$m = array("lodgings", "rooms");
$m = array("location", "there and away");
$m = array("functions", "events and groups");
$m = array("activities", "things to do", "exclusive activities");
$m = array("enquiries", "tariffs");
$m = array("download", "media info");
|
by: silvrique |
last post by:
I am totally lost.
I have an xml script example as follows:
<?xml version="1.0" encoding="utf8" ?>
<starter>
<second>
<name>Silver</name>
</second>
</starter>
| |
by: Ole |
last post by:
Hi there,
I think I'm lost in the XML attribute jungle in my attempt to
serialize/deserializing data that must be persistant, and any help is highly
appriciated.
I need to save this class in an XML file and it must be unicode formatted:
class classToSave
|
by: c++dummy |
last post by:
I got this project for my class and I'm totally lost as to how to copy
the 1d array with the bone name into a 2d array using this supposed
strncpy function I'm supposed to create. I believe the teacher wants us
to make the function and not use the library function.
Here's the info:
Write a C++ program that
|
by: vunet.us |
last post by:
Please, explain an interesting phenomenon, if you can. I have an array
of references to an HTML element:
<div id='container'>
<div id='someId1'></div>
<div id='someId2'></div>
</div>
.....
myArray = document.getElementById("someId1");
myArray = document.getElementById("someId2");
|
by: =?Utf-8?B?U2hhcm9u?= |
last post by:
Hi Gurus,
I need to transfer a jagged array of byte by reference to unmanaged
function, The unmanaged code should changed the values of the array, and when
the unmanaged function returns I need to show the array data to the end user.
Can I do that?
How?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: 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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |