Thanks for everybody assistance, found a an appropiate solution to my problem.
Without having to use the case statement.
Cheers
Paul
From: Hal Wigoda
To: beginners@perl.org
Sent: Thursday, 2 August 2012 5:38 AM
Subject: Re: case statement in perl
so why
I have removed the switch funtion from the script.
From: Uri Guttman
To: beginners@perl.org
Sent: Thursday, 2 August 2012 2:02 AM
Subject: Re: case statement in perl
On 08/01/2012 03:08 AM, Paul.G wrote:
> The example below is just a test, I need to be a
On Wed, Aug 01, 2012 at 14:38:42 -0500 , Hal Wigoda wrote:
> so why don't they get rid of it?
I'm not sure which "it" you're referring to: Switch.pm or given/when.
For better or worse, Perl has a strong culture of backwards
compatibility. Perl is one of the few languages where you can use code
wr
so why don't they get rid of it?
On Wed, Aug 1, 2012 at 2:33 PM, Chris Nehren
wrote:
> On Wed, Aug 01, 2012 at 12:02:04 -0400 , Uri Guttman wrote:
>> On 08/01/2012 03:08 AM, Paul.G wrote:
>> >The example below is just a test, I need to be able to insert
>> >multiple values a command, those value
On Wed, Aug 01, 2012 at 12:02:04 -0400 , Uri Guttman wrote:
> On 08/01/2012 03:08 AM, Paul.G wrote:
> >The example below is just a test, I need to be able to insert
> >multiple values into a command, those values can be either 1, 2 or
> >upto 5.
> >
> >
> you aren't getting the issue. the switch mo
On 08/01/2012 03:08 AM, Paul.G wrote:
The example below is just a test, I need to be able to insert multiple values
into a command, those values can be either 1, 2 or upto 5.
you aren't getting the issue. the switch module was a major mistake and
no one should be using it. you have to underst
Paul.G wrote:
The example below is just a test, I need to be able to insert multiple values
into a command, those values can be either 1, 2 or upto 5.
Below is closer to the working example, but I will read that document and to
help make a final decision.
# Check Free PV's
operation_CHECKFREE
]");
> }
>}
># lvsync
>run("/usr/sbin/lvsync -T $sourcelv");
>logprint "Successful $NEWMIRROR mirrors \t\t synced";
> }
> else {
>cleanexit (10, "FAIL \t\t No Free PV's Available");
> }
>
> return 0;
> }
&g
t\t synced";
}
else {
cleanexit (10, "FAIL \t\t No Free PV's Available");
}
return 0;
}
____
From: John W. Krahn
To: Perl Beginners
Sent: Wednesday, 1 August 2012 4:58 PM
Subject: Re: case statement in perl
Paul.G wrote:
> Below is an extract from the perl
Paul.G wrote:
Below is an extract from the perl script, the switch/case statement seemed like
a simple solution.
# Mail Program #
operation_CHECKFREEPVS();
print "$numPV \n";
# print "$FreePV[1] $FreePV[0] $numPV\n";
if ($numPV ne 0 ) {
case 2 { print "$FreePV[0] $FreePV[1] \n"; }
> case 3 { print "$FreePV[0] $FreePV[1] $FreePV[2] \n"; }
>}
> }
> else {
>print "No PV's available \n";
> }
>
>
>
> From: Chris N
__
From: Chris Nehren
To: beginners@perl.org
Sent: Wednesday, 1 August 2012 2:54 PM
Subject: Re: case statement in perl
On Tue, Jul 31, 2012 at 23:47:45 -0500 , Hal Wigoda wrote:
> Use the switch/case combination.
>
> On Tue, Jul 31, 2012 at 11:41 PM, Paul.G wrot
On Tue, Jul 31, 2012 at 23:47:45 -0500 , Hal Wigoda wrote:
> Use the switch/case combination.
>
> On Tue, Jul 31, 2012 at 11:41 PM, Paul.G wrote:
> > Hi All
> >
> >
> > Does perl have a case statement or an equivalent?
> >
> >
> > Cheers
> >
> > Paul
Don't use Switch.pm. It's a source filter and
Use the switch/case combination.
On Tue, Jul 31, 2012 at 11:41 PM, Paul.G wrote:
> Hi All
>
>
> Does perl have a case statement or an equivalent?
>
>
> Cheers
>
> Paul
--
-
Chicago
Hal Wigoda
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands,
On Apr 12, 2005 4:24 PM, David Gilden <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am trying to create case statement, and I am not sure I am on the right
> track,
> any comments?
perldoc Switch
Jonathan Paton
--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 0
On Tue, 12 Apr 2005, Wagner, David --- Senior Programmer Analyst --- WGO wrote:
> Chris Devers wrote:
> > Also, as a side note, if $whichForm is numeric, you should just use
> > the nueric comparisons rather than the string ones:
> >
> > if $whichForm eq "123" # bad!
> > if $whichForm
Chris Devers wrote:
> On Tue, 12 Apr 2005, David Gilden wrote:
>
>> I am trying to create case statement, and I am not sure I am on the
>> right track, any comments?
>
> Would something like this get the same result?
>
> my %form_action = (
> 000 => sub {}, # silently ignore this one
On Tue, 12 Apr 2005, David Gilden wrote:
> I am trying to create case statement, and I am not sure I am on the right
> track,
> any comments?
Would something like this get the same result?
my %form_action = (
000 => sub {}, # silently ignore this one
123 => handle_form(123);
David Gilden [DG], on Tuesday, April 12, 2005 at 10:24 (-0500) typed
the following:
DG> I am trying to create case statement, and I am not sure I am on the right
track,
DG> any comments?
try to write at your console your subject, eg:
perldoc -q "case statement"
--
...m8s, cu l8r, Brano.
["W
* Vladimir D Belousov <[EMAIL PROTECTED]> [2005-02-28T07:01:02]
> Is in the perl operator like C/C++ 'case' ?
I believe you are asking: Is there Perl equivalent to C's switch/case
construct?
Not exactly.
To see the official Perl documentation on this, run: perldoc -q case
This will search the F
On Jan 6, 2004, at 2:08 PM, [EMAIL PROTECTED] wrote:
Yo.
what Up.
I read in Learning Perl that there are no such constructs
like a case statement. Is there something similar or did I misread
this?
As folks have already pointed to both
the classic perlfaq, and implied that
one should consult
You can do something like this:
my $flip = "something";
SWITCH: {
( $flip =~ /^0$/ || $flip =~ /^1$/ || $flip =~ /^2$/ ) && do {
$local_pref = "FL"; last SWITCH; };
( $flip =~ /^3$/ || $flip =~ /^4$/ || $flip =~ /^5$/ ) && do {
$local_pref = "FU"; las
[EMAIL PROTECTED] wrote:
> People of the Perl,
>
> thanks for the infoI am familiar with perls subroutines so I will use
> these and this name instead of functions. Also, my intention was to avoid
> the if , then ,elif, then constructs, mentioned by Dan, for certain
> situations which is why
> "DBSMITH" == DBSMITH <[EMAIL PROTECTED]> writes:
DBSMITH> Also, my intention was to avoid the if , then ,elif, then
DBSMITH> constructs, mentioned by Dan, for certain situations
What is the source of your fear? Sounds like a phobia to me.
--
Randal L. Schwartz - Stonehenge Consulting
read the perldoc.
thanks
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
614-566-4145
"Jenda Krynicky" <[EMAIL PROTECTED]>
01/06/2004 05:18 PM
To: [EMAIL PROTECTED]
cc:
Subject:Re: case and functions
From: [EMAIL PROTECTED]
>
[EMAIL PROTECTED] wrote:
From: [EMAIL PROTECTED]
I read in Learning Perl that there are no such constructs like a case
statement. Is there something similar or did I misread this?
Ask the FAQ, run
perldoc -q "case statement"
Also
what about functions and function calls, do the
From: [EMAIL PROTECTED]
> I read in Learning Perl that there are no such constructs like a case
> statement. Is there something similar or did I misread this?
Ask the FAQ, run
perldoc -q "case statement"
> Also
> what about functions and function calls, do these exits or does the
> su
> Yo.
What's up dog? :)
>
> I read in Learning Perl that there are no such constructs
> like a case statement. Is there
Yes, there is.
Do you mean:
if(this) { do this }
elsif(that) { do that }
else { do the other }
> something similar or did I misread this? Als
There is no 'case' statement in Perl but it is easy to mimic such a construct.
Tony Esposito
Oracle Developer, Enterprise Business Intelligence
XO Communications
Plano, TX 75074
Work Phone: 972-516-5344
Work Cell: 972-670-6144
Email: [EMAIL PROTECTED]
-Original Message-
From: [EMAIL PRO
In article <[EMAIL PROTECTED]>, Jenda Krynicky wrote:
> From: Gary Stainburn <[EMAIL PROTECTED]>
>> I've got to tidy some data, including converting case. I need to
>> convert
>>
>> ANOTHER COMPANY NAME LTD **
>>
>> to
>>
>> Another Company Name Ltd **
>>
>> while retaining spaces.
--On Friday, September 05, 2003 2:14 PM +0100 Gary Stainburn
<[EMAIL PROTECTED]> wrote:
I've got to tidy some data, including converting case. I need to convert
ANOTHER COMPANY NAME LTD **
to
Another Company Name Ltd **
while retaining spaces.
I've tried using split / join / lc
On Fri, Sep 05, 2003 at 12:29:31PM -0700, david wrote:
> John Fisher wrote:
>
> > I am trying to figure out how clever it actually is.
> > I reversed \L\u with \u\L expecting different results and got the same
> > result. Another Company Name Ltd
> >
> > Why didn't reversing the metacharacters c
John Fisher wrote:
> I am trying to figure out how clever it actually is.
> I reversed \L\u with \u\L expecting different results and got the same
> result. Another Company Name Ltd
>
> Why didn't reversing the metacharacters change the results.
>
[snip]
>
> $pt=~s/(\w+)/\u\L$1/g
>
> $pt=~s/
I am trying to figure out how clever it actually is.
I reversed \L\u with \u\L expecting different results and got the same result.
Another Company Name Ltd
Why didn't reversing the metacharacters change the results.
the \L escape forces lowercase
When written in lowercase (\l and \u), they affec
On Friday, September 5, 2003, at 08:52 AM, Gary Stainburn wrote:
On Friday 05 Sep 2003 2:25 pm, Jenda Krynicky wrote:
From: Gary Stainburn <[EMAIL PROTECTED]>
I've got to tidy some data, including converting case. I need to
convert
ANOTHER COMPANY NAME LTD **
to
Another Company Name Ltd
Jenda Krynicky said:
> From: Gary Stainburn <[EMAIL PROTECTED]>
>> I've got to tidy some data, including converting case. I need to
>> convert
>>
>> ANOTHER COMPANY NAME LTD **
>>
>> to
>>
>> Another Company Name Ltd **
>>
>> while retaining spaces.
>
> $text =~ s/(\w+)/\L\u$1/g;$y
\L\
On Friday 05 Sep 2003 2:25 pm, Jenda Krynicky wrote:
> From: Gary Stainburn <[EMAIL PROTECTED]>
>
> > I've got to tidy some data, including converting case. I need to
> > convert
> >
> > ANOTHER COMPANY NAME LTD **
> >
> > to
> >
> > Another Company Name Ltd **
> >
> > while retaining sp
Gary Stainburn said:
> Hi folks,
>
> I've got a problem I hope you can help me with.
>
> I've got to tidy some data, including converting case. I need to convert
>
> ANOTHER COMPANY NAME LTD **
>
> to
>
> Another Company Name Ltd **
>
> while retaining spaces.
>
> I've tried using split
From: Gary Stainburn <[EMAIL PROTECTED]>
> I've got to tidy some data, including converting case. I need to
> convert
>
> ANOTHER COMPANY NAME LTD **
>
> to
>
> Another Company Name Ltd **
>
> while retaining spaces.
$text =~ s/(\w+)/\L\u$1/g;$y
Jenda
= [EMAIL PROTECTED] === ht
On Friday, September 5, 2003, at 08:14 AM, Gary Stainburn wrote:
Hi folks,
I've got a problem I hope you can help me with.
I've got to tidy some data, including converting case. I need to
convert
ANOTHER COMPANY NAME LTD **
to
Another Company Name Ltd **
while retaining spaces.
> > "Scott" == Scott Taylor <[EMAIL PROTECTED]> writes:
>
> Scott> Any one have or know of a function to convert ugly
> "NAME, USER"
> Scott> to "User Name"?
>
I'd do soemthign like this:
my($name, $user) = split(/,/, $line);
$name =~ s/^\s+//;
$name = ucfirst(lc($n
> "Scott" == Scott Taylor <[EMAIL PROTECTED]> writes:
Scott> Any one have or know of a function to convert ugly "NAME, USER" to "User Name"?
s/NAME, USER/User Name/;
:-)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge
On Friday, August 15, 2003, at 05:09 PM, Scott Taylor wrote:
$var = 'NAME, USER';
print "$var\n";
@var = reverse split(', ',$var);
print "@var\n";
$var = join(' ',(ucfirst lc $var[0],ucfirst lc $var[1])); # whitout
the
comma this time
print "$var\n";
This works well, too, and join seems to fix t
On Friday, August 15, 2003, at 04:55 PM, Scott Taylor wrote:
At 02:28 PM 08/15/2003, James Edward Gray II wrote:
On Friday, August 15, 2003, at 04:20 PM, Scott Taylor wrote:
Any one have or know of a function to convert ugly "NAME, USER" to
"User Name"?
Maybe something like:
s/^(\w+), ?(\w+)$
At 02:46 PM 08/15/2003, Degey, Didier wrote:
-Original Message-
From: Scott Taylor [mailto:[EMAIL PROTECTED]
Sent: vendredi 15 août 2003 23:20
To: [EMAIL PROTECTED]
Subject: Case conversions
Any one have or know of a function to convert ugly "NAME, USER" to "User
Name"?
Strange email thing
At 02:28 PM 08/15/2003, James Edward Gray II wrote:
On Friday, August 15, 2003, at 04:20 PM, Scott Taylor wrote:
Any one have or know of a function to convert ugly "NAME, USER" to "User
Name"?
Maybe something like:
s/^(\w+), ?(\w+)$/ucfirst(lc $2) . ' ' . ucfirst(lc $1)/e
Nice, very useful! On
I've just used Elias' idea to change a file's content...
Where file name is word:
perl -i -p -e 's/(.)(.*)/$1\L$2/' word
On Friday, Aug 15, 2003, at 23:29 Europe/Brussels, Elias Assmann wrote:
On Fri, Aug 15, 2003 at 02:20:19PM -0700, Scott Taylor wrote:
Any one have or know of a function to c
> Any one have or know of a function to convert ugly "NAME, USER" to "User
Name"?
timtowtdi:
$str = "User Name" if ($str eq "NAME, USER");
$str =~ s/^NAME, USER$/User Name/;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
$var = 'NAME, USER';
print "$var\n";
@var = reverse split(', ',$var);
print "@var\n";
$var = join(' ',(ucfirst lc $var[0],ucfirst lc $var[1])); # whitout the
comma this time
print "$var\n";
-Original Message-
From: Scott Taylor [mailto:[EMAIL PROTECTED]
Sent: vendredi 15 août 2003 23:20
T
On Fri, Aug 15, 2003 at 02:20:19PM -0700, Scott Taylor wrote:
>
> Any one have or know of a function to convert ugly "NAME, USER" to "User
> Name"?
$ perl -le '$_ = "NAME"; s/(.)(.*)/$1\L$2/; print'
Name
The function to convert a string to lower case is "lc".
HTH,
Elias
--
If you ta
On Friday, August 15, 2003, at 04:20 PM, Scott Taylor wrote:
Any one have or know of a function to convert ugly "NAME, USER" to
"User Name"?
Maybe something like:
s/^(\w+), ?(\w+)$/ucfirst(lc $2) . ' ' . ucfirst(lc $1)/e
Hope that helps.
James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For
Pablo Fischer wrote at Sat, 26 Jul 2003 23:35:14 +:
> I need to evaluate a lot of conditionals, and of course the use of a lot of
> if's its not the 'right' way, so Im using something like this:
>
> CASE: {
> ($string == "match1") && do {
> actions..
> last CASE;
> };
Pablo Fischer wrote:
>
> Hello Again!
Hello,
> I need to evaluate a lot of conditionals, and of course the use of a lot of
> if's its not the 'right' way, so Im using something like this:
>
> CASE: {
> ($string == "match1") && do {
^^^
> actions..
>
- Original Message -
From: "Pablo Fischer" <[EMAIL PROTECTED]>
To: "Perl Beginners" <[EMAIL PROTECTED]>
Sent: Saturday, July 26, 2003 1:35 PM
Subject: Case Statement
> Hello Again!
>
> I need to evaluate a lot of conditionals, and of course the use of a lot
of
> if's its not the 'right'
Jenda Krynicky wrote:
> Better, but still incorrect.
Glad that you point this out! :-) I always make that kind of mistake!
david
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
From: david <[EMAIL PROTECTED]>
> Dylan Boudreau wrote:
>
> > I could be wrong here as I am still pretty new to perl but couldn't
> > you just do it like this
> >
> > if ($x =~ /$y/i)
> >
> > Dylan
> >
>
> almost correct! :-) how about:
>
> if($x =~ /^$y$/i)
>
> your reg. only checks to see
Dylan Boudreau wrote:
> I could be wrong here as I am still pretty new to perl but couldn't you
> just do it like this
>
> if ($x =~ /$y/i)
>
> Dylan
>
almost correct! :-) how about:
if($x =~ /^$y$/i)
your reg. only checks to see if $y is within $x, not equal.
david
--
To unsubscribe, e-m
0, "Rob Dixon" <[EMAIL PROTECTED]> wrote:
> That would work fine, or you could change both to the same case for the
> duration of the comparison:
>
> if ( "\U$x" eq "\U$y" )
>
> Rob
>
>
> - Original Message -
> From:
Ain't perl great?
There are always at least 58 ways to do anything/everthing! :)
Aloha => Beau.
-Original Message-
From: Rob Dixon [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 03, 2002 3:41 AM
To: Dylan Boudreau; [EMAIL PROTECTED]
Subject: Re: Case Insensitive
That wo
Or, you could:
if (lc $x eq lc $y) { ... }
lc changes to lower case.
Aloha => Beau.
-Original Message-
From: SATAR VAFAPOOR [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 03, 2002 3:27 AM
To: [EMAIL PROTECTED]
Subject: Case Insensitive
Hello all,
I want to make comaprisons in an
That would work fine, or you could change both to the same case for the
duration of the comparison:
if ( "\U$x" eq "\U$y" )
Rob
- Original Message -
From: "Dylan Boudreau" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, D
On Tue, 2002-12-03 at 13:26, SATAR VAFAPOOR wrote:
> I want to make comaprisons in an if statement without caring
> about upper or lower case eg $x='T'; $y='t' if($x eq $y). can
> the i that is used in regex be used here or is there another way.
Simplest way is to convert both to lower case, u
I could be wrong here as I am still pretty new to perl but couldn't you
just do it like this
if ($x =~ /$y/i)
Dylan
-Original Message-
From: SATAR VAFAPOOR [mailto:[EMAIL PROTECTED]]
Sent: December 3, 2002 9:27 AM
To: [EMAIL PROTECTED]
Subject: Case Insensitive
Hello
On Tue, 2002-04-23 at 10:30, Chas Owens wrote:
> On Mon, 2002-04-22 at 06:52, walter valenti wrote:
> > Hi,
> >
> > there is in Perl a statement "case" like in "C" or in "Pascal" ???
> >
> > Walter
>
> Damian Conway has written a module to implement a switch for Perl as a
> proof of concept
On Mon, 2002-04-22 at 06:52, walter valenti wrote:
> Hi,
>
> there is in Perl a statement "case" like in "C" or in "Pascal" ???
>
> Walter
Damian Conway has written a module to implement a switch for Perl as a
proof of concept for Perl 6. You can install it by saying
perl -MCPAN -e "inst
On Monday, April 22, 2002, at 04:18 , Gary Stainburn wrote:
> On Monday 22 April 2002 12:07 pm, Marc te Vruchte wrote:
>> Well, there isn't a real case statement as in C or Pascal, but, you can
>> emulate one through a block =)
we went around the Idea of also using a HashSwitch -
if you were do
On Monday 22 April 2002 12:07 pm, Marc te Vruchte wrote:
> Well, there isn't a real case statement as in C or Pascal, but, you can
> emulate one through a block =)
>
>
> SWITCH: for ($str_fruit) {
> if (/apple/) {
> ...
> last SWITCH;
> }
> if (/banana
Well, there isn't a real case statement as in C or Pascal, but, you can emulate
one through a block =)
SWITCH: for ($str_fruit) {
if (/apple/) {
...
last SWITCH;
}
if (/banana/) {
...
last SWITCH;
}
68 matches
Mail list logo