Programming :: Check If An Array Is Empty In Perl?

Nov 28, 2008

To do this, can I do this?:

if (@ary = ""),

or is something more needed?

View 4 Replies


ADVERTISEMENT

Programming :: Perl Array Last 2 Elements Will Not Pop?

Apr 27, 2010

created this array and the last two elements will not pop - phil and sylvia never get up to bat.

1#!/usr/bin/perl
2use strict;
3use warnings;

[code]...

View 3 Replies View Related

Programming :: Passing Array From One Perl Script To Another?

Dec 14, 2010

How do I pass an array from one perl script to another .. also how to read it in another script ?I tried below -

Script 1 - sender program
system ("./program2.pl @array1 @array2");
printf("

[code]...

View 2 Replies View Related

Programming :: Perl Pushing Two Dimensional Array

Apr 22, 2011

I tried to look for this, but there are so little of perl on internet:
Code:
@array = [$title, $description, $pubDate, $link];
push(@feeds1, $array);

I am trying to create a 2 D array by PUSH, so the output would look like:
([ $title, $description, $pubDate, $link ], [ $title, $description, $pubDate, $link ], [ $title, $description, $pubDate, $link ], [ $title, $description, $pubDate, $link ]...etc )

View 2 Replies View Related

Programming :: Perl - Regex With Array Elements?

Mar 13, 2011

I have .txt.gz files that store queries made on a browser, d my job is to analyze them.The information is stored in a xml-like style.Quote:

<browser>lwp-trivial/1.41</browser>
<http_code>200</http_code>
<keywords />

[code]...

View 6 Replies View Related

Programming :: Split Fields In A Perl Array?

Dec 16, 2010

I have an array called @logons. How can I step thru the array and split the fields? This is what I have so far, but doesnt work. I got the feeling I the split statement syntax is incorrect.

Code:

print @logons;
foreach my $logons(@logons){
($userid, $ip) = split(',',$logons);

[code]....

Update: Appears the data in @logons has a column header from the mysql query which I used to populate it with. So that code which I was testing does indeed work.

View 10 Replies View Related

Programming :: How To Check For Empty Variables In PHP

Apr 26, 2010

I want to check if a MySQL db query will return an empty result - I first do this:

$query="SELECT * from <whatever" ;
$result=mysql_query($query) ;
$row=mysql_fetch_row($result) ;

Now how do I check if $row is empty or not? Will $row="" do the trick?

View 2 Replies View Related

Programming :: Check If Buffer Is Empty In C?

Apr 12, 2011

Greetings EveryOne

how to check if buffer is empty in c?

View 14 Replies View Related

Programming :: Assigning Output Of A Command To An Array In Perl?

Nov 25, 2010

I am trying to execute a Unix Command in perl and assigning its output to an array:

Code:
@File_List=exec("ls -1 /tmp");
but it is not working. I have tried the perl function system() also but its return code is

[code]...

View 10 Replies View Related

Programming :: Count Occurrency Of Each Array Element - Perl?

May 10, 2010

Exist it a perl function to count how much each array element is into array?

View 14 Replies View Related

Programming :: Restrict The Perl Array Maximum Size?

Feb 9, 2010

How to restrict the maximum size of an array variable in perl such that Ishould not be able to have array elements beyond the maximum size?

View 7 Replies View Related

Programming :: Perl - Stop Range Search At End Of An Array?

Dec 7, 2010

I have data that looks similar to this -

Quote:

John Smith (Address)
123 Main St
Unit 1

[code].....

So I need everything between each name, but I am not guaranteed that each time I match a name that I will have the same amount of lines, so I do a range pattern search line this to get all lines, no matter if there is 5 or 10 or 15. I simply do a loop that goes through the whole array until I hit the match, and this is my search pattern.

Code:

if ($LINE =~ /^s+$SELECTED_NAME/ ... $LINE =~ /(Address)/) {
push @ADDRESS_INFO, $LINE;
}

This works perfectly... until I hit the end and it doesn't get its final pattern match because it's at the end and there is no next entry with a (Address) line. So as a 'hack', I ended up inserting a final scalar at the end of the array that just says (Address) so it knows it's at the end. Ideally though, I'd like to do an "or" statement that says search for Address || return true if I hit the end of the array. How would I match on "End Of Array" essentially?

View 1 Replies View Related

Programming :: Perl - Store And Access An Array In A Hash Of Hashes?

Jul 7, 2010

I am in need of some syntax help. I'm trying to figure out how to store and retrieve an array out of a hash of hashes. For this example, I'm trying to access the city list for a particular state for a particular country. I understand I could do a join and split on the hash key to combine Country and State, but trying to keep things separated.The code I have gets in all the information for the Countries, and states, and gets the list of cities together, no problem. I store all the city names in an array, then make an anonymous pointer to the array for the hash, like this - $MY_CITIES{$COUNTRY}{$STATE} = [@CITIES]I believe that syntax is correct, or is it? What I'd like to do is I need to cycle through every hash to find if a city exists or not. If it exists in 3 states, then it should print 3 times. Here is the code block to search -

Code:
for $COUNTRY (@LIST_OF_COUNTRIES) {
for $STATE ( keys %MY_CITIES{$COUNTRY){$STATE} ) {

[code]...

View 4 Replies View Related

Programming :: Perl Beginner - Can't Get PerlMagick To Read Filename From Array Element?

Aug 21, 2010

it's been a while since I logged on here! I've been trying my hand at a little perl and have hit a brick wall.I'm using the Imagemagick module to manipulate some images. I can get the following to work without issue:

Code:
$teampath = "/var/www/team1";
$player=Image::Magick->new;

[code]...

View 1 Replies View Related

Programming :: Perl's Foreach Loop Can't Use An Array Element As The Control Variable?

Jul 22, 2011

I'm reading "OReilly Learning Perl 5th Edition", and there are such words:Code:You can use an array element like $fred[2] in every place? where you could use any other scalavariable like $fred.At the bottom of the page, it explains the ? like this:Code:The most notable exception is that the control variable of a foreach loop, which you?ll see later in this chapter, must be a simple scalar.Since Perl has the save-and-restore mechanism for the control variable, why an array element can't be used as the control variable

View 1 Replies View Related

Programming :: Setup Array To Check Tables?

Nov 9, 2010

I want to specify about 10 tables that should be checked before the application starts, since if they are empty the results are not so good!

Here is what I have so far:

//specify what tables we want to check
$db_array =
array("attendance_codes","ethnicity","generations","grades","grade_terms","health_codes",$
//walk the array checking each table for more than 0 records

[code]....

it's not working,

View 2 Replies View Related

Programming :: Perl - Can't Use String ("html") As An ARRAY Ref While "strict Refs"?

Aug 8, 2009

The below snippet works fine until I use strict. Then it dies with the following error: uote:Can't use string ("html") as an ARRAY ref while "strict refs" in use at ./filetest3 line 18.I want to create @lists based on the $scalars in @type. However, "my @$ext = ()"; and push (@$ext, @files); do not play nice with strict. How do I get around this?Quote:

#!/usr/bin/perl -w
system clear;
use strict;

[code]...

View 9 Replies View Related

Ubuntu :: 10.04 - Prepare Disk Space With Empty Array

Sep 30, 2010

I have a PC with Windows 2000 Pro installed in an NTFS partition of 60GB. My rest hard disk (500GB) is empty, no partition at all. When I run Ubuntu 10.04 installation after step number 3 I get a weird step number 4 showing prepare partitions with an empty array and no available command button at the bottom! So I can not create any partition... Also in step 4 I never see the "prepare disk space" menu. If I use a 9.04 Ubuntu CD and I try to install I get every menu fine as expected. I even tried the 10.04 CD to another PC with Windows XP PRO and the installer worked as expected for partitions.

View 1 Replies View Related

Programming :: C Realloc Resize Array / Delete And Add Information Into The Array?

Mar 6, 2011

I am trying to dynamically delete and add information into the array "blah"

Code:
int blahsize = 1;
char** blah = (char**) calloc(blahsize+1,sizeof(char*));
Adding information:
Code:
blah[1]=stuff1;
blah[2]=stuff2;
code....

View 2 Replies View Related

Programming :: Convert Short Array To Char Array?

Jun 7, 2010

I have trouble converting a short array to a char array

Code:

short pShort[4] = { 0x41, 0x42, 0x43, 0x44 };

How to convert this to a char array?

View 4 Replies View Related

Programming :: Converting A PHP Array Into An HTML Array?

Aug 9, 2009

I'm writing a PHP program. I've encountered a problem; in the following code I try to pass $_POST['delete'] which is an array as the value of a hidden input to some form, but it doesn't do so.there's something wrong with converting PHP array into HTML array. I'm sure that $_POST['delete'] is not null and is a real array.

echo '<input type="hidden" name="delete[]" value="'.$_POST['delete'].'" />';

View 4 Replies View Related

General :: Bash Scripting - Executes A Few Perl Scripts - Create A New Array And Take The Hostname

Apr 4, 2011

I'm writing a bash script that executes a few perl scripts. One of the perl scripts that I need to execute requires two arguments with it. The arguments are stored in a txt file, each line contains a hostname and its corresponding IP address separated by a ":" (colon), the txt file looks like this below:

[Code]...

I'm not sure if it's the best way to accomplish this but here it goes. In the bash file, let's call it getHosts.sh, I create an array and assign each line of the file to an element in that array. I then think I need to create a new array where I take the hostname (which is before the ":") separate it from its IP address and place the IP address on a new line just below the hostname (this way I can reference to it like $hostNames[$x] would be the hostname, and $hostNames[$x+1] would be its IP address). So the new array would now look like this below:

[Code]...

View 4 Replies View Related

General :: File Type Check In Perl?

Oct 12, 2010

I am witing a file upload program in perl where i need to upload a wav or a gsm file and save it as a gsm file.How can i make sure that the uploaded file is a wav or a gsm sound file and not an executable malicious script or something.

View 2 Replies View Related

Programming :: Filling 2D Array With 1D Array In C?

May 26, 2010

(I am using vector() and matrix() functions from "Numerical recipes in C".)There are 100 numbers to be stored in 2D array of 10 rows and 10 columns.100 numbers are stored in a 1D array.I get "segmentation fault" at the line indicated in the segment of my code below:

Code:

:
:
#define size 100
#define nl 1

[code]....

View 12 Replies View Related

Ubuntu :: Check The Status Of Software Raid Array?

May 21, 2011

In Zentyal, it showed me active drives, if the array was degraded, and if there was any syncing happening when the array was building. How can I check that without Zentyal? Is there a terminal command or an application I can install to tell me the same information?

View 2 Replies View Related

General :: Check On Hard Drives In RAID 1 Array?

Feb 23, 2010

I'm renting a dedicated server with a company that claims that the server has 2 hard drives in a software RAID 1 array, but I need to make sure that the server really has the 2 HDD, and the size of the 2nd drive... how to do that ?? system is Centos 5.3

View 1 Replies View Related

General :: Bash Shell Script To Check / If Empty Files Are Being Created & Start Process

Jun 25, 2010

I have an Ubuntu server in which a file is dumped every hour and a new file for the next hour and the process continues. If there is any problem due to which the creation of file stops then empty files are created every minute till the process is killed & started again. I need help to make a shell script to check if the empty files are being created and then kill the process and start it again.It would be a great help if anyone can help me regarding this.

View 9 Replies View Related

Programming :: Bash Array Add Function Example Using Indirect Array Reference As Function Argument?

Jun 20, 2010

I looked on the net for such function or example and didin't find anything, thus after having made one i guess it would be legitimate to drop it to see what others thinks of it.

#!/bin/bash
addelementtoarray()
{
local arrayname=$1

[code]....

View 10 Replies View Related

CentOS 5 :: Perl-Scalar-List-Utils Transaction Check Error

Oct 13, 2010

what is this, and more importantly, how do I fix it?

Quote:

Package Arch Version Repository Size

[Code].....

View 2 Replies View Related

Programming :: Check Menu & Check List In Utility Dialog?

Aug 19, 2010

I want to put check menu & check list in utility dialog.i dont know how i do this

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved