Sponsored Content
Full Discussion: Perl substr or similar help
Top Forums Shell Programming and Scripting Perl substr or similar help Post 303025177 by Neo on Friday 26th of October 2018 03:07:31 AM
Old 10-26-2018
This is not how web developers process the DOM in HTML, especially on the client side.

Should I assume you are processing the value on the server side?

Either way, your post confused me. On the client side , we easily get the value attribute of the input DOM element with Javacript:

Code:
var value = document.getElementsByTagName("input")[0].getAttribute("value");

If on the server side, normally you use PHP or PERL and you get the attribute value when you submit on the browser to the server.

PHP Example:

Code:
$value = $_GET['value'];

or

Code:
$value = $_POST['value']

We web developers do not process HTML files as big strings and use PERL or PHP or any language to extract a value; because this is easily done on both the client or server side with existing built-in methods.

Getting the value of an HTML DOM attribute does not require a script like you have written. Hidden values are normally submitted with HTML forms via the $_POST method.

This means on the server side, you would simple read the value of $_POST['value'] when the DOM element is submitted.
This User Gave Thanks to Neo For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to declare hashes in KSH similar to Perl ?

Hi, Is it possible to delcare hashes in KSH the way we do it in Perl. Like I want to declare something like: fruits="Juicy" fruits="healthy" fruits="sour" echo fruits Ofcourse this piece of code does not work in KSH. Please let me know if there is a way of doing it in KSH. ... (2 Replies)
Discussion started by: tipsy
2 Replies

2. Shell Programming and Scripting

copy substr in existing string in Perl

Any clue to write something to a particular location in Perl? Suppose $line = ‘abc cde 1234” How to write ( example string "test") on location 4 without parsing the whole line. Output should be $line = ‘abctest 1234” this is not search and replace. just to add substring into... (3 Replies)
Discussion started by: jaivipin
3 Replies

3. UNIX for Dummies Questions & Answers

substr in perl

Let's assume that I have a file with contents delimited by pipe: "The mouse|ran up|the|clock" "May|had a|little|lamb" How would I use 'substr' to get the 3rd field. For example, "the" from the first line, and "little" from the second line? # Loop over a file and read $LINE { ... (2 Replies)
Discussion started by: ChicagoBlues
2 Replies

4. UNIX for Dummies Questions & Answers

substr function in perl

Hi friends, I have written a perl code and it works fine but I am not sure tommorow it works or not, please help me. problem : When diff is 1 then success other than its failure but tomorrow its 20090401 and the enddate is 20090331. thats why I write the code this type but it does not work and... (1 Reply)
Discussion started by: tukuna82
1 Replies

5. Shell Programming and Scripting

20090620231013 to date format i am using substr, any simple way in perl?

Hi Everyone, $tmp="20090620231013"; $tmp = substr($tmp,0,8)." ".substr($tmp,8,2).":".substr($tmp,10,2).":".substr($tmp,12,2); So my output is: 20090620 23:10:13. I only can think substr is easy, any perl can do this just one line very simple efficient one? :eek: Thanks (3 Replies)
Discussion started by: jimmy_y
3 Replies

6. Shell Programming and Scripting

perl file, one line code include "length, rindex, substr", slow

Hi Everyone, # cat a.txt a;b;c;64O a;b;c;d;ee;f # cat a.pl #!/usr/bin/perl use strict; use warnings; my $tmp3 = ",,a,,b,,c,,d,,e,,f,,"; open(my $FA, "a.txt") or die "$!"; while(<$FA>) { chomp; my @tmp=split(/\;/, $_); if ( ($tmp =~ m/^(64O)/i) || ($tmp... (3 Replies)
Discussion started by: jimmy_y
3 Replies

7. Shell Programming and Scripting

Joining multiple files based on one column with different and similar values (shell or perl)

Hi, I have nine files looking similar to file1 & file2 below. File1: 1 ABCA1 1 ABCC8 1 ABR:N 1 ACACB 1 ACAP2 1 ACOT1 1 ACSBG 1 ACTR1 1 ACTRT 1 ADAMT 1 AEN:N 1 AKAP1File2: 1 A4GAL 1 ACTBL 1 ACTL7 (4 Replies)
Discussion started by: seqbiologist
4 Replies

8. Shell Programming and Scripting

Perl match multiple numbers from a variable similar to egrep

I want to match the number exactly from the variable which has multiple numbers seperated by pipe symbol similar to search in egrep.below is the code which i tried #!/usr/bin/perl my $searchnum = $ARGV; my $num = "148|1|0|256"; print $num; if ($searchnum =~ /$num/) { print "found"; }... (2 Replies)
Discussion started by: kar_333
2 Replies

9. Shell Programming and Scripting

How to use if/else if with substr?

I have a command like this: listdb ID923 -l |gawk '{if (substr($0,37,1)==1 && NR == 3)print "YES" else if (substr ($0,37,1)==0 && NR == 3) print "NO"}' This syntax doesn't work. But I was able to get this to work: listdb ID923 -l |gawk '{if (substr($0,37,1)==1 && NR == 3)print "YES"}' ... (4 Replies)
Discussion started by: newbie2010
4 Replies

10. UNIX for Dummies Questions & Answers

Substr

awk '/^>/{id=$0;next}length>=7 { print id, "\n"$0}' Test.txt Can I use substr to achieve the same task? Thanks! (8 Replies)
Discussion started by: Xterra
8 Replies
XML::DOM::Element(3)					User Contributed Perl Documentation				      XML::DOM::Element(3)

NAME
XML::DOM::Element - An XML element node in XML::DOM DESCRIPTION
XML::DOM::Element extends XML::DOM::Node. By far the vast majority of objects (apart from text) that authors encounter when traversing a document are Element nodes. Assume the following XML document: <elementExample id="demo"> <subelement1/> <subelement2><subsubelement/></subelement2> </elementExample> When represented using DOM, the top node is an Element node for "elementExample", which contains two child Element nodes, one for "subelement1" and one for "subelement2". "subelement1" contains no child nodes. Elements may have attributes associated with them; since the Element interface inherits from Node, the generic Node interface method getAttributes may be used to retrieve the set of all attributes for an element. There are methods on the Element interface to retrieve either an Attr object by name or an attribute value by name. In XML, where an attribute value may contain entity references, an Attr object should be retrieved to examine the possibly fairly complex sub-tree representing the attribute value. On the other hand, in HTML, where all attributes have simple string values, methods to directly access an attribute value can safely be used as a convenience. METHODS getTagName The name of the element. For example, in: <elementExample id="demo"> ... </elementExample> tagName has the value "elementExample". Note that this is case-preserving in XML, as are all of the operations of the DOM. getAttribute (name) Retrieves an attribute value by name. Return Value: The Attr value as a string, or the empty string if that attribute does not have a specified or default value. setAttribute (name, value) Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string, it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNode to assign it as the value of an attribute. DOMExceptions: o INVALID_CHARACTER_ERR Raised if the specified name contains an invalid character. o NO_MODIFICATION_ALLOWED_ERR Raised if this node is readonly. removeAttribute (name) Removes an attribute by name. If the removed attribute has a default value it is immediately replaced. DOMExceptions: o NO_MODIFICATION_ALLOWED_ERR Raised if this node is readonly. getAttributeNode Retrieves an Attr node by name. Return Value: The Attr node with the specified attribute name or undef if there is no such attribute. setAttributeNode (attr) Adds a new attribute. If an attribute with that name is already present in the element, it is replaced by the new one. Return Value: If the newAttr attribute replaces an existing attribute with the same name, the previously existing Attr node is returned, otherwise undef is returned. DOMExceptions: o WRONG_DOCUMENT_ERR Raised if newAttr was created from a different document than the one that created the element. o NO_MODIFICATION_ALLOWED_ERR Raised if this node is readonly. o INUSE_ATTRIBUTE_ERR Raised if newAttr is already an attribute of another Element object. The DOM user must explicitly clone Attr nodes to re-use them in other elements. removeAttributeNode (oldAttr) Removes the specified attribute. If the removed Attr has a default value it is immediately replaced. If the Attr already is the default value, nothing happens and nothing is returned. Parameters: oldAttr The Attr node to remove from the attribute list. Return Value: The Attr node that was removed. DOMExceptions: o NO_MODIFICATION_ALLOWED_ERR Raised if this node is readonly. o NOT_FOUND_ERR Raised if oldAttr is not an attribute of the element. Additional methods not in the DOM Spec setTagName (newTagName) Sets the tag name of the Element. Note that this method is not portable between DOM implementations. DOMExceptions: o INVALID_CHARACTER_ERR Raised if the specified name contains an invalid character. check ($checker) Uses the specified XML::Checker to validate the document. NOTE: an XML::Checker must be supplied. The checker can be created in different ways, e.g. when parsing a document with XML::DOM::ValParser, or with XML::DOM::Document::createChecker(). See XML::Checker for more info. POD ERRORS
Hey! The above document had some coding errors, which are explained below: Around line 162: You forgot a '=back' before '=head2' perl v5.12.1 2000-01-31 XML::DOM::Element(3)
All times are GMT -4. The time now is 04:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy