From 6aa26c2e4446f544f2658d39a7c594932acf58ab Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 7 Sep 2010 12:33:15 -0500 Subject: [PATCH] remove WebGUI::Utility::isIn --- lib/WebGUI/Account/Inbox.pm | 2 +- lib/WebGUI/Account/Profile.pm | 2 +- lib/WebGUI/Account/Shop.pm | 2 +- lib/WebGUI/Asset.pm | 4 +-- lib/WebGUI/Asset/File/ZipArchive.pm | 3 +-- lib/WebGUI/Asset/RichEdit.pm | 6 ++--- lib/WebGUI/Asset/Sku/EMSBadge.pm | 12 +++++++-- lib/WebGUI/Asset/Sku/EMSRibbon.pm | 5 ++-- lib/WebGUI/Asset/Sku/EMSTicket.pm | 7 ++++-- lib/WebGUI/Asset/Sku/EMSToken.pm | 6 +++-- lib/WebGUI/Asset/Sku/Product.pm | 2 +- lib/WebGUI/Asset/Template.pm | 4 +-- lib/WebGUI/Asset/Wobject/Collaboration.pm | 2 +- .../Asset/Wobject/Collaboration/Newsletter.pm | 4 +-- lib/WebGUI/Asset/Wobject/Dashboard.pm | 8 +++--- lib/WebGUI/Asset/Wobject/DataForm.pm | 2 +- .../Asset/Wobject/EventManagementSystem.pm | 6 ++--- lib/WebGUI/Asset/Wobject/Matrix.pm | 2 +- lib/WebGUI/Asset/Wobject/Navigation.pm | 2 +- lib/WebGUI/Asset/Wobject/Thingy.pm | 6 ++--- lib/WebGUI/Asset/Wobject/UserList.pm | 8 +++--- lib/WebGUI/Asset/Wobject/WikiMaster.pm | 5 ++-- lib/WebGUI/AssetExportHtml.pm | 6 ++--- lib/WebGUI/AssetLineage.pm | 16 ++++++------ lib/WebGUI/AssetTrash.pm | 4 +-- lib/WebGUI/Auth.pm | 2 +- lib/WebGUI/Content/AssetDiscovery.pm | 2 +- lib/WebGUI/Crud.pm | 2 +- lib/WebGUI/DatabaseLink.pm | 6 ++--- lib/WebGUI/FilePump/Bundle.pm | 10 ++++---- lib/WebGUI/Form/Image.pm | 4 +-- lib/WebGUI/Friends.pm | 2 +- lib/WebGUI/Group.pm | 4 +-- lib/WebGUI/Image/Graph.pm | 2 +- lib/WebGUI/Inbox.pm | 2 +- lib/WebGUI/Macro/RandomThread.pm | 2 +- lib/WebGUI/Operation/SpellCheck.pm | 2 +- lib/WebGUI/ProfileCategory.pm | 4 +-- lib/WebGUI/ProfileField.pm | 2 +- lib/WebGUI/Session/DateTime.pm | 4 +-- lib/WebGUI/Session/Http.pm | 2 +- lib/WebGUI/Session/Url.pm | 2 +- lib/WebGUI/Shop/TaxDriver/EU.pm | 2 +- lib/WebGUI/Shop/Vendor.pm | 4 +-- lib/WebGUI/Storage.pm | 8 +++--- lib/WebGUI/User.pm | 8 +++--- lib/WebGUI/Utility.pm | 25 +------------------ lib/WebGUI/VersionTag.pm | 2 +- .../Workflow/Activity/SyncProfilesToLdap.pm | 4 +-- sbin/fileImport.pl | 2 +- sbin/rebuildLineage.pl | 4 +-- sbin/testEnvironment.pl | 9 +------ sbin/thumbnailer.pl | 4 +-- sbin/userImport.pl | 2 +- t/Asset/Asset_diagnose.t | 2 +- t/Asset/Wobject/StoryArchive.t | 4 +-- t/Form/ProfileEnabled.t | 2 +- t/Group.t | 6 ++--- t/Session/Id.t | 2 +- t/Utility.t | 3 --- t/Workflow.t | 1 - 61 files changed, 126 insertions(+), 148 deletions(-) diff --git a/lib/WebGUI/Account/Inbox.pm b/lib/WebGUI/Account/Inbox.pm index 952613c31..d61f57b80 100644 --- a/lib/WebGUI/Account/Inbox.pm +++ b/lib/WebGUI/Account/Inbox.pm @@ -1177,7 +1177,7 @@ sub www_sendMessage { $activeFriendCount++; } - my $isChecked = WebGUI::Utility::isIn($friendId,@friendsChecked); + my $isChecked = $friendId ~~ @friendsChecked; my $friendHash = { 'friend_id' => $friendId, 'friend_name' => $friends->{$friendId}, diff --git a/lib/WebGUI/Account/Profile.pm b/lib/WebGUI/Account/Profile.pm index e5ff26d19..685777f99 100644 --- a/lib/WebGUI/Account/Profile.pm +++ b/lib/WebGUI/Account/Profile.pm @@ -242,7 +242,7 @@ sub getExtrasStyle { my $requiredStyle = q{class="profilefield_required"}; my $errorStyle = q{class="profilefield_error"}; #Required Field Not Filled In and Error Returend - return $errorStyle if(WebGUI::Utility::isIn($field->getId,@{$fieldErrors})); + return $errorStyle if $field->getId ~~ $fieldErrors; return "" unless ($field->isRequired); return $requiredStyle unless($self->session->user->profileField($field->getId) || $fieldValue); return $requiredStyleOff; diff --git a/lib/WebGUI/Account/Shop.pm b/lib/WebGUI/Account/Shop.pm index 6e8f37a51..72b34fc58 100644 --- a/lib/WebGUI/Account/Shop.pm +++ b/lib/WebGUI/Account/Shop.pm @@ -52,7 +52,7 @@ sub appendCommonVars { my $method = $session->form->get("do"); $var->{ 'manage_purchases_url' } = $self->getUrl("module=shop;do=managePurchases"); - $var->{ 'managesPurchasesIsActive' } = WebGUI::Utility::isIn($method,("","managePurchases","view","viewTransaction")); + $var->{ 'managesPurchasesIsActive' } = $method ~~ ["","managePurchases","view","viewTransaction"]; $var->{ 'view_sales_url' } = $self->getUrl( 'module=shop;do=viewSales' ); $var->{ 'viewSalesIsActive' } = $method eq 'viewSales'; diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 66fac0278..9227435f0 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -1046,7 +1046,7 @@ sub getEditForm { }; # Kludge... - if ( isIn( $fieldHash->{fieldType}, 'selectBox', 'workflow' ) and ref $fieldHash->{value} ne 'ARRAY' ) { + if ( $fieldHash->{fieldType} ~~ ['selectBox', 'workflow'] ) and ref $fieldHash->{value} ne 'ARRAY' ) { $fieldHash->{value} = [ $fieldHash->{value} ]; } @@ -2589,7 +2589,7 @@ sub www_add { my $prototype = WebGUI::Asset->newById($self->session, $self->session->form->process("prototype")); foreach my $property ($prototype->getProperties) { # cycle through rather than copying properties to avoid grabbing stuff we shouldn't grab my $definition = $prototype->getProperty($property); - next if (isIn($property,qw(title menuTitle url isPrototype isPackage))); + next if ( $property ~~ [qw(title menuTitle url isPrototype isPackage)]); next if ($definition->{noFormPost}); $prototypeProperties{$property} = $prototype->get($property); } diff --git a/lib/WebGUI/Asset/File/ZipArchive.pm b/lib/WebGUI/Asset/File/ZipArchive.pm index b8fe15722..151378716 100644 --- a/lib/WebGUI/Asset/File/ZipArchive.pm +++ b/lib/WebGUI/Asset/File/ZipArchive.pm @@ -46,7 +46,6 @@ use Archive::Tar; use Archive::Zip; use Cwd (); use Scope::Guard (); -use WebGUI::Utility qw/isIn/; =head1 NAME @@ -133,7 +132,7 @@ sub fixFilenames { my $files = $storage->getFiles('all'); FILE: foreach my $file (@{ $files }) { my $extension = $storage->getFileExtension($file); - next FILE unless isIn($extension, qw/pl perl pm cgi php asp sh/); + next FILE unless $extension ~~ [qw/pl perl pm cgi php asp sh/]; my $newFile = $file; #$newFile =~ s/\.$extension$/_$extension.txt/; $newFile =~ s/\.$extension$/_$extension.txt/; diff --git a/lib/WebGUI/Asset/RichEdit.pm b/lib/WebGUI/Asset/RichEdit.pm index 65dccc501..28e4e1121 100644 --- a/lib/WebGUI/Asset/RichEdit.pm +++ b/lib/WebGUI/Asset/RichEdit.pm @@ -288,9 +288,9 @@ override getEditForm => sub { my $evenOddToggle = 0; foreach my $key (keys %buttons) { $evenOddToggle = $evenOddToggle ? 0 : 1; - my $checked1 = isIn($key,@toolbarRow1); - my $checked2 = isIn($key,@toolbarRow2); - my $checked3 = isIn($key,@toolbarRow3); + my $checked1 = $key ~~ @toolbarRow1; + my $checked2 = $key ~~ @toolbarRow2; + my $checked3 = $key ~~ @toolbarRow3; $buttonGrid .= ' '.$buttons{$key}.' diff --git a/lib/WebGUI/Asset/Sku/EMSBadge.pm b/lib/WebGUI/Asset/Sku/EMSBadge.pm index 379838dfa..086afd93e 100644 --- a/lib/WebGUI/Asset/Sku/EMSBadge.pm +++ b/lib/WebGUI/Asset/Sku/EMSBadge.pm @@ -284,7 +284,11 @@ sub onRefund { # get rid of any items in the cart related to this badge foreach my $cartitem (@{$self->getCart->getItems()}) { my $sku = $cartitem->getSku; - if (isIn((ref $sku), qw(WebGUI::Asset::Sku::EMSTicket WebGUI::Asset::Sku::EMSRibbon WebGUI::Asset::Sku::EMSToken))) { + if ((ref $sku) ~~ [qw( + WebGUI::Asset::Sku::EMSTicket + WebGUI::Asset::Sku::EMSRibbon + WebGUI::Asset::Sku::EMSToken + )]) { if ($sku->getOptions->{badgeId} eq $badgeId) { $cartitem->remove; } @@ -309,7 +313,11 @@ sub onRemoveFromCart { my $badgeId = $self->getOptions->{badgeId}; foreach my $cartitem (@{$item->cart->getItems()}) { my $sku = $cartitem->getSku; - if (isIn((ref $sku), qw(WebGUI::Asset::Sku::EMSTicket WebGUI::Asset::Sku::EMSRibbon WebGUI::Asset::Sku::EMSToken))) { + if ((ref $sku) ~~ [qw( + WebGUI::Asset::Sku::EMSTicket + WebGUI::Asset::Sku::EMSRibbon + WebGUI::Asset::Sku::EMSToken + )]) { if ($sku->getOptions->{badgeId} eq $badgeId) { $cartitem->remove; } diff --git a/lib/WebGUI/Asset/Sku/EMSRibbon.pm b/lib/WebGUI/Asset/Sku/EMSRibbon.pm index d8d047d34..b8abdc9f3 100644 --- a/lib/WebGUI/Asset/Sku/EMSRibbon.pm +++ b/lib/WebGUI/Asset/Sku/EMSRibbon.pm @@ -232,8 +232,9 @@ sub www_delete { my ($self) = @_; return $self->session->privilege->insufficient() unless ($self->canEdit && $self->canEditIfLocked); return $self->session->privilege->vitalComponent() if $self->isSystem; - return $self->session->privilege->vitalComponent() if (isIn($self->getId, -$self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage"))); + return $self->session->privilege->vitalComponent() if $self->getId ~~ [ + $self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage") + ]; $self->trash; return $self->getParent->www_buildBadge(undef,'ribbons'); } diff --git a/lib/WebGUI/Asset/Sku/EMSTicket.pm b/lib/WebGUI/Asset/Sku/EMSTicket.pm index 0bfd61bc8..defd0787b 100644 --- a/lib/WebGUI/Asset/Sku/EMSTicket.pm +++ b/lib/WebGUI/Asset/Sku/EMSTicket.pm @@ -328,7 +328,7 @@ sub getPrice { my $discount = 0; my $badgeId = $self->getOptions->{badgeId}; my $ribbonId = $self->session->db->quickScalar("select ribbonAssetId from EMSRegistrantRibbon where badgeId=? limit 1",[$badgeId]); - if (defined $ribbonId && isIn($ribbonId, @ribbonIds)) { + if (defined $ribbonId && $ribbonId ~~ @ribbonIds) { my $ribbon = WebGUI::Asset->newById($self->session, $ribbonId); $discount = $ribbon->percentageDiscount; } @@ -536,7 +536,10 @@ sub www_delete { my ($self) = @_; return $self->session->privilege->insufficient() unless ($self->canEdit && $self->canEditIfLocked); return $self->session->privilege->vitalComponent() if $self->isSystem; - return $self->session->privilege->vitalComponent() if (isIn($self->getId, $self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage"))); + return $self->session->privilege->vitalComponent() if $self->getId ~~ [ + $self->session->setting->get("defaultPage"), + $self->session->setting->get("notFoundPage"), + ]; $self->trash; return $self->getParent->www_buildBadge(undef,'tickets'); } diff --git a/lib/WebGUI/Asset/Sku/EMSToken.pm b/lib/WebGUI/Asset/Sku/EMSToken.pm index 2546f266e..5e65c382c 100644 --- a/lib/WebGUI/Asset/Sku/EMSToken.pm +++ b/lib/WebGUI/Asset/Sku/EMSToken.pm @@ -226,8 +226,10 @@ sub www_delete { my ($self) = @_; return $self->session->privilege->insufficient() unless ($self->canEdit && $self->canEditIfLocked); return $self->session->privilege->vitalComponent() if $self->isSystem; - return $self->session->privilege->vitalComponent() if (isIn($self->getId, -$self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage"))); + return $self->session->privilege->vitalComponent() if $self->getId ~~ [ + $self->session->setting->get("defaultPage"), + $self->session->setting->get("notFoundPage"), + ]; $self->trash; return $self->getParent->www_buildBadge(undef,'tokens'); } diff --git a/lib/WebGUI/Asset/Sku/Product.pm b/lib/WebGUI/Asset/Sku/Product.pm index 3db3055d5..6b3140349 100644 --- a/lib/WebGUI/Asset/Sku/Product.pm +++ b/lib/WebGUI/Asset/Sku/Product.pm @@ -1107,7 +1107,7 @@ sub www_deleteFileConfirm { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit); my $column = $self->session->form->process("file"); - return $self->www_edit unless (isIn($column, qw(image1 image2 image3 manual warranty brochure))); + return $self->www_edit unless $column ~~ [qw(image1 image2 image3 manual warranty brochure)]; my $store = $self->get($column); my $file = WebGUI::Storage->get($self->session,$store); $file->delete if defined $file; diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index cab520050..6e35a95b1 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -486,7 +486,7 @@ sub prepare { my $id = $self->getId; # don't send head block if we've already sent it for this template - return if isIn($id, @$sent); + return if $id ~~ $sent; my $session = $self->session; my ($db, $style) = $session->quick(qw(db style)); @@ -587,7 +587,7 @@ override processEditForm => sub { my $needsUpdate = 0; if ($self->parser ne $self->session->form->process("parser","className") && ($self->session->form->process("parser","className") ne "")) { $needsUpdate = 1; - if (isIn($self->session->form->process("parser","className"),@{$self->session->config->get("templateParsers")})) { + if ($self->session->form->process("parser","className") ~~ $self->session->config->get("templateParsers") ) { %data = ( parser => $self->session->form->process("parser","className") ); } else { %data = ( parser => $self->session->config->get("defaultTemplateParser") ); diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index 01200f29d..7b76ceeb6 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -1162,7 +1162,7 @@ sub getThreadsPaginator { $sortBy =~ s/^\w+\.//; # Sort by the thread rating instead of the post rating. other places don't care about threads. $sortBy = $sortBy eq 'rating' ? 'threadRating' : $sortBy; - if (! WebGUI::Utility::isIn($sortBy, qw/userDefined1 userDefined2 userDefined3 userDefined4 userDefined5 title lineage revisionDate creationDate karmaRank threadRating views replies lastPostDate/)) { + if (! $sortBy ~~ [qw/userDefined1 userDefined2 userDefined3 userDefined4 userDefined5 title lineage revisionDate creationDate karmaRank threadRating views replies lastPostDate/]) { $sortBy = 'revisionDate'; } if ($sortBy eq 'assetId' || $sortBy eq 'revisionDate') { diff --git a/lib/WebGUI/Asset/Wobject/Collaboration/Newsletter.pm b/lib/WebGUI/Asset/Wobject/Collaboration/Newsletter.pm index 7f503925a..5b799dd33 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration/Newsletter.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration/Newsletter.pm @@ -192,7 +192,7 @@ sub www_mySubscriptions { my @userPrefs = $self->getUserSubscriptions; foreach my $id (keys %{$meta}) { my @options = (); - if (isIn($id, split("\n", $self->newsletterCategories))) { + if ($id ~~ [split("\n", $self->newsletterCategories))]) { foreach my $option (split("\n", $meta->{$id}{possibleValues})) { $option =~ s/\s+$//; # remove trailing spaces next if $option eq ""; # skip blank values @@ -202,7 +202,7 @@ sub www_mySubscriptions { optionForm => WebGUI::Form::checkbox($self->session, { name => "subscriptions", value => $preferenceName, - checked => isIn($preferenceName, @userPrefs), + checked => $preferenceName ~~ @userPrefs, }) }); } diff --git a/lib/WebGUI/Asset/Wobject/Dashboard.pm b/lib/WebGUI/Asset/Wobject/Dashboard.pm index 18ef8e79c..1b21d4254 100644 --- a/lib/WebGUI/Asset/Wobject/Dashboard.pm +++ b/lib/WebGUI/Asset/Wobject/Dashboard.pm @@ -270,7 +270,7 @@ override prepareView => sub { next; } last unless $child; - unless (isIn($child->getId, @hidden) || !($child->canView)) { + unless ( $child->getId ~~ @hidden || !$child->canView) { $self->session->style->setRawHeadTags($child->getExtraHeadTags); $child->prepareView; } @@ -341,7 +341,7 @@ sub view { push(@hidden,$child->shortcutToAssetId) if ref $child eq 'WebGUI::Asset::Shortcut'; #the following loop will initially place just-dashletted assets. for (my $i = 0; $i < scalar(@positions); $i++) { - next unless isIn($child->shortcutToAssetId,@hidden); + next unless $child->shortcutToAssetId ~~ @hidden; my $newChildId = $child->getId; my $oldChildId = $child->shortcutToAssetId; $positions[$i] =~ s/${oldChildId}/${newChildId}/g; @@ -362,7 +362,7 @@ sub view { foreach my $asset (@assets) { foreach my $child (@{$children}) { if ($asset eq $child->getId) { - unless (isIn($asset,@hidden) || !($child->canView)) { + unless ($asset ~~ @hidden || !$child->canView) { $self->session->style->setRawHeadTags($child->getExtraHeadTags); $child->{_properties}{title} = $child->getTitle; $child->{_properties}{title} = $child->getShortcut->getTitle if (ref $child eq 'WebGUI::Asset::Shortcut'); @@ -400,7 +400,7 @@ sub view { } # deal with unplaced children foreach my $child (@{$children}) { - unless (isIn($child->getId, @found)||isIn($child->getId,@hidden)) { + unless ($child->getId ~~ @found || $child->getId ~~ @hidden) { if ($child->canView) { $child->{_properties}{title} = $child->getShortcut->title if (ref $child eq 'WebGUI::Asset::Shortcut'); push(@{$vars{"position1_loop"}},{ diff --git a/lib/WebGUI/Asset/Wobject/DataForm.pm b/lib/WebGUI/Asset/Wobject/DataForm.pm index 4c2e2e5b9..854e5df59 100644 --- a/lib/WebGUI/Asset/Wobject/DataForm.pm +++ b/lib/WebGUI/Asset/Wobject/DataForm.pm @@ -437,7 +437,7 @@ Returns true if the DataForm uses a captcha as one of the fields. sub hasCaptcha { my $self = shift; - return isIn('Captcha', map { $_->{type} } map { $self->getFieldConfig($_) } @{ $self->getFieldOrder }); + return 'Captcha' ~~ [map { $_->{type} } map { $self->getFieldConfig($_) } @{ $self->getFieldOrder })]; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm index d9c718b6c..74ee0b983 100644 --- a/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm +++ b/lib/WebGUI/Asset/Wobject/EventManagementSystem.pm @@ -398,7 +398,7 @@ sub getEventFieldsForImport { foreach my $definition (@{WebGUI::Asset::Sku::EMSTicket->definition($self->session)}) { $count++; foreach my $field (keys %{$definition->{properties}}) { - next if ($count > 1 && !isIn($field, qw(title description))); + next if ($count > 1 && ! $field ~~ [qw(title description)]); next unless ($definition->{properties}{$field}{label} ne ""); push(@fields, { name => $field, @@ -1855,7 +1855,7 @@ className='WebGUI::Asset::Sku::EMSTicket' and state='published' and revisionDate foreach my $id (@ids) { # skip tickets we already have - if (isIn($id, @existingTickets)) { + if ($id ~~ @existingTickets) { $totalTickets--; next; } @@ -2125,7 +2125,7 @@ $|=1; my $metadata = $event->getEventMetaData; my $i = 0; foreach my $field (@{$fields}) { - next unless isIn($field->{name}, @import); + next unless $field->{name} ~~ @import; $out->print("\tAdding field ".$field->{label}."\n",1); my $type = $field->{type}; ##Force the use of Form::DateTime and MySQL Format diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index cc66bca36..24d20f28c 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -1185,7 +1185,7 @@ sub www_getCompareFormData { } else { foreach my $result (@{$self->getListings}) { - if(WebGUI::Utility::isIn($result->{assetId},@listingIds)){ + if($result->{assetId} ~~ @listingIds){ $result->{checked} = 'checked'; } push @results, $result; diff --git a/lib/WebGUI/Asset/Wobject/Navigation.pm b/lib/WebGUI/Asset/Wobject/Navigation.pm index 96b909d7a..cd2aa7969 100644 --- a/lib/WebGUI/Asset/Wobject/Navigation.pm +++ b/lib/WebGUI/Asset/Wobject/Navigation.pm @@ -422,7 +422,7 @@ sub view { my %rules; $rules{endingLineageLength} = $start->getLineageLength+$self->descendantEndPoint; - $rules{assetToPedigree} = $current if (isIn("pedigree",@includedRelationships)); + $rules{assetToPedigree} = $current if ("pedigree" ~~ @includedRelationships); $rules{ancestorLimit} = $self->ancestorEndPoint; $rules{orderByClause} = 'rpad(asset.lineage, 255, 9) desc' if ($self->reversePageLoop); my $assetIter = $start->getLineageIterator(\@includedRelationships,\%rules); diff --git a/lib/WebGUI/Asset/Wobject/Thingy.pm b/lib/WebGUI/Asset/Wobject/Thingy.pm index 8ecb4ad0b..8ec5109ce 100644 --- a/lib/WebGUI/Asset/Wobject/Thingy.pm +++ b/lib/WebGUI/Asset/Wobject/Thingy.pm @@ -975,7 +975,7 @@ sub getFormPlugin { } } - if ( WebGUI::Utility::isIn( $data->{fieldType}, qw(SelectList CheckList SelectBox Attachments) ) ) { + if ( $data->{fieldType} ~~ [qw(SelectList CheckList SelectBox Attachments) ] ) { my @values; if ( $useFormPostData && $session->form->param($name) ) { $param{ value } = [ $session->form->process( $name, $data->{fieldType} ) ]; @@ -1285,7 +1285,7 @@ sub importAssetCollateralData { # delete deleted things my $thingsInDatabase = $self->getThings; while (my $thingInDataBase = $thingsInDatabase->hashRef) { - if (!WebGUI::Utility::isIn($thingInDataBase->{thingId},@importThings)){ + if (!$thingInDataBase->{thingId} ~~ @importThings){ # delete thing $self->deleteThing($thingInDataBase->{thingId}); } @@ -1312,7 +1312,7 @@ sub importAssetCollateralData { my $fieldsInDatabase = $session->db->read('select fieldId, thingId from Thingy_fields where assetId = ?', [$self->getId]); while (my $fieldInDataBase = $fieldsInDatabase->hashRef) { - if (!WebGUI::Utility::isIn($fieldInDataBase->{fieldId},@importFields)){ + if (!$fieldInDataBase->{fieldId} ~~ @importFields){ # delete field $self->deleteField($fieldInDataBase->{fieldId},$fieldInDataBase->{thingId},"1"); } diff --git a/lib/WebGUI/Asset/Wobject/UserList.pm b/lib/WebGUI/Asset/Wobject/UserList.pm index 124b576f9..18f631397 100644 --- a/lib/WebGUI/Asset/Wobject/UserList.pm +++ b/lib/WebGUI/Asset/Wobject/UserList.pm @@ -227,7 +227,7 @@ sub getFormElement { $param{value} = ($data->{defaultValue} =~ /checked/xi) ? 1 : ""; } - if (WebGUI::Utility::isIn($data->{fieldType},qw(SelectList CheckList SelectBox Attachments SelectSlider))) { + if ($data->{fieldType} ~~ [qw(SelectList CheckList SelectBox Attachments SelectSlider)]) { my @defaultValues; if ($self->session->form->param($name)) { @defaultValues = $self->session->form->selectList($name); @@ -358,7 +358,7 @@ sub view { my $currentUrlWithoutSort = $self->getUrl(); foreach ($form->param) { - unless (WebGUI::Utility::isIn($_,qw(sortBy sortOrder op func)) || $_ =~ /identifier/i || $_ =~ /password/i) { + unless ( $_ ~~ [qw(sortBy sortOrder op func), qr/identifier/i, qr/password/i]) { $currentUrlWithoutSort = $url->append($currentUrlWithoutSort, $url->escape($_) .'='.$url->escape($form->process($_))); } @@ -502,7 +502,7 @@ sub view { } my @sortByUserProperties = ('dateCreated', 'lastUpdated', 'karma', 'userId'); - if(isIn($sortBy,@sortByUserProperties)){ + if( $sortBy ~~ @sortByUserProperties ){ $sortBy = 'users.'.$sortBy; } $sortBy = join '.', map { $dbh->quote_identifier($_) } split /\./, $sortBy; @@ -550,7 +550,7 @@ sub view { # Handle special case of alias, which does not have a default value but is set to the username by default $value = $user->{userName} if ($profileFieldName eq 'alias' && $value eq ''); my %profileFieldValues; - if (WebGUI::Utility::isIn(ucfirst $profileField->{fieldType},qw(File Image)) && $value ne ''){ + if ((ucfirst $profileField->{fieldType}) ~~ [qw(File Image)]) && $value ne ''){ my $file = WebGUI::Form::DynamicField->new($self->session, fieldType=>$profileField->{fieldType}, value=>$value diff --git a/lib/WebGUI/Asset/Wobject/WikiMaster.pm b/lib/WebGUI/Asset/Wobject/WikiMaster.pm index 8a28657a7..74d7d24c9 100644 --- a/lib/WebGUI/Asset/Wobject/WikiMaster.pm +++ b/lib/WebGUI/Asset/Wobject/WikiMaster.pm @@ -195,7 +195,7 @@ with 'WebGUI::Role::Asset::RssFeed'; use WebGUI::International; use HTML::Parser; use URI::Escape; -use WebGUI::Utility qw/isIn/; +use WebGUI::Utility qw//; use WebGUI::Form; use Clone qw/clone/; @@ -390,8 +390,7 @@ sub autolinkHtml { my %mapping = $self->session->db->buildHash("SELECT LOWER(d.title), d.url FROM asset AS i INNER JOIN assetData AS d ON i.assetId = d.assetId WHERE i.parentId = ? and className='WebGUI::Asset::WikiPage' and i.state='published' and d.status='approved' order by d.revisionDate ASC", [$self->getId]); TITLE: foreach my $title (keys %mapping) { my $url = delete $mapping{$title}; - ##isIn short circuits and is faster than grep and/or first - next TITLE if isIn($title, @skipTitles); + next TITLE if $title ~~ @skipTitles; $mapping{$title} = $self->session->url->gateway($url); } diff --git a/lib/WebGUI/AssetExportHtml.pm b/lib/WebGUI/AssetExportHtml.pm index dd8579347..d98fdc970 100644 --- a/lib/WebGUI/AssetExportHtml.pm +++ b/lib/WebGUI/AssetExportHtml.pm @@ -250,11 +250,11 @@ sub exportAsHtml { # extrasUploadAction and rootUrlAction must have values matching something # in the arrays defined above - if( defined $extrasUploadAction && !WebGUI::Utility::isIn($extrasUploadAction, @extraUploadActions) ) { + if( defined $extrasUploadAction && !$extrasUploadAction ~~ @extraUploadActions ) { WebGUI::Error->throw(error => "'$extrasUploadAction' is not a valid extrasUploadAction"); } - if( defined $rootUrlAction && !WebGUI::Utility::isIn($rootUrlAction, @rootUrlActions) ) { + if( defined $rootUrlAction && !$rootUrlAction ~~ @rootUrlActions ) { WebGUI::Error->throw(error => "'$rootUrlAction' is not a valid rootUrlAction"); } @@ -607,7 +607,7 @@ sub exportGetUrlAsPath { my $filename = pop @pathComponents; my ($extension) = $filename =~ /\.([^.]+)$/; - if ($extension && WebGUI::Utility::isIn($extension, @{ $fileTypes }) ) { + if ($extension && $extension ~~ $fileTypes ) { return Path::Class::File->new($exportPath, @pathComponents, $filename); } else { diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index 960e0f192..06b92bfb0 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -639,12 +639,12 @@ sub getLineageSql { my $lineage = $self->lineage; my @whereModifiers; # let's get those siblings - if (isIn("siblings",@{$relatives})) { + if ("siblings" ~~ $relatives) { push(@whereModifiers, " (asset.parentId=".$db->quote($self->parentId)." and asset.assetId<>".$db->quote($self->getId).")"); } # ancestors too my @specificFamilyMembers = (); - if (isIn("ancestors",@{$relatives})) { + if ("ancestors" ~~ $relatives) { my $i = 1; my @familyTree = ($lineage =~ /(.{6})/g); while (pop(@familyTree)) { @@ -654,14 +654,14 @@ sub getLineageSql { } } # let's add ourself to the list - if (isIn("self",@{$relatives})) { + if ("self" ~~ $relatives) { push(@specificFamilyMembers, $self->lineage); } if (scalar(@specificFamilyMembers) > 0) { push(@whereModifiers,"(asset.lineage in (".$db->quoteAndJoin(\@specificFamilyMembers)."))"); } # we need to include descendants - if (isIn("descendants",@{$relatives})) { + if ("descendants" ~~ $relatives) { my $mod = "(asset.lineage like ".$db->quote($lineage.'_%'); if (exists $rules->{endingLineageLength}) { $mod .= " and length(asset.lineage) <= ".($rules->{endingLineageLength}*6); @@ -670,11 +670,11 @@ sub getLineageSql { push(@whereModifiers,$mod); } # we need to include children - if (isIn("children",@{$relatives})) { + if ("children" ~~ $relatives) { push(@whereModifiers,"(asset.parentId=".$db->quote($self->getId).")"); } # now lets add in all of the siblings in every level between ourself and the asset we wish to pedigree - if (isIn("pedigree",@{$relatives}) && exists $rules->{assetToPedigree}) { + if ("pedigree" ~~ $relatives && exists $rules->{assetToPedigree}) { my $pedigreeLineage = $rules->{assetToPedigree}->lineage; if (substr($pedigreeLineage,0,length($lineage)) eq $lineage) { my @mods; @@ -712,8 +712,8 @@ sub getLineageSql { my $statusCodes = $rules->{statusToInclude} || []; if($rules->{includeArchived}) { - push(@{$statusCodes},'archived') if(!WebGUI::Utility::isIn('archived',@{$statusCodes})); - push(@{$statusCodes},'approved') if(!WebGUI::Utility::isIn('approved',@{$statusCodes})); + push(@{$statusCodes},'archived') if(!'archived' ~~ $statusCodes); + push(@{$statusCodes},'approved') if(!'approved' ~~ $statusCodes); } my $status = "assetData.status='approved'"; diff --git a/lib/WebGUI/AssetTrash.pm b/lib/WebGUI/AssetTrash.pm index a89fe1cf0..9bce0a824 100644 --- a/lib/WebGUI/AssetTrash.pm +++ b/lib/WebGUI/AssetTrash.pm @@ -15,7 +15,7 @@ package WebGUI::Asset; =cut use strict; -use WebGUI::Utility qw(isIn); +use WebGUI::Utility qw(); use Number::Format (); use JSON; @@ -326,7 +326,7 @@ sub www_delete { my $self = shift; return $self->session->privilege->insufficient() unless ($self->canEdit && $self->canEditIfLocked); return $self->session->privilege->vitalComponent() if $self->get('isSystem'); - return $self->session->privilege->vitalComponent() if (isIn($self->getId, $self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage"))); + return $self->session->privilege->vitalComponent() if ($self->getId ~~ [$self->session->setting->get("defaultPage"), $self->session->setting->get("notFoundPage")]); $self->trash; my $asset = $self->getContainer; if ($self->getId eq $asset->getId) { diff --git a/lib/WebGUI/Auth.pm b/lib/WebGUI/Auth.pm index 8f21cd39b..e8a090db1 100644 --- a/lib/WebGUI/Auth.pm +++ b/lib/WebGUI/Auth.pm @@ -800,7 +800,7 @@ Returns whether or not a method is callable sub isCallable { my $self = shift; - return 1 if isIn($_[0],@{$self->{callable}}); + return 1 if $_[0] ~~ $self->{callable}; return 1 if $self->can( 'www_' . $_[0] ); return 0; } diff --git a/lib/WebGUI/Content/AssetDiscovery.pm b/lib/WebGUI/Content/AssetDiscovery.pm index 0cec5beb9..f4f259acf 100644 --- a/lib/WebGUI/Content/AssetDiscovery.pm +++ b/lib/WebGUI/Content/AssetDiscovery.pm @@ -116,7 +116,7 @@ sub handler { while (my ($id) = $matchingAssets->array) { my $asset = eval { WebGUI::Asset->newById($session, $id); }; if (! Exception::Class->caught() ) { - if ($asset->canView && $asset->state eq 'published' && isIn($asset->status, 'approved', 'archived')) { + if ($asset->canView && $asset->state eq 'published' && $asset->status ~~ ['approved', 'archived']) { push @assets, { title => $asset->getTitle, menuTitle => $asset->menuTitle, diff --git a/lib/WebGUI/Crud.pm b/lib/WebGUI/Crud.pm index 305980f7a..6cfd6dd5d 100644 --- a/lib/WebGUI/Crud.pm +++ b/lib/WebGUI/Crud.pm @@ -445,7 +445,7 @@ sub crud_updateTable { my $sth = $db->read("DESCRIBE ".$tableName); my $tableKey = $class->crud_getTableKey($session); while (my ($col, $type, $null, $key, $default) = $sth->array) { - next if (isIn($col, $tableKey, 'lastUpdated', 'dateCreated','sequenceNumber')); + next if ($col ~~ [$tableKey, 'lastUpdated', 'dateCreated','sequenceNumber']); $tableFields{$col} = { type => $type, null => $null, diff --git a/lib/WebGUI/DatabaseLink.pm b/lib/WebGUI/DatabaseLink.pm index 7537058bd..e6c68b813 100644 --- a/lib/WebGUI/DatabaseLink.pm +++ b/lib/WebGUI/DatabaseLink.pm @@ -106,10 +106,10 @@ sub checkPrivileges { } # Check if all required privs are present. - return 1 if (isIn('ALL PRIVILEGES', @privileges)); + return 1 if ('ALL PRIVILEGES' ~~ @privileges); foreach (@{ $requestedPrivileges }) { - return 0 unless (isIn(uc($_), @privileges)); + return 0 unless (uc($_) ~~ @privileges); } return 1; @@ -386,7 +386,7 @@ sub queryIsAllowed { my ($firstWord) = $query =~ /(\w+)/; $firstWord = lc $firstWord; - return isIn($firstWord, split(/\s+/, lc $self->{_databaseLink}{allowedKeywords})) ? 1 : 0; + return $firstWord ~~ [split(/\s+/, lc $self->{_databaseLink}{allowedKeywords})] ? 1 : 0; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/FilePump/Bundle.pm b/lib/WebGUI/FilePump/Bundle.pm index b79f87c7c..8cce89cf9 100644 --- a/lib/WebGUI/FilePump/Bundle.pm +++ b/lib/WebGUI/FilePump/Bundle.pm @@ -38,7 +38,7 @@ it will return 0 and an error message. sub addFile { my ($self, $type, $uri) = @_; - return 0, 'Illegal type' unless WebGUI::Utility::isIn($type, 'JS', 'CSS', 'OTHER'); + return 0, 'Illegal type' unless $type ~~ ['JS', 'CSS', 'OTHER']; return 0, 'No URI' unless $uri; my $collateralType = $type eq 'JS' ? 'jsFiles' : $type eq 'CSS' ? 'cssFiles' @@ -412,7 +412,7 @@ types of files. sub deleteFiles { my ($self, $type) = @_; - return 0, 'Illegal type' unless WebGUI::Utility::isIn($type, 'JS', 'CSS', 'OTHER'); + return 0, 'Illegal type' unless $type ~~ ['JS', 'CSS', 'OTHER']; my $collateralType = $type eq 'JS' ? 'jsFiles' : $type eq 'CSS' ? 'cssFiles' : 'otherFiles'; @@ -440,7 +440,7 @@ The unique collateral GUID to delete from the bundle. sub deleteFile { my ($self, $type, $fileId) = @_; - return 0, 'Illegal type' unless WebGUI::Utility::isIn($type, 'JS', 'CSS', 'OTHER'); + return 0, 'Illegal type' unless $type ~~ ['JS', 'CSS', 'OTHER']; return 0, 'No fileId' unless $fileId; my $collateralType = $type eq 'JS' ? 'jsFiles' : $type eq 'CSS' ? 'cssFiles' @@ -714,7 +714,7 @@ The unique collateral GUID to move in the bundle. sub moveFileDown { my ($self, $type, $fileId) = @_; - return 0, 'Illegal type' unless WebGUI::Utility::isIn($type, 'JS', 'CSS', 'OTHER'); + return 0, 'Illegal type' unless $type ~~ ['JS', 'CSS', 'OTHER']; return 0, 'No fileId' unless $fileId; my $collateralType = $type eq 'JS' ? 'jsFiles' : $type eq 'CSS' ? 'cssFiles' @@ -748,7 +748,7 @@ The unique collateral GUID to move in the bundle. sub moveFileUp { my ($self, $type, $fileId) = @_; - return 0, 'Illegal type' unless WebGUI::Utility::isIn($type, 'JS', 'CSS', 'OTHER'); + return 0, 'Illegal type' unless $type ~~ ['JS', 'CSS', 'OTHER']; return 0, 'No fileId' unless $fileId; my $collateralType = $type eq 'JS' ? 'jsFiles' : $type eq 'CSS' ? 'cssFiles' diff --git a/lib/WebGUI/Form/Image.pm b/lib/WebGUI/Form/Image.pm index 2e51a51b5..f96e5b186 100644 --- a/lib/WebGUI/Form/Image.pm +++ b/lib/WebGUI/Form/Image.pm @@ -19,7 +19,7 @@ use base 'WebGUI::Form::File'; use WebGUI::International; use WebGUI::Storage; use WebGUI::Form::YesNo; -use WebGUI::Utility qw/isIn/; +use WebGUI::Utility qw//; =head1 NAME @@ -141,7 +141,7 @@ sub getValue { my @files = @{$storage->getFiles}; my @images = grep{$storage->isImage($_)} @files; # Put all filenames that isImage returns true for into @images if ($self->get('forceImageOnly')) { - $storage->deleteFile($_) for grep{!isIn($_, @images)} @files; # Search @files for filenames that are not in @images and delete them + $storage->deleteFile($_) for grep{ ! $_ ~~ @images } @files; # Search @files for filenames that are not in @images and delete them @files = @images; } diff --git a/lib/WebGUI/Friends.pm b/lib/WebGUI/Friends.pm index 210505295..cea5a30f9 100644 --- a/lib/WebGUI/Friends.pm +++ b/lib/WebGUI/Friends.pm @@ -249,7 +249,7 @@ The userId to check against this user. sub isFriend { my $self = shift; my $userId = shift; - return isIn($userId, @{$self->user->friends->getUsers}); + return $userId ~~ $self->user->friends->getUsers; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Group.pm b/lib/WebGUI/Group.pm index e4e10f51b..6db9c3d9e 100644 --- a/lib/WebGUI/Group.pm +++ b/lib/WebGUI/Group.pm @@ -136,7 +136,7 @@ sub addGroups { my ($isIn) = $self->session->db->quickArray("select count(*) from groupGroupings where groupId=? and inGroup=?", [$gid, $self->getId]); next GROUP if $isIn; my $group = WebGUI::Group->new($self->session, $gid); - my $recursive = isIn($self->getId, @{$group->getGroupsIn(1)}); + my $recursive = $self->getId ~~ $group->getGroupsIn(1); next GROUP if $recursive; $self->session->db->write("insert into groupGroupings (groupId,inGroup) values (?,?)",[$gid, $self->getId]); } @@ -1981,7 +1981,7 @@ sub vitalGroup { if (! $groupId && ref $class ) { $groupId = $class->getId; } - return isIn ( $groupId, (1..17), qw/pbgroup000000000000015 pbgroup000000000000016 pbgroup000000000000017 / ); + return $groupId ~~ [ map { "$_" } (1..17), qw/pbgroup000000000000015 pbgroup000000000000016 pbgroup000000000000017 /]; } 1; diff --git a/lib/WebGUI/Image/Graph.pm b/lib/WebGUI/Image/Graph.pm index 3e598b90f..69301d8e6 100644 --- a/lib/WebGUI/Image/Graph.pm +++ b/lib/WebGUI/Image/Graph.pm @@ -609,7 +609,7 @@ sub processConfigurationForm { my $namespace = "WebGUI::Image::".$session->form->process('graphingPlugin'); $namespace =~ s/_/::/g; - if (! isIn($namespace, @{$class->getPluginList($session)})) { + if (! $namespace ~~ $class->getPluginList($session)) { WebGUI::Error->throw(error => "Graphing plugin not available") } diff --git a/lib/WebGUI/Inbox.pm b/lib/WebGUI/Inbox.pm index b562baca9..e19939f24 100644 --- a/lib/WebGUI/Inbox.pm +++ b/lib/WebGUI/Inbox.pm @@ -375,7 +375,7 @@ sub getMessagesPaginator { my $whereClause = $properties->{whereClause} || ''; #Make sure a valid sortBy is passed in - if($sortBy && !WebGUI::Utility::isIn($sortBy,qw( subject sentBy dateStamp status ))) { + if($sortBy && !$sortBy ~~ [qw( subject sentBy dateStamp status )]) { $sortBy = q{dateStamp} } #Sort by fullname if user wants to sort by who sent the message diff --git a/lib/WebGUI/Macro/RandomThread.pm b/lib/WebGUI/Macro/RandomThread.pm index a1e43ee89..468234da0 100644 --- a/lib/WebGUI/Macro/RandomThread.pm +++ b/lib/WebGUI/Macro/RandomThread.pm @@ -75,7 +75,7 @@ sub process { } $relatives = lc($relatives); - unless ( isIn($relatives, ('siblings','children','ancestors','self','descendants','pedigree')) ) { + unless ( $relatives ~~ ['siblings','children','ancestors','self','descendants','pedigree'] ) { $session->errorHandler->warn('Error: invalid relatives specified. Must be one of siblings, children, ancestors, self, descendants, pedigree. Check parameters of macro on page '.$session->asset->url); return ''; } diff --git a/lib/WebGUI/Operation/SpellCheck.pm b/lib/WebGUI/Operation/SpellCheck.pm index 5ed94ac35..566a2485d 100644 --- a/lib/WebGUI/Operation/SpellCheck.pm +++ b/lib/WebGUI/Operation/SpellCheck.pm @@ -57,7 +57,7 @@ sub _getSpeller { # Get language my $speller = Text::Aspell->new; die "Language not available in server side spellcheck" - unless (isIn($lang, map {m/^.*?:([^:]*):.*?$/} $speller->list_dictionaries)); + unless ($lang ~~ [map {m/^.*?:([^:]*):.*?$/} $speller->list_dictionaries]); # User homedir my $homeDir = $session->config->get('uploadsPath').'/dictionaries/'; diff --git a/lib/WebGUI/ProfileCategory.pm b/lib/WebGUI/ProfileCategory.pm index d78a437b0..2f4ab10e6 100644 --- a/lib/WebGUI/ProfileCategory.pm +++ b/lib/WebGUI/ProfileCategory.pm @@ -151,7 +151,7 @@ sub getCategories { my $bindvars = []; foreach my $key (keys %{$options}) { - next unless WebGUI::Utility::isIn($key,qw(editable visible)); + next unless $key ~~ [qw(editable visible)]; $whereClause .= " and" unless ($whereClause eq ""); $whereClause .= " $key=?"; push(@{$bindvars},$options->{$key}); @@ -214,7 +214,7 @@ sub getFields { foreach my $key (keys %{$options}) { #Skip bad stuff that will crash the query - next unless WebGUI::Utility::isIn($key,qw(editable visible required)); + next unless $key ~~ [qw(editable visible required)]; $whereClause .= " and $key=?"; push(@{$bindvars},$options->{$key}); } diff --git a/lib/WebGUI/ProfileField.pm b/lib/WebGUI/ProfileField.pm index c70d52e04..f25e3f6d1 100644 --- a/lib/WebGUI/ProfileField.pm +++ b/lib/WebGUI/ProfileField.pm @@ -67,7 +67,7 @@ Return true iff fieldName is reserved and therefore not usable as a profile fiel sub isReservedFieldName { my $class = shift; my $fieldName = shift; - return isIn($fieldName, qw/userId shop specialState func op wg_privacySettings username authMethod dateCreated lastUpdated karma status referringAffiliate friendsGroup/); + return $fieldName ~~ [qw/userId shop specialState func op wg_privacySettings username authMethod dateCreated lastUpdated karma status referringAffiliate friendsGroup/]; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Session/DateTime.pm b/lib/WebGUI/Session/DateTime.pm index 19e7768a6..757362dde 100644 --- a/lib/WebGUI/Session/DateTime.pm +++ b/lib/WebGUI/Session/DateTime.pm @@ -22,7 +22,7 @@ use DateTime::TimeZone; use Scalar::Util qw( weaken ); use Tie::IxHash; use WebGUI::International; -use WebGUI::Utility qw(isIn); +use WebGUI::Utility qw(); use Scalar::Util qw(weaken); @@ -609,7 +609,7 @@ sub getTimeZone { my $zone = $self->session->user->profileField('timeZone'); $zone =~ s/ /\_/g; if ($zone) { - if (isIn($zone, @zones)) { + if ( $zone ~~ @zones ) { $self->session->user->{_timeZone} = $zone; return $zone; } diff --git a/lib/WebGUI/Session/Http.pm b/lib/WebGUI/Session/Http.pm index 7079ca005..2c9b0916c 100644 --- a/lib/WebGUI/Session/Http.pm +++ b/lib/WebGUI/Session/Http.pm @@ -17,7 +17,7 @@ package WebGUI::Session::Http; use strict; use Scalar::Util qw(weaken); -use WebGUI::Utility qw(isIn); +use WebGUI::Utility qw(); use HTTP::Date (); sub _deprecated { diff --git a/lib/WebGUI/Session/Url.pm b/lib/WebGUI/Session/Url.pm index cc8fac68d..d4874efd2 100644 --- a/lib/WebGUI/Session/Url.pm +++ b/lib/WebGUI/Session/Url.pm @@ -349,7 +349,7 @@ sub getSiteURL { my $site = ""; my $sitenames = $self->session->config->get("sitename"); my ($http_host,$currentPort) = split(':', $self->session->request->env->{"HTTP_HOST"}); - if ($self->session->setting->get("hostToUse") eq "HTTP_HOST" and isIn($http_host,@{$sitenames})) { + if ($self->session->setting->get("hostToUse") eq "HTTP_HOST" and $http_host ~~ $sitenames) { $site = $http_host; } else { $site = $sitenames->[0]; diff --git a/lib/WebGUI/Shop/TaxDriver/EU.pm b/lib/WebGUI/Shop/TaxDriver/EU.pm index 77b1291b9..81e093298 100644 --- a/lib/WebGUI/Shop/TaxDriver/EU.pm +++ b/lib/WebGUI/Shop/TaxDriver/EU.pm @@ -18,7 +18,7 @@ use strict; use WebGUI::Content::Account; use WebGUI::TabForm; -use WebGUI::Utility qw{ isIn }; +use WebGUI::Utility qw{}; use WebGUI::International; use Business::Tax::VAT::Validation; diff --git a/lib/WebGUI/Shop/Vendor.pm b/lib/WebGUI/Shop/Vendor.pm index 4584aa601..d8be81d05 100644 --- a/lib/WebGUI/Shop/Vendor.pm +++ b/lib/WebGUI/Shop/Vendor.pm @@ -91,7 +91,7 @@ around BUILDARGS => sub { use WebGUI::Shop::Admin; use WebGUI::Exception::Shop; use WebGUI::International; -use WebGUI::Utility qw{ isIn }; +use WebGUI::Utility qw{}; use List::Util qw{ sum }; use JSON qw{ encode_json }; @@ -646,7 +646,7 @@ sub www_setPayoutStatus { return $session->privilege->adminOnly() unless ($admin->canManage); my $status = $form->process('status'); - return "error: wrong status [$status]" unless isIn( $status, qw{ NotPaid Scheduled } ); + return "error: wrong status [$status]" unless $status ~~ [qw{ NotPaid Scheduled }]; my @itemIds; if ( $form->process( 'all' ) ) { diff --git a/lib/WebGUI/Storage.pm b/lib/WebGUI/Storage.pm index 8b579899c..171d8b0dd 100644 --- a/lib/WebGUI/Storage.pm +++ b/lib/WebGUI/Storage.pm @@ -25,7 +25,7 @@ use File::Spec; use Image::Magick; use Path::Class::Dir; use Storable (); -use WebGUI::Utility qw(isIn); +use WebGUI::Utility qw(); use WebGUI::Paths; use JSON (); @@ -507,7 +507,7 @@ sub block_extensions { my $self = shift; my $file = shift; my $extension = $self->getFileExtension($file); - if (isIn($extension, qw(pl perl sh cgi php asp pm html htm))) { + if ($extension ~~ [qw(pl perl sh cgi php asp pm html htm)]) { $file =~ s/\.$extension/\_$extension/; $file .= ".txt"; } @@ -570,7 +570,7 @@ sub copy { my $newStorage = shift || WebGUI::Storage->create($self->session); my $filelist = shift || $self->getFiles('all'); FILE: foreach my $file (@{$filelist}) { - next if isIn($file, '.cdn', '.'); + next if $file ~~ ['.cdn', '.']; my $origFile = $self->getPath($file); my $copyFile = $newStorage->getPath($file); if (-d $origFile) { @@ -1332,7 +1332,7 @@ The file to check. sub isImage { my $self = shift; my $filename = shift; - return isIn($self->getFileExtension($filename), qw(jpeg jpg gif png)) + return $self->getFileExtension($filename) ~~ [qw(jpeg jpg gif png)]; } diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index d459a5cce..2bc735b16 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -87,7 +87,7 @@ sub _create { foreach my $field (@fields) { #$session->errorHandler->warn('getting privacy setting for field: '.$fieldName); my $privacySetting = $field->get('defaultPrivacySetting'); - next unless (WebGUI::Utility::isIn($privacySetting,qw(all none friends))); + next unless $privacySetting ~~ [qw(all none friends)]; $privacy->{$field->get('fieldName')} = $privacySetting; } my $json = JSON->new->encode($privacy); @@ -210,7 +210,7 @@ sub authInstance { else { $authMethod = $self->authMethod || $session->setting->get("authMethod"); } - if ( ! isIn($authMethod, @{ $session->config->get('authMethods') } ) ) { + if ( ! $authMethod ~~ $session->config->get('authMethods') ) { $authMethod = $session->config->get('authMethods')->[0] || 'WebGUI'; } my $authClass = 'WebGUI::Auth::' . $authMethod; @@ -333,7 +333,7 @@ sub canViewField { return 1 if ($self->userId eq $user->userId); my $privacySetting = $self->getProfileFieldPrivacySetting($field); - return 0 unless (WebGUI::Utility::isIn($privacySetting,qw(all none friends))); + return 0 unless $privacySetting ~~ [qw(all none friends)]; return 1 if ($privacySetting eq "all"); return 0 if ($privacySetting eq "none"); @@ -1286,7 +1286,7 @@ sub setProfileFieldPrivacySetting { foreach my $fieldId (keys %{$settings}) { my $privacySetting = $settings->{$fieldId}; - next unless (WebGUI::Utility::isIn($privacySetting,qw(all none friends))); + next unless $privacySetting ~~ [qw(all none friends)]; $currentSettings->{$fieldId} = $settings->{$fieldId}; } diff --git a/lib/WebGUI/Utility.pm b/lib/WebGUI/Utility.pm index 1678fa680..7bba87659 100644 --- a/lib/WebGUI/Utility.pm +++ b/lib/WebGUI/Utility.pm @@ -23,7 +23,7 @@ use Net::CIDR::Lite; our @ISA = qw(Exporter); our @EXPORT = qw( - &sortHash &isIn + &sortHash ); @@ -38,7 +38,6 @@ This package provides miscellaneous but useful utilities to the WebGUI programme =head1 SYNOPSIS use WebGUI::Utility; - $boolean = isIn($value, @array); %hash = sortHash(%hash); =head1 METHODS @@ -49,28 +48,6 @@ These subroutines are available from this package: #------------------------------------------------------------------- -=head2 isIn ( value, list ) - -Returns a boolean value as to whether the value is in the array. - -=head3 value - -The value to check for. - -=head3 list - -An array to look for the value in. - -=cut - -sub isIn { - my $key = shift; - $_ eq $key and return 1 for @_; - return 0; -} - -#------------------------------------------------------------------- - =head2 sortHash ( hash ) Sorts a hash by its values. Returns a Tie::IxHash. You must assign this to diff --git a/lib/WebGUI/VersionTag.pm b/lib/WebGUI/VersionTag.pm index d62eadaa6..61d8249ba 100644 --- a/lib/WebGUI/VersionTag.pm +++ b/lib/WebGUI/VersionTag.pm @@ -491,7 +491,7 @@ sub getVersionTagMode { $mode = $session->user()->profileField(q{versionTagMode}); #verify mode. - if (!(defined $mode && WebGUI::Utility::isIn($mode, qw{autoCommit siteWide singlePerUser multiPerUser}))) { + if (!(defined $mode && $mode ~~ [qw{autoCommit siteWide singlePerUser multiPerUser}])) { $mode = q{}; } diff --git a/lib/WebGUI/Workflow/Activity/SyncProfilesToLdap.pm b/lib/WebGUI/Workflow/Activity/SyncProfilesToLdap.pm index 42382df24..52d46e233 100644 --- a/lib/WebGUI/Workflow/Activity/SyncProfilesToLdap.pm +++ b/lib/WebGUI/Workflow/Activity/SyncProfilesToLdap.pm @@ -163,9 +163,9 @@ sub execute { my $result = $ldap->search(base => $userData->{connectDN}, filter => "&(objectClass=*)"); - if ($result->code && !isIn($result->code, @noResultsCodes)) { + if ($result->code && ! $result->code ~~ @noResultsCodes) { $self->session->errorHandler->error("SyncProfilesToLdap: Couldn't search LDAP link $ldapUrl ($currentLinkId) to find user $username ($userId) with DN ".$userData->{connectDN}.": LDAP returned: ".$ldapStatusCode{$result->code}); - } elsif (isIn($result->code, @noResultsCodes) || $result->count == 0) { + } elsif ($result->code ~~ @noResultsCodes || $result->count == 0) { $self->session->errorHandler->warn("SyncProfilesToLdap: No results returned by LDAP server for user with dn ".$userData->{connectDN}); } else { my $entry = $result->entry(0); diff --git a/sbin/fileImport.pl b/sbin/fileImport.pl index 3c00104be..c10838278 100755 --- a/sbin/fileImport.pl +++ b/sbin/fileImport.pl @@ -121,7 +121,7 @@ sub addFiles { print "\tAdding ".$file->{fullPathFile}." to the database.\n" unless ($quiet); # Figure out whether the file is an image or not by its extension. - if (isIn(lc($file->{ext}),@nailable)) { + if (lc($file->{ext}) ~~ @nailable) { $class = 'WebGUI::Asset::File::Image'; $templateId = 'PBtmpl0000000000000088'; } diff --git a/sbin/rebuildLineage.pl b/sbin/rebuildLineage.pl index a8d652634..c87c6cac0 100755 --- a/sbin/rebuildLineage.pl +++ b/sbin/rebuildLineage.pl @@ -43,7 +43,7 @@ print "\nLooking for orphans...\n" unless ($quiet); my $orphansFound = 0; my $rs = $session->db->read("select assetId from asset order by lineage"); while (my ($id) = $rs->array) { - unless (isIn($id, @found)) { + unless ($id ~~ @found) { print "\tFound an orphan with an assetId of $id. Moving it to the import node.\n"; $session->db->write("update asset set parentId='PBasset000000000000002' where assetId=?",[$id]); getDescendants($id); @@ -80,7 +80,7 @@ print "\nDon't forget to clear your cache.\n" unless ($quiet); sub getDescendants { my $parentId = shift; my $depth = shift || 0; - if (isIn($parentId, @found)) { + if ($parentId ~~ @found) { print "\nFound circular relationships involving $parentId. This requires manual intervention.\n" unless ($quiet); exit; } diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index ac8c71892..b62c88908 100755 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -398,13 +398,6 @@ sub installModule { chdir $cwd; } -#---------------------------------------- -sub isIn { - my $key = shift; - $_ eq $key and return 1 for @_; - return 0; -} - #---------------------------------------- sub isRootRequirementMet { if (getOs() eq "Linuxish") { @@ -437,7 +430,7 @@ sub prompt { my $answer = ; chomp $answer; $answer = $default if ($answer eq ""); - $answer = prompt($question,$default,@answers) if (($#answers > 0 && !(isIn($answer,@answers))) || $answer eq ""); + $answer = prompt($question,$default,@answers) if (($#answers > 0 && !($answer ~~ @answers)) || $answer eq ""); return $answer; } diff --git a/sbin/thumbnailer.pl b/sbin/thumbnailer.pl index 4fe33e77c..83858562d 100755 --- a/sbin/thumbnailer.pl +++ b/sbin/thumbnailer.pl @@ -72,7 +72,7 @@ sub createThumbnail { ($x, $y) = $image->Get('width','height'); $r = $x>$y ? $x / $thumbnailSize : $y / $thumbnailSize; $image->Scale(width=>($x/$r),height=>($y/$r)) if ($r > 0); - if (isIn($type, qw(tif tiff bmp))) { + if ( $type ~~ [qw(tif tiff bmp)] ) { $image->Write('thumb-'.$fileName.'.png'); } else { $image->Write($_[1].'/thumb-'.$fileName); @@ -88,7 +88,7 @@ sub shouldThumbnail { return 0 if $fileName =~ m/thumb-/; ##I am not a graphics file, skip me - return 0 if !isIn($fileType, qw(jpg jpeg gif png tif tiff bmp)); + return 0 if ! $fileType ~~ [qw(jpg jpeg gif png tif tiff bmp)]; ##My thumbnail already exists and I was told not to do it again return 0 if ($onlyMissingThumbnails && -e 'thumb-'.$fileName); diff --git a/sbin/userImport.pl b/sbin/userImport.pl index f040b9951..c0b32d6b2 100755 --- a/sbin/userImport.pl +++ b/sbin/userImport.pl @@ -174,7 +174,7 @@ while(my $line = ) { if $user{connectDN}; $auth->saveParams($u->userId,"WebGUI",{changePassword=>$user{changePassword}}); foreach my $field (keys %user) { - if (isIn($field, @profileFields)) { + if ($field ~~ @profileFields) { $u->profileField($field,$user{$field}); } } diff --git a/t/Asset/Asset_diagnose.t b/t/Asset/Asset_diagnose.t index 6c4d11893..f34fc4c2d 100644 --- a/t/Asset/Asset_diagnose.t +++ b/t/Asset/Asset_diagnose.t @@ -21,7 +21,7 @@ use Test::Deep; my $session = WebGUI::Test->session; -my @assets = grep { !isIn($_, qw/WebGUI::Asset::FilePile/) } ( +my @assets = grep { $_ ne 'WebGUI::Asset::FilePile' } ( keys %{ $session->config->get('assets') } ); diff --git a/t/Asset/Wobject/StoryArchive.t b/t/Asset/Wobject/StoryArchive.t index a76bcdb02..454bcf890 100644 --- a/t/Asset/Wobject/StoryArchive.t +++ b/t/Asset/Wobject/StoryArchive.t @@ -247,7 +247,7 @@ cmp_deeply( ); KEY: foreach my $key (keys %{ $templateVars }) { - next KEY if isIn($key, qw/canPostStories addStoryUrl date_loop mode/); + next KEY if $key ~~ [qw/canPostStories addStoryUrl date_loop mode/]; delete $templateVars->{$key}; } @@ -305,7 +305,7 @@ $session->user({userId => 3}); $templateVars = $archive->viewTemplateVariables(); KEY: foreach my $key (keys %{ $templateVars }) { - next KEY if isIn($key, qw/canPostStories addStoryUrl date_loop/); + next KEY if $key ~~ [qw/canPostStories addStoryUrl date_loop/]; delete $templateVars->{$key}; } diff --git a/t/Form/ProfileEnabled.t b/t/Form/ProfileEnabled.t index abe770e10..4a8ffd61f 100644 --- a/t/Form/ProfileEnabled.t +++ b/t/Form/ProfileEnabled.t @@ -43,7 +43,7 @@ my @notEnabled = qw/Button Control List MimeType SubscriptionGroup Slider Submit foreach my $formType (@formTypes) { my $form = WebGUI::Form::DynamicField->new($session, fieldType => $formType); my $ref = (split /::/, ref $form)[-1]; - if (isIn($ref, @notEnabled)) { + if ($ref ~~ @notEnabled) { ok(!$form->isDynamicCompatible, " $ref should not be profile enabled"); } else { diff --git a/t/Group.t b/t/Group.t index 7929b7eda..942844561 100644 --- a/t/Group.t +++ b/t/Group.t @@ -485,10 +485,10 @@ is( $session->stow->get('isInGroup'), undef, 'setting dbQuery clears cached isIn is( $mob[0]->isInGroup($gY->getId), 1, 'mob[0] is in group Y after setting dbQuery'); is( $mob[0]->isInGroup($gZ->getId), 1, 'mob[0] isInGroup Z'); -ok( isIn($mob[0]->userId, @{ $gY->getAllUsers() }), 'mob[0] in list of group Y users'); -ok( !isIn($mob[0]->userId, @{ $gZ->getUsers() }), 'mob[0] not in list of group Z users'); +ok( $mob[0]->userId ~~ $gY->getAllUsers, 'mob[0] in list of group Y users'); +ok( ! $mob[0]->userId ~~ $gZ->getUsers, 'mob[0] not in list of group Z users'); -ok( isIn($mob[0]->userId, @{ $gZ->getAllUsers() }), 'mob[0] in list of group Z users, recursively'); +ok( $mob[0]->userId ~~ $gZ->getAllUsers, 'mob[0] in list of group Z users, recursively'); $gY->clearCaches; diff --git a/t/Session/Id.t b/t/Session/Id.t index ad78068f9..3a9c28d5d 100644 --- a/t/Session/Id.t +++ b/t/Session/Id.t @@ -62,7 +62,7 @@ my $isValid = 1; for (1..2000) { last unless $isUnique; my $id = $session->id->generate(); - $isUnique = ($isUnique ? !isIn($id,@uniqueIds) : 0); + $isUnique = ($isUnique ? ! $id ~~ @uniqueIds : 0); $isValid = ($isValid ? $session->id->valid($id) : 0); push(@uniqueIds,$id); } diff --git a/t/Utility.t b/t/Utility.t index e553050d5..51e6b6918 100644 --- a/t/Utility.t +++ b/t/Utility.t @@ -20,9 +20,6 @@ use Test::Deep; my $session = WebGUI::Test->session; -# isIn -ok(WebGUI::Utility::isIn("webgui", qw(cars trucks webgui trains)), 'isIn()'); - { # Just some basic tests for now. diff --git a/t/Workflow.t b/t/Workflow.t index a59c8bab4..af21d71d3 100644 --- a/t/Workflow.t +++ b/t/Workflow.t @@ -13,7 +13,6 @@ use WebGUI::Test; use WebGUI::Session; use WebGUI::Workflow; use WebGUI::Workflow::Cron; -use WebGUI::Utility qw/isIn/; use Test::More tests => 75; # increment this value for each test you create use Test::Deep;